Commit cf34a476 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

scaletemp: setup filter_t only when successful

parent 51a324b0
......@@ -386,33 +386,12 @@ static int reinit_buffers( filter_t *p_filter )
static int Open( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys;
bool b_fit = true;
if( p_filter->fmt_in.audio.i_format != VLC_CODEC_FL32 ||
p_filter->fmt_out.audio.i_format != VLC_CODEC_FL32 )
{
b_fit = false;
p_filter->fmt_in.audio.i_format = p_filter->fmt_out.audio.i_format = VLC_CODEC_FL32;
msg_Warn( p_filter, "bad input or output format" );
}
if( ! AOUT_FMTS_SIMILAR( &p_filter->fmt_in.audio, &p_filter->fmt_out.audio ) )
{
b_fit = false;
memcpy( &p_filter->fmt_out.audio, &p_filter->fmt_in.audio, sizeof(audio_sample_format_t) );
msg_Warn( p_filter, "input and output formats are not similar" );
}
if( ! b_fit )
return VLC_EGENERIC;
/* Allocate structure */
p_sys = p_filter->p_sys = malloc( sizeof(*p_sys) );
filter_sys_t *p_sys = p_filter->p_sys = malloc( sizeof(*p_sys) );
if( ! p_sys )
return VLC_ENOMEM;
p_filter->pf_audio_filter = DoWork;
p_sys->scale = 1.0;
p_sys->sample_rate = p_filter->fmt_in.audio.i_rate;
p_sys->samples_per_frame = aout_FormatNbChannels( &p_filter->fmt_in.audio );
......@@ -447,6 +426,10 @@ static int Open( vlc_object_t *p_this )
Close( p_this );
return VLC_EGENERIC;
}
p_filter->fmt_in.audio.i_format = VLC_CODEC_FL32;
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
p_filter->pf_audio_filter = DoWork;
return VLC_SUCCESS;
}
......
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