]> git.sesse.net Git - vlc/blobdiff - modules/demux/au.c
Use var_Inherit* instead of var_CreateGet*.
[vlc] / modules / demux / au.c
index b73ed5ae447d0104b1961a0e0c0f8d3274e5a4fe..1efd2d0a3647454b88090c74e9be13302c3608fa 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * au.c : au file input module for vlc
  *****************************************************************************
- * Copyright (C) 2001-2003 VideoLAN
- * $Id: au.c,v 1.14 2004/03/03 11:40:19 fenrir Exp $
+ * Copyright (C) 2001-2007 the VideoLAN team
+ * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
 
-#include <vlc/vlc.h>
-#include <vlc/input.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_demux.h>
 
 /* TODO:
  *  - all adpcm things (I _NEED_ samples)
 static int  Open ( vlc_object_t * );
 static void Close( vlc_object_t * );
 
-vlc_module_begin();
-    set_description( _("AU demuxer") );
-    set_capability( "demux2", 10 );
-    set_callbacks( Open, Close );
-    add_shortcut( "au" );
-vlc_module_end();
+vlc_module_begin ()
+    set_category( CAT_INPUT )
+    set_subcategory( SUBCAT_INPUT_DEMUX )
+    set_description( N_("AU demuxer") )
+    set_capability( "demux", 10 )
+    set_callbacks( Open, Close )
+    add_shortcut( "au" )
+vlc_module_end ()
 
 /*****************************************************************************
  * Local prototypes
@@ -87,7 +93,7 @@ struct demux_sys_t
     int             i_header_size;
 };
 
-static int DemuxPCM( demux_t * );
+static int Demux( demux_t * );
 static int Control ( demux_t *, int i_query, va_list args );
 
 /*****************************************************************************
@@ -99,20 +105,15 @@ static int Open( vlc_object_t *p_this )
     demux_sys_t *p_sys;
 
     uint8_t      hdr[20];
-    uint8_t     *p_peek;
+    const uint8_t *p_peek;
     int          i_cat;
     int          i_samples, i_modulo;
 
-    if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 )
-    {
-        msg_Warn( p_demux, "cannot peek" );
+    if( stream_Peek( p_demux->s , &p_peek, 4 ) < 4 )
         return VLC_EGENERIC;
-    }
-    if( strncmp( p_peek, ".snd", 4 ) )
-    {
-        msg_Warn( p_demux, "AU module discarded" );
+
+    if( memcmp( p_peek, ".snd", 4 ) )
         return VLC_EGENERIC;
-    }
 
     /* skip signature */
     stream_Read( p_demux->s, NULL, 4 );   /* cannot fail */
@@ -130,7 +131,7 @@ static int Open( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
-    p_sys = p_demux->p_sys = malloc( sizeof( demux_sys_t ) );
+    DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys;
     p_sys->i_time = 0;
     p_sys->i_header_size = GetDWBE( &hdr[0] );
 
@@ -155,14 +156,14 @@ static int Open( vlc_object_t *p_this )
     switch( GetDWBE( &hdr[8] ) )
     {
         case AU_ALAW_8:        /* 8-bit ISDN A-law */
-            p_sys->fmt.i_codec               = VLC_FOURCC( 'a','l','a','w' );
+            p_sys->fmt.i_codec               = VLC_CODEC_ALAW;
             p_sys->fmt.audio.i_bitspersample = 8;
             p_sys->fmt.audio.i_blockalign    = 1 * p_sys->fmt.audio.i_channels;
             i_cat                    = AU_CAT_PCM;
             break;
 
         case AU_MULAW_8:       /* 8-bit ISDN u-law */
-            p_sys->fmt.i_codec               = VLC_FOURCC( 'u','l','a','w' );
+            p_sys->fmt.i_codec               = VLC_CODEC_MULAW;
             p_sys->fmt.audio.i_bitspersample = 8;
             p_sys->fmt.audio.i_blockalign    = 1 * p_sys->fmt.audio.i_channels;
             i_cat                    = AU_CAT_PCM;
@@ -278,25 +279,21 @@ static int Open( vlc_object_t *p_this )
                             (mtime_t)i_samples /
                             (mtime_t)p_sys->fmt.audio.i_rate;
 
-    /* finish to set up p_demux */
-    p_demux->pf_demux   = DemuxPCM;
-    p_demux->pf_control = Control;
-
     return VLC_SUCCESS;
 }
 
 /*****************************************************************************
- * DemuxPCM: read packet and send them to decoders
+ * Demux: read packet and send them to decoders
  *****************************************************************************
  * Returns -1 in case of error, 0 in case of EOF, 1 otherwise
  *****************************************************************************/
-static int DemuxPCM( demux_t *p_demux )
+static int Demux( demux_t *p_demux )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     block_t     *p_block;
 
     /* set PCR */
-    es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_sys->i_time );
+    es_out_Control( p_demux->out, ES_OUT_SET_PCR, VLC_TS_0 + p_sys->i_time );
 
     if( ( p_block = stream_Block( p_demux->s, p_sys->i_frame_size ) ) == NULL )
     {
@@ -305,7 +302,7 @@ static int DemuxPCM( demux_t *p_demux )
     }
 
     p_block->i_dts =
-    p_block->i_pts = p_sys->i_time;
+    p_block->i_pts = VLC_TS_0 + p_sys->i_time;
 
     es_out_Send( p_demux->out, p_sys->es, p_block );
 
@@ -332,7 +329,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
 
-    return demux2_vaControlHelper( p_demux->s, p_sys->i_header_size, -1,
+    return demux_vaControlHelper( p_demux->s, p_sys->i_header_size, -1,
                                    p_sys->fmt.i_bitrate, p_sys->fmt.audio.i_blockalign,
                                    i_query, args );
 }