summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-09 23:19:05 +0100
committerwm4 <wm4@nowhere>2013-11-09 23:32:52 +0100
commit31f409a3c510c7fc289ad2b75091c6b77dd2b235 (patch)
tree6c91ba43905776cdef51d0282eadc4b5ad4a82c3
parent65571dd0d543ced01fc2d10f1fcb8fea933f1e9b (diff)
downloadmpv-31f409a3c510c7fc289ad2b75091c6b77dd2b235.tar.bz2
mpv-31f409a3c510c7fc289ad2b75091c6b77dd2b235.tar.xz
af_surround: fix format negotiation
This did strange things; perhaps caused by the channel layout changes.
-rw-r--r--audio/filter/af_surround.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/audio/filter/af_surround.c b/audio/filter/af_surround.c
index 25218c1b05..e584e6505a 100644
--- a/audio/filter/af_surround.c
+++ b/audio/filter/af_surround.c
@@ -91,15 +91,17 @@ static int control(struct af_instance* af, int cmd, void* arg)
af_surround_t *s = af->setup;
switch(cmd){
case AF_CONTROL_REINIT:{
+ struct mp_audio *in = arg;
float fc;
- mp_audio_copy_config(af->data, (struct mp_audio*)arg);
- mp_audio_set_channels_old(af->data, ((struct mp_audio*)arg)->nch*2);
- mp_audio_set_format(af->data, AF_FORMAT_FLOAT_NE);
-
- if (af->data->nch != 4){
- mp_msg(MSGT_AFILTER, MSGL_ERR, "[surround] Only stereo input is supported.\n");
- return AF_DETACH;
+ if (!mp_chmap_is_stereo(&in->channels)) {
+ mp_msg(MSGT_AFILTER, MSGL_ERR, "[surround] Only stereo input is supported.\n");
+ return AF_DETACH;
}
+
+ mp_audio_set_format(in, AF_FORMAT_FLOAT_NE);
+ mp_audio_copy_config(af->data, in);
+ mp_audio_set_channels_old(af->data, in->nch * 2);
+
// Surround filer coefficients
fc = 2.0 * 7000.0/(float)af->data->rate;
if (-1 == af_filter_design_fir(L, s->w, &fc, LP|HAMMING, 0)){
@@ -122,11 +124,6 @@ static int control(struct af_instance* af, int cmd, void* arg)
// printf("%i\n",s->wi);
s->ri = 0;
- if((af->data->format != ((struct mp_audio*)arg)->format) ||
- (af->data->bps != ((struct mp_audio*)arg)->bps)){
- mp_audio_set_format((struct mp_audio*)arg, af->data->format);
- return AF_FALSE;
- }
return AF_OK;
}
case AF_CONTROL_COMMAND_LINE:{