[vlc-devel] [PATCH] playlist: swipe away the category / onelevel mess -> singular item storage
Laurent Aimar
fenrir at via.ecp.fr
Mon Feb 1 12:36:57 CET 2010
Hi,
On Mon, Feb 01, 2010, Jakob Leben wrote:
> Hi all!
>
> +void input_item_BeginAddSubItems( input_item_t *p_item )
> +{
> + vlc_event_t event;
> + event.type = vlc_InputItemBeginAddSubItems;
> + vlc_event_send( &p_item->event_manager, &event );
> +}
> +
> +void input_item_EndAddSubItems( input_item_t *p_item )
> +{
> + vlc_event_t event;
> + event.type = vlc_InputItemEndAddSubItems;
> + vlc_event_send( &p_item->event_manager, &event );
> +}
Why are they needed ?
They are a call to future bugs (way too easy to forget them
or to break when moving arround code).
> +static void EndAddSubItems ( const vlc_event_t * p_event,
> + void * user_data )
> +{
> + input_item_t *p_input = p_event->p_obj;
> + playlist_item_t *p_parent = ( playlist_item_t* ) user_data;
> + playlist_t *p_playlist = p_parent->p_playlist;
> +
> + PL_LOCK;
> + playlist_item_t *p_status_item = get_current_status_item( p_playlist );
> + bool b_play = var_CreateGetBool( p_playlist, "playlist-autostart" ) &&
> + p_status_item &&
> + p_input == p_status_item->p_input;
> + PL_UNLOCK;
> +
> + if( b_play && p_parent->i_flags & PLAYLIST_SUBITEM_STOP_FLAG )
> + {
> + p_parent->i_flags &= ~PLAYLIST_SUBITEM_STOP_FLAG;
> + playlist_Stop( p_playlist );
> + }
> + else if( b_play )
> + {
> + playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,
> + pl_Unlocked, p_parent, NULL );
> + }
> +
> + vlc_event_detach( &p_input->event_manager,
> + vlc_InputItemSubItemAdded, AddSubItem, p_parent );
> + vlc_event_detach( &p_input->event_manager,
> + vlc_InputItemEndAddSubItems, EndAddSubItems, p_parent );
> +}
> +
> +static void BeginAddSubItems ( const vlc_event_t * p_event,
> + void * user_data )
> +{
> + input_item_t *p_input = p_event->p_obj;
> + playlist_t *p_playlist = ( playlist_t* ) user_data;
> +
> + PL_LOCK;
> +
> + playlist_item_t *p_parent =
> + playlist_ItemFindFromInputAndRoot( p_playlist, p_input,
> + p_playlist->p_root_category, true );
> + assert( p_parent != NULL );
> +
> + if( p_parent->i_children == -1 )
> + {
> + p_parent = ItemToNode( p_playlist, p_parent, pl_Locked );
> + p_parent->p_input->i_type = ITEM_TYPE_PLAYLIST;
> + }
> +
> + PL_UNLOCK;
> +
> + vlc_event_attach( &p_input->event_manager, vlc_InputItemSubItemAdded,
> + AddSubItem, p_parent );
> + vlc_event_attach( &p_input->event_manager, vlc_InputItemEndAddSubItems,
> + EndAddSubItems, p_parent );
> +}
I am a bit suspucious about the locking but I haven't really checked it.
--
fenrir
More information about the vlc-devel
mailing list