From c15ad990b334a9c8c949972d4b59e827e4bb13f5 Mon Sep 17 00:00:00 2001
From: Jakob Leben <jleben@videolan.org>
Date: Mon, 1 Feb 2010 07:27:24 +0100
Subject: [PATCH 2/3] update modules to use input_item_[Begin/End]SubItems

---
 modules/access/cdda.c                     |    4 +++
 modules/access/mms/mmsh.c                 |    5 +++-
 modules/demux/mp4/mp4.c                   |    3 ++
 modules/demux/playlist/asx.c              |    5 +++
 modules/demux/playlist/b4s.c              |    6 ++++
 modules/demux/playlist/dvb.c              |    4 +++
 modules/demux/playlist/gvp.c              |    4 +++
 modules/demux/playlist/ifo.c              |    4 +++
 modules/demux/playlist/itml.c             |    2 +
 modules/demux/playlist/m3u.c              |    2 +
 modules/demux/playlist/pls.c              |    4 +++
 modules/demux/playlist/podcast.c          |    7 +++++
 modules/demux/playlist/qtl.c              |    2 +
 modules/demux/playlist/ram.c              |    3 ++
 modules/demux/playlist/sgimb.c            |    2 +
 modules/demux/playlist/shoutcast.c        |    3 ++
 modules/demux/playlist/wpl.c              |    5 +++
 modules/demux/playlist/xspf.c             |   42 ++++++++++++++++++++---------
 modules/demux/playlist/zpl.c              |    4 +++
 modules/misc/lua/vlc.c                    |    4 +++
 modules/services_discovery/upnp_intel.cpp |    4 +++
 21 files changed, 105 insertions(+), 14 deletions(-)

diff --git a/modules/access/cdda.c b/modules/access/cdda.c
index 6dface0..11edf58 100644
--- a/modules/access/cdda.c
+++ b/modules/access/cdda.c
@@ -480,6 +480,8 @@ static int GetTracks( access_t *p_access, input_item_t *p_current )
                                CDDA_DATA_SIZE * 1000000 / 44100 / 2 / 2;
     input_item_SetDuration( p_current, i_duration );
 
+    input_item_BeginAddSubItems( p_current );
+
     /* Build title table */
     for( int i = 0; i < i_titles; i++ )
     {
@@ -583,6 +585,8 @@ static int GetTracks( access_t *p_access, input_item_t *p_current )
 #undef ON_EMPTY
 #undef NONEMPTY
 
+    input_item_EndAddSubItems( p_current );
+
     /* */
     for( int i = 0; i < i_cd_text; i++ )
     {
diff --git a/modules/access/mms/mmsh.c b/modules/access/mms/mmsh.c
index b89565c..ee45f6a 100644
--- a/modules/access/mms/mmsh.c
+++ b/modules/access/mms/mmsh.c
@@ -165,7 +165,10 @@ 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_AddSubItem( input_GetItem( p_input ), p_new_loc );
+        input_item_t *p_item = input_GetItem( p_input );
+        input_item_BeginAddSubItems( p_item );
+        input_item_AddSubItem( p_item, p_new_loc );
+        input_item_EndAddSubItems( p_item );
         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 c07bb1d..8286497 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -370,6 +370,8 @@ static int Open( vlc_object_t * p_this )
         input_thread_t *p_input = demux_GetParentInput( p_demux );
         input_item_t *p_current = input_GetItem( p_input );
 
+        input_item_BeginAddSubItems( p_current );
+
         for( i = 0; i < i_count; i++ )
         {
             MP4_Box_t *p_rdrf = MP4_BoxGet( p_rmra, "rmda[%d]/rdrf", i );
@@ -431,6 +433,7 @@ static int Open( vlc_object_t * p_this )
             }
             free( psz_ref );
         }
+        input_item_EndAddSubItems( p_current );
         vlc_object_release( p_input );
     }
 
