]> git.sesse.net Git - vlc/blobdiff - modules/demux/mpeg/mpga.c
demuxers: remove the need for input_thread_t by using the new "meta-preparsed" input...
[vlc] / modules / demux / mpeg / mpga.c
index 2d2400ef12c1cae5555d7020955c959773b33364..d1f871b5921d85875b5eb4f73082556fece24521 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <vlc/vlc.h>
 #include <vlc_demux.h>
+#include <vlc_meta.h>
 #include <vlc_codec.h>
 #include <vlc_input.h>
 
@@ -255,32 +256,22 @@ static int Open( vlc_object_t * p_this )
     p_sys->p_block_out = p_block_out;
 
     /* Parse possible id3 header */
-    input_thread_t *p_input = (input_thread_t *)
-            vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT );
-    if( p_input )
+    if( !var_CreateGetBool( p_demux, "meta-preparsed" ) )
     {
-        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 )
+            return VLC_ENOMEM;
+        if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
         {
-            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 );
+            module_Unneed( p_demux, p_id3 );
+            demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
+            p_sys->meta = p_demux_meta->p_meta;
+            p_sys->i_attachments = p_demux_meta->i_attachments;
+            p_sys->attachments = p_demux_meta->attachments;
         }
-        vlc_object_release( p_input );
+        free( p_demux->p_private );
     }
-
+    else printf("SKIP\n");
     /* */
     p_sys->p_packetizer->fmt_out.b_packetized = VLC_TRUE;
     vlc_audio_replay_gain_MergeFromMeta( &p_sys->p_packetizer->fmt_out.audio_replay_gain,
@@ -355,6 +346,8 @@ static void Close( vlc_object_t * p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys = p_demux->p_sys;
 
+    var_Destroy( p_demux, "meta-preparsed" );
+
     DESTROY_PACKETIZER( p_sys->p_packetizer );
     if( p_sys->meta ) vlc_meta_Delete( p_sys->meta );
     if( p_sys->p_block_out ) block_Release( p_sys->p_block_out );