termux-packages/packages/mpv/sles_rate.patch
Tom Yan 3c279e179a 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.
2021-10-31 00:33:58 +05:30

14 lines
560 B
Diff

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));