Commit e355ca91 authored by Romain Vimont's avatar Romain Vimont
Browse files

playlist: receive events from input thread

Replace listeners on the input item by preparser callbacks (for
preparsing) and input thread callbacks (for normal playback).
parent d56e7961
......@@ -51,13 +51,19 @@ static int RecursiveInsertCopy (
* An input item has gained subitems (Event Callback)
*****************************************************************************/
static void input_item_add_subitem_tree ( const vlc_event_t * p_event,
void * user_data )
static void input_item_subtree_added(input_item_t *p_input,
input_item_node_t *subtree,
void *user_data)
{
playlist_t *playlist = user_data;
playlist_AddSubtree(playlist, p_input, subtree);
}
void playlist_AddSubtree(playlist_t *p_playlist,
input_item_t *p_input, input_item_node_t *subtree)
{
input_item_t *p_input = p_event->p_obj;
playlist_t *p_playlist = user_data;
playlist_private_t *p_sys = pl_priv( p_playlist );
input_item_node_t *p_new_root = p_event->u.input_item_subitem_tree_added.p_root;
input_item_node_t *p_new_root = subtree;
PL_LOCK;
......@@ -309,8 +315,6 @@ playlist_item_t *playlist_ItemNewFromInput( playlist_t *p_playlist,
vlc_event_manager_t *p_em = &p_item->p_input->event_manager;
vlc_event_attach( p_em, vlc_InputItemSubItemTreeAdded,
input_item_add_subitem_tree, p_playlist );
vlc_event_attach( p_em, vlc_InputItemDurationChanged,
input_item_changed, p_playlist );
vlc_event_attach( p_em, vlc_InputItemMetaChanged,
......@@ -346,8 +350,6 @@ void playlist_ItemRelease( playlist_t *p_playlist, playlist_item_t *p_item )
vlc_event_manager_t *p_em = &p_item->p_input->event_manager;
vlc_event_detach( p_em, vlc_InputItemSubItemTreeAdded,
input_item_add_subitem_tree, p_playlist );
vlc_event_detach( p_em, vlc_InputItemMetaChanged,
input_item_changed, p_playlist );
vlc_event_detach( p_em, vlc_InputItemDurationChanged,
......@@ -724,6 +726,10 @@ vlc_tick_t playlist_GetNodeDuration( playlist_item_t* node )
return duration;
}
static const input_preparser_callbacks_t input_preparser_callbacks = {
.on_subtree_added = input_item_subtree_added,
};
/***************************************************************************
* The following functions are local
***************************************************************************/
......@@ -745,7 +751,8 @@ static void playlist_Preparse( playlist_t *p_playlist,
if( sys->b_preparse && !input_item_IsPreparsed( input )
&& (EMPTY_STR(psz_artist) || EMPTY_STR(psz_album)) )
vlc_MetadataRequest( p_playlist->obj.libvlc, input, 0,
NULL, NULL, -1, p_item );
&input_preparser_callbacks, p_playlist,
-1, p_item );
free( psz_artist );
free( psz_album );
}
......
......@@ -118,6 +118,8 @@ void playlist_SendAddNotify( playlist_t *p_playlist, playlist_item_t *item );
int playlist_InsertInputItemTree ( playlist_t *,
playlist_item_t *, input_item_node_t *, int, bool );
void playlist_AddSubtree(playlist_t *, input_item_t *, input_item_node_t *);
/* Tree walking */
int playlist_NodeInsert(playlist_item_t*, playlist_item_t *, int);
......
......@@ -185,6 +185,18 @@ void ResetCurrentlyPlaying( playlist_t *p_playlist,
p_sys->b_reset_currently_playing = false;
}
static void on_input_event(input_thread_t *input, void *userdata,
const struct vlc_input_event *event)
{
if (event->type == INPUT_EVENT_SUBITEMS)
{
playlist_t *playlist = userdata;
input_item_t *item = input_GetItem(input);
playlist_AddSubtree(playlist, item, event->subitems);
}
input_LegacyEvents(input, userdata, event);
}
/**
* Start the input for an item
......@@ -216,7 +228,7 @@ static bool PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
libvlc_MetadataCancel( p_playlist->obj.libvlc, p_item );
input_thread_t *p_input_thread = input_Create( p_playlist,
input_LegacyEvents, NULL,
on_input_event, p_playlist,
p_input, NULL,
p_sys->p_input_resource,
p_renderer );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment