summaryrefslogtreecommitdiffstats
path: root/audio/filter
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-06-22 15:02:03 +0200
committerwm4 <wm4@nowhere>2015-06-22 16:03:07 +0200
commit3d55340c6d22e68ee6b9eaac44fa80969fc1ba4b (patch)
tree2ebb2803c491746ae3bd9268ee18ccf9e53e5fd8 /audio/filter
parent17e8815e3769c4c6940828b00815df3fe663d9e0 (diff)
downloadmpv-3d55340c6d22e68ee6b9eaac44fa80969fc1ba4b.tar.bz2
mpv-3d55340c6d22e68ee6b9eaac44fa80969fc1ba4b.tar.xz
af: restore detaching of PCM filters when using spdif
Basically, af_fix_format_conversion() behaves stupid you insert a conversion filter that won't work, and adding back the conversion test function is the simplest fix to it.
Diffstat (limited to 'audio/filter')
-rw-r--r--audio/filter/af.c7
-rw-r--r--audio/filter/af.h2
-rw-r--r--audio/filter/af_lavrresample.c6
3 files changed, 14 insertions, 1 deletions
diff --git a/audio/filter/af.c b/audio/filter/af.c
index e67fc29203..3e7fdf045a 100644
--- a/audio/filter/af.c
+++ b/audio/filter/af.c
@@ -352,18 +352,23 @@ static int af_fix_format_conversion(struct af_stream *s,
return AF_FALSE;
int dstfmt = in.format;
char *filter = "lavrresample";
+ if (!af_lavrresample_test_conversion(actual.format, dstfmt))
+ return AF_ERROR;
if (strcmp(filter, prev->info->name) == 0) {
if (prev->control(prev, AF_CONTROL_SET_FORMAT, &dstfmt) == AF_OK) {
*p_af = prev;
return AF_OK;
}
+ return AF_ERROR;
}
struct af_instance *new = af_prepend(s, af, filter, NULL);
if (new == NULL)
return AF_ERROR;
new->auto_inserted = true;
- if (AF_OK != (rv = new->control(new, AF_CONTROL_SET_FORMAT, &dstfmt)))
+ if (AF_OK != (rv = new->control(new, AF_CONTROL_SET_FORMAT, &dstfmt))) {
+ af_remove(s, new);
return rv;
+ }
*p_af = new;
return AF_OK;
}
diff --git a/audio/filter/af.h b/audio/filter/af.h
index b35901232d..e8beac9631 100644
--- a/audio/filter/af.h
+++ b/audio/filter/af.h
@@ -161,4 +161,6 @@ int af_from_dB(int n, float *in, float *out, float k, float mi, float ma);
int af_from_ms(int n, float *in, int *out, int rate, float mi, float ma);
float af_softclip(float a);
+bool af_lavrresample_test_conversion(int src_format, int dst_format);
+
#endif /* MPLAYER_AF_H */
diff --git a/audio/filter/af_lavrresample.c b/audio/filter/af_lavrresample.c
index 7c2d7315e2..89fe2c414c 100644
--- a/audio/filter/af_lavrresample.c
+++ b/audio/filter/af_lavrresample.c
@@ -178,6 +178,12 @@ static int check_output_conversion(int mp_format)
return af_to_avformat(mp_format);
}
+bool af_lavrresample_test_conversion(int src_format, int dst_format)
+{
+ return af_to_avformat(src_format) != AV_SAMPLE_FMT_NONE &&
+ check_output_conversion(dst_format) != AV_SAMPLE_FMT_NONE;
+}
+
// mp_chmap_get_reorder() performs:
// to->speaker[n] = from->speaker[src[n]]
// but libavresample does: