Demuxers: do not load "meta reader" module if the input item has already been preparsed.
authorRafaël Carré <funman@videolan.org>
Wed, 3 Oct 2007 19:29:49 +0000 (19:29 +0000)
committerRafaël Carré <funman@videolan.org>
Wed, 3 Oct 2007 19:29:49 +0000 (19:29 +0000)
modules/codec/ffmpeg/demux.c
modules/demux/flac.c
modules/demux/mpc.c
modules/demux/mpeg/m4a.c
modules/demux/mpeg/mpga.c
modules/demux/ogg.c
modules/demux/tta.c

index 7953794..10051e0 100644 (file)
@@ -259,27 +259,30 @@ int E_(OpenDemux)( vlc_object_t *p_this )
     input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT );
     if( p_input )
     {
-        p_demux->p_private = malloc( sizeof( demux_meta_t ) );
-        if( !p_demux->p_private )
+        if( !( input_GetItem( p_input )->p_meta->i_status & ITEM_PREPARSED ) )
         {
-            vlc_object_release( p_input );
-            return VLC_ENOMEM;
-        }
-        module_t *p_meta = module_Need( p_demux, "meta reader", NULL, 0 );
-        if( p_meta )
-        {
-            demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
-            vlc_meta_Merge( input_GetItem(p_input)->p_meta,
-                    p_demux_meta->p_meta );
-            vlc_meta_Delete( p_demux_meta->p_meta );
-            module_Unneed( p_demux, p_meta );
-            int i;
-            for( i = 0; i < p_demux_meta->i_attachments; i++ )
-                free( p_demux_meta->attachments[i] );
-            TAB_CLEAN( p_demux_meta->i_attachments, p_demux_meta->attachments );
+            p_demux->p_private = malloc( sizeof( demux_meta_t ) );
+            if( !p_demux->p_private )
+            {
+                vlc_object_release( p_input );
+                return VLC_ENOMEM;
+            }
+            module_t *p_meta = module_Need( p_demux, "meta reader", NULL, 0 );
+            if( p_meta )
+            {
+                demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
+                vlc_meta_Merge( input_GetItem(p_input)->p_meta,
+                        p_demux_meta->p_meta );
+                vlc_meta_Delete( p_demux_meta->p_meta );
+                module_Unneed( p_demux, p_meta );
+                int i;
+                for( i = 0; i < p_demux_meta->i_attachments; i++ )
+                    free( p_demux_meta->attachments[i] );
+                TAB_CLEAN( p_demux_meta->i_attachments, p_demux_meta->attachments );
+            }
+            free( p_demux->p_private );
         }
         vlc_object_release( p_input );
-        free( p_demux->p_private );
     }
 
     return VLC_SUCCESS;
index ab88625..7ff557c 100644 (file)
@@ -155,34 +155,45 @@ static int Open( vlc_object_t * p_this )
     }
 
     /* Parse possible id3 header */
-    p_demux->p_private = malloc( sizeof( demux_meta_t ) );
-    if( !p_demux->p_private )
-        return VLC_ENOMEM;
-    if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
+    input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT );
+    if( p_input )
     {
-        demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
-        vlc_meta_t *p_meta = p_demux_meta->p_meta;
-
-        if( !p_sys->p_meta )
+        if( !( input_GetItem( p_input )->p_meta->i_status & ITEM_PREPARSED ) )
         {
-            p_sys->p_meta = p_meta;
-        }
-        else if( p_meta )
-        {
-            vlc_meta_Merge( p_sys->p_meta, p_meta );
-            vlc_meta_Delete( p_meta );
+            p_demux->p_private = malloc( sizeof( demux_meta_t ) );
+            if( !p_demux->p_private )
+            {
+                vlc_object_release( p_input );
+                return VLC_ENOMEM;
+            }
+            if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
+            {
+                demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
+                vlc_meta_t *p_meta = p_demux_meta->p_meta;
+
+                if( !p_sys->p_meta )
+                {
+                    p_sys->p_meta = p_meta;
+                }
+                else if( p_meta )
+                {
+                    vlc_meta_Merge( p_sys->p_meta, p_meta );
+                    vlc_meta_Delete( p_meta );
+                }
+                p_demux->p_private = NULL;
+                module_Unneed( p_demux, p_id3 );
+                int i;
+                for( i = 0; i < p_demux_meta->i_attachments; i++ )
+                    TAB_APPEND_CAST( (input_attachment_t**),
+                            p_sys->i_attachments, p_sys->attachments,
+                            p_demux_meta->attachments[p_demux_meta->i_attachments] );
+                TAB_CLEAN( p_demux_meta->i_attachments,
+                            p_demux_meta->attachments );
+            }
+            free( p_demux->p_private );
         }
-        p_demux->p_private = NULL;
-        module_Unneed( p_demux, p_id3 );
-        int i;
-        for( i = 0; i < p_demux_meta->i_attachments; i++ )
-            TAB_APPEND_CAST( (input_attachment_t**),
-                    p_sys->i_attachments, p_sys->attachments,
-                    p_demux_meta->attachments[p_demux_meta->i_attachments] );
-
-        TAB_CLEAN( p_demux_meta->i_attachments, p_demux_meta->attachments );
+        vlc_object_release( p_input );
     }