diff --git a/modules/demux/playlist/asx.c b/modules/demux/playlist/asx.c
index 06810f6..1447498 100644
--- a/modules/demux/playlist/asx.c
+++ b/modules/demux/playlist/asx.c
@@ -261,6 +261,8 @@ static int Demux( demux_t *p_demux )
         if( p_sys->i_data_len <= 0 ) return -1;
     }
 
+    input_item_BeginAddSubItems( p_current_input );
+
     psz_parse = p_sys->psz_data;
     /* Find first element */
     if( ( psz_parse = strcasestr( psz_parse, "<ASX" ) ) )
@@ -761,6 +763,9 @@ static int Demux( demux_t *p_demux )
             STARTMARK
 #endif
     }
+
+    input_item_EndAddSubItems( p_current_input );
+
     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 e6ebe08..8ccac7d 100644
--- a/modules/demux/playlist/b4s.c
+++ b/modules/demux/playlist/b4s.c
@@ -80,6 +80,7 @@ static int Demux( demux_t *p_demux )
     input_item_t *p_input;
     char *psz_mrl = NULL, *psz_title = NULL, *psz_genre = NULL;
     char *psz_now = NULL, *psz_listeners = NULL, *psz_bitrate = NULL;
+    bool b_began_adding_subitems = false;
 
     input_item_t *p_current_input = GetCurrentItem(p_demux);
 
@@ -161,6 +162,9 @@ static int Demux( demux_t *p_demux )
         free( psz_value );
     }
 
+    input_item_BeginAddSubItems( p_current_input );
+    b_began_adding_subitems = true;
+
     while( (i_ret = xml_ReaderRead( p_xml_reader )) == 1 )
     {
         // Get the node type
@@ -290,6 +294,8 @@ static int Demux( demux_t *p_demux )
 end:
     free( psz_elname );
 
+    if( b_began_adding_subitems ) input_item_EndAddSubItems( p_current_input );
+
     vlc_gc_decref( p_current_input );
     if( p_xml_reader )
         xml_ReaderDelete( p_xml, p_xml_reader );
diff --git a/modules/demux/playlist/dvb.c b/modules/demux/playlist/dvb.c
index 9a7d6e2..f664220 100644
--- a/modules/demux/playlist/dvb.c
+++ b/modules/demux/playlist/dvb.c
@@ -102,6 +102,8 @@ static int Demux( demux_t *p_demux )
     input_item_t *p_input;
     input_item_t *p_current_input = GetCurrentItem(p_demux);
 
+    input_item_BeginAddSubItems( p_current_input );
+
     while( (psz_line = stream_ReadLine( p_demux->s )) )
     {
         char **ppsz_options = NULL;
@@ -130,6 +132,8 @@ static int Demux( demux_t *p_demux )
         free( psz_line );
     }
 
+    input_item_EndAddSubItems( p_current_input );
+
     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 59299d7..56003ea 100644
--- a/modules/demux/playlist/gvp.c
+++ b/modules/demux/playlist/gvp.c
@@ -131,6 +131,8 @@ static int Demux( demux_t *p_demux )
 
     input_item_t *p_current_input = GetCurrentItem(p_demux);
 
+    input_item_BeginAddSubItems( p_current_input );
+
     p_sys->p_current_input = p_current_input;
 
     while( ( psz_line = stream_ReadLine( p_demux->s ) ) )
@@ -212,6 +214,8 @@ static int Demux( demux_t *p_demux )
         vlc_gc_decref( p_input );
     }
 
+    input_item_EndAddSubItems( p_current_input );
+
     vlc_gc_decref(p_current_input);
 
     free( psz_version );
diff --git a/modules/demux/playlist/ifo.c b/modules/demux/playlist/ifo.c
index c8043ba..28ae40c 100644
--- a/modules/demux/playlist/ifo.c
+++ b/modules/demux/playlist/ifo.c
@@ -109,8 +109,10 @@ static int Demux( demux_t *p_demux )
     snprintf( psz_url, len+1, "dvd://%s", p_demux->psz_path );
 
     input_item_t *p_current_input = GetCurrentItem(p_demux);
