mpv: add rate guards to the opensles ao

Upstream "Wilhelm" (the Android OpenSLES implementation) supports
only 8000 <= rate <= 192000. Make sure mpv resamples the audio
when necessary.
This commit is contained in:
Tom Yan 2021-10-30 18:00:43 +08:00 committed by buttaface
parent 17712de701
commit 3c279e179a
2 changed files with 14 additions and 0 deletions

View File

@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION="Command-line media player"
TERMUX_PKG_LICENSE="GPL-3.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=0.33.1
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://github.com/mpv-player/mpv/archive/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=100a116b9f23bdcda3a596e9f26be3a69f166a4f1d00910d1789b6571c46f3a9
TERMUX_PKG_AUTO_UPDATE=true

View File

@ -0,0 +1,13 @@
diff --git a/audio/out/ao_opensles.c b/audio/out/ao_opensles.c
index 40ab5324b5..aef78c2dec 100644
--- a/audio/out/ao_opensles.c
+++ b/audio/out/ao_opensles.c
@@ -111,6 +111,8 @@ static int init(struct ao *ao)
// This AO only supports two channels at the moment
mp_chmap_from_channels(&ao->channels, 2);
+ // Upstream "Wilhelm" supports only 8000 <= rate <= 192000
+ ao->samplerate = MPMIN(MPMAX(ao->samplerate, 8000), 192000);
CHK(slCreateEngine(&p->sl, 0, NULL, 0, NULL, NULL));
CHK((*p->sl)->Realize(p->sl, SL_BOOLEAN_FALSE));