Commit 2d5d0047 authored by Jakob Leben's avatar Jakob Leben

input_item: compress two functions into one and rename "Add" into "Post" for...

input_item: compress two functions into one and rename "Add" into "Post" for clarity and consistency
parent 85297c0a
...@@ -125,46 +125,46 @@ VLC_EXPORT( void, input_item_SetName, ( input_item_t *p_item, const char *psz_na ...@@ -125,46 +125,46 @@ VLC_EXPORT( void, input_item_SetName, ( input_item_t *p_item, const char *psz_na
* Like the playlist, that there is a new sub item. With this design * Like the playlist, that there is a new sub item. With this design
* It is not the input item's responsability to keep all the ref of * It is not the input item's responsability to keep all the ref of
* the input item children. */ * the input item children. */
VLC_EXPORT( void, input_item_AddSubItem, ( input_item_t *p_parent, input_item_t *p_child ) ); VLC_EXPORT( void, input_item_PostSubItem, ( input_item_t *p_parent, input_item_t *p_child ) );
/** /**
* Start adding multiple subitems at once. * Start adding multiple subitems.
* *
* This is a hint for the client that he should probably wait for * Create a root node to hold a tree of subitems for given item
* input_item_AddSubItemTree()'s input_item_subitemtree_added event before
* processing any added subitem.
*/ */
VLC_EXPORT( input_item_node_t *, input_item_node_Create, ( input_item_t *p_input ) ); VLC_EXPORT( input_item_node_t *, input_item_node_Create, ( input_item_t *p_input ) );
/**
* Notify that we are done adding subitems to this tree.
*
* This send a input_item_subitemtree_added event.
*/
VLC_EXPORT( void, input_item_AddSubItemTree, ( input_item_node_t *p_root ) );
/** /**
* Add a subitem to this input_item and to this input_item_node. * Add a subitem to this input_item and to this input_item_node.
* *
* An input_item_subitem_added event will be sent right away. * A vlc_InputItemSubItemAdded event will be sent right away.
*/ */
VLC_EXPORT( input_item_node_t *, input_item_node_AppendItem, ( input_item_node_t *p_node, input_item_t *p_item ) ); VLC_EXPORT( input_item_node_t *, input_item_node_AppendItem, ( input_item_node_t *p_node, input_item_t *p_item ) );
/** /**
* Add a subitem to this input_item and to this input_item_node. * Add a subitem to this input_item and to this input_item_node.
* *
* An input_item_subitem_added event will be sent right away for the subitem * A vlc_InputItemSubItemAdded event will be sent right away for the subitem
* pointed by input_item_node_t. * pointed by input_item_node_t.
*/ */
VLC_EXPORT( void, input_item_node_AppendNode, ( input_item_node_t *p_node, input_item_node_t *p_item ) ); VLC_EXPORT( void, input_item_node_AppendNode, ( input_item_node_t *p_node, input_item_node_t *p_item ) );
/** /**
* Delete the result of input_item_node_Create(). * Delete a node created with input_item_node_Create() and all its children.
*/ */
VLC_EXPORT( void, input_item_node_Delete, ( input_item_node_t *p_node ) ); VLC_EXPORT( void, input_item_node_Delete, ( input_item_node_t *p_node ) );
/**
* End adding multiple subitems.
*
* Send a notification that the item pointed to by the given root node
* has created new subitems that are pointed to by all the children of the node.
* Then delete the node and all its children.
*
* A vlc_InputItemSubItemTreeAdded event will be sent.
*/
VLC_EXPORT( void, input_item_node_PostAndDelete, ( input_item_node_t *p_node ) );
/** /**
......
...@@ -585,8 +585,7 @@ static int GetTracks( access_t *p_access, input_item_t *p_current ) ...@@ -585,8 +585,7 @@ static int GetTracks( access_t *p_access, input_item_t *p_current )
#undef ON_EMPTY #undef ON_EMPTY
#undef NONEMPTY #undef NONEMPTY
input_item_AddSubItemTree( p_root ); input_item_node_PostAndDelete( p_root );
input_item_node_Delete( p_root );
/* */ /* */
for( int i = 0; i < i_cd_text; i++ ) for( int i = 0; i < i_cd_text; i++ )
......
...@@ -166,7 +166,7 @@ int MMSHOpen( access_t *p_access ) ...@@ -166,7 +166,7 @@ int MMSHOpen( access_t *p_access )
/** \bug we do not autodelete here */ /** \bug we do not autodelete here */
p_new_loc = input_item_New( p_access, psz_location, psz_location ); p_new_loc = input_item_New( p_access, psz_location, psz_location );
input_item_t *p_item = input_GetItem( p_input ); input_item_t *p_item = input_GetItem( p_input );
input_item_AddSubItem( p_item, p_new_loc ); input_item_PostSubItem( p_item, p_new_loc );
vlc_gc_decref( p_new_loc ); vlc_gc_decref( p_new_loc );
vlc_object_release( p_input ); vlc_object_release( p_input );
......
...@@ -423,7 +423,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -423,7 +423,6 @@ static int Open( vlc_object_t * p_this )
msg_Dbg( p_demux, "adding ref = `%s'", psz_ref ); msg_Dbg( p_demux, "adding ref = `%s'", psz_ref );
input_item_t *p_input = input_item_New( p_demux, psz_ref, NULL ); input_item_t *p_input = input_item_New( p_demux, psz_ref, NULL );
input_item_CopyOptions( p_current, p_input ); input_item_CopyOptions( p_current, p_input );
input_item_AddSubItem( p_current, p_input );
input_item_node_AppendItem( p_subitems, p_input ); input_item_node_AppendItem( p_subitems, p_input );
vlc_gc_decref( p_input ); vlc_gc_decref( p_input );
} }
...@@ -434,8 +433,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -434,8 +433,7 @@ static int Open( vlc_object_t * p_this )
} }
free( psz_ref ); free( psz_ref );
} }
input_item_AddSubItemTree( p_subitems ); input_item_node_PostAndDelete( p_subitems );
input_item_node_Delete( p_subitems );
vlc_object_release( p_input ); vlc_object_release( p_input );
} }
......
...@@ -764,8 +764,7 @@ static int Demux( demux_t *p_demux ) ...@@ -764,8 +764,7 @@ static int Demux( demux_t *p_demux )
#endif #endif
} }
input_item_AddSubItemTree( p_subitems ); input_item_node_PostAndDelete( p_subitems );
input_item_node_Delete( p_subitems );
vlc_gc_decref(p_current_input); vlc_gc_decref(p_current_input);
return 0; /* Needed for correct operation of go back */ return 0; /* Needed for correct operation of go back */
......
...@@ -294,10 +294,7 @@ end: ...@@ -294,10 +294,7 @@ end:
free( psz_elname ); free( psz_elname );
if( p_subitems ) if( p_subitems )
{ input_item_node_PostAndDelete( p_subitems );
input_item_AddSubItemTree( p_subitems );
input_item_node_Delete( p_subitems );
}
vlc_gc_decref( p_current_input ); vlc_gc_decref( p_current_input );
if( p_xml_reader ) if( p_xml_reader )
......
...@@ -132,8 +132,7 @@ static int Demux( demux_t *p_demux ) ...@@ -132,8 +132,7 @@ static int Demux( demux_t *p_demux )
free( psz_line ); free( psz_line );
} }
input_item_AddSubItemTree( p_subitems ); input_item_node_PostAndDelete( p_subitems );
input_item_node_Delete( p_subitems );
vlc_gc_decref(p_current_input); vlc_gc_decref(p_current_input);
return 0; /* Needed for correct operation of go back */ return 0; /* Needed for correct operation of go back */
......
...@@ -214,8 +214,7 @@ static int Demux( demux_t *p_demux ) ...@@ -214,8 +214,7 @@ static int Demux( demux_t *p_demux )
vlc_gc_decref( p_input ); vlc_gc_decref( p_input );
} }
input_item_AddSubItemTree( p_subitems ); input_item_node_PostAndDelete( p_subitems );
input_item_node_Delete( p_subitems );
vlc_gc_decref(p_current_input); vlc_gc_decref(p_current_input);
......
...@@ -110,7 +110,7 @@ static int Demux( demux_t *p_demux ) ...@@ -110,7 +110,7 @@ static int Demux( demux_t *p_demux )
input_item_t *p_current_input = GetCurrentItem(p_demux); input_item_t *p_current_input = GetCurrentItem(p_demux);
input_item_t *p_input = input_item_New( p_demux, psz_url, psz_url ); input_item_t *p_input = input_item_New( p_demux, psz_url, psz_url );
input_item_AddSubItem( p_current_input, p_input ); input_item_PostSubItem( p_current_input, p_input );
vlc_gc_decref( p_input ); vlc_gc_decref( p_input );
vlc_gc_decref(p_current_input); vlc_gc_decref(p_current_input);
...@@ -132,7 +132,7 @@ static int DemuxDVD_VR( demux_t *p_demux ) ...@@ -132,7 +132,7 @@ static int DemuxDVD_VR( demux_t *p_demux )
input_item_t *p_current_input = GetCurrentItem(p_demux); input_item_t *p_current_input = GetCurrentItem(p_demux);
input_item_t *p_input = input_item_New( p_demux, psz_url, psz_url ); input_item_t *p_input = input_item_New( p_demux, psz_url, psz_url );
input_item_AddSubItem( p_current_input, p_input ); input_item_PostSubItem( p_current_input, p_input );
vlc_gc_decref( p_input ); vlc_gc_decref( p_input );
......
...@@ -106,8 +106,7 @@ int Demux( demux_t *p_demux ) ...@@ -106,8 +106,7 @@ int Demux( demux_t *p_demux )
{ {"dict", COMPLEX_CONTENT, {.cmplx = parse_plist_dict} } }; { {"dict", COMPLEX_CONTENT, {.cmplx = parse_plist_dict} } };
parse_plist_node( p_demux, p_subitems, NULL, p_xml_reader, "plist", parse_plist_node( p_demux, p_subitems, NULL, p_xml_reader, "plist",
pl_elements ); pl_elements );
input_item_AddSubItemTree( p_subitems ); input_item_node_PostAndDelete( p_subitems );
input_item_node_Delete( p_subitems );
vlc_gc_decref(p_current_input); vlc_gc_decref(p_current_input);
......
...@@ -254,8 +254,7 @@ static int Demux( demux_t *p_demux ) ...@@ -254,8 +254,7 @@ static int Demux( demux_t *p_demux )
b_cleanup = false; b_cleanup = false;
} }
} }
input_item_AddSubItemTree( p_subitems ); input_item_node_PostAndDelete( p_subitems );
input_item_node_Delete( p_subitems );
vlc_gc_decref(p_current_input); vlc_gc_decref(p_current_input);
var_Destroy( p_demux, "m3u-extvlcopt" ); var_Destroy( p_demux, "m3u-extvlcopt" );
return 0; /* Needed for correct operation of go back */ return 0; /* Needed for correct operation of go back */
......
...@@ -230,8 +230,7 @@ static int Demux( demux_t *p_demux ) ...@@ -230,8 +230,7 @@ static int Demux( demux_t *p_demux )
free( psz_name ); free( psz_name );
psz_name = NULL; psz_name = NULL;
input_item_AddSubItemTree( p_subitems ); input_item_node_PostAndDelete( p_subitems );
input_item_node_Delete( p_subitems );
vlc_gc_decref(p_current_input); vlc_gc_decref(p_current_input);
return 0; /* Needed for correct operation of go back */ return 0; /* Needed for correct operation of go back */
......
...@@ -368,8 +368,7 @@ static int Demux( demux_t *p_demux ) ...@@ -368,8 +368,7 @@ static int Demux( demux_t *p_demux )
xml_ReaderDelete( p_xml, p_xml_reader ); xml_ReaderDelete( p_xml, p_xml_reader );
xml_Delete( p_xml ); xml_Delete( p_xml );
input_item_AddSubItemTree( p_subitems ); input_item_node_PostAndDelete( p_subitems );
input_item_node_Delete( p_subitems );
vlc_gc_decref(p_current_input); vlc_gc_decref(p_current_input);
return 0; /* Needed for correct operation of go back */ return 0; /* Needed for correct operation of go back */
...@@ -393,9 +392,7 @@ error: ...@@ -393,9 +392,7 @@ error:
if( p_xml ) if( p_xml )
xml_Delete( p_xml ); xml_Delete( p_xml );
if( p_subitems ) if( p_subitems )
{
input_item_node_Delete( p_subitems ); input_item_node_Delete( p_subitems );
}
vlc_gc_decref(p_current_input); vlc_gc_decref(p_current_input);
return -1; return -1;
......
...@@ -318,8 +318,7 @@ static int Demux( demux_t *p_demux ) ...@@ -318,8 +318,7 @@ static int Demux( demux_t *p_demux )
input_item_node_AppendItem( p_subitems, p_input ); input_item_node_AppendItem( p_subitems, p_input );
vlc_gc_decref( p_input ); vlc_gc_decref( p_input );
} }
input_item_AddSubItemTree( p_subitems ); input_item_node_PostAndDelete( p_subitems );
input_item_node_Delete( p_subitems );
} }
i_ret = 0; /* Needed for correct operation of go back */ i_ret = 0; /* Needed for correct operation of go back */
......
...@@ -360,8 +360,7 @@ static int Demux( demux_t *p_demux ) ...@@ -360,8 +360,7 @@ static int Demux( demux_t *p_demux )
b_cleanup = false; b_cleanup = false;
} }
} }
input_item_AddSubItemTree( p_subitems ); input_item_node_PostAndDelete( p_subitems );
input_item_node_Delete( p_subitems );
vlc_gc_decref(p_current_input); vlc_gc_decref(p_current_input);
var_Destroy( p_demux, "m3u-extvlcopt" ); var_Destroy( p_demux, "m3u-extvlcopt" );
return 0; /* Needed for correct operation of go back */ return 0; /* Needed for correct operation of go back */
......
...@@ -402,7 +402,7 @@ static int Demux ( demux_t *p_demux ) ...@@ -402,7 +402,7 @@ static int Demux ( demux_t *p_demux )
if( !p_sys->psz_mcast_ip && p_sys->b_rtsp_kasenna ) if( !p_sys->psz_mcast_ip && p_sys->b_rtsp_kasenna )
input_item_AddOption( p_child, "rtsp-kasenna", VLC_INPUT_OPTION_TRUSTED ); input_item_AddOption( p_child, "rtsp-kasenna", VLC_INPUT_OPTION_TRUSTED );
input_item_AddSubItem( p_current_input, p_child ); input_item_PostSubItem( p_current_input, p_child );
vlc_gc_decref( p_child ); vlc_gc_decref( p_child );
vlc_gc_decref(p_current_input); vlc_gc_decref(p_current_input);
return 0; /* Needed for correct operation of go back */ return 0; /* Needed for correct operation of go back */
......
...@@ -126,7 +126,8 @@ static int Demux( demux_t *p_demux ) ...@@ -126,7 +126,8 @@ static int Demux( demux_t *p_demux )
goto error; goto error;
} }
input_item_AddSubItemTree( p_input_node ); input_item_node_PostAndDelete( p_input_node );
p_input_node = NULL;
i_ret = 0; /* Needed for correct operation of go back */ i_ret = 0; /* Needed for correct operation of go back */
...@@ -136,7 +137,7 @@ error: ...@@ -136,7 +137,7 @@ error:
if( p_xml ) if( p_xml )
xml_Delete( p_xml ); xml_Delete( p_xml );
free( psz_eltname ); free( psz_eltname );
input_item_node_Delete( p_input_node ); if( p_input_node ) input_item_node_Delete( p_input_node );
vlc_gc_decref(p_current_input); vlc_gc_decref(p_current_input);
return i_ret; return i_ret;
} }
......
...@@ -112,8 +112,7 @@ static int Demux( demux_t *p_demux ) ...@@ -112,8 +112,7 @@ static int Demux( demux_t *p_demux )
} }
input_item_AddSubItemTree( p_subitems ); input_item_node_PostAndDelete( p_subitems );
input_item_node_Delete( p_subitems );
vlc_gc_decref(p_current_input); vlc_gc_decref(p_current_input);
var_Destroy( p_demux, "wpl-extvlcopt" ); var_Destroy( p_demux, "wpl-extvlcopt" );
......
...@@ -133,8 +133,7 @@ int Demux( demux_t *p_demux ) ...@@ -133,8 +133,7 @@ int Demux( demux_t *p_demux )
} }
} }
input_item_AddSubItemTree( p_subitems ); input_item_node_PostAndDelete( p_subitems );
input_item_node_Delete( p_subitems );
end: end:
vlc_gc_decref(p_current_input); vlc_gc_decref(p_current_input);
......
...@@ -168,7 +168,6 @@ static int Demux( demux_t *p_demux ) ...@@ -168,7 +168,6 @@ static int Demux( demux_t *p_demux )
/* create the input item */ /* create the input item */
input_item_t *p_input = input_item_NewExt( p_demux, psz_mrl, input_item_t *p_input = input_item_NewExt( p_demux, psz_mrl,
psz_title, 0, NULL, 0, i_duration ); psz_title, 0, NULL, 0, i_duration );
input_item_AddSubItem( p_current_input, p_input );
input_item_node_AppendItem( p_subitems, p_input ); input_item_node_AppendItem( p_subitems, p_input );
FREENULL( psz_mrl ); FREENULL( psz_mrl );
FREENULL( psz_title ); FREENULL( psz_title );
...@@ -202,8 +201,7 @@ static int Demux( demux_t *p_demux ) ...@@ -202,8 +201,7 @@ static int Demux( demux_t *p_demux )
psz_line = stream_ReadLine( p_demux->s ); psz_line = stream_ReadLine( p_demux->s );
} }
input_item_AddSubItemTree( p_subitems ); input_item_node_PostAndDelete( p_subitems );
input_item_node_Delete( p_subitems );
vlc_gc_decref(p_current_input); vlc_gc_decref(p_current_input);
var_Destroy( p_demux, "zpl-extvlcopt" ); var_Destroy( p_demux, "zpl-extvlcopt" );
......
...@@ -474,7 +474,7 @@ int __vlclua_playlist_add_internal( vlc_object_t *p_this, lua_State *L, ...@@ -474,7 +474,7 @@ int __vlclua_playlist_add_internal( vlc_object_t *p_this, lua_State *L,
/* Append item to playlist */ /* Append item to playlist */
if( p_parent ) /* Add to node */ if( p_parent ) /* Add to node */
{ {
input_item_AddSubItem( p_parent, p_input ); input_item_PostSubItem( p_parent, p_input );
} }
else /* Play or Enqueue (preparse) */ else /* Play or Enqueue (preparse) */
/* FIXME: playlist_AddInput() can fail */ /* FIXME: playlist_AddInput() can fail */
......
...@@ -811,9 +811,7 @@ void MediaServer::_buildPlaylist( Container* parent, input_item_node_t *p_input_ ...@@ -811,9 +811,7 @@ void MediaServer::_buildPlaylist( Container* parent, input_item_node_t *p_input_
} }
if( send ) if( send )
{ input_item_node_PostAndDelete( p_input_node );
input_item_node_Delete( p_input_node );
}
} }
void MediaServer::setInputItem( input_item_t* p_input_item ) void MediaServer::setInputItem( input_item_t* p_input_item )
......
...@@ -262,26 +262,15 @@ static void notify_subitem_added(input_item_t *p_parent, input_item_t *p_child) ...@@ -262,26 +262,15 @@ static void notify_subitem_added(input_item_t *p_parent, input_item_t *p_child)
* Like the playlist, that there is a new sub item. With this design * Like the playlist, that there is a new sub item. With this design
* It is not the input item's responsability to keep all the ref of * It is not the input item's responsability to keep all the ref of
* the input item children. */ * the input item children. */
void input_item_AddSubItem( input_item_t *p_parent, input_item_t *p_child ) void input_item_PostSubItem( input_item_t *p_parent, input_item_t *p_child )
{ {
vlc_mutex_lock( &p_parent->lock ); vlc_mutex_lock( &p_parent->lock );
p_parent->i_type = ITEM_TYPE_PLAYLIST; p_parent->i_type = ITEM_TYPE_PLAYLIST;
vlc_mutex_unlock( &p_parent->lock ); vlc_mutex_unlock( &p_parent->lock );
notify_subitem_added(p_parent, p_child);
input_item_node_t *p_node = input_item_node_Create( p_parent ); input_item_node_t *p_node = input_item_node_Create( p_parent );
input_item_node_AppendItem( p_node, p_child ); input_item_node_AppendItem( p_node, p_child );
input_item_AddSubItemTree( p_node ); input_item_node_PostAndDelete( p_node );
input_item_node_Delete( p_node );
}
void input_item_AddSubItemTree ( input_item_node_t *p_root )
{
vlc_event_t event;
event.type = vlc_InputItemSubItemTreeAdded;
event.u.input_item_subitem_tree_added.p_root = p_root;
vlc_event_send( &p_root->p_item->event_manager, &event );
} }
bool input_item_HasErrorWhenReading( input_item_t *p_item ) bool input_item_HasErrorWhenReading( input_item_t *p_item )
...@@ -1043,3 +1032,13 @@ void input_item_node_AppendNode( input_item_node_t *p_parent, input_item_node_t ...@@ -1043,3 +1032,13 @@ void input_item_node_AppendNode( input_item_node_t *p_parent, input_item_node_t
p_child ); p_child );
p_child->p_parent = p_parent; p_child->p_parent = p_parent;
} }
void input_item_node_PostAndDelete( input_item_node_t *p_root )
{
vlc_event_t event;
event.type = vlc_InputItemSubItemTreeAdded;
event.u.input_item_subitem_tree_added.p_root = p_root;
vlc_event_send( &p_root->p_item->event_manager, &event );
input_item_node_Delete( p_root );
}
...@@ -188,8 +188,6 @@ input_DetachResource ...@@ -188,8 +188,6 @@ input_DetachResource
input_GetItem input_GetItem
input_item_AddInfo input_item_AddInfo
input_item_AddOption input_item_AddOption
input_item_AddSubItem
input_item_AddSubItemTree
input_item_CopyOptions input_item_CopyOptions
input_item_DelInfo input_item_DelInfo
input_item_GetDuration input_item_GetDuration
...@@ -208,6 +206,8 @@ input_item_node_AppendItem ...@@ -208,6 +206,8 @@ input_item_node_AppendItem
input_item_node_AppendNode input_item_node_AppendNode
input_item_node_Create input_item_node_Create
input_item_node_Delete input_item_node_Delete
input_item_node_PostAndDelete
input_item_PostSubItem
input_item_SetDuration input_item_SetDuration
input_item_SetMeta input_item_SetMeta
input_item_SetName input_item_SetName
......
Markdown is supported
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