+    input_item_BeginAddSubItems( p_current_input );
     input_item_t *p_input = input_item_New( p_demux, psz_url, psz_url );
     input_item_AddSubItem( p_current_input, p_input );
+    input_item_EndAddSubItems( p_current_input );
     vlc_gc_decref( p_input );
 
     vlc_gc_decref(p_current_input);
@@ -131,8 +133,10 @@ static int DemuxDVD_VR( demux_t *p_demux )
     strncpy( psz_url + len - 12, "VR_MOVIE.VRO", 12 );
 
     input_item_t *p_current_input = GetCurrentItem(p_demux);
+    input_item_BeginAddSubItems( p_current_input );
     input_item_t *p_input = input_item_New( p_demux, psz_url, psz_url );
     input_item_AddSubItem( p_current_input, p_input );
+    input_item_EndAddSubItems( p_current_input );
     vlc_gc_decref( p_input );
 
     vlc_gc_decref(p_current_input);
diff --git a/modules/demux/playlist/itml.c b/modules/demux/playlist/itml.c
index 05c0fce..1753bf2 100644
--- a/modules/demux/playlist/itml.c
+++ b/modules/demux/playlist/itml.c
@@ -101,10 +101,12 @@ int Demux( demux_t *p_demux )
         goto end;
     }
 
+    input_item_BeginAddSubItems( p_current_input );
     xml_elem_hnd_t pl_elements[] =
         { {"dict",    COMPLEX_CONTENT, {.cmplx = parse_plist_dict} } };
     parse_plist_node( p_demux, p_current_input, NULL, p_xml_reader, "plist",
                       pl_elements );
+    input_item_EndAddSubItems( p_current_input );
 
     vlc_gc_decref(p_current_input);
 
diff --git a/modules/demux/playlist/m3u.c b/modules/demux/playlist/m3u.c
index e4168ad..ecfb345 100644
--- a/modules/demux/playlist/m3u.c
+++ b/modules/demux/playlist/m3u.c
@@ -145,6 +145,7 @@ static int Demux( demux_t *p_demux )
     input_item_t *p_input;
 
     input_item_t *p_current_input = GetCurrentItem(p_demux);
+    input_item_BeginAddSubItems( p_current_input );
 
     psz_line = stream_ReadLine( p_demux->s );
     while( psz_line )
@@ -253,6 +254,7 @@ static int Demux( demux_t *p_demux )
             b_cleanup = false;
         }
     }
+    input_item_EndAddSubItems( p_current_input );
     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 c0427eb..1297f06 100644
--- a/modules/demux/playlist/pls.c
+++ b/modules/demux/playlist/pls.c
@@ -93,6 +93,8 @@ static int Demux( demux_t *p_demux )
 
     input_item_t *p_current_input = GetCurrentItem(p_demux);
 
