Commit 9e0f68a3 authored by Laurent Aimar's avatar Laurent Aimar

Removed unneeded macros.

parent e8eb236b
...@@ -196,44 +196,6 @@ VLC_EXPORT( void, demux_PacketizerDestroy, ( decoder_t *p_packetizer ) ); ...@@ -196,44 +196,6 @@ VLC_EXPORT( void, demux_PacketizerDestroy, ( decoder_t *p_packetizer ) );
if( !p_demux->p_sys ) return VLC_ENOMEM;\ if( !p_demux->p_sys ) return VLC_ENOMEM;\
memset( p_demux->p_sys, 0, sizeof( demux_sys_t ) ); } while(0) 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)
/** /**
* @} * @}
*/ */
......
...@@ -109,8 +109,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -109,8 +109,7 @@ static int Open( vlc_object_t *p_this )
if( stream_Peek( p_demux->s, &p_peek, 12 ) < 12 ) if( stream_Peek( p_demux->s, &p_peek, 12 ) < 12 )
return VLC_EGENERIC; return VLC_EGENERIC;
if( memcmp( p_peek, "FORM", 4 ) if( memcmp( p_peek, "FORM", 4 ) || memcmp( &p_peek[8], "AIFF", 4 ) )
|| memcmp( &p_peek[8], "AIFF", 4 ) )
return VLC_EGENERIC; return VLC_EGENERIC;
/* skip aiff header */ /* skip aiff header */
...@@ -126,14 +125,18 @@ static int Open( vlc_object_t *p_this ) ...@@ -126,14 +125,18 @@ static int Open( vlc_object_t *p_this )
{ {
uint32_t i_size; 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] ); i_size = GetDWBE( &p_peek[4] );
msg_Dbg( p_demux, "chunk fcc=%4.4s size=%d", p_peek, i_size ); msg_Dbg( p_demux, "chunk fcc=%4.4s size=%d", p_peek, i_size );
if( !memcmp( p_peek, "COMM", 4 ) ) 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' ) ); 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_channels = GetWBE( &p_peek[8] );
p_sys->fmt.audio.i_bitspersample = GetWBE( &p_peek[14] ); p_sys->fmt.audio.i_bitspersample = GetWBE( &p_peek[14] );
...@@ -144,7 +147,9 @@ static int Open( vlc_object_t *p_this ) ...@@ -144,7 +147,9 @@ static int Open( vlc_object_t *p_this )
} }
else if( !memcmp( p_peek, "SSND", 4 ) ) 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_pos = stream_Tell( p_demux->s );
p_sys->i_ssnd_size = i_size; p_sys->i_ssnd_size = i_size;
p_sys->i_ssnd_offset = GetDWBE( &p_peek[8] ); p_sys->i_ssnd_offset = GetDWBE( &p_peek[8] );
......
...@@ -109,12 +109,11 @@ static int Open( vlc_object_t *p_this ) ...@@ -109,12 +109,11 @@ static int Open( vlc_object_t *p_this )
int i_cat; int i_cat;
int i_samples, i_modulo; 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 ) ) if( memcmp( p_peek, ".snd", 4 ) )
{
return VLC_EGENERIC; return VLC_EGENERIC;
}
/* skip signature */ /* skip signature */
stream_Read( p_demux->s, NULL, 4 ); /* cannot fail */ stream_Read( p_demux->s, NULL, 4 ); /* cannot fail */
......
...@@ -82,11 +82,11 @@ struct demux_sys_t ...@@ -82,11 +82,11 @@ struct demux_sys_t
int64_t i_position; int64_t i_position;
}; };
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 );
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 );
mpc_int32_t ReaderTell( void *p_private); static mpc_int32_t ReaderTell( void *p_private);
mpc_int32_t ReaderGetSize( void *p_private ); static mpc_int32_t ReaderGetSize( void *p_private );
mpc_bool_t ReaderCanSeek( void *p_private ); static mpc_bool_t ReaderCanSeek( void *p_private );
/***************************************************************************** /*****************************************************************************
* Open: initializes ES structures * Open: initializes ES structures
...@@ -120,8 +120,9 @@ static int Open( vlc_object_t * p_this ) ...@@ -120,8 +120,9 @@ static int Open( vlc_object_t * p_this )
} }
/* */ /* */
p_sys = malloc( sizeof( demux_sys_t ) ); p_sys = calloc( 1, sizeof( *p_sys ) );
memset( p_sys, 0, sizeof(demux_sys_t) ); if( !p_sys )
return VLC_ENOMEM;
p_sys->i_position = 0; p_sys->i_position = 0;
...@@ -135,20 +136,12 @@ static int Open( vlc_object_t * p_this ) ...@@ -135,20 +136,12 @@ static int Open( vlc_object_t * p_this )
/* Load info */ /* Load info */
mpc_streaminfo_init( &p_sys->info ); mpc_streaminfo_init( &p_sys->info );
if( mpc_streaminfo_read( &p_sys->info, &p_sys->reader ) != ERROR_CODE_OK ) if( mpc_streaminfo_read( &p_sys->info, &p_sys->reader ) != ERROR_CODE_OK )
{ goto error;
/* invalid file */
free( p_sys );
return VLC_EGENERIC;
}
/* */ /* */
mpc_decoder_setup( &p_sys->decoder, &p_sys->reader ); mpc_decoder_setup( &p_sys->decoder, &p_sys->reader );
if( !mpc_decoder_initialize( &p_sys->decoder, &p_sys->info ) ) if( !mpc_decoder_initialize( &p_sys->decoder, &p_sys->info ) )
{ goto error;
/* */
free( p_sys );
return VLC_EGENERIC;
}
/* Fill p_demux fields */ /* Fill p_demux fields */
p_demux->pf_demux = Demux; p_demux->pf_demux = Demux;
...@@ -187,8 +180,14 @@ static int Open( vlc_object_t * p_this ) ...@@ -187,8 +180,14 @@ static int Open( vlc_object_t * p_this )
} }
p_sys->p_es = es_out_Add( p_demux->out, &fmt ); p_sys->p_es = es_out_Add( p_demux->out, &fmt );
if( !p_sys->p_es )
goto error;
return VLC_SUCCESS; return VLC_SUCCESS;
error:
free( p_sys );
return VLC_EGENERIC;
} }
/***************************************************************************** /*****************************************************************************
...@@ -215,6 +214,9 @@ static int Demux( demux_t *p_demux ) ...@@ -215,6 +214,9 @@ static int Demux( demux_t *p_demux )
p_data = block_New( p_demux, p_data = block_New( p_demux,
MPC_DECODER_BUFFER_LENGTH*sizeof(MPC_SAMPLE_FORMAT) ); MPC_DECODER_BUFFER_LENGTH*sizeof(MPC_SAMPLE_FORMAT) );
if( !p_data )
return -1;
i_ret = mpc_decoder_decode( &p_sys->decoder, i_ret = mpc_decoder_decode( &p_sys->decoder,
(MPC_SAMPLE_FORMAT*)p_data->p_buffer, (MPC_SAMPLE_FORMAT*)p_data->p_buffer,
NULL, NULL ); NULL, NULL );
...@@ -301,31 +303,31 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) ...@@ -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; demux_t *p_demux = (demux_t*)p_private;
return stream_Read( p_demux->s, dst, i_size ); 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; demux_t *p_demux = (demux_t*)p_private;
return !stream_Seek( p_demux->s, i_offset ); 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; demux_t *p_demux = (demux_t*)p_private;
return stream_Tell( p_demux->s ); 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; demux_t *p_demux = (demux_t*)p_private;
return stream_Size( p_demux->s ); 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; demux_t *p_demux = (demux_t*)p_private;
bool b_canseek; bool b_canseek;
......
...@@ -79,3 +79,28 @@ void Close_iTML ( vlc_object_t * ); ...@@ -79,3 +79,28 @@ void Close_iTML ( vlc_object_t * );
#define HANDLE_PLAY_AND_RELEASE \ #define HANDLE_PLAY_AND_RELEASE \
vlc_object_release( p_input_thread ); 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)
...@@ -94,9 +94,10 @@ static int Open( vlc_object_t * p_this ) ...@@ -94,9 +94,10 @@ static int Open( vlc_object_t * p_this )
if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 ) if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 )
return VLC_EGENERIC; 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 */ /* User forced */
msg_Err( p_demux, "this doesn't look like a true-audio stream, " msg_Err( p_demux, "this doesn't look like a true-audio stream, "
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment