summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Mitchell <kevmitch@gmail.com>2016-03-17 00:58:07 -0700
committerKevin Mitchell <kevmitch@gmail.com>2016-03-17 02:31:05 -0700
commite26462599bc272f7e90c2c6e820d5d9ec1c801d6 (patch)
treece7a4306831ece9d3d7539aba547142251cd2f08
parent96053d53a75f69ff1662a0641e009f7cbad3cbc2 (diff)
downloadmpv-e26462599bc272f7e90c2c6e820d5d9ec1c801d6.tar.bz2
mpv-e26462599bc272f7e90c2c6e820d5d9ec1c801d6.tar.xz
ao_lavc: use new af_select_best_samplerate function
This is particularly useful for opus which allows only a fairly restrictive set of samplerates. If the codec doesn't provide a list of samplerates, just continue to try the requsted one and hope for the best. fixes #2957
-rw-r--r--audio/out/ao_lavc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c
index b671301922..bf1728682a 100644
--- a/audio/out/ao_lavc.c
+++ b/audio/out/ao_lavc.c
@@ -108,6 +108,11 @@ static int init(struct ao *ao)
codec = encode_lavc_get_codec(ao->encode_lavc_ctx, ac->stream);
+ int samplerate = af_select_best_samplerate(ao->samplerate,
+ codec->supported_samplerates);
+ if (samplerate > 0)
+ ao->samplerate = samplerate;
+
// TODO: Remove this redundancy with encode_lavc_alloc_stream also
// setting the time base.
// Using codec->time_bvase is deprecated, but needed for older lavf.