]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/gvp.c
MKV: code simplification by scope reduction
[vlc] / modules / demux / playlist / gvp.c
index fdec2fbd86e97e505699aa9202baab24244fc54a..2747d985c2f66ce94c93b20b21e8c3aef5e538bd 100644 (file)
@@ -96,7 +96,9 @@ int Import_GVP( vlc_object_t *p_this )
     STANDARD_DEMUX_INIT_MSG(  "using Google Video Playlist (gvp) import" );
     p_demux->pf_control = Control;
     p_demux->pf_demux = Demux;
-    MALLOC_ERR( p_demux->p_sys, demux_sys_t );
+    p_demux->p_sys = malloc( sizeof( demux_sys_t ) );
+    if( !p_demux->p_sys )
+        return VLC_ENOMEM;
 
     return VLC_SUCCESS;
 }
@@ -127,7 +129,9 @@ static int Demux( demux_t *p_demux )
     char *psz_description = NULL;
     input_item_t *p_input;
 
-    INIT_PLAYLIST_STUFF;
+    input_item_t *p_current_input = GetCurrentItem(p_demux);
+
+    input_item_node_t *p_subitems = input_item_node_Create( p_current_input );
 
     p_sys->p_current_input = p_current_input;
 
@@ -178,9 +182,8 @@ static int Demux( demux_t *p_demux )
             else
             {
                 /* handle multi-line descriptions */
-                buf = malloc( strlen( psz_description )
-                            + strlen( psz_attrvalue ) + 2 );
-                sprintf( buf, "%s\n%s", psz_description, psz_attrvalue );
+                if( asprintf( &buf, "%s\n%s", psz_description, psz_attrvalue ) == -1 )
+                    buf = NULL;
                 free( psz_description );
                 psz_description = buf;
             }
@@ -201,18 +204,19 @@ static int Demux( demux_t *p_demux )
     }
     else
     {
-        p_input = input_ItemNewExt( p_demux,
-                                    psz_url, psz_title, 0, NULL, -1 );
-#define SADD_INFO( type, field ) if( field ) { input_ItemAddInfo( \
-                    p_input, _("Google Video"), _(type), "%s", field ) ; }
+        p_input = input_item_New( p_demux, psz_url, psz_title );
+#define SADD_INFO( type, field ) if( field ) { input_item_AddInfo( \
+                    p_input, _("Google Video"), type, "%s", field ) ; }
         SADD_INFO( "gvp_version", psz_version );
         SADD_INFO( "docid", psz_docid );
         SADD_INFO( "description", psz_description );
-        input_ItemAddSubItem( p_current_input, p_input );
+        input_item_node_AppendItem( p_subitems, p_input );
         vlc_gc_decref( p_input );
     }
 
-    HANDLE_PLAY_AND_RELEASE;
+    input_item_node_PostAndDelete( p_subitems );
+
+    vlc_gc_decref(p_current_input);
 
     free( psz_version );
     free( psz_url );