]> git.sesse.net Git - vlc/commitdiff
Removed unneeded macros.
authorLaurent Aimar <fenrir@videolan.org>
Fri, 21 Nov 2008 18:54:23 +0000 (19:54 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Sat, 22 Nov 2008 15:29:54 +0000 (16:29 +0100)
include/vlc_demux.h
modules/demux/aiff.c
modules/demux/au.c
modules/demux/mpc.c
modules/demux/playlist/playlist.h
modules/demux/tta.c

index cd70b4bf85eb3c762892f9d56cd25c53bd55af49..bc6caff60f29aec8388908175a44a71bd65d7979 100644 (file)
@@ -196,44 +196,6 @@ VLC_EXPORT( void, demux_PacketizerDestroy, ( decoder_t *p_packetizer ) );
     if( !p_demux->p_sys ) return VLC_ENOMEM;\
     memset( p_demux->p_sys, 0, sizeof( demux_sys_t ) ); } while(0)
 
-#define STANDARD_DEMUX_INIT_MSG( msg ) do { \
-    DEMUX_INIT_COMMON();                    \
-    msg_Dbg( p_demux, "%s", msg ); } while(0)
-
-#define DEMUX_BY_EXTENSION( ext ) \
-    demux_t *p_demux = (demux_t *)p_this; \
-    if( !demux_IsPathExtension( p_demux, ext ) ) \
-        return VLC_EGENERIC; \
-    DEMUX_INIT_COMMON();
-
-#define DEMUX_BY_EXTENSION_MSG( ext, msg ) \
-    demux_t *p_demux = (demux_t *)p_this; \
-    if( !demux_IsPathExtension( p_demux, ext ) ) \
-        return VLC_EGENERIC; \
-    STANDARD_DEMUX_INIT_MSG( msg );
-
-#define DEMUX_BY_EXTENSION_OR_FORCED( ext, module ) \
-    demux_t *p_demux = (demux_t *)p_this; \
-    if( !demux_IsPathExtension( p_demux, ext ) && !demux_IsForced( p_demux, module ) ) \
-        return VLC_EGENERIC; \
-    DEMUX_INIT_COMMON();
-
-#define DEMUX_BY_EXTENSION_OR_FORCED_MSG( ext, module, msg ) \
-    demux_t *p_demux = (demux_t *)p_this; \
-    if( !demux_IsPathExtension( p_demux, ext ) && !demux_IsForced( p_demux, module ) ) \
-        return VLC_EGENERIC; \
-    STANDARD_DEMUX_INIT_MSG( msg );
-
-#define CHECK_PEEK( zepeek, size ) \
-    if( stream_Peek( p_demux->s , &zepeek, size ) < size ){ \
-        msg_Dbg( p_demux, "not enough data" ); return VLC_EGENERIC; }
-
-#define CHECK_PEEK_GOTO( zepeek, size ) \
-    if( stream_Peek( p_demux->s , &zepeek, size ) < size ) { \
-        msg_Dbg( p_demux, "not enough data" ); goto error; }
-
-#define POKE( peek, stuff, size ) (strncasecmp( (const char *)peek, stuff, size )==0)
-
 /**
  * @}
  */
index 186606713b561e7b941ee139d25a393e05144f90..cfc4b1659ce99346a5bf4d27331755d1857a2af2 100644 (file)
@@ -109,8 +109,7 @@ static int Open( vlc_object_t *p_this )
 
     if( stream_Peek( p_demux->s, &p_peek, 12 ) < 12 )
         return VLC_EGENERIC;
-    if( memcmp( p_peek, "FORM", 4 )
-     || memcmp( &p_peek[8], "AIFF", 4 ) )
+    if( memcmp( p_peek, "FORM", 4 ) || memcmp( &p_peek[8], "AIFF", 4 ) )
         return VLC_EGENERIC;
 
     /* skip aiff header */
