Commit 6302901c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

aiff: use vlc_obj_calloc()

parent a8282e0e
......@@ -42,14 +42,13 @@
* Module descriptor
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
vlc_module_begin ()
set_category( CAT_INPUT )
set_subcategory( SUBCAT_INPUT_DEMUX )
set_description( N_("AIFF demuxer" ) )
set_capability( "demux", 10 )
set_callbacks( Open, Close )
set_callbacks( Open, NULL )
add_shortcut( "aiff" )
vlc_module_end ()
......@@ -117,7 +116,7 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC;
/* Fill p_demux field */
demux_sys_t *p_sys = calloc( 1, sizeof (*p_sys) );
demux_sys_t *p_sys = vlc_obj_calloc( p_this, 1, sizeof (*p_sys) );
es_format_Init( &p_sys->fmt, AUDIO_ES, VLC_FOURCC( 't', 'w', 'o', 's' ) );
p_sys->i_time = 0;
p_sys->i_ssnd_pos = -1;
......@@ -125,7 +124,7 @@ static int Open( vlc_object_t *p_this )
for( ;; )
{
if( vlc_stream_Peek( p_demux->s, &p_peek, 8 ) < 8 )
goto error;
return VLC_EGENERIC;
uint32_t i_data_size = GetDWBE( &p_peek[4] );
uint64_t i_chunk_size = UINT64_C( 8 ) + i_data_size + ( i_data_size & 1 );
......@@ -136,7 +135,7 @@ static int Open( vlc_object_t *p_this )
if( !memcmp( p_peek, "COMM", 4 ) )
{
if( vlc_stream_Peek( p_demux->s, &p_peek, 18+8 ) < 18+8 )
goto error;
return VLC_EGENERIC;
p_sys->fmt.audio.i_channels = GetWBE( &p_peek[8] );
p_sys->fmt.audio.i_bitspersample = GetWBE( &p_peek[14] );
......@@ -149,7 +148,7 @@ static int Open( vlc_object_t *p_this )
else if( !memcmp( p_peek, "SSND", 4 ) )
{
if( vlc_stream_Peek( p_demux->s, &p_peek, 8+8 ) < 8+8 )
goto error;
return VLC_EGENERIC;
p_sys->i_ssnd_pos = vlc_stream_Tell( p_demux->s );
p_sys->i_ssnd_size = i_data_size;
......@@ -176,7 +175,7 @@ static int Open( vlc_object_t *p_this )
if( vlc_stream_Read( p_demux->s, NULL, i_req ) != i_req )
{
msg_Warn( p_demux, "incomplete file" );
goto error;
return VLC_EGENERIC;
}
}
}
......@@ -190,7 +189,7 @@ static int Open( vlc_object_t *p_this )
if( p_sys->i_ssnd_fsize <= 0 || p_sys->fmt.audio.i_rate == 0 )
{
msg_Err( p_demux, "invalid audio parameters" );
goto error;
return VLC_EGENERIC;
}
if( p_sys->i_ssnd_size <= 0 )
......@@ -203,7 +202,7 @@ static int Open( vlc_object_t *p_this )
if( vlc_stream_Seek( p_demux->s, p_sys->i_ssnd_start ) )
{
msg_Err( p_demux, "cannot seek to data chunk" );
goto error;
return VLC_EGENERIC;
}
/* */
......@@ -214,24 +213,8 @@ static int Open( vlc_object_t *p_this )
p_demux->p_sys = p_sys;
return VLC_SUCCESS;
error:
free( p_sys );
return VLC_EGENERIC;
}
/*****************************************************************************
* Close
*****************************************************************************/
static void Close( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys;
free( p_sys );
}
/*****************************************************************************
* Demux:
*****************************************************************************/
......
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