Commit 85297c0a authored by Pierre's avatar Pierre

input_item: Remove input_item_AddSubItem2 and send subitem_added event from...

input_item: Remove input_item_AddSubItem2 and send subitem_added event from input_item_node_AppendNode().

This means that we don't need input_item_AddSubItem if there is an input_item_node_Append*().
input_item_AddSubItem now send the subitem_tree_added event as well.
parent a968c242
......@@ -118,16 +118,53 @@ struct input_item_node_t
VLC_EXPORT( void, input_item_CopyOptions, ( input_item_t *p_parent, input_item_t *p_child ) );
VLC_EXPORT( void, input_item_SetName, ( input_item_t *p_item, const char *psz_name ) );
/* This won't hold the item, but can tell to interested third parties
/**
* Add one subitem to this item
*
* This won't hold the item, but can tell to interested third parties
* 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 ) );
/**
* Start adding multiple subitems at once.
*
* 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.
*/
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 ) );
/* Will send vlc_InputItemSubItemTreeAdded event, just as input_item_AddSubItemTree */
VLC_EXPORT( void, input_item_AddSubItem2, ( input_item_t *p_parent, input_item_t *p_child ) );
/**
* Add a subitem to this input_item and to this input_item_node.
*
* An input_item_subitem_added 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
* 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().
*/
VLC_EXPORT( void, input_item_node_Delete, ( input_item_node_t *p_node ) );
/**
......@@ -225,14 +262,6 @@ VLC_EXPORT( input_item_t *, __input_item_NewExt, (vlc_object_t *, const char *ps
*/
#define input_item_New( a,b,c ) input_item_NewExt( a, b, c, 0, NULL, 0, -1 )
VLC_EXPORT( input_item_node_t *, input_item_node_Create, ( input_item_t *p_input ) );
VLC_EXPORT( void, input_item_node_Delete, ( input_item_node_t *p_node ) );
VLC_EXPORT( input_item_node_t *, input_item_node_AppendItem, ( input_item_node_t *p_node, input_item_t *p_item ) );
VLC_EXPORT( void, input_item_node_AppendNode, ( input_item_node_t *p_node, input_item_node_t *p_item ) );
/******************
* Input stats
******************/
......
......@@ -577,7 +577,6 @@ static int GetTracks( access_t *p_access, input_item_t *p_current )
snprintf( psz_num, sizeof(psz_num), "%d", 1+i );
input_item_SetTrackNum( p_input_item, psz_num );
input_item_AddSubItem( p_current, p_input_item );
input_item_node_AppendItem( p_root, p_input_item );
vlc_gc_decref( p_input_item );
free( psz_uri ); free( psz_opt ); free( psz_name );
......
......@@ -167,7 +167,6 @@ int MMSHOpen( access_t *p_access )
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_AddSubItem2( p_item, p_new_loc );
vlc_gc_decref( p_new_loc );
vlc_object_release( p_input );
......
......@@ -473,7 +473,6 @@ static int Demux( demux_t *p_demux )
input_item_t *p_input;
p_input = input_item_New( p_demux, psz_string, psz_title_asx );
input_item_CopyOptions( p_current_input, p_input );
input_item_AddSubItem( p_current_input, p_input );
input_item_node_AppendItem( p_subitems, p_input );
vlc_gc_decref( p_input );
free( psz_string );
......@@ -572,7 +571,6 @@ static int Demux( demux_t *p_demux )
uniq_entry_ad_backup = NULL;
vlc_gc_decref( uniq_entry_ad_backup );
}
input_item_AddSubItem( p_current_input, p_entry );
input_item_node_AppendItem( p_subitems, p_entry );
vlc_gc_decref( p_entry );
}
......@@ -650,7 +648,6 @@ static int Demux( demux_t *p_demux )
if( psz_copyright_entry ) input_item_SetCopyright( p_entry, psz_copyright_entry );
if( psz_moreinfo_entry ) input_item_SetURL( p_entry, psz_moreinfo_entry );
if( psz_abstract_entry ) input_item_SetDescription( p_entry, psz_abstract_entry );
input_item_AddSubItem( p_current_input, p_entry );
input_item_node_AppendItem( p_subitems, p_entry );
vlc_gc_decref( p_entry );
}
......@@ -754,7 +751,6 @@ static int Demux( demux_t *p_demux )
{
msg_Dbg( p_demux, "added unique entry even if ad");
/* If ASX contains a unique entry, we add it, it is probably not an ad */
input_item_AddSubItem( p_current_input, uniq_entry_ad_backup );
input_item_node_AppendItem( p_subitems, uniq_entry_ad_backup );
vlc_gc_decref( uniq_entry_ad_backup);
}
......
......@@ -267,7 +267,6 @@ static int Demux( demux_t *p_demux )
if( psz_bitrate )
msg_Err( p_demux, "Unsupported meta bitrate" );
input_item_AddSubItem( p_current_input, p_input );
input_item_node_AppendItem( p_subitems, p_input );
vlc_gc_decref( p_input );
FREENULL( psz_title );
......
......@@ -122,7 +122,6 @@ static int Demux( demux_t *p_demux )
p_input = input_item_NewExt( p_demux, "dvb://", psz_name,
i_options, (const char**)ppsz_options, VLC_INPUT_OPTION_TRUSTED, -1 );
input_item_AddSubItem( p_current_input, p_input );
input_item_node_AppendItem( p_subitems, p_input );
vlc_gc_decref( p_input );
......
......@@ -210,7 +210,6 @@ static int Demux( demux_t *p_demux )
SADD_INFO( "gvp_version", psz_version );
SADD_INFO( "docid", psz_docid );
SADD_INFO( "description", psz_description );
input_item_AddSubItem( p_current_input, p_input );
input_item_node_AppendItem( p_subitems, p_input );
vlc_gc_decref( p_input );
}
......
......@@ -111,7 +111,6 @@ 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_AddSubItem2( p_current_input, p_input );
vlc_gc_decref( p_input );
vlc_gc_decref(p_current_input);
......@@ -134,7 +133,6 @@ 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_AddSubItem2( p_current_input, p_input );
vlc_gc_decref( p_input );
......
......@@ -382,7 +382,6 @@ static bool parse_track_dict( demux_t *p_demux, input_item_node_t *p_input_node,
msg_Info( p_demux, "Adding '%s'", psz_uri );
p_new_input = input_item_New( p_demux, psz_uri, NULL );
input_item_AddSubItem( p_input_node->p_item, p_new_input );
input_item_node_AppendItem( p_input_node, p_new_input );
/* add meta info */
......
......@@ -227,7 +227,6 @@ static int Demux( demux_t *p_demux )
input_item_SetArtist( p_input, psz_artist );
if( psz_name ) input_item_SetTitle( p_input, psz_name );
input_item_AddSubItem( p_current_input, p_input );
input_item_node_AppendItem( p_subitems, p_input );
vlc_gc_decref( p_input );
}
......
......@@ -163,7 +163,6 @@ static int Demux( demux_t *p_demux )
{
p_input = input_item_New( p_demux, psz_mrl, psz_name );
input_item_CopyOptions( p_current_input, p_input );
input_item_AddSubItem( p_current_input, p_input );
input_item_node_AppendItem( p_subitems, p_input );
vlc_gc_decref( p_input );
}
......@@ -219,7 +218,6 @@ static int Demux( demux_t *p_demux )
{
p_input = input_item_New( p_demux, psz_mrl, psz_name );
input_item_CopyOptions( p_current_input, p_input );
input_item_AddSubItem( p_current_input, p_input );
input_item_node_AppendItem( p_subitems, p_input );
vlc_gc_decref( p_input );
free( psz_mrl_orig );
......
......@@ -331,7 +331,6 @@ static int Demux( demux_t *p_demux )
"%s bytes",
psz_item_size );
}
input_item_AddSubItem( p_current_input, p_input );
input_item_node_AppendItem( p_subitems, p_input );
vlc_gc_decref( p_input );
FREENULL( psz_item_name );
......@@ -395,7 +394,6 @@ error:
xml_Delete( p_xml );
if( p_subitems )
{
input_item_AddSubItemTree( p_subitems );
input_item_node_Delete( p_subitems );
}
......
......@@ -310,13 +310,11 @@ static int Demux( demux_t *p_demux )
p_input, "QuickTime Media Link", type, "%s", field ) ; }
SADD_INFO( "href", psz_href );
SADD_INFO( _("Mime"), psz_mimetype );
input_item_AddSubItem( p_current_input, p_input );
input_item_node_AppendItem( p_subitems, p_input );
vlc_gc_decref( p_input );
if( psz_qtnext )
{
p_input = input_item_New( p_demux, psz_qtnext, NULL );
input_item_AddSubItem( p_current_input, p_input );
input_item_node_AppendItem( p_subitems, p_input );
vlc_gc_decref( p_input );
}
......
......@@ -327,7 +327,6 @@ static int Demux( demux_t *p_demux )
if( !EMPTY_STR( psz_cdnum ) ) input_item_SetTrackNum( p_input, psz_cdnum );
if( !EMPTY_STR( psz_comments ) ) input_item_SetDescription( p_input, psz_comments );
input_item_AddSubItem( p_current_input, p_input );
input_item_node_AppendItem( p_subitems, p_input );
vlc_gc_decref( p_input );
free( psz_mrl );
......
......@@ -169,7 +169,7 @@ int Import_SGIMB( vlc_object_t * p_this )
p_demux->p_sys->i_sid = 0;
p_demux->p_sys->b_rtsp_kasenna = false;
p_demux->p_sys->b_concert = false;
return VLC_SUCCESS;
}
}
......@@ -379,7 +379,7 @@ static int Demux ( demux_t *p_demux )
p_child = input_item_NewWithType( VLC_OBJECT(p_demux), p_sys->psz_uri,
p_sys->psz_name ? p_sys->psz_name : p_sys->psz_uri,
0, NULL, 0, p_sys->i_duration, ITEM_TYPE_NET );
if( !p_child )
{
msg_Err( p_demux, "A valid playlistitem could not be created" );
......@@ -403,7 +403,6 @@ static int Demux ( demux_t *p_demux )
input_item_AddOption( p_child, "rtsp-kasenna", VLC_INPUT_OPTION_TRUSTED );
input_item_AddSubItem( p_current_input, p_child );
input_item_AddSubItem2( 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 */
......
......@@ -226,7 +226,6 @@ static int DemuxGenre( demux_t *p_demux, xml_reader_t *p_xml_reader,
p_input = input_item_New( p_demux, psz_mrl, psz_name );
input_item_CopyOptions( p_input_node->p_item, p_input );
free( psz_mrl );
input_item_AddSubItem( p_input_node->p_item, p_input );
input_item_node_AppendItem( p_input_node, p_input );
vlc_gc_decref( p_input );
}
......@@ -418,7 +417,6 @@ static int DemuxStation( demux_t *p_demux, xml_reader_t *p_xml_reader,
input_item_SetNowPlaying( p_input, psz_ct );
if( psz_rt )
input_item_SetRating( p_input, psz_rt );
input_item_AddSubItem( p_input_node->p_item, p_input );
input_item_node_AppendItem( p_input_node, p_input );
vlc_gc_decref( p_input );
FREENULL( psz_base );
......
......@@ -102,7 +102,6 @@ static int Demux( demux_t *p_demux )
psz_uri = ProcessMRL( psz_uri, p_demux->p_sys->psz_prefix );
p_input = input_item_NewExt( p_demux, psz_uri, psz_uri,
0, NULL, 0, -1 );
input_item_AddSubItem( p_current_input, p_input );
input_item_node_AppendItem( p_subitems, p_input );
vlc_gc_decref( p_input );
}
......
......@@ -129,7 +129,6 @@ int Demux( demux_t *p_demux )
input_item_t *p_new_input = p_demux->p_sys->pp_tracklist[i];
if( p_new_input )
{
input_item_AddSubItem( p_current_input, p_new_input );
input_item_node_AppendItem( p_subitems, p_new_input );
}
}
......@@ -508,7 +507,6 @@ static bool parse_track_node COMPLEX_INTERFACE
if( p_sys->i_track_id < 0 )
{
input_item_AddSubItem( p_input_item, p_new_input );
input_item_node_AppendNode( p_input_node, p_new_node );
vlc_gc_decref( p_new_input );
return true;
......@@ -724,7 +722,6 @@ static bool parse_extension_node COMPLEX_INTERFACE
ITEM_TYPE_DIRECTORY );
if( p_new_input )
{
input_item_AddSubItem( p_input_item, p_new_input );
p_input_node =
input_item_node_AppendItem( p_input_node, p_new_input );
p_input_item = p_new_input;
......@@ -917,7 +914,6 @@ static bool parse_extitem_node COMPLEX_INTERFACE
p_new_input = p_demux->p_sys->pp_tracklist[ i_tid ];
if( p_new_input )
{
input_item_AddSubItem( p_input_node->p_item, p_new_input );
input_item_node_AppendItem( p_input_node, p_new_input );
vlc_gc_decref( p_new_input );
p_demux->p_sys->pp_tracklist[i_tid] = NULL;
......
......@@ -475,7 +475,6 @@ int __vlclua_playlist_add_internal( vlc_object_t *p_this, lua_State *L,
if( p_parent ) /* Add to node */
{
input_item_AddSubItem( p_parent, p_input );
input_item_AddSubItem2( p_parent, p_input );
}
else /* Play or Enqueue (preparse) */
/* FIXME: playlist_AddInput() can fail */
......
......@@ -790,8 +790,7 @@ void MediaServer::_buildPlaylist( Container* parent, input_item_node_t *p_input_
{
Container* container = parent->getContainer( i );
input_item_t* p_input_item = input_item_New( _p_sd, "vlc://nop", parent->getTitle() );
input_item_AddSubItem( parent->getInputItem(), p_input_item );
input_item_t* p_input_item = input_item_New( _p_sd, "vlc://nop", parent->getTitle() );
input_item_node_t *p_new_node =
input_item_node_AppendItem( p_input_node, p_input_item );
......@@ -807,14 +806,12 @@ void MediaServer::_buildPlaylist( Container* parent, input_item_node_t *p_input_
item->getResource(),
item->getTitle() );
assert( p_input_item );
input_item_AddSubItem( parent->getInputItem(), p_input_item );
input_item_node_AppendItem( p_input_node, p_input_item );
item->setInputItem( p_input_item );
}
if( send )
{
input_item_AddSubItemTree( p_input_node );
input_item_node_Delete( p_input_node );
}
}
......
......@@ -183,14 +183,14 @@ void input_item_SetArtNotFound( input_item_t *p_i, bool b_not_found )
p_i->p_meta = vlc_meta_New();
int status = vlc_meta_GetStatus(p_i->p_meta);
if( b_not_found )
status |= ITEM_ART_NOTFOUND;
else
status &= ~ITEM_ART_NOTFOUND;
vlc_meta_SetStatus(p_i->p_meta, status);
vlc_mutex_unlock( &p_i->lock );
}
......@@ -202,7 +202,7 @@ void input_item_SetArtFetched( input_item_t *p_i, bool b_art_fetched )
p_i->p_meta = vlc_meta_New();
int status = vlc_meta_GetStatus(p_i->p_meta);
if( b_art_fetched )
status |= ITEM_ART_FETCHED;
else
......@@ -229,7 +229,7 @@ void input_item_SetMeta( input_item_t *p_i, vlc_meta_type_t meta_type, const cha
vlc_event_send( &p_i->event_manager, &event );
}
/* FIXME GRRRRRRRRRR args should be in the reverse order to be
/* FIXME GRRRRRRRRRR args should be in the reverse order to be
* consistant with (nearly?) all or copy funcs */
void input_item_CopyOptions( input_item_t *p_parent,
input_item_t *p_child )
......@@ -249,6 +249,15 @@ void input_item_CopyOptions( input_item_t *p_parent,
vlc_mutex_unlock( &p_parent->lock );
}
static void notify_subitem_added(input_item_t *p_parent, input_item_t *p_child)
{
/* Notify interested third parties */
vlc_event_t event;
event.type = vlc_InputItemSubItemAdded;
event.u.input_item_subitem_added.p_new_child = p_child;
vlc_event_send( &p_parent->event_manager, &event );
}
/* This won't hold the item, but can tell to interested third parties
* 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
......@@ -256,17 +265,15 @@ void input_item_CopyOptions( input_item_t *p_parent,
void input_item_AddSubItem( 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 interested third parties */
vlc_event_t event;
notify_subitem_added(p_parent, p_child);
event.type = vlc_InputItemSubItemAdded;
event.u.input_item_subitem_added.p_new_child = p_child;
vlc_event_send( &p_parent->event_manager, &event );
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 )
......@@ -277,14 +284,6 @@ void input_item_AddSubItemTree ( input_item_node_t *p_root )
vlc_event_send( &p_root->p_item->event_manager, &event );
}
void input_item_AddSubItem2 ( input_item_t *p_parent, input_item_t *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 );
}
bool input_item_HasErrorWhenReading( input_item_t *p_item )
{
vlc_mutex_lock( &p_item->lock );
......@@ -1035,6 +1034,8 @@ input_item_node_t *input_item_node_AppendItem( input_item_node_t *p_node, input_
void input_item_node_AppendNode( input_item_node_t *p_parent, input_item_node_t *p_child )
{
notify_subitem_added(p_parent->p_item, p_child->p_item);
assert( p_parent && p_child && p_child->p_parent == NULL );
INSERT_ELEM( p_parent->pp_children,
p_parent->i_children,
......
......@@ -189,7 +189,6 @@ input_GetItem
input_item_AddInfo
input_item_AddOption
input_item_AddSubItem
input_item_AddSubItem2
input_item_AddSubItemTree
input_item_CopyOptions
input_item_DelInfo
......
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