+    input_item_BeginAddSubItems( p_current_input );
+
     while( ( psz_line = stream_ReadLine( p_demux->s ) ) )
     {
         if( !strncasecmp( psz_line, "[playlist]", sizeof("[playlist]")-1 ) ||
@@ -228,6 +230,8 @@ static int Demux( demux_t *p_demux )
     free( psz_name );
     psz_name = NULL;
 
+    input_item_EndAddSubItems( p_current_input );
+
     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 ee95cea..df2decc 100644
--- a/modules/demux/playlist/podcast.c
+++ b/modules/demux/playlist/podcast.c
@@ -69,6 +69,7 @@ void Close_podcast( vlc_object_t *p_this )
 /* "specs" : http://phobos.apple.com/static/iTunesRSS.html */
 static int Demux( demux_t *p_demux )
 {
+    bool b_began_adding_subitems = false;
     bool b_item = false;
     bool b_image = false;
     int i_ret;
@@ -128,6 +129,9 @@ static int Demux( demux_t *p_demux )
     }
     FREENULL( psz_elname );
 
+    input_item_BeginAddSubItems( p_current_input );
+    b_began_adding_subitems = true;
+
     while( (i_ret = xml_ReaderRead( p_xml_reader )) == 1 )
     {
         // Get the node type
@@ -365,6 +369,7 @@ static int Demux( demux_t *p_demux )
     xml_ReaderDelete( p_xml, p_xml_reader );
     xml_Delete( p_xml );
 
+    input_item_EndAddSubItems( p_current_input );
     vlc_gc_decref(p_current_input);
     return 0; /* Needed for correct operation of go back */
 
@@ -387,6 +392,8 @@ error:
         xml_ReaderDelete( p_xml, p_xml_reader );
     if( p_xml )
         xml_Delete( p_xml );
+    if( b_began_adding_subitems )
+        input_item_EndAddSubItems( p_current_input );
 
     vlc_gc_decref(p_current_input);
     return -1;
diff --git a/modules/demux/playlist/qtl.c b/modules/demux/playlist/qtl.c
index 51f5a5e..1ee410d 100644
--- a/modules/demux/playlist/qtl.c
+++ b/modules/demux/playlist/qtl.c
@@ -304,6 +304,7 @@ static int Demux( demux_t *p_demux )
     }
     else
     {
+        input_item_BeginAddSubItems( p_current_input );
         p_input = input_item_New( p_demux, psz_src, psz_moviename );
 #define SADD_INFO( type, field ) if( field ) { input_item_AddInfo( \
                     p_input, "QuickTime Media Link", type, "%s", field ) ; }
@@ -317,6 +318,7 @@ static int Demux( demux_t *p_demux )
             input_item_AddSubItem( p_current_input, p_input );
             vlc_gc_decref( p_input );
         }
+        input_item_EndAddSubItems( p_current_input );
     }
 
     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 8542f06..a1932b9 100644
--- a/modules/demux/playlist/ram.c
+++ b/modules/demux/playlist/ram.c
@@ -214,6 +214,8 @@ static int Demux( demux_t *p_demux )
 
     input_item_t *p_current_input = GetCurrentItem(p_demux);
 
+    input_item_BeginAddSubItems( p_current_input );
+
     psz_line = stream_ReadLine( p_demux->s );
     while( psz_line )
     {
@@ -358,6 +360,7 @@ static int Demux( demux_t *p_demux )
             b_cleanup = false;
         }
     }
+    input_item_EndAddSubItems( p_current_input );
     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 d0a3200..055068b 100644
--- a/modules/demux/playlist/sgimb.c
+++ b/modules/demux/playlist/sgimb.c
@@ -402,7 +402,9 @@ 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_BeginAddSubItems( p_current_input );
     input_item_AddSubItem( p_current_input, p_child );
+    input_item_EndAddSubItems( p_current_input );
     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 b6935c8..08c0d60 100644
--- a/modules/demux/playlist/shoutcast.c
+++ b/modules/demux/playlist/shoutcast.c
@@ -110,6 +110,8 @@ static int Demux( demux_t *p_demux )
         goto error;
     }
 
+    input_item_BeginAddSubItems( p_current_input );
+
     if( !strcmp( psz_eltname, "genrelist" ) )
     {
         /* we're reading a genre list */
@@ -132,6 +134,7 @@ error:
     if( p_xml )
         xml_Delete( p_xml );
     free( psz_eltname );
+    input_item_EndAddSubItems( p_current_input );
     vlc_gc_decref(p_current_input);
     return i_ret;
 }
diff --git a/modules/demux/playlist/wpl.c b/modules/demux/playlist/wpl.c
index 488d2ef..d2a1d1b 100644
--- a/modules/demux/playlist/wpl.c
+++ b/modules/demux/playlist/wpl.c
@@ -78,6 +78,8 @@ static int Demux( demux_t *p_demux )
     char       *psz_line;
     input_item_t *p_current_input = GetCurrentItem(p_demux);
 
+    input_item_BeginAddSubItems( p_current_input );
+
     while( (psz_line = stream_ReadLine( p_demux->s )) )
     {
         char *psz_parse = psz_line;
@@ -108,6 +110,9 @@ static int Demux( demux_t *p_demux )
         free( psz_line );
 
     }
