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 )
}
/* Malloc with automatic error */
#define MALLOC_VOID( var, type ) { var = (type*)malloc( sizeof( type) ); \
if( !var ) return; }
#define MALLOC_NULL( var, type ) { var = (type*)malloc( sizeof( type) ); \
if( !var ) return NULL; }
#define MALLOC_ERR( var, type ) { var = (type*)malloc( sizeof( type) ); \
if( !var ) return VLC_ENOMEM; }
#define MALLOC_GOTOERR( var, type ) { var = (type*)malloc( sizeof( type) ); \
if( !var ) goto error; }
#define MALLOC_VOID( var, type ) do { var = (type*)malloc( sizeof( type) ); \
if( !var ) return; } while(0)
#define MALLOC_NULL( var, type ) do { var = (type*)malloc( sizeof( type) ); \
if( !var ) return NULL; } while(0)
#define MALLOC_ERR( var, type ) do { var = (type*)malloc( sizeof( type) ); \
if( !var ) return VLC_ENOMEM; } while(0)
#define MALLOC_GOTOERR( var, type ) do { var = (type*)malloc( sizeof( type) ); \
if( !var ) goto error; } while(0)
#define DECMALLOC_VOID( var, type ) type* var = (type*)malloc( sizeof(type) );\
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;
#define DECMALLOC_NULL( var, type ) type* var = (type*)malloc( sizeof(type) );\
if( !var ) return NULL;
#define FREENULL(a) if( a ) { free( a ); a = NULL; }
#define FREE(a) if( a ) { free( a ); }
#define FREENULL(a) do { if( a ) { free( a ); a = NULL; } } while(0)
#define FREE(a) do { if( a ) { free( a ); } } while(0)
#define EMPTY_STR(str) (!str || !*str)
......@@ -814,6 +814,9 @@ static inline void _SetQWBE( uint8_t *p, uint64_t i_qw )
# define ATTR_ALIGN(align)
#endif
/* */
#define VLC_UNUSED(x) (void)(x)
/* Alignment of critical dynamic data structure
*
* 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
static inline vlc_bool_t demux2_IsPathExtension( demux_t *p_demux, const char *psz_extension )
{
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_TRUE;
}
......@@ -140,24 +140,21 @@ static inline vlc_bool_t demux2_IsForced( demux_t *p_demux, const char *psz_name
return VLC_TRUE;
}
#define STANDARD_DEMUX_INIT \
p_demux->pf_control = Control; \
p_demux->pf_demux = Demux; \
#define DEMUX_INIT_COMMON() do { \
p_demux->pf_control = Control; \
p_demux->pf_demux = Demux; \
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 ) \
p_demux->pf_control = Control; \
p_demux->pf_demux = Demux; \
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 STANDARD_DEMUX_INIT_MSG( msg ) do { \
DEMUX_INIT_COMMON(); \
msg_Dbg( p_demux, msg ); } while(0)
#define DEMUX_BY_EXTENSION( ext ) \
demux_t *p_demux = (demux_t *)p_this; \
if( !demux2_IsPathExtension( p_demux, ext ) ) \
return VLC_EGENERIC; \
STANDARD_DEMUX_INIT;
DEMUX_INIT_COMMON();
#define DEMUX_BY_EXTENSION_MSG( ext, msg ) \
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
demux_t *p_demux = (demux_t *)p_this; \
if( !demux2_IsPathExtension( p_demux, ext ) && !demux2_IsForced( p_demux, module ) ) \
return VLC_EGENERIC; \
STANDARD_DEMUX_INIT;
DEMUX_INIT_COMMON();
#define DEMUX_BY_EXTENSION_OR_FORCED_MSG( ext, module, msg ) \
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
if( stream_Peek( p_demux->s , &zepeek, size ) < size ) { \
msg_Dbg( p_demux, "not enough data" ); goto error; }
#define CHECK_DISCARD_PEEK( size ) { uint8_t *p_peek; \
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 POKE( peek, stuff, size ) (strncasecmp( (const char *)peek, stuff, size )==0)
#define COMMON_INIT_PACKETIZER( location ) \
location = vlc_object_create( p_demux, VLC_OBJECT_PACKETIZER ); \
......
......@@ -209,7 +209,7 @@ static int Open( vlc_object_t *p_this )
free( psz_name );
/* 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;
ps_track_init( p_sys->tk );
......
......@@ -247,7 +247,7 @@ static int Open( vlc_object_t *p_this )
msg_Dbg( p_demux, "VMG opened" );
/* 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 );
p_sys->i_aspect = -1;
......
......@@ -97,7 +97,7 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC;
/* 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_title = 0;
p_demux->info.i_seekpoint = 0;
......
......@@ -129,10 +129,8 @@ static int Open( vlc_object_t * p_this )
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;
}
/* User forced */
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 )
}
/* 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->i_mux_rate = 0;
p_sys->b_big_endian = b_big_endian;
......
......@@ -74,7 +74,7 @@ static int Demux ( demux_t *p_demux );
static int Control( demux_t *p_demux, int i_query, va_list args );
/* 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] );
int i_exp = 30 - p[1];
......@@ -112,7 +112,7 @@ static int Open( vlc_object_t *p_this )
stream_Read( p_demux->s, NULL, 12 );
/* 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 );
p_sys->i_time = 1;
p_sys->i_ssnd_pos = -1;
......
......@@ -127,7 +127,7 @@ static int Open( vlc_object_t *p_this )
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_header_size = GetDWBE( &hdr[0] );
......
......@@ -225,7 +225,7 @@ static int Open( vlc_object_t * p_this )
unsigned int i_track;
unsigned int i, i_peeker;
uint8_t *p_peek;
const uint8_t *p_peek;
/* Is it an avi file ? */
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,
****************************************************************************/
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 )
{
......
......@@ -31,7 +31,7 @@
#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] );
}
......@@ -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 )
{
uint8_t *p_peek;
const uint8_t *p_peek;
int i_peek;
memset( p_chk, 0, sizeof( avi_chunk_t ) );
......@@ -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 )
{
avi_chunk_t *p_chk;
uint8_t *p_peek;
const uint8_t *p_peek;
vlc_bool_t b_seekable;
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 )
{
p_chk->idx1.i_entry_count = 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 )
/* Identify cdg file by extension, as there is no simple way to
* detect it */
if( !demux2_IsPathExtension( p_demux, ".cdg" ) &&
!demux2_IsPathExtension( p_demux, ".CDG" ) &&
!demux2_IsForced( p_demux, "cdg" ) )
if( !demux2_IsPathExtension( p_demux, ".cdg" ) && !p_demux->b_force )
return VLC_EGENERIC;
/* 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 )
vlc_bool_t b_append;
/* Accept only if forced */
if( strcasecmp( p_demux->psz_demux, "dump" ) )
if( !p_demux->b_force )
return VLC_EGENERIC;
var_Create( p_demux, "demuxdump-append", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
......
......@@ -140,16 +140,15 @@ static int Open( vlc_object_t * p_this )
if( CheckSync( p_peek + i_peek ) != VLC_SUCCESS )
{
if( strncmp( p_demux->psz_demux, "dts", 3 ) )
{
if( !p_demux->b_force )
return VLC_EGENERIC;
}
/* User forced */
msg_Err( p_demux, "this doesn't look like a DTS audio stream, "
"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',' ' );
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 )
#define IF_EXTRACT(txt,var) \
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 ) \
{ \
char * newval; \
......@@ -630,7 +630,6 @@ static void ParseComment( demux_t *p_demux, const uint8_t *p_data, int i_data )
} \
else \
vlc_meta_Set( p_sys->p_meta, vlc_meta_ ## var, &psz[strlen(txt)] ); \
free( oldval ); \
}
IF_EXTRACT("TITLE=", Title )
else IF_EXTRACT("ALBUM=", Album )
......
......@@ -114,7 +114,7 @@ static int Open( vlc_object_t *p_this )
vlc_value_t val;
/* 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 ||
stream_Size( p_demux->s ) == 0 ) return VLC_EGENERIC;
......
......@@ -74,7 +74,7 @@ struct demux_sys_t
mtime_t i_frame_length;
char *psz_separator;
int i_frame_size_estimate;
uint8_t *p_peek;
const uint8_t *p_peek;
int i_data_peeked;
};
......@@ -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 )
{
demux_sys_t *p_sys = p_demux->p_sys;
uint8_t *p_buf;
const uint8_t *p_buf;
int i_size;
int i;
char *p_line;
......@@ -300,7 +300,6 @@ static int Open( vlc_object_t * p_this )
int i_size;
int b_matched = VLC_FALSE;
vlc_value_t val;
char *psz_ext;
p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
......@@ -342,9 +341,8 @@ static int Open( vlc_object_t * p_this )
/* Check for jpeg file extension */
p_sys->b_still = VLC_FALSE;
p_sys->i_still_end = 0;
psz_ext = strrchr( p_demux->psz_path, '.' );
if( psz_ext && ( !strcasecmp( psz_ext, ".jpeg" ) ||
!strcasecmp( psz_ext, ".jpg" ) ) )
if( demux2_IsPathExtension( p_demux, ".jpeg" ) ||
demux2_IsPathExtension( p_demux, ".jpg" ) )
{
p_sys->b_still = VLC_TRUE;
if( val.f_float)
......
......@@ -129,14 +129,14 @@ static int Open( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
char *ext;
int i;
ModPlug_Settings settings;
vlc_value_t val;
/* 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 ||
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 )
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 )
......@@ -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 )
{
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 )
......@@ -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 )
{
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_shadowed_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 )
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 )
......@@ -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 )
{
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 )
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
es_format_t fmt;
uint8_t *p_peek;
const uint8_t *p_peek;
module_t *p_id3;
if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 )
......@@ -111,18 +111,12 @@ static int Open( vlc_object_t * p_this )
if( i_version < 4 || i_version > 6 )
return VLC_EGENERIC;
if( !p_demux->psz_demux || strcmp( p_demux->psz_demux, "mpc" ) )
if( !p_demux->b_force )
{
/* Check file name extension */
int i_len;
if( !p_demux->psz_path )
return VLC_EGENERIC;
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" ) ) )
if( !demux2_IsPathExtension( p_demux, ".mpc" ) &&
!demux2_IsPathExtension( p_demux, ".mp+" ) &&
!demux2_IsPathExtension( p_demux, ".mpp" ) )
return VLC_EGENERIC;
}
}
......
......@@ -74,7 +74,7 @@ static int Open( vlc_object_t * p_this )
{
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
uint8_t *p_peek;
const uint8_t *p_peek;
vlc_value_t val;
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 )
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
module_t *p_id3;
uint8_t *p_peek;
const uint8_t *p_peek;
int b_forced = VLC_FALSE;
if( p_demux->psz_path )
{
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( demux2_IsPathExtension( p_demux, ".aac" ) )
b_forced = VLC_TRUE;
if( !p_demux->b_force && !b_forced )
{
return VLC_EGENERIC;
}
/* peek the begining (10 is for adts header) */
if( stream_Peek( p_demux->s, &p_peek, 10 ) < 10 )
......
......@@ -74,7 +74,7 @@ static int Open( vlc_object_t * p_this )
{
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
uint8_t *p_peek;
const uint8_t *p_peek;
vlc_value_t val;
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 )
vlc_bool_t b_forced = VLC_FALSE;
uint32_t header;
uint8_t *p_peek;
const uint8_t *p_peek;
module_t *p_id3;
block_t *p_block_in, *p_block_out;
if( p_demux->psz_path )
{
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;
}
}
if( demux2_IsPathExtension( p_demux, ".mp3" ) )
b_forced = VLC_TRUE;
if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 ) return VLC_EGENERIC;
......@@ -156,7 +150,7 @@ static int Open( vlc_object_t * p_this )
if( !b_ok && !p_demux->b_force ) return VLC_EGENERIC;
}
STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys;
DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys;
memset( p_sys, 0, sizeof( demux_sys_t ) );
p_sys->p_es = 0;
p_sys->b_start = VLC_TRUE;
......@@ -171,7 +165,7 @@ static int Open( vlc_object_t * p_this )
if( HeaderCheck( header ) )
{
int i_xing, i_skip;
uint8_t *p_xing;
const uint8_t *p_xing;
if( ( i_xing = stream_Peek( p_demux->s, &p_xing, 1024 ) ) < 21 )
return VLC_SUCCESS; /* No header */
......
......@@ -70,7 +70,7 @@ static int Open( vlc_object_t * p_this )
demux_sys_t *p_sys;
vlc_bool_t b_forced = VLC_FALSE;
uint8_t *p_peek;
const uint8_t *p_peek;
es_format_t fmt;
......@@ -80,10 +80,8 @@ static int Open( vlc_object_t * p_this )
return VLC_EGENERIC;
}
if( !strncmp( p_demux->psz_demux, "mpgv", 4 ) )
{
if( p_demux->b_force )
b_forced = VLC_TRUE;
}
if( p_peek[0] != 0x00 || p_peek[1] != 0x00 || p_peek[2] != 0x01 )
{
......
......@@ -264,7 +264,7 @@ static char *nscdec( vlc_object_t *p_demux, char* p_encoded )
static int DemuxOpen( vlc_object_t * p_this )
{
demux_t *p_demux = (demux_t *)p_this;
byte_t *p_peek;
const byte_t *p_peek;
int i_size;
/* Lets check the content to see if this is a NSC file */
......
......@@ -93,10 +93,8 @@ static int Open( vlc_object_t *p_this )
if( memcmp( p_peek, "NSVf", 4 ) && memcmp( p_peek, "NSVs", 4 ) )
{
/* In case we had force this demuxer we try to resynch */
if( strcmp( p_demux->psz_demux, "nsv" ) || ReSynch( p_demux ) )
{
if( !p_demux->b_force || ReSynch( p_demux ) )
return VLC_EGENERIC;
}
}
/* Fill p_demux field */
......
......@@ -192,7 +192,7 @@ static int Open( vlc_object_t * p_this )
{
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
uint8_t *p_peek;
const uint8_t *p_peek;
frame_header_t fh;
vlc_bool_t b_extended;
......
......@@ -186,7 +186,7 @@ static int Open( vlc_object_t * p_this )
/* Check if we are dealing with an ogg stream */
if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 ) return VLC_EGENERIC;
if( strcmp( p_demux->psz_demux, "ogg" ) && memcmp( p_peek, "OggS", 4 ) )
if( !p_demux->b_force && memcmp( p_peek, "OggS", 4 ) )
{
return VLC_EGENERIC;
}
......
......@@ -184,7 +184,7 @@ static int ParseTime(char *s, size_t i_strlen)
int E_(Import_ASX)( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
uint8_t *p_peek;
const uint8_t *p_peek;
CHECK_PEEK( p_peek, 10 );
// skip over possible leading empty lines and empty spaces
......@@ -529,14 +529,14 @@ static int Demux( demux_t *p_demux )
input_ItemAddSubItem( p_current_input, p_entry );
}
/* cleanup entry */
FREENULL( psz_href )
FREENULL( psz_title_entry )
FREENULL( psz_base_entry )
FREENULL( psz_artist_entry )
FREENULL( psz_copyright_entry )
FREENULL( psz_moreinfo_entry )
FREENULL( psz_abstract_entry )
/* cleanup entry */;
FREENULL( psz_href );
FREENULL( psz_title_entry );
FREENULL( psz_base_entry );
FREENULL( psz_artist_entry );
FREENULL( psz_copyright_entry );
FREENULL( psz_moreinfo_entry );
FREENULL( psz_abstract_entry );
b_entry = VLC_FALSE;
}
else if( !strncasecmp( psz_parse, "<Entry", 6 ) )
......
......@@ -50,7 +50,7 @@ static int ParseLine( char *, char **, char ***, int *);
int E_(Import_DVB)( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
uint8_t *p_peek;
const uint8_t *p_peek;
int i_peek;
vlc_bool_t b_valid = VLC_FALSE;
......
......@@ -74,7 +74,7 @@ int E_(Import_GVP)( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
int i_peek, i, b_found = VLC_FALSE;
byte_t *p_peek;
const byte_t *p_peek;
i_peek = stream_Peek( p_demux->s, &p_peek, MAX_LINE );
......@@ -90,7 +90,7 @@ int E_(Import_GVP)( vlc_object_t *p_this )
if( !b_found ) return VLC_EGENERIC;
STANDARD_DEMUX_INIT_MSG( "using Google Video Playlist (gvp) import" )
STANDARD_DEMUX_INIT_MSG( "using Google Video Playlist (gvp) import" );
p_demux->pf_control = Control;
p_demux->pf_demux = Demux;
MALLOC_ERR( p_demux->p_sys, demux_sys_t );
......
......@@ -54,7 +54,7 @@ int E_(Import_IFO)( vlc_object_t *p_this )
&& !strcasecmp( psz_file + strlen( "VTS_00_0" ) , ".IFO" ) ) ) )
{
int i_peek;
byte_t *p_peek;
const byte_t *p_peek;
i_peek = stream_Peek( p_demux->s, &p_peek, 8 );
if( strncmp( p_peek, "DVDVIDEO", 8 ) )
......
......@@ -50,7 +50,7 @@ static void parseEXTINF( char *psz_string, char **ppsz_artist, char **ppsz_name,
int E_(Import_M3U)( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
uint8_t *p_peek;
const uint8_t *p_peek;
CHECK_PEEK( p_peek, 8 );
if(! ( POKE( p_peek, "#EXTM3U", 7 ) || POKE( p_peek, "RTSPtext", 8 ) ||
......
......@@ -47,7 +47,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args );
int E_(Import_PLS)( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
uint8_t *p_peek;
const uint8_t *p_peek;
CHECK_PEEK( p_peek, 10 );
if( POKE( p_peek, "[playlist]", 10 ) || POKE( p_peek, "[Reference]", 10 ) ||
......
......@@ -134,7 +134,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args );
int E_(Import_SGIMB)( vlc_object_t * p_this )
{
demux_t *p_demux = (demux_t *)p_this;
byte_t *p_peek;
const byte_t *p_peek;
int i_size;
/* Lets check the content to see if this is a sgi mediabase file */
......
......@@ -425,13 +425,13 @@ static int DemuxStation( demux_t *p_demux )
input_ItemAddSubItem( p_sys->p_current_input, p_input );
FREENULL( psz_name );
FREENULL( psz_mt )
FREENULL( psz_id )
FREENULL( psz_br )
FREENULL( psz_genre )
FREENULL( psz_ct )
FREENULL( psz_lc )
FREENULL( psz_rt )
FREENULL( psz_mt );
FREENULL( psz_id );
FREENULL( psz_br );
FREENULL( psz_genre );
FREENULL( psz_ct );
FREENULL( psz_lc );
FREENULL( psz_rt );
}
free( psz_eltname );
break;
......
......@@ -98,7 +98,7 @@ static int OpenCommon( vlc_object_t *p_this, vlc_bool_t b_force )
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
uint8_t *p_peek;
const uint8_t *p_peek;
if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 )