-    free( p_demux->p_private );
 
     if( p_sys->i_cover_idx < p_sys->i_attachments )
     {
index b61f7e0..c201ed8 100644 (file)
@@ -189,20 +189,32 @@ static int Open( vlc_object_t * p_this )
     }
 
     /* Parse possible id3 header */
-    p_demux->p_private = malloc( sizeof( demux_meta_t ) );
-    if( !p_demux->p_private )
-        return VLC_ENOMEM;
-    if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
+    input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT );
+    if( p_input )
     {
-        demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
-        p_sys->p_meta = p_demux_meta->p_meta;
-        module_Unneed( p_demux, p_id3 );
-        int i;
-        for( i = 0; i < p_demux_meta->i_attachments; i++ )
-            free( p_demux_meta->attachments[i] );
-        TAB_CLEAN( p_demux_meta->i_attachments, p_demux_meta->attachments );
+        if( !( input_GetItem( p_input )->p_meta->i_status & ITEM_PREPARSED ) )
+        {
+            p_demux->p_private = malloc( sizeof( demux_meta_t ) );
+            if( !p_demux->p_private )
+            {
+                vlc_object_release( p_input );
+                return VLC_ENOMEM;
+            }
+            if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
+            {
+                demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
+                p_sys->p_meta = p_demux_meta->p_meta;
+                module_Unneed( p_demux, p_id3 );
+                int i;
+                for( i = 0; i < p_demux_meta->i_attachments; i++ )
+                    free( p_demux_meta->attachments[i] );
+                TAB_CLEAN( p_demux_meta->i_attachments,
+                            p_demux_meta->attachments );
+            }
+            free( p_demux->p_private );
+        }
+        vlc_object_release( p_input );
     }
-    free( p_demux->p_private );
 
     if( !p_sys->p_meta )
         p_sys->p_meta = vlc_meta_New();
index 70da53a..5911d49 100644 (file)
@@ -110,21 +110,33 @@ static int Open( vlc_object_t * p_this )
     LOAD_PACKETIZER_OR_FAIL( p_sys->p_packetizer, "mp4 audio" );
 
     /* Parse possible id3 header */
-    p_demux->p_private = malloc( sizeof( demux_meta_t ) );
-    if( !p_demux->p_private )
-        return VLC_ENOMEM;
-    if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
+    input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT );
+    if( p_input )
     {
-        demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
-        p_sys->meta = p_demux_meta->p_meta;
-        p_demux->p_private = NULL;
-        module_Unneed( p_demux, p_id3 );
-        int i;
-        for( i = 0; i < p_demux_meta->i_attachments; i++ )
-            free( p_demux_meta->attachments[i] );
-        TAB_CLEAN( p_demux_meta->i_attachments, p_demux_meta->attachments );
+        if( !( input_GetItem( p_input )->p_meta->i_status & ITEM_PREPARSED ) )
+        {
+            p_demux->p_private = malloc( sizeof( demux_meta_t ) );
+            if( !p_demux->p_private )
+            {
+                vlc_object_release( p_input );
+                return VLC_ENOMEM;
+            }
+            if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
+            {
+                demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
+                p_sys->meta = p_demux_meta->p_meta;
+                p_demux->p_private = NULL;
+                module_Unneed( p_demux, p_id3 );
+                int i;
+                for( i = 0; i < p_demux_meta->i_attachments; i++ )
+                    free( p_demux_meta->attachments[i] );
+                TAB_CLEAN( p_demux_meta->i_attachments,
+                            p_demux_meta->attachments );
+            }
+            free( p_demux->p_private );
+        }
+        vlc_object_release( p_input );
     }
-    free( p_demux->p_private );
     return VLC_SUCCESS;
 }
 
index 6e0b565..2d2400e 100644 (file)
@@ -255,19 +255,31 @@ static int Open( vlc_object_t * p_this )
     p_sys->p_block_out = p_block_out;
 
     /* Parse possible id3 header */
