int64_t input_layout = av_get_default_channel_layout(s->input_channels);
uint_t output_channels = multi ? s->input_channels : 1;
int64_t output_layout = av_get_default_channel_layout(output_channels);
- if (s->avr != NULL) {
- avresample_close( s->avr );
- av_free ( s->avr );
- s->avr = NULL;
- }
- AVAudioResampleContext *avr = s->avr;
- avr = avresample_alloc_context();
+ AVAudioResampleContext *avr = avresample_alloc_context();
+ AVAudioResampleContext *oldavr = s->avr;
av_opt_set_int(avr, "in_channel_layout", input_layout, 0);
av_opt_set_int(avr, "out_channel_layout", output_layout, 0);
return;
}
s->avr = avr;
+ if (oldavr != NULL) {
+ avresample_close( oldavr );
+ av_free ( oldavr );
+ oldavr = NULL;
+ }
s->multi = multi;
}
}