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)
-
/**
* @}
*/
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 */
{
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] );
}
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] );
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 */
struct demux_sys_t
{
/* */
- es_out_id_t *p_es;
+ es_out_id_t *p_es;
/* */
mpc_decoder decoder;
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
}
/* */
- 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;
/* 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;
}
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;
}
/*****************************************************************************
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 );
}
}
-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;
#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)
+
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, "