-    p_demux->p_private = malloc( sizeof( demux_meta_t ) );
-    if( !p_demux->p_private )
-        return VLC_ENOMEM;
-    if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
+    input_thread_t *p_input = (input_thread_t *)
+            vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT );
+    if( p_input )
     {
-        demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
-        p_sys->meta = p_demux_meta->p_meta;
-        p_demux->p_private = NULL;
-        module_Unneed( p_demux, p_id3 );
-        p_sys->i_attachments = p_demux_meta->i_attachments;
-        p_sys->attachments = p_demux_meta->attachments;
+        if( !( input_GetItem( p_input )->p_meta->i_status & ITEM_PREPARSED ) )
+        {
+            p_demux->p_private = malloc( sizeof( demux_meta_t ) );
+            if( !p_demux->p_private )
+            {
+                vlc_object_release( p_input );
+                return VLC_ENOMEM;
+            }
+            if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
+            {
+                demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
+                p_sys->meta = p_demux_meta->p_meta;
+                p_demux->p_private = NULL;
+                module_Unneed( p_demux, p_id3 );
+                p_sys->i_attachments = p_demux_meta->i_attachments;
+                p_sys->attachments = p_demux_meta->attachments;
+            }
+            free( p_demux->p_private );
+        }
+        vlc_object_release( p_input );
     }
-    free( p_demux->p_private );
 
     /* */
     p_sys->p_packetizer->fmt_out.b_packetized = VLC_TRUE;
index 4082522..b2b56cf 100644 (file)
@@ -211,25 +211,28 @@ static int Open( vlc_object_t * p_this )
     p_input = (input_thread_t *)vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT );
     if( p_input )
     {
-        p_demux->p_private = malloc( sizeof( demux_meta_t ) );
-        if( !p_demux->p_private )
+        if( !( input_GetItem( p_input )->p_meta->i_status & ITEM_PREPARSED ) )
         {
-            vlc_object_release( p_input );
-            return VLC_ENOMEM;
-        }
-        module_t *p_meta = module_Need( p_demux, "meta reader", NULL, 0 );
-        if( p_meta )
-        {
-            demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
-            vlc_meta_Merge( input_GetItem(p_input)->p_meta,
-                    p_demux_meta->p_meta );
-            vlc_meta_Delete( p_demux_meta->p_meta );
-            module_Unneed( p_demux, p_meta );
-            p_sys->i_attachments = p_demux_meta->i_attachments;
-            p_sys->attachments = p_demux_meta->attachments;
+            p_demux->p_private = malloc( sizeof( demux_meta_t ) );
+            if( !p_demux->p_private )
+            {
+                vlc_object_release( p_input );
+                return VLC_ENOMEM;
+            }
+            module_t *p_meta = module_Need( p_demux, "meta reader", NULL, 0 );
+            if( p_meta )
+            {
+                demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
+                vlc_meta_Merge( input_GetItem(p_input)->p_meta,
+                        p_demux_meta->p_meta );
+                vlc_meta_Delete( p_demux_meta->p_meta );
+                module_Unneed( p_demux, p_meta );
+                p_sys->i_attachments = p_demux_meta->i_attachments;
+                p_sys->attachments = p_demux_meta->attachments;
+            }
+            free( p_demux->p_private );
         }
         vlc_object_release( p_input );
-        free( p_demux->p_private );
     }
 
     /* Initialize the Ogg physical bitstream parser */
index 8a226c2..7763edf 100644 (file)
@@ -141,22 +141,34 @@ static int Open( vlc_object_t * p_this )
 
 #if 0
     /* Parse possible id3 header */
-    p_demux->p_private = malloc( sizeof( demux_meta_t ) );
-    if( !p_demux->p_private )
-        return VLC_ENOMEM;
-    if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
+    input_thread_t *p_input = (input_thread_t *)
+            vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT );
+    if( p_input )
     {
-        demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
-        p_sys->p_meta = p_demux_meta->p_meta;
-        p_demux->p_private = NULL;
-        module_Unneed( p_demux, p_id3 );
-        int i;
-        for( i = 0; i < p_demux_meta->i_attachments; i++ )
-            free( p_demux_meta->attachments[i] );
-        TAB_CLEAN( p_demux_meta->i_attachments, p_demux_meta->attachments );
+        if( !( input_GetItem( p_input )->p_meta->i_status & ITEM_PREPARSED ) )
+        {
+            p_demux->p_private = malloc( sizeof( demux_meta_t ) );
+            if( !p_demux->p_private )
+            {
+                vlc_object_release( p_input );
+                return VLC_ENOMEM;
+            }
+            if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
+            {
+                demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
+                p_sys->p_meta = p_demux_meta->p_meta;
+                p_demux->p_private = NULL;
+                module_Unneed( p_demux, p_id3 );
+                int i;
+                for( i = 0; i < p_demux_meta->i_attachments; i++ )
+                    free( p_demux_meta->attachments[i] );
+                TAB_CLEAN( p_demux_meta->i_attachments,
+                            p_demux_meta->attachments );
+            }
+            free( p_demux->p_private );
+        }
+        vlc_object_release( p_input );
     }
-    free( p_demux->p_private );
-
     if( !p_sys->p_meta )
         p_sys->p_meta = vlc_meta_New();
 #endif