From 2d5d004768fa322a36b95524a05f0f52e7822469 Mon Sep 17 00:00:00 2001 From: Jakob Leben Date: Wed, 3 Feb 2010 03:47:17 +0100 Subject: [PATCH] input_item: compress two functions into one and rename "Add" into "Post" for clarity and consistency --- include/vlc_input_item.h | 32 +++++++++++------------ modules/access/cdda.c | 3 +-- modules/access/mms/mmsh.c | 2 +- modules/demux/mp4/mp4.c | 4 +-- modules/demux/playlist/asx.c | 3 +-- modules/demux/playlist/b4s.c | 5 +--- modules/demux/playlist/dvb.c | 3 +-- modules/demux/playlist/gvp.c | 3 +-- modules/demux/playlist/ifo.c | 4 +-- modules/demux/playlist/itml.c | 3 +-- modules/demux/playlist/m3u.c | 3 +-- modules/demux/playlist/pls.c | 3 +-- modules/demux/playlist/podcast.c | 5 +--- modules/demux/playlist/qtl.c | 3 +-- modules/demux/playlist/ram.c | 3 +-- modules/demux/playlist/sgimb.c | 2 +- modules/demux/playlist/shoutcast.c | 5 ++-- modules/demux/playlist/wpl.c | 3 +-- modules/demux/playlist/xspf.c | 3 +-- modules/demux/playlist/zpl.c | 4 +-- modules/misc/lua/vlc.c | 2 +- modules/services_discovery/upnp_intel.cpp | 4 +-- src/input/item.c | 25 +++++++++--------- src/libvlccore.sym | 4 +-- 24 files changed, 54 insertions(+), 77 deletions(-) diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h index 72f9d39b08..e9940f6fbb 100644 --- a/include/vlc_input_item.h +++ b/include/vlc_input_item.h @@ -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 * It is not the input item's responsability to keep all the ref of * 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 - * input_item_AddSubItemTree()'s input_item_subitemtree_added event before - * processing any added subitem. + * Create a root node to hold a tree of subitems for given item */ 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. * - * 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 ) ); /** * 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. */ 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 ) ); - +/** + * 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 ) ); /** diff --git a/modules/access/cdda.c b/modules/access/cdda.c index 8cee1b627d..f680740946 100644 --- a/modules/access/cdda.c +++ b/modules/access/cdda.c @@ -585,8 +585,7 @@ static int GetTracks( access_t *p_access, input_item_t *p_current ) #undef ON_EMPTY #undef NONEMPTY - input_item_AddSubItemTree( p_root ); - input_item_node_Delete( p_root ); + input_item_node_PostAndDelete( p_root ); /* */ for( int i = 0; i < i_cd_text; i++ ) diff --git a/modules/access/mms/mmsh.c b/modules/access/mms/mmsh.c index c689c27769..d353f0cb45 100644 --- a/modules/access/mms/mmsh.c +++ b/modules/access/mms/mmsh.c @@ -166,7 +166,7 @@ int MMSHOpen( access_t *p_access ) /** \bug we do not autodelete here */ p_new_loc = input_item_New( p_access, psz_location, psz_location ); 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_object_release( p_input ); diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c index cf1827e6d5..5e772f93cf 100644 --- a/modules/demux/mp4/mp4.c +++ b/modules/demux/mp4/mp4.c @@ -423,7 +423,6 @@ static int Open( vlc_object_t * p_this ) msg_Dbg( p_demux, "adding ref = `%s'", psz_ref ); input_item_t *p_input = input_item_New( p_demux, psz_ref, NULL ); input_item_CopyOptions( p_current, p_input ); - input_item_AddSubItem( p_current, p_input ); input_item_node_AppendItem( p_subitems, p_input ); vlc_gc_decref( p_input ); } @@ -434,8 +433,7 @@ static int Open( vlc_object_t * p_this ) } free( psz_ref ); } - input_item_AddSubItemTree( p_subitems ); - input_item_node_Delete( p_subitems ); + input_item_node_PostAndDelete( p_subitems ); vlc_object_release( p_input ); } diff --git a/modules/demux/playlist/asx.c b/modules/demux/playlist/asx.c index 4d467cfd3b..8d225b7393 100644 --- a/modules/demux/playlist/asx.c +++ b/modules/demux/playlist/asx.c @@ -764,8 +764,7 @@ static int Demux( demux_t *p_demux ) #endif } - input_item_AddSubItemTree( p_subitems ); - input_item_node_Delete( p_subitems ); + input_item_node_PostAndDelete( p_subitems ); vlc_gc_decref(p_current_input); return 0; /* Needed for correct operation of go back */ diff --git a/modules/demux/playlist/b4s.c b/modules/demux/playlist/b4s.c index ac33bc7deb..d08814d962 100644 --- a/modules/demux/playlist/b4s.c +++ b/modules/demux/playlist/b4s.c @@ -294,10 +294,7 @@ end: free( psz_elname ); if( p_subitems ) - { - input_item_AddSubItemTree( p_subitems ); - input_item_node_Delete( p_subitems ); - } + input_item_node_PostAndDelete( p_subitems ); vlc_gc_decref( p_current_input ); if( p_xml_reader ) diff --git a/modules/demux/playlist/dvb.c b/modules/demux/playlist/dvb.c index 8df00ccaf3..15e057894e 100644 --- a/modules/demux/playlist/dvb.c +++ b/modules/demux/playlist/dvb.c @@ -132,8 +132,7 @@ static int Demux( demux_t *p_demux ) free( psz_line ); } - input_item_AddSubItemTree( p_subitems ); - input_item_node_Delete( p_subitems ); + input_item_node_PostAndDelete( p_subitems ); vlc_gc_decref(p_current_input); return 0; /* Needed for correct operation of go back */ diff --git a/modules/demux/playlist/gvp.c b/modules/demux/playlist/gvp.c index 316dbde079..2747d985c2 100644 --- a/modules/demux/playlist/gvp.c +++ b/modules/demux/playlist/gvp.c @@ -214,8 +214,7 @@ static int Demux( demux_t *p_demux ) vlc_gc_decref( p_input ); } - input_item_AddSubItemTree( p_subitems ); - input_item_node_Delete( p_subitems ); + input_item_node_PostAndDelete( p_subitems ); vlc_gc_decref(p_current_input); diff --git a/modules/demux/playlist/ifo.c b/modules/demux/playlist/ifo.c index 14660f37e3..54d29db9dd 100644 --- a/modules/demux/playlist/ifo.c +++ b/modules/demux/playlist/ifo.c @@ -110,7 +110,7 @@ static int Demux( demux_t *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_AddSubItem( p_current_input, p_input ); + input_item_PostSubItem( p_current_input, p_input ); vlc_gc_decref( p_input ); vlc_gc_decref(p_current_input); @@ -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_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 ); diff --git a/modules/demux/playlist/itml.c b/modules/demux/playlist/itml.c index ac4c6f053c..3d99a22160 100644 --- a/modules/demux/playlist/itml.c +++ b/modules/demux/playlist/itml.c @@ -106,8 +106,7 @@ int Demux( demux_t *p_demux ) { {"dict", COMPLEX_CONTENT, {.cmplx = parse_plist_dict} } }; parse_plist_node( p_demux, p_subitems, NULL, p_xml_reader, "plist", pl_elements ); - input_item_AddSubItemTree( p_subitems ); - input_item_node_Delete( p_subitems ); + input_item_node_PostAndDelete( p_subitems ); vlc_gc_decref(p_current_input); diff --git a/modules/demux/playlist/m3u.c b/modules/demux/playlist/m3u.c index acafc3eeb8..9320a6b11e 100644 --- a/modules/demux/playlist/m3u.c +++ b/modules/demux/playlist/m3u.c @@ -254,8 +254,7 @@ static int Demux( demux_t *p_demux ) b_cleanup = false; } } - input_item_AddSubItemTree( p_subitems ); - input_item_node_Delete( p_subitems ); + input_item_node_PostAndDelete( p_subitems ); vlc_gc_decref(p_current_input); var_Destroy( p_demux, "m3u-extvlcopt" ); return 0; /* Needed for correct operation of go back */ diff --git a/modules/demux/playlist/pls.c b/modules/demux/playlist/pls.c index 0089db3cda..7bbdcb4e4f 100644 --- a/modules/demux/playlist/pls.c +++ b/modules/demux/playlist/pls.c @@ -230,8 +230,7 @@ static int Demux( demux_t *p_demux ) free( psz_name ); psz_name = NULL; - input_item_AddSubItemTree( p_subitems ); - input_item_node_Delete( p_subitems ); + input_item_node_PostAndDelete( p_subitems ); vlc_gc_decref(p_current_input); return 0; /* Needed for correct operation of go back */ diff --git a/modules/demux/playlist/podcast.c b/modules/demux/playlist/podcast.c index 6a2b256422..2360adf6b5 100644 --- a/modules/demux/playlist/podcast.c +++ b/modules/demux/playlist/podcast.c @@ -368,8 +368,7 @@ static int Demux( demux_t *p_demux ) xml_ReaderDelete( p_xml, p_xml_reader ); xml_Delete( p_xml ); - input_item_AddSubItemTree( p_subitems ); - input_item_node_Delete( p_subitems ); + input_item_node_PostAndDelete( p_subitems ); vlc_gc_decref(p_current_input); return 0; /* Needed for correct operation of go back */ @@ -393,9 +392,7 @@ error: if( p_xml ) xml_Delete( p_xml ); if( p_subitems ) - { input_item_node_Delete( p_subitems ); - } vlc_gc_decref(p_current_input); return -1; diff --git a/modules/demux/playlist/qtl.c b/modules/demux/playlist/qtl.c index 145676a108..d10d4f5f23 100644 --- a/modules/demux/playlist/qtl.c +++ b/modules/demux/playlist/qtl.c @@ -318,8 +318,7 @@ static int Demux( demux_t *p_demux ) input_item_node_AppendItem( p_subitems, p_input ); vlc_gc_decref( p_input ); } - input_item_AddSubItemTree( p_subitems ); - input_item_node_Delete( p_subitems ); + input_item_node_PostAndDelete( p_subitems ); } i_ret = 0; /* Needed for correct operation of go back */ diff --git a/modules/demux/playlist/ram.c b/modules/demux/playlist/ram.c index 0c6149f0e5..d2cb5b2294 100644 --- a/modules/demux/playlist/ram.c +++ b/modules/demux/playlist/ram.c @@ -360,8 +360,7 @@ static int Demux( demux_t *p_demux ) b_cleanup = false; } } - input_item_AddSubItemTree( p_subitems ); - input_item_node_Delete( p_subitems ); + input_item_node_PostAndDelete( p_subitems ); vlc_gc_decref(p_current_input); var_Destroy( p_demux, "m3u-extvlcopt" ); return 0; /* Needed for correct operation of go back */ diff --git a/modules/demux/playlist/sgimb.c b/modules/demux/playlist/sgimb.c index effece1702..07065db664 100644 --- a/modules/demux/playlist/sgimb.c +++ b/modules/demux/playlist/sgimb.c @@ -402,7 +402,7 @@ static int Demux ( demux_t *p_demux ) if( !p_sys->psz_mcast_ip && p_sys->b_rtsp_kasenna ) 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_current_input); return 0; /* Needed for correct operation of go back */ diff --git a/modules/demux/playlist/shoutcast.c b/modules/demux/playlist/shoutcast.c index a608631206..dcaa0559bd 100644 --- a/modules/demux/playlist/shoutcast.c +++ b/modules/demux/playlist/shoutcast.c @@ -126,7 +126,8 @@ static int Demux( demux_t *p_demux ) 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 */ @@ -136,7 +137,7 @@ error: if( p_xml ) xml_Delete( p_xml ); 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); return i_ret; } diff --git a/modules/demux/playlist/wpl.c b/modules/demux/playlist/wpl.c index 71209cb15b..a73af68277 100644 --- a/modules/demux/playlist/wpl.c +++ b/modules/demux/playlist/wpl.c @@ -112,8 +112,7 @@ static int Demux( demux_t *p_demux ) } - input_item_AddSubItemTree( p_subitems ); - input_item_node_Delete( p_subitems ); + input_item_node_PostAndDelete( p_subitems ); vlc_gc_decref(p_current_input); var_Destroy( p_demux, "wpl-extvlcopt" ); diff --git a/modules/demux/playlist/xspf.c b/modules/demux/playlist/xspf.c index 1933c11727..c24e0dab61 100644 --- a/modules/demux/playlist/xspf.c +++ b/modules/demux/playlist/xspf.c @@ -133,8 +133,7 @@ int Demux( demux_t *p_demux ) } } - input_item_AddSubItemTree( p_subitems ); - input_item_node_Delete( p_subitems ); + input_item_node_PostAndDelete( p_subitems ); end: vlc_gc_decref(p_current_input); diff --git a/modules/demux/playlist/zpl.c b/modules/demux/playlist/zpl.c index b9ee3d23b4..7c2efbd95e 100644 --- a/modules/demux/playlist/zpl.c +++ b/modules/demux/playlist/zpl.c @@ -168,7 +168,6 @@ static int Demux( demux_t *p_demux ) /* create the input item */ input_item_t *p_input = input_item_NewExt( p_demux, psz_mrl, psz_title, 0, NULL, 0, i_duration ); - input_item_AddSubItem( p_current_input, p_input ); input_item_node_AppendItem( p_subitems, p_input ); FREENULL( psz_mrl ); FREENULL( psz_title ); @@ -202,8 +201,7 @@ static int Demux( demux_t *p_demux ) psz_line = stream_ReadLine( p_demux->s ); } - input_item_AddSubItemTree( p_subitems ); - input_item_node_Delete( p_subitems ); + input_item_node_PostAndDelete( p_subitems ); vlc_gc_decref(p_current_input); var_Destroy( p_demux, "zpl-extvlcopt" ); diff --git a/modules/misc/lua/vlc.c b/modules/misc/lua/vlc.c index a0c38de0e8..dc499033b3 100644 --- a/modules/misc/lua/vlc.c +++ b/modules/misc/lua/vlc.c @@ -474,7 +474,7 @@ int __vlclua_playlist_add_internal( vlc_object_t *p_this, lua_State *L, /* Append item to playlist */ 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) */ /* FIXME: playlist_AddInput() can fail */ diff --git a/modules/services_discovery/upnp_intel.cpp b/modules/services_discovery/upnp_intel.cpp index 185ef74d38..427c27ec43 100644 --- a/modules/services_discovery/upnp_intel.cpp +++ b/modules/services_discovery/upnp_intel.cpp @@ -811,9 +811,7 @@ void MediaServer::_buildPlaylist( Container* parent, input_item_node_t *p_input_ } if( send ) - { - input_item_node_Delete( p_input_node ); - } + input_item_node_PostAndDelete( p_input_node ); } void MediaServer::setInputItem( input_item_t* p_input_item ) diff --git a/src/input/item.c b/src/input/item.c index 5fea1217d4..e6f17015ee 100644 --- a/src/input/item.c +++ b/src/input/item.c @@ -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 * It is not the input item's responsability to keep all the ref of * 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 ); p_parent->i_type = ITEM_TYPE_PLAYLIST; 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_AppendItem( p_node, p_child ); - input_item_AddSubItemTree( 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 ); + input_item_node_PostAndDelete( p_node ); } 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 p_child ); 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 ); +} diff --git a/src/libvlccore.sym b/src/libvlccore.sym index bb515ed602..031bf223ca 100644 --- a/src/libvlccore.sym +++ b/src/libvlccore.sym @@ -188,8 +188,6 @@ input_DetachResource input_GetItem input_item_AddInfo input_item_AddOption -input_item_AddSubItem -input_item_AddSubItemTree input_item_CopyOptions input_item_DelInfo input_item_GetDuration @@ -208,6 +206,8 @@ input_item_node_AppendItem input_item_node_AppendNode input_item_node_Create input_item_node_Delete +input_item_node_PostAndDelete +input_item_PostSubItem input_item_SetDuration input_item_SetMeta input_item_SetName -- 2.39.5