]> git.sesse.net Git - vlc/blobdiff - modules/demux/wav.c
* New (experimental and incomplete) demuxstream module. It bypasses the
[vlc] / modules / demux / wav.c
index 6a2c3070e8a82e7e1457975a20edb2c262b1fab2..d3dc00187af99f44a21d6bbca4ccc598b4aeba98 100644 (file)
@@ -2,7 +2,7 @@
  * wav.c : wav file input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: wav.c,v 1.4 2003/08/18 00:17:44 fenrir Exp $
+ * $Id: wav.c,v 1.7 2003/09/12 16:26:40 fenrir Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -30,7 +30,6 @@
 #include <vlc/input.h>
 
 #include <codecs.h>
-#include <ninput.h>
 
 /*****************************************************************************
  * Module descriptor
@@ -53,8 +52,6 @@ static int  Demux       ( input_thread_t * );
 
 struct demux_sys_t
 {
-    stream_t        *s;
-
     WAVEFORMATEX    *p_wf;
     es_descriptor_t *p_es;
 
@@ -104,19 +101,14 @@ static int Open( vlc_object_t * p_this )
     }
 
     p_input->pf_demux     = Demux;
+    p_input->pf_demux_control = demux_vaControlDefault;
     p_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) );
     p_sys->p_wf           = NULL;
     p_sys->p_es           = NULL;
     p_sys->i_time         = 0;
 
-    if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL )
-    {
-        msg_Err( p_input, "cannot create stream" );
-        goto error;
-    }
-
     /* skip riff header */
-    stream_Read( p_sys->s, NULL, 12 );  /* cannot fail as peek succeed */
+    stream_Read( p_input->s, NULL, 12 );  /* cannot fail as peek succeed */
 
     /* search fmt chunk */
     if( ChunkFind( p_input, "fmt ", &i_size ) )
@@ -129,12 +121,13 @@ static int Open( vlc_object_t * p_this )
         msg_Err( p_input, "invalid 'fmt ' chunk" );
         goto error;
     }
-    stream_Read( p_sys->s, NULL, 8 );   /* cannot fail */
+    stream_Read( p_input->s, NULL, 8 );   /* cannot fail */
 
     /* load waveformatex */
     p_sys->p_wf = malloc( __EVEN( i_size ) + 2 ); /* +2, for raw audio -> no cbSize */
     p_sys->p_wf->cbSize = 0;
-    if( stream_Read( p_sys->s, p_sys->p_wf, __EVEN( i_size ) ) < (int)__EVEN( i_size ) )
+    if( stream_Read( p_input->s,
+                     p_sys->p_wf, __EVEN( i_size ) ) < (int)__EVEN( i_size ) )
     {
         msg_Err( p_input, "cannot load 'fmt ' chunk" );
         goto error;
@@ -164,9 +157,9 @@ static int Open( vlc_object_t * p_this )
         goto error;
     }
 
-    stream_Control( p_sys->s, STREAM_GET_POSITION, &p_sys->i_data_pos );
+    p_sys->i_data_pos = stream_Tell( p_input->s );
 
-    stream_Read( p_sys->s, NULL, 8 );   /* cannot fail */
+    stream_Read( p_input->s, NULL, 8 );   /* cannot fail */
 
     wf_tag_to_fourcc( p_sys->p_wf->wFormatTag, &i_fourcc, &psz_name );
     if( i_fourcc == VLC_FOURCC( 'u', 'n', 'd', 'f' ) )
@@ -254,10 +247,6 @@ relay:
     {
         free( p_sys->p_wf );
     }
-    if( p_sys->s )
-    {
-        stream_Release( p_sys->s );
-    }
     free( p_sys );
 
     return VLC_EGENERIC;
@@ -276,13 +265,13 @@ static int Demux( input_thread_t *p_input )
 
     if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT )
     {
-        stream_Control( p_sys->s, STREAM_GET_POSITION, &i_pos );
+        i_pos = stream_Tell( p_input->s );
         if( p_sys->p_wf->nBlockAlign != 0 )
         {
             i_pos += p_sys->p_wf->nBlockAlign - i_pos % p_sys->p_wf->nBlockAlign;
-            if( stream_Control( p_sys->s, STREAM_SET_POSITION, i_pos ) )
+            if( stream_Seek( p_input->s, i_pos ) )
             {
-                msg_Err( p_input, "STREAM_SET_POSITION failed (cannot resync)" );
+                msg_Err( p_input, "stream_Sekk failed (cannot resync)" );
             }
         }
     }
@@ -291,7 +280,7 @@ static int Demux( input_thread_t *p_input )
                           p_input->stream.p_selected_program,
                           p_sys->i_time * 9 / 100 );
 
-    stream_Control( p_sys->s, STREAM_GET_POSITION, &i_pos );
+    i_pos = stream_Tell( p_input->s );
 
     if( p_sys->i_data_size > 0 &&
         i_pos >= p_sys->i_data_pos + p_sys->i_data_size )
@@ -300,7 +289,7 @@ static int Demux( input_thread_t *p_input )
         return 0;
     }
 
-    if( ( p_pes = stream_PesPacket( p_sys->s, p_sys->i_frame_size ) ) == NULL )
+    if( ( p_pes = stream_PesPacket( p_input->s, p_sys->i_frame_size ) )==NULL )
     {
         msg_Warn( p_input, "cannot read data" );
         return 0;
@@ -330,7 +319,6 @@ static void Close ( vlc_object_t * p_this )
     input_thread_t *p_input = (input_thread_t *)p_this;
     demux_sys_t    *p_sys = p_input->p_demux_data;
 
-    stream_Release( p_sys->s );
     free( p_sys->p_wf );
     free( p_sys );
 }
@@ -342,14 +330,13 @@ static void Close ( vlc_object_t * p_this )
 static int ChunkFind( input_thread_t *p_input,
                       char *fcc, unsigned int *pi_size )
 {
-    demux_sys_t *p_sys = p_input->p_demux_data;
     uint8_t     *p_peek;
 
     for( ;; )
     {
         int i_size;
 
-        if( stream_Peek( p_sys->s, &p_peek, 8 ) < 8 )
+        if( stream_Peek( p_input->s, &p_peek, 8 ) < 8 )
         {
             msg_Err( p_input, "cannot peek()" );
             return VLC_EGENERIC;
@@ -369,7 +356,7 @@ static int ChunkFind( input_thread_t *p_input,
         }
 
         i_size = __EVEN( i_size ) + 8;
-        if( stream_Read( p_sys->s, NULL, i_size ) != i_size )
+        if( stream_Read( p_input->s, NULL, i_size ) != i_size )
         {
             return VLC_EGENERIC;
         }