+
+    input_item_EndAddSubItems( p_current_input );
+
     vlc_gc_decref(p_current_input);
     var_Destroy( p_demux, "wpl-extvlcopt" );
     return 0; /* Needed for correct operation of go back */
diff --git a/modules/demux/playlist/xspf.c b/modules/demux/playlist/xspf.c
index ec5f9f6..a9f2265 100644
--- a/modules/demux/playlist/xspf.c
+++ b/modules/demux/playlist/xspf.c
@@ -118,6 +118,8 @@ int Demux( demux_t *p_demux )
     }
     free( psz_name );
 
+    input_item_BeginAddSubItems( p_current_input );
+
     i_ret = parse_playlist_node( p_demux, p_current_input,
                                  p_xml_reader, "playlist" ) ? 0 : -1;
 
@@ -130,6 +132,8 @@ int Demux( demux_t *p_demux )
         }
     }
 
+    input_item_EndAddSubItems( p_current_input );
+
 end:
     vlc_gc_decref(p_current_input);
     if( p_xml_reader )
@@ -446,10 +450,14 @@ static bool parse_track_node COMPLEX_INTERFACE
                 if( p_handler->type == COMPLEX_CONTENT )
                 {
                     FREE_VALUE();
-                    if( p_handler->pf_handler.cmplx( p_demux,
-                                                     p_new_input,
-                                                     p_xml_reader,
-                                                     p_handler->name ) )
+
+                    input_item_BeginAddSubItems( p_new_input );
+                    bool b_res = p_handler->pf_handler.cmplx( p_demux,
+                                                        p_new_input,
+                                                        p_xml_reader,
+                                                        p_handler->name );
+                    input_item_EndAddSubItems( p_new_input );
+                    if( b_res )
                     {
                         p_handler = NULL;
                     }
@@ -713,6 +721,7 @@ static bool parse_extension_node COMPLEX_INTERFACE
             input_item_AddSubItem( p_input_item, p_new_input );
             p_input_item = p_new_input;
             b_release_input_item = true;
+            input_item_BeginAddSubItems( p_new_input );
         }
         free( psz_title );
     }
@@ -732,6 +741,13 @@ static bool parse_extension_node COMPLEX_INTERFACE
     }
     free( psz_application );
 
+#define RELEASE {                                 \
+    if( b_release_input_item ) {                  \
+        input_item_EndAddSubItems( p_new_input ); \
+        vlc_gc_decref( p_new_input );             \
+    }                                             \
+}                                                 \
+
     /* parse the child elements */
     while( xml_ReaderRead( p_xml_reader ) == 1 )
     {
@@ -747,7 +763,7 @@ static bool parse_extension_node COMPLEX_INTERFACE
                 {
                     msg_Err( p_demux, "invalid xml stream" );
                     FREE_ATT();
-                    if( b_release_input_item ) vlc_gc_decref( p_new_input );
+                     RELEASE
                     return false;
                 }
                 /* choose handler */
@@ -758,7 +774,7 @@ static bool parse_extension_node COMPLEX_INTERFACE
                 {
                     msg_Err( p_demux, "unexpected element <%s>", psz_name );
                     FREE_ATT();
-                    if( b_release_input_item ) vlc_gc_decref( p_new_input );
+                    RELEASE;
                     return false;
                 }
                 FREE_NAME();
@@ -776,7 +792,7 @@ static bool parse_extension_node COMPLEX_INTERFACE
                     else
                     {
                         FREE_ATT();
-                        if( b_release_input_item ) vlc_gc_decref( p_new_input );
+                        RELEASE;
                         return false;
                     }
                 }
@@ -790,7 +806,7 @@ static bool parse_extension_node COMPLEX_INTERFACE
                 {
                     msg_Err( p_demux, "invalid xml stream" );
                     FREE_ATT();
-                    if( b_release_input_item ) vlc_gc_decref( p_new_input );
+                    RELEASE;
                     return false;
                 }
                 break;
