-
-/**************************************************************************
- * libvlc_media_list_dynamic_sublist (Public)
- *
- * Lock should be hold when entering.
- **************************************************************************/
-libvlc_media_list_t *
-libvlc_media_list_dynamic_sublist( libvlc_media_list_t * p_mlist,
- libvlc_tag_query_t * p_query,
- libvlc_exception_t * p_e )
-{
- libvlc_media_list_t * p_submlist;
- libvlc_event_manager_t * p_em;
- int count, i;
-
- (void)p_e;
-
- p_submlist = libvlc_media_list_new( p_mlist->p_libvlc_instance, p_e );
- if( !p_submlist )
- {
- if( !libvlc_exception_raised( p_e ) )
- libvlc_exception_raise( p_e, "Can't get the new media_list" );
- return NULL;
- }
-
- /* We have a query */
- libvlc_tag_query_retain( p_query );
- p_submlist->p_query = p_query;
-
- /* We have a media provider */
- libvlc_media_list_retain( p_mlist );
- p_submlist->p_media_provider = p_mlist;
-
-
- libvlc_media_list_lock( p_submlist );
-
- count = libvlc_media_list_count( p_mlist, p_e );
-
- /* This should be running in a thread, a good plan to achieve that
- * move all the dynamic code to libvlc_tag_query. */
- for( i = 0; i < count; i++ )
- {
- libvlc_media_descriptor_t * p_md;
- p_md = libvlc_media_list_item_at_index( p_mlist, i, p_e );
- if( libvlc_tag_query_match( p_query, p_md, NULL ) )
- libvlc_media_list_add_media_descriptor( p_submlist, p_md, p_e );
- }
-
- /* And we will listen to its event, so we can update p_submlist
- * accordingly */
- p_em = libvlc_media_list_event_manager( p_mlist, p_e );
- libvlc_event_attach( p_em, libvlc_MediaListItemAdded,
- dynamic_list_propose_item, p_submlist, p_e );
- libvlc_event_attach( p_em, libvlc_MediaListItemDeleted,
- dynamic_list_remove_item, p_submlist, p_e );
- libvlc_event_attach( p_em, libvlc_MediaListItemChanged,
- dynamic_list_change_item, p_submlist, p_e );
-
- libvlc_media_list_unlock( p_submlist );
-
- return p_submlist;
-}
-