Commit 3f07af6a authored by Laurent Aimar's avatar Laurent Aimar

Added const wheen needed for stream_Peek (demuxer/access)

Made demux2_IsPathExtension case insensitive.
Used demux2_IsPathExtension/p_demux->b_force when appropriate
Fixed a regression in flac demuxer (segfault when reading meta data)
Added a VLC_UNUSED(x) macro to avoid seeing ugly (void)x around the code.
Improved a bit a few vlc_common.h macro (do {} while(0))
parent b7c4c4a6
...@@ -668,23 +668,23 @@ static inline uint8_t clip_uint8_vlc( int32_t a ) ...@@ -668,23 +668,23 @@ static inline uint8_t clip_uint8_vlc( int32_t a )
} }
/* Malloc with automatic error */ /* Malloc with automatic error */
#define MALLOC_VOID( var, type ) { var = (type*)malloc( sizeof( type) ); \ #define MALLOC_VOID( var, type ) do { var = (type*)malloc( sizeof( type) ); \
if( !var ) return; } if( !var ) return; } while(0)
#define MALLOC_NULL( var, type ) { var = (type*)malloc( sizeof( type) ); \ #define MALLOC_NULL( var, type ) do { var = (type*)malloc( sizeof( type) ); \
if( !var ) return NULL; } if( !var ) return NULL; } while(0)
#define MALLOC_ERR( var, type ) { var = (type*)malloc( sizeof( type) ); \ #define MALLOC_ERR( var, type ) do { var = (type*)malloc( sizeof( type) ); \
if( !var ) return VLC_ENOMEM; } if( !var ) return VLC_ENOMEM; } while(0)
#define MALLOC_GOTOERR( var, type ) { var = (type*)malloc( sizeof( type) ); \ #define MALLOC_GOTOERR( var, type ) do { var = (type*)malloc( sizeof( type) ); \
if( !var ) goto error; } if( !var ) goto error; } while(0)
#define DECMALLOC_VOID( var, type ) type* var = (type*)malloc( sizeof(type) );\ #define DECMALLOC_VOID( var, type ) type* var = (type*)malloc( sizeof(type) );\
if( !var ) return; if( !var ) return;
#define DECMALLOC_ERR( var, type ) type* var = (type*)malloc( sizeof(type) );\ #define DECMALLOC_ERR( var, type ) type* var = (type*)malloc( sizeof(type) );\
if( !var ) return VLC_ENOMEM; if( !var ) return VLC_ENOMEM;
#define DECMALLOC_NULL( var, type ) type* var = (type*)malloc( sizeof(type) );\ #define DECMALLOC_NULL( var, type ) type* var = (type*)malloc( sizeof(type) );\
if( !var ) return NULL; if( !var ) return NULL;
#define FREENULL(a) if( a ) { free( a ); a = NULL; } #define FREENULL(a) do { if( a ) { free( a ); a = NULL; } } while(0)
#define FREE(a) if( a ) { free( a ); } #define FREE(a) do { if( a ) { free( a ); } } while(0)
#define EMPTY_STR(str) (!str || !*str) #define EMPTY_STR(str) (!str || !*str)
...@@ -814,6 +814,9 @@ static inline void _SetQWBE( uint8_t *p, uint64_t i_qw ) ...@@ -814,6 +814,9 @@ static inline void _SetQWBE( uint8_t *p, uint64_t i_qw )
# define ATTR_ALIGN(align) # define ATTR_ALIGN(align)
#endif #endif
/* */
#define VLC_UNUSED(x) (void)(x)
/* Alignment of critical dynamic data structure /* Alignment of critical dynamic data structure
* *
* Not all platforms support memalign so we provide a vlc_memalign wrapper * Not all platforms support memalign so we provide a vlc_memalign wrapper
......
...@@ -128,7 +128,7 @@ VLC_EXPORT( int, demux2_vaControlHelper, ( stream_t *, int64_t i_start, in ...@@ -128,7 +128,7 @@ VLC_EXPORT( int, demux2_vaControlHelper, ( stream_t *, int64_t i_start, in
static inline vlc_bool_t demux2_IsPathExtension( demux_t *p_demux, const char *psz_extension ) static inline vlc_bool_t demux2_IsPathExtension( demux_t *p_demux, const char *psz_extension )
{ {
const char *psz_ext = strrchr ( p_demux->psz_path, '.' ); const char *psz_ext = strrchr ( p_demux->psz_path, '.' );
if( !psz_ext || strcmp( psz_ext, psz_extension ) ) if( !psz_ext || strcasecmp( psz_ext, psz_extension ) )
return VLC_FALSE; return VLC_FALSE;
return VLC_TRUE; return VLC_TRUE;
} }
...@@ -140,24 +140,21 @@ static inline vlc_bool_t demux2_IsForced( demux_t *p_demux, const char *psz_name ...@@ -140,24 +140,21 @@ static inline vlc_bool_t demux2_IsForced( demux_t *p_demux, const char *psz_name
return VLC_TRUE; return VLC_TRUE;
} }
#define STANDARD_DEMUX_INIT \ #define DEMUX_INIT_COMMON() do { \
p_demux->pf_control = Control; \ p_demux->pf_control = Control; \
p_demux->pf_demux = Demux; \ p_demux->pf_demux = Demux; \
MALLOC_ERR( p_demux->p_sys, demux_sys_t ); \ MALLOC_ERR( p_demux->p_sys, demux_sys_t ); \
memset( p_demux->p_sys, 0, sizeof( demux_sys_t ) ); memset( p_demux->p_sys, 0, sizeof( demux_sys_t ) ); } while(0)
#define STANDARD_DEMUX_INIT_MSG( msg ) \ #define STANDARD_DEMUX_INIT_MSG( msg ) do { \
p_demux->pf_control = Control; \ DEMUX_INIT_COMMON(); \
p_demux->pf_demux = Demux; \ msg_Dbg( p_demux, msg ); } while(0)
MALLOC_ERR( p_demux->p_sys, demux_sys_t ); \
memset( p_demux->p_sys, 0, sizeof( demux_sys_t ) ); \
msg_Dbg( p_demux, msg ); \
#define DEMUX_BY_EXTENSION( ext ) \ #define DEMUX_BY_EXTENSION( ext ) \
demux_t *p_demux = (demux_t *)p_this; \ demux_t *p_demux = (demux_t *)p_this; \
if( !demux2_IsPathExtension( p_demux, ext ) ) \ if( !demux2_IsPathExtension( p_demux, ext ) ) \
return VLC_EGENERIC; \ return VLC_EGENERIC; \
STANDARD_DEMUX_INIT; DEMUX_INIT_COMMON();
#define DEMUX_BY_EXTENSION_MSG( ext, msg ) \ #define DEMUX_BY_EXTENSION_MSG( ext, msg ) \
demux_t *p_demux = (demux_t *)p_this; \ demux_t *p_demux = (demux_t *)p_this; \
...@@ -169,7 +166,7 @@ static inline vlc_bool_t demux2_IsForced( demux_t *p_demux, const char *psz_name ...@@ -169,7 +166,7 @@ static inline vlc_bool_t demux2_IsForced( demux_t *p_demux, const char *psz_name
demux_t *p_demux = (demux_t *)p_this; \ demux_t *p_demux = (demux_t *)p_this; \
if( !demux2_IsPathExtension( p_demux, ext ) && !demux2_IsForced( p_demux, module ) ) \ if( !demux2_IsPathExtension( p_demux, ext ) && !demux2_IsForced( p_demux, module ) ) \
return VLC_EGENERIC; \ return VLC_EGENERIC; \
STANDARD_DEMUX_INIT; DEMUX_INIT_COMMON();
#define DEMUX_BY_EXTENSION_OR_FORCED_MSG( ext, module, msg ) \ #define DEMUX_BY_EXTENSION_OR_FORCED_MSG( ext, module, msg ) \
demux_t *p_demux = (demux_t *)p_this; \ demux_t *p_demux = (demux_t *)p_this; \
...@@ -185,10 +182,7 @@ static inline vlc_bool_t demux2_IsForced( demux_t *p_demux, const char *psz_name ...@@ -185,10 +182,7 @@ static inline vlc_bool_t demux2_IsForced( demux_t *p_demux, const char *psz_name
if( stream_Peek( p_demux->s , &zepeek, size ) < size ) { \ if( stream_Peek( p_demux->s , &zepeek, size ) < size ) { \
msg_Dbg( p_demux, "not enough data" ); goto error; } msg_Dbg( p_demux, "not enough data" ); goto error; }
#define CHECK_DISCARD_PEEK( size ) { uint8_t *p_peek; \ #define POKE( peek, stuff, size ) (strncasecmp( (const char *)peek, stuff, size )==0)
if( stream_Peek( p_demux->s , &p_peek, size ) < size ) return VLC_EGENERIC;}
#define POKE( peek, stuff, size ) (strncasecmp( (char *)peek, stuff, size )==0)
#define COMMON_INIT_PACKETIZER( location ) \ #define COMMON_INIT_PACKETIZER( location ) \
location = vlc_object_create( p_demux, VLC_OBJECT_PACKETIZER ); \ location = vlc_object_create( p_demux, VLC_OBJECT_PACKETIZER ); \
......
...@@ -209,7 +209,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -209,7 +209,7 @@ static int Open( vlc_object_t *p_this )
free( psz_name ); free( psz_name );
/* Fill p_demux field */ /* Fill p_demux field */
STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys; DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys;
p_sys->dvdnav = p_dvdnav; p_sys->dvdnav = p_dvdnav;
ps_track_init( p_sys->tk ); ps_track_init( p_sys->tk );
......
...@@ -247,7 +247,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -247,7 +247,7 @@ static int Open( vlc_object_t *p_this )
msg_Dbg( p_demux, "VMG opened" ); msg_Dbg( p_demux, "VMG opened" );
/* Fill p_demux field */ /* Fill p_demux field */
STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys; DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys;
ps_track_init( p_sys->tk ); ps_track_init( p_sys->tk );
p_sys->i_aspect = -1; p_sys->i_aspect = -1;
......
...@@ -97,7 +97,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -97,7 +97,7 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
/* Set up p_demux */ /* Set up p_demux */
STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys; DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys;
p_demux->info.i_update = 0; p_demux->info.i_update = 0;
p_demux->info.i_title = 0; p_demux->info.i_title = 0;
p_demux->info.i_seekpoint = 0; p_demux->info.i_seekpoint = 0;
......
...@@ -129,10 +129,8 @@ static int Open( vlc_object_t * p_this ) ...@@ -129,10 +129,8 @@ static int Open( vlc_object_t * p_this )
if( CheckSync( p_peek + i_peek, &b_big_endian ) != VLC_SUCCESS ) if( CheckSync( p_peek + i_peek, &b_big_endian ) != VLC_SUCCESS )
{ {
if( strncmp( p_demux->psz_demux, "a52", 3 ) ) if( !p_demux->b_force )
{
return VLC_EGENERIC; return VLC_EGENERIC;
}
/* User forced */ /* User forced */
msg_Err( p_demux, "this doesn't look like a A52 audio stream, " msg_Err( p_demux, "this doesn't look like a A52 audio stream, "
...@@ -140,7 +138,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -140,7 +138,7 @@ static int Open( vlc_object_t * p_this )
} }
/* Fill p_demux fields */ /* Fill p_demux fields */
STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys; DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys;
p_sys->b_start = VLC_TRUE; p_sys->b_start = VLC_TRUE;
p_sys->i_mux_rate = 0; p_sys->i_mux_rate = 0;
p_sys->b_big_endian = b_big_endian; p_sys->b_big_endian = b_big_endian;
......
...@@ -74,7 +74,7 @@ static int Demux ( demux_t *p_demux ); ...@@ -74,7 +74,7 @@ static int Demux ( demux_t *p_demux );
static int Control( demux_t *p_demux, int i_query, va_list args ); static int Control( demux_t *p_demux, int i_query, va_list args );
/* GetF80BE: read a 80 bits float in big endian */ /* GetF80BE: read a 80 bits float in big endian */
static unsigned int GetF80BE( uint8_t p[10] ) static unsigned int GetF80BE( const uint8_t p[10] )
{ {
unsigned int i_mantissa = GetDWBE( &p[2] ); unsigned int i_mantissa = GetDWBE( &p[2] );
int i_exp = 30 - p[1]; int i_exp = 30 - p[1];
...@@ -112,7 +112,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -112,7 +112,7 @@ static int Open( vlc_object_t *p_this )
stream_Read( p_demux->s, NULL, 12 ); stream_Read( p_demux->s, NULL, 12 );
/* Fill p_demux field */ /* Fill p_demux field */
STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys; DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys;
es_format_Init( &p_sys->fmt, UNKNOWN_ES, 0 ); es_format_Init( &p_sys->fmt, UNKNOWN_ES, 0 );
p_sys->i_time = 1; p_sys->i_time = 1;
p_sys->i_ssnd_pos = -1; p_sys->i_ssnd_pos = -1;
......
...@@ -127,7 +127,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -127,7 +127,7 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys; DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys;
p_sys->i_time = 1; p_sys->i_time = 1;
p_sys->i_header_size = GetDWBE( &hdr[0] ); p_sys->i_header_size = GetDWBE( &hdr[0] );
......
...@@ -225,7 +225,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -225,7 +225,7 @@ static int Open( vlc_object_t * p_this )
unsigned int i_track; unsigned int i_track;
unsigned int i, i_peeker; unsigned int i, i_peeker;
uint8_t *p_peek; const uint8_t *p_peek;
/* Is it an avi file ? */ /* Is it an avi file ? */
if( stream_Peek( p_demux->s, &p_peek, 200 ) < 200 ) return VLC_EGENERIC; if( stream_Peek( p_demux->s, &p_peek, 200 ) < 200 ) return VLC_EGENERIC;
...@@ -1898,7 +1898,7 @@ static void AVI_ParseStreamHeader( vlc_fourcc_t i_id, ...@@ -1898,7 +1898,7 @@ static void AVI_ParseStreamHeader( vlc_fourcc_t i_id,
****************************************************************************/ ****************************************************************************/
static int AVI_PacketGetHeader( demux_t *p_demux, avi_packet_t *p_pk ) static int AVI_PacketGetHeader( demux_t *p_demux, avi_packet_t *p_pk )
{ {
uint8_t *p_peek; const uint8_t *p_peek;
if( stream_Peek( p_demux->s, &p_peek, 16 ) < 16 ) if( stream_Peek( p_demux->s, &p_peek, 16 ) < 16 )
{ {
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#define __EVEN( x ) ( (x)&0x01 ? (x)+1 : (x) ) #define __EVEN( x ) ( (x)&0x01 ? (x)+1 : (x) )
static vlc_fourcc_t GetFOURCC( byte_t *p_buff ) static vlc_fourcc_t GetFOURCC( const byte_t *p_buff )
{ {
return VLC_FOURCC( p_buff[0], p_buff[1], p_buff[2], p_buff[3] ); return VLC_FOURCC( p_buff[0], p_buff[1], p_buff[2], p_buff[3] );
} }
...@@ -46,7 +46,7 @@ void _AVI_ChunkFree( stream_t *, avi_chunk_t *p_chk ); ...@@ -46,7 +46,7 @@ void _AVI_ChunkFree( stream_t *, avi_chunk_t *p_chk );
****************************************************************************/ ****************************************************************************/
static int AVI_ChunkReadCommon( stream_t *s, avi_chunk_t *p_chk ) static int AVI_ChunkReadCommon( stream_t *s, avi_chunk_t *p_chk )
{ {
uint8_t *p_peek; const uint8_t *p_peek;
int i_peek; int i_peek;
memset( p_chk, 0, sizeof( avi_chunk_t ) ); memset( p_chk, 0, sizeof( avi_chunk_t ) );
...@@ -111,7 +111,7 @@ static int AVI_NextChunk( stream_t *s, avi_chunk_t *p_chk ) ...@@ -111,7 +111,7 @@ static int AVI_NextChunk( stream_t *s, avi_chunk_t *p_chk )
static int AVI_ChunkRead_list( stream_t *s, avi_chunk_t *p_container ) static int AVI_ChunkRead_list( stream_t *s, avi_chunk_t *p_container )
{ {
avi_chunk_t *p_chk; avi_chunk_t *p_chk;
uint8_t *p_peek; const uint8_t *p_peek;
vlc_bool_t b_seekable; vlc_bool_t b_seekable;
if( p_container->common.i_chunk_size > 0 && p_container->common.i_chunk_size < 8 ) if( p_container->common.i_chunk_size > 0 && p_container->common.i_chunk_size < 8 )
...@@ -471,7 +471,7 @@ static void AVI_ChunkFree_idx1( avi_chunk_t *p_chk ) ...@@ -471,7 +471,7 @@ static void AVI_ChunkFree_idx1( avi_chunk_t *p_chk )
{ {
p_chk->idx1.i_entry_count = 0; p_chk->idx1.i_entry_count = 0;
p_chk->idx1.i_entry_max = 0; p_chk->idx1.i_entry_max = 0;
FREENULL( p_chk->idx1.entry ) FREENULL( p_chk->idx1.entry );
} }
......
...@@ -73,9 +73,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -73,9 +73,7 @@ static int Open( vlc_object_t * p_this )
/* Identify cdg file by extension, as there is no simple way to /* Identify cdg file by extension, as there is no simple way to
* detect it */ * detect it */
if( !demux2_IsPathExtension( p_demux, ".cdg" ) && if( !demux2_IsPathExtension( p_demux, ".cdg" ) && !p_demux->b_force )
!demux2_IsPathExtension( p_demux, ".CDG" ) &&
!demux2_IsForced( p_demux, "cdg" ) )
return VLC_EGENERIC; return VLC_EGENERIC;
/* CDG file size has to be multiple of CDG_FRAME_SIZE (it works even /* CDG file size has to be multiple of CDG_FRAME_SIZE (it works even
......
...@@ -91,7 +91,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -91,7 +91,7 @@ static int Open( vlc_object_t * p_this )
vlc_bool_t b_append; vlc_bool_t b_append;
/* Accept only if forced */ /* Accept only if forced */
if( strcasecmp( p_demux->psz_demux, "dump" ) ) if( !p_demux->b_force )
return VLC_EGENERIC; return VLC_EGENERIC;
var_Create( p_demux, "demuxdump-append", VLC_VAR_BOOL|VLC_VAR_DOINHERIT ); var_Create( p_demux, "demuxdump-append", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
......
...@@ -140,16 +140,15 @@ static int Open( vlc_object_t * p_this ) ...@@ -140,16 +140,15 @@ static int Open( vlc_object_t * p_this )
if( CheckSync( p_peek + i_peek ) != VLC_SUCCESS ) if( CheckSync( p_peek + i_peek ) != VLC_SUCCESS )
{ {
if( strncmp( p_demux->psz_demux, "dts", 3 ) ) if( !p_demux->b_force )
{
return VLC_EGENERIC; return VLC_EGENERIC;
}
/* User forced */ /* User forced */
msg_Err( p_demux, "this doesn't look like a DTS audio stream, " msg_Err( p_demux, "this doesn't look like a DTS audio stream, "
"continuing anyway" ); "continuing anyway" );
} }
STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys; DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys;
INIT_APACKETIZER( p_sys->p_packetizer, 'd','t','s',' ' ); INIT_APACKETIZER( p_sys->p_packetizer, 'd','t','s',' ' );
LOAD_PACKETIZER_OR_FAIL( p_sys->p_packetizer, "DTS" ); LOAD_PACKETIZER_OR_FAIL( p_sys->p_packetizer, "DTS" );
......
...@@ -620,7 +620,7 @@ static void ParseComment( demux_t *p_demux, const uint8_t *p_data, int i_data ) ...@@ -620,7 +620,7 @@ static void ParseComment( demux_t *p_demux, const uint8_t *p_data, int i_data )
#define IF_EXTRACT(txt,var) \ #define IF_EXTRACT(txt,var) \
if( !strncasecmp(psz, txt, strlen(txt)) ) \ if( !strncasecmp(psz, txt, strlen(txt)) ) \
{ \ { \
char * oldval = vlc_meta_Get( p_sys->p_meta, vlc_meta_ ## var ); \ const char *oldval = vlc_meta_Get( p_sys->p_meta, vlc_meta_ ## var ); \
if( oldval ) \ if( oldval ) \
{ \ { \
char * newval; \ char * newval; \
...@@ -630,7 +630,6 @@ static void ParseComment( demux_t *p_demux, const uint8_t *p_data, int i_data ) ...@@ -630,7 +630,6 @@ static void ParseComment( demux_t *p_demux, const uint8_t *p_data, int i_data )
} \ } \
else \ else \
vlc_meta_Set( p_sys->p_meta, vlc_meta_ ## var, &psz[strlen(txt)] ); \ vlc_meta_Set( p_sys->p_meta, vlc_meta_ ## var, &psz[strlen(txt)] ); \
free( oldval ); \
} }
IF_EXTRACT("TITLE=", Title ) IF_EXTRACT("TITLE=", Title )
else IF_EXTRACT("ALBUM=", Album ) else IF_EXTRACT("ALBUM=", Album )
......
...@@ -114,7 +114,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -114,7 +114,7 @@ static int Open( vlc_object_t *p_this )
vlc_value_t val; vlc_value_t val;
/* We accept file based on extention match */ /* We accept file based on extention match */
if( strcasecmp( p_demux->psz_demux, "gme" ) ) if( !p_demux->b_force )
{ {
if( ( ext = strrchr( p_demux->psz_path, '.' ) ) == NULL || if( ( ext = strrchr( p_demux->psz_path, '.' ) ) == NULL ||
stream_Size( p_demux->s ) == 0 ) return VLC_EGENERIC; stream_Size( p_demux->s ) == 0 ) return VLC_EGENERIC;
......
...@@ -74,7 +74,7 @@ struct demux_sys_t ...@@ -74,7 +74,7 @@ struct demux_sys_t
mtime_t i_frame_length; mtime_t i_frame_length;
char *psz_separator; char *psz_separator;
int i_frame_size_estimate; int i_frame_size_estimate;
uint8_t *p_peek; const uint8_t *p_peek;
int i_data_peeked; int i_data_peeked;
}; };
...@@ -117,7 +117,7 @@ static vlc_bool_t Peek( demux_t *p_demux, vlc_bool_t b_first ) ...@@ -117,7 +117,7 @@ static vlc_bool_t Peek( demux_t *p_demux, vlc_bool_t b_first )
static char* GetLine( demux_t *p_demux, int *p_pos ) static char* GetLine( demux_t *p_demux, int *p_pos )
{ {
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
uint8_t *p_buf; const uint8_t *p_buf;
int i_size; int i_size;
int i; int i;
char *p_line; char *p_line;
...@@ -300,7 +300,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -300,7 +300,6 @@ static int Open( vlc_object_t * p_this )
int i_size; int i_size;
int b_matched = VLC_FALSE; int b_matched = VLC_FALSE;
vlc_value_t val; vlc_value_t val;
char *psz_ext;
p_demux->pf_control = Control; p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
...@@ -342,9 +341,8 @@ static int Open( vlc_object_t * p_this ) ...@@ -342,9 +341,8 @@ static int Open( vlc_object_t * p_this )
/* Check for jpeg file extension */ /* Check for jpeg file extension */
p_sys->b_still = VLC_FALSE; p_sys->b_still = VLC_FALSE;
p_sys->i_still_end = 0; p_sys->i_still_end = 0;
psz_ext = strrchr( p_demux->psz_path, '.' ); if( demux2_IsPathExtension( p_demux, ".jpeg" ) ||
if( psz_ext && ( !strcasecmp( psz_ext, ".jpeg" ) || demux2_IsPathExtension( p_demux, ".jpg" ) )
!strcasecmp( psz_ext, ".jpg" ) ) )
{ {
p_sys->b_still = VLC_TRUE; p_sys->b_still = VLC_TRUE;
if( val.f_float) if( val.f_float)
......
...@@ -129,14 +129,14 @@ static int Open( vlc_object_t *p_this ) ...@@ -129,14 +129,14 @@ static int Open( vlc_object_t *p_this )
{ {
demux_t *p_demux = (demux_t*)p_this; demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys; demux_sys_t *p_sys;
char *ext;
int i;
ModPlug_Settings settings; ModPlug_Settings settings;
vlc_value_t val; vlc_value_t val;
/* We accept file based on extension match */ /* We accept file based on extension match */
if( strcasecmp( p_demux->psz_demux, "mod" ) ) if( !p_demux->b_force )
{ {
char *ext;
int i;
if( ( ext = strrchr( p_demux->psz_path, '.' ) ) == NULL || if( ( ext = strrchr( p_demux->psz_path, '.' ) ) == NULL ||
stream_Size( p_demux->s ) == 0 ) return VLC_EGENERIC; stream_Size( p_demux->s ) == 0 ) return VLC_EGENERIC;
......
...@@ -703,7 +703,7 @@ static int MP4_ReadBox_url( stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -703,7 +703,7 @@ static int MP4_ReadBox_url( stream_t *p_stream, MP4_Box_t *p_box )
static void MP4_FreeBox_url( MP4_Box_t *p_box ) static void MP4_FreeBox_url( MP4_Box_t *p_box )
{ {
FREENULL( p_box->data.p_url->psz_location ) FREENULL( p_box->data.p_url->psz_location );
} }
static int MP4_ReadBox_urn( stream_t *p_stream, MP4_Box_t *p_box ) static int MP4_ReadBox_urn( stream_t *p_stream, MP4_Box_t *p_box )
...@@ -1552,7 +1552,7 @@ static int MP4_ReadBox_stss( stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -1552,7 +1552,7 @@ static int MP4_ReadBox_stss( stream_t *p_stream, MP4_Box_t *p_box )
static void MP4_FreeBox_stss( MP4_Box_t *p_box ) static void MP4_FreeBox_stss( MP4_Box_t *p_box )
{ {
FREENULL( p_box->data.p_stss->i_sample_number ) FREENULL( p_box->data.p_stss->i_sample_number );
} }
static int MP4_ReadBox_stsh( stream_t *p_stream, MP4_Box_t *p_box ) static int MP4_ReadBox_stsh( stream_t *p_stream, MP4_Box_t *p_box )
...@@ -1589,8 +1589,8 @@ static int MP4_ReadBox_stsh( stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -1589,8 +1589,8 @@ static int MP4_ReadBox_stsh( stream_t *p_stream, MP4_Box_t *p_box )
static void MP4_FreeBox_stsh( MP4_Box_t *p_box ) static void MP4_FreeBox_stsh( MP4_Box_t *p_box )
{ {
FREENULL( p_box->data.p_stsh->i_shadowed_sample_number ) FREENULL( p_box->data.p_stsh->i_shadowed_sample_number );
FREENULL( p_box->data.p_stsh->i_sync_sample_number ) FREENULL( p_box->data.p_stsh->i_sync_sample_number );
} }
...@@ -1621,7 +1621,7 @@ static int MP4_ReadBox_stdp( stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -1621,7 +1621,7 @@ static int MP4_ReadBox_stdp( stream_t *p_stream, MP4_Box_t *p_box )
static void MP4_FreeBox_stdp( MP4_Box_t *p_box ) static void MP4_FreeBox_stdp( MP4_Box_t *p_box )
{ {
FREENULL( p_box->data.p_stdp->i_priority ) FREENULL( p_box->data.p_stdp->i_priority );
} }
static int MP4_ReadBox_padb( stream_t *p_stream, MP4_Box_t *p_box ) static int MP4_ReadBox_padb( stream_t *p_stream, MP4_Box_t *p_box )
...@@ -1970,7 +1970,7 @@ static int MP4_ReadBox_rdrf( stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -1970,7 +1970,7 @@ static int MP4_ReadBox_rdrf( stream_t *p_stream, MP4_Box_t *p_box )
static void MP4_FreeBox_rdrf( MP4_Box_t *p_box ) static void MP4_FreeBox_rdrf( MP4_Box_t *p_box )
{ {
FREENULL( p_box->data.p_rdrf->psz_ref ) FREENULL( p_box->data.p_rdrf->psz_ref );
} }
......
...@@ -97,7 +97,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -97,7 +97,7 @@ static int Open( vlc_object_t * p_this )
demux_t *p_demux = (demux_t*)p_this; demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys; demux_sys_t *p_sys;
es_format_t fmt; es_format_t fmt;
uint8_t *p_peek; const uint8_t *p_peek;
module_t *p_id3; module_t *p_id3;
if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 ) if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 )
...@@ -111,18 +111,12 @@ static int Open( vlc_object_t * p_this ) ...@@ -111,18 +111,12 @@ static int Open( vlc_object_t * p_this )
if( i_version < 4 || i_version > 6 ) if( i_version < 4 || i_version > 6 )
return VLC_EGENERIC; return VLC_EGENERIC;
if( !p_demux->psz_demux || strcmp( p_demux->psz_demux, "mpc" ) ) if( !p_demux->b_force )
{ {
/* Check file name extension */ /* Check file name extension */
int i_len; if( !demux2_IsPathExtension( p_demux, ".mpc" ) &&
if( !p_demux->psz_path ) !demux2_IsPathExtension( p_demux, ".mp+" ) &&
return VLC_EGENERIC; !demux2_IsPathExtension( p_demux, ".mpp" ) )
i_len = strlen( p_demux->psz_path );
if( i_len < 4 ||
( strcasecmp( &p_demux->psz_path[i_len-4], ".mpc" ) &&
strcasecmp( &p_demux->psz_path[i_len-4], ".mp+" ) &&
strcasecmp( &p_demux->psz_path[i_len-4], ".mpp" ) ) )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
} }
......
...@@ -74,7 +74,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -74,7 +74,7 @@ static int Open( vlc_object_t * p_this )
{ {
demux_t *p_demux = (demux_t*)p_this; demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys; demux_sys_t *p_sys;
uint8_t *p_peek; const uint8_t *p_peek;
vlc_value_t val; vlc_value_t val;
if( stream_Peek( p_demux->s, &p_peek, 5 ) < 5 ) return VLC_EGENERIC; if( stream_Peek( p_demux->s, &p_peek, 5 ) < 5 ) return VLC_EGENERIC;
......
...@@ -78,23 +78,14 @@ static int Open( vlc_object_t * p_this ) ...@@ -78,23 +78,14 @@ static int Open( vlc_object_t * p_this )
demux_t *p_demux = (demux_t*)p_this; demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys; demux_sys_t *p_sys;
module_t *p_id3; module_t *p_id3;
uint8_t *p_peek; const uint8_t *p_peek;
int b_forced = VLC_FALSE; int b_forced = VLC_FALSE;
if( p_demux->psz_path ) if( demux2_IsPathExtension( p_demux, ".aac" ) )
{ b_forced = VLC_TRUE;
int i_len = strlen( p_demux->psz_path );
if( i_len > 4 && !strcasecmp( &p_demux->psz_path[i_len - 4], ".aac" ) )
{
b_forced = VLC_TRUE;
}
}
if( !p_demux->b_force && !b_forced ) if( !p_demux->b_force && !b_forced )
{
return VLC_EGENERIC; return VLC_EGENERIC;
}
/* peek the begining (10 is for adts header) */ /* peek the begining (10 is for adts header) */
if( stream_Peek( p_demux->s, &p_peek, 10 ) < 10 ) if( stream_Peek( p_demux->s, &p_peek, 10 ) < 10 )
......
...@@ -74,7 +74,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -74,7 +74,7 @@ static int Open( vlc_object_t * p_this )
{ {
demux_t *p_demux = (demux_t*)p_this; demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys; demux_sys_t *p_sys;
uint8_t *p_peek; const uint8_t *p_peek;
vlc_value_t val; vlc_value_t val;
if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 ) return VLC_EGENERIC; if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 ) return VLC_EGENERIC;
......
...@@ -120,18 +120,12 @@ static int Open( vlc_object_t * p_this ) ...@@ -120,18 +120,12 @@ static int Open( vlc_object_t * p_this )
vlc_bool_t b_forced = VLC_FALSE; vlc_bool_t b_forced = VLC_FALSE;
uint32_t header; uint32_t header;
uint8_t *p_peek; const uint8_t *p_peek;
module_t *p_id3; module_t *p_id3;
block_t *p_block_in, *p_block_out; block_t *p_block_in, *p_block_out;
if( p_demux->psz_path ) if( demux2_IsPathExtension( p_demux, ".mp3" ) )
{ b_forced = VLC_TRUE;
int i_len = strlen( p_demux->psz_path );
if( i_len > 4 && !strcasecmp( &p_demux->psz_path[i_len - 4], ".mp3" ) )
{
b_forced = VLC_TRUE;
}
}