@@ -802,14 +818,14 @@ static bool parse_extension_node COMPLEX_INTERFACE
                 {
                     msg_Err( p_demux, "invalid xml stream" );
                     FREE_ATT();
-                    if( b_release_input_item ) vlc_gc_decref( p_new_input );
+                    RELEASE;
                     return false;
                 }
                 /* leave if the current parent node is terminated */
                 if( !strcmp( psz_name, psz_element ) )
                 {
                     FREE_ATT();
-                    if( b_release_input_item ) vlc_gc_decref( p_new_input );
+                    RELEASE;
                     return true;
                 }
                 /* there MUST have been a start tag for that element name */
@@ -819,7 +835,7 @@ static bool parse_extension_node COMPLEX_INTERFACE
                     msg_Err( p_demux, "there's no open element left for <%s>",
                              psz_name );
                     FREE_ATT();
-                    if( b_release_input_item ) vlc_gc_decref( p_new_input );
+                    RELEASE;
                     return false;
                 }
 
@@ -841,12 +857,12 @@ static bool parse_extension_node COMPLEX_INTERFACE
                 /* unknown/unexpected xml node */
                 msg_Err( p_demux, "unexpected xml node %i", i_node );
                 FREE_ATT();
-                if( b_release_input_item ) vlc_gc_decref( p_new_input );
+                RELEASE;
                 return false;
         }
         FREE_NAME();
     }
-    if( b_release_input_item ) vlc_gc_decref( p_new_input );
+    RELEASE;
     return false;
 }
 
diff --git a/modules/demux/playlist/zpl.c b/modules/demux/playlist/zpl.c
index 8d64afc..eed0417 100644
--- a/modules/demux/playlist/zpl.c
+++ b/modules/demux/playlist/zpl.c
@@ -103,6 +103,8 @@ static int Demux( demux_t *p_demux )
         psz_line = stream_ReadLine( p_demux->s );
     }
 
+    input_item_BeginAddSubItems( p_current_input );
+
     /* Loop on all lines */
     while( psz_line )
     {
@@ -198,6 +200,8 @@ static int Demux( demux_t *p_demux )
         psz_line = stream_ReadLine( p_demux->s );
     }
 
+    input_item_EndAddSubItems( p_current_input );
+
     vlc_gc_decref(p_current_input);
     var_Destroy( p_demux, "zpl-extvlcopt" );
     return 0; /* Needed for correct operation of go back */
diff --git a/modules/misc/lua/vlc.c b/modules/misc/lua/vlc.c
index bb4ba98..072a907 100644
--- a/modules/misc/lua/vlc.c
+++ b/modules/misc/lua/vlc.c
@@ -473,7 +473,11 @@ 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_BeginAddSubItems( p_parent );
                         input_item_AddSubItem( p_parent, p_input );
+                        input_item_EndAddSubItems( p_parent );
+                    }
                     else /* Play or Enqueue (preparse) */
                         /* FIXME: playlist_AddInput() can fail */
                         playlist_AddInput( p_playlist, p_input,
diff --git a/modules/services_discovery/upnp_intel.cpp b/modules/services_discovery/upnp_intel.cpp
index 6ea48cf..ce1a213 100644
--- a/modules/services_discovery/upnp_intel.cpp
+++ b/modules/services_discovery/upnp_intel.cpp
@@ -782,6 +782,8 @@ bool MediaServer::_fetchContents( Container* parent )
 
 void MediaServer::_buildPlaylist( Container* parent )
 {
+    input_item_BeginAddSubItems( parent->getInputItem() );
+
     for ( unsigned int i = 0; i < parent->getNumContainers(); i++ )
     {
         Container* container = parent->getContainer( i );
@@ -804,6 +806,8 @@ void MediaServer::_buildPlaylist( Container* parent )
         input_item_AddSubItem( parent->getInputItem(), p_input_item );
         item->setInputItem( p_input_item );
     }
+
+    input_item_EndAddSubItems( parent->getInputItem() );
 }
 
 void MediaServer::setInputItem( input_item_t* p_input_item )
-- 
1.6.3.3