@@ -126,14 +125,18 @@ static int Open( vlc_object_t *p_this )
     {
         uint32_t i_size;
 
-        CHECK_PEEK_GOTO( p_peek, 8 );
+        if( stream_Peek( p_demux->s, &p_peek, 8 ) < 8 )
+            goto error;
+
         i_size = GetDWBE( &p_peek[4] );
 
         msg_Dbg( p_demux, "chunk fcc=%4.4s size=%d", p_peek, i_size );
 
         if( !memcmp( p_peek, "COMM", 4 ) )
         {
-            CHECK_PEEK_GOTO( p_peek, 18+8 );
+            if( stream_Peek( p_demux->s, &p_peek, 18+8 ) < 18+8 )
+                goto error;
+
             es_format_Init( &p_sys->fmt, AUDIO_ES, VLC_FOURCC( 't', 'w', 'o', 's' ) );
             p_sys->fmt.audio.i_channels = GetWBE( &p_peek[8] );
             p_sys->fmt.audio.i_bitspersample = GetWBE( &p_peek[14] );
@@ -144,7 +147,9 @@ static int Open( vlc_object_t *p_this )
         }
         else if( !memcmp( p_peek, "SSND", 4 ) )
         {
-            CHECK_PEEK_GOTO( p_peek, 8+8 );
+            if( stream_Peek( p_demux->s, &p_peek, 8+8 ) < 8+8 )
+                goto error;
+
             p_sys->i_ssnd_pos = stream_Tell( p_demux->s );
             p_sys->i_ssnd_size = i_size;
             p_sys->i_ssnd_offset = GetDWBE( &p_peek[8] );
index 87fb9e42379e962064aa7139a75b9d16fa9b66c6..08f7e986417f0d84d2dd2f418d98a09742dcc6b2 100644 (file)
@@ -109,12 +109,11 @@ static int Open( vlc_object_t *p_this )
     int          i_cat;
     int          i_samples, i_modulo;
 
-    CHECK_PEEK( p_peek, 4 );
+    if( stream_Peek( p_demux->s , &p_peek, 4 ) < 4 )
+        return VLC_EGENERIC;
 
     if( memcmp( p_peek, ".snd", 4 ) )
-    {
         return VLC_EGENERIC;
-    }
 
     /* skip signature */
     stream_Read( p_demux->s, NULL, 4 );   /* cannot fail */
index d0a9d931f971db82855629b328359db77654048d..b02e4cdf51610470676a4a793e07d4d6edc8ab15 100644 (file)
@@ -71,7 +71,7 @@ static int Control( demux_t *, int, va_list );
 struct demux_sys_t
 {
     /* */
-    es_out_id_t *p_es;
+    es_out_id_t   *p_es;
 
     /* */
     mpc_decoder    decoder;
@@ -82,11 +82,11 @@ struct demux_sys_t
     int64_t        i_position;
 };
 
-mpc_int32_t ReaderRead( void *p_private, void *dst, mpc_int32_t i_size );
-mpc_bool_t  ReaderSeek( void *p_private, mpc_int32_t i_offset );
-mpc_int32_t ReaderTell( void *p_private);
-mpc_int32_t ReaderGetSize( void *p_private );
-mpc_bool_t  ReaderCanSeek( void *p_private );
+static mpc_int32_t ReaderRead( void *p_private, void *dst, mpc_int32_t i_size );
+static mpc_bool_t  ReaderSeek( void *p_private, mpc_int32_t i_offset );
+static mpc_int32_t ReaderTell( void *p_private);
+static mpc_int32_t ReaderGetSize( void *p_private );
+static mpc_bool_t  ReaderCanSeek( void *p_private );
 
 /*****************************************************************************
  * Open: initializes ES structures
@@ -120,8 +120,9 @@ static int Open( vlc_object_t * p_this )
     }
 
     /* */
-    p_sys = malloc( sizeof( demux_sys_t ) );
-    memset( p_sys, 0, sizeof(demux_sys_t) );
+    p_sys = calloc( 1, sizeof( *p_sys ) );
+    if( !p_sys )
+        return VLC_ENOMEM;
 
     p_sys->i_position = 0;
 
@@ -135,20 +136,12 @@ static int Open( vlc_object_t * p_this )
     /* Load info */
     mpc_streaminfo_init( &p_sys->info );
     if( mpc_streaminfo_read( &p_sys->info, &p_sys->reader ) != ERROR_CODE_OK )
-    {
-        /* invalid file */
-        free( p_sys );
-        return VLC_EGENERIC;
-    }
+        goto error;
 
     /* */
     mpc_decoder_setup( &p_sys->decoder, &p_sys->reader );
     if( !mpc_decoder_initialize( &p_sys->decoder, &p_sys->info ) )
-    {
-        /* */
-        free( p_sys );
-        return VLC_EGENERIC;
-    }
+        goto error;
 
     /* Fill p_demux fields */
     p_demux->pf_demux = Demux;
@@ -187,8 +180,14 @@ static int Open( vlc_object_t * p_this )
     }
 
     p_sys->p_es = es_out_Add( p_demux->out, &fmt );
+    if( !p_sys->p_es )
+        goto error;
 
     return VLC_SUCCESS;
+
+error:
+    free( p_sys );
+    return VLC_EGENERIC;
 }
 
 /*****************************************************************************
@@ -215,9 +214,12 @@ static int Demux( demux_t *p_demux )
 
     p_data = block_New( p_demux,
                         MPC_DECODER_BUFFER_LENGTH*sizeof(MPC_SAMPLE_FORMAT) );
+    if( !p_data )
+        return -1;
+
     i_ret = mpc_decoder_decode( &p_sys->decoder,
-                               (MPC_SAMPLE_FORMAT*)p_data->p_buffer,
-                               NULL, NULL );
+                                (MPC_SAMPLE_FORMAT*)p_data->p_buffer,
+                                NULL, NULL );
     if( i_ret <= 0 )
     {
         block_Release( p_data );
@@ -301,31 +303,31 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
     }
 }
 
-mpc_int32_t ReaderRead( void *p_private, void *dst, mpc_int32_t i_size )
+static mpc_int32_t ReaderRead( void *p_private, void *dst, mpc_int32_t i_size )
 {
     demux_t *p_demux = (demux_t*)p_private;
     return stream_Read( p_demux->s, dst, i_size );
 }
 
-mpc_bool_t ReaderSeek( void *p_private, mpc_int32_t i_offset )
+static mpc_bool_t ReaderSeek( void *p_private, mpc_int32_t i_offset )
 {
     demux_t *p_demux = (demux_t*)p_private;
     return !stream_Seek( p_demux->s, i_offset );
 }
 
-mpc_int32_t ReaderTell( void *p_private)
+static mpc_int32_t ReaderTell( void *p_private)
 {
     demux_t *p_demux = (demux_t*)p_private;
     return stream_Tell( p_demux->s );
 }
 
-mpc_int32_t ReaderGetSize( void *p_private )
+static mpc_int32_t ReaderGetSize( void *p_private )
 {
     demux_t *p_demux = (demux_t*)p_private;
     return stream_Size( p_demux->s );
 }
 
-mpc_bool_t ReaderCanSeek( void *p_private )
+static mpc_bool_t ReaderCanSeek( void *p_private )
 {
     demux_t *p_demux = (demux_t*)p_private;
     bool b_canseek;
index ee27e2720bfc130d5842a4ced146988d212e3555..bfa0666db72ae0ad5567af805b749106c9ec15bc 100644 (file)
@@ -79,3 +79,28 @@ void Close_iTML ( vlc_object_t * );
 
 #define HANDLE_PLAY_AND_RELEASE \
     vlc_object_release( p_input_thread );
+
+
+#define STANDARD_DEMUX_INIT_MSG( msg ) do { \
+    DEMUX_INIT_COMMON();                    \
+    msg_Dbg( p_demux, "%s", msg ); } while(0)
+
+#define DEMUX_BY_EXTENSION_MSG( ext, msg ) \
+    demux_t *p_demux = (demux_t *)p_this; \
+    if( !demux_IsPathExtension( p_demux, ext ) ) \
+        return VLC_EGENERIC; \
+    STANDARD_DEMUX_INIT_MSG( msg );
+
+#define DEMUX_BY_EXTENSION_OR_FORCED_MSG( ext, module, msg ) \
+    demux_t *p_demux = (demux_t *)p_this; \
+    if( !demux_IsPathExtension( p_demux, ext ) && !demux_IsForced( p_demux, module ) ) \
+        return VLC_EGENERIC; \
+    STANDARD_DEMUX_INIT_MSG( msg );
+
+
+#define CHECK_PEEK( zepeek, size ) do { \
+    if( stream_Peek( p_demux->s , &zepeek, size ) < size ){ \
+        msg_Dbg( p_demux, "not enough data" ); return VLC_EGENERIC; } } while(0)
+
+#define POKE( peek, stuff, size ) (strncasecmp( (const char *)peek, stuff, size )==0)
+
index 3f295c92ea9aabb8912a68093ed7f7a5b87536f2..0922f389536461e946cab0cebd810c71afec35dd 100644 (file)
@@ -94,9 +94,10 @@ static int Open( vlc_object_t * p_this )
     if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 )
         return VLC_EGENERIC;
 
-    if( !POKE( p_peek, "TTA1", 4 ) )
+    if( memcmp( p_peek, "TTA1", 4 ) )
     {
-        if( !p_demux->b_force ) return VLC_EGENERIC;
+        if( !p_demux->b_force )
+            return VLC_EGENERIC;
 
         /* User forced */
         msg_Err( p_demux, "this doesn't look like a true-audio stream, "