summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Yan <tom.ty89@gmail.com>2018-03-13 03:06:23 +0800
committerJan Ekström <jeebjp@gmail.com>2018-04-05 04:35:49 +0300
commit14b429de8da30f1c83d14ffd4568ac8fa9687869 (patch)
tree30b23970492e5881b781146050c2e0e8f5c37110
parent5a8c48fde2a26fe00c3552e3ccf83a965b6d3576 (diff)
downloadmpv-14b429de8da30f1c83d14ffd4568ac8fa9687869.tar.bz2
mpv-14b429de8da30f1c83d14ffd4568ac8fa9687869.tar.xz
ao_opensles: bump device buffer size to 250ms
Although half (non-fast track on sink rate) or one-third (non-fast track not on sink rate) of the buffer size of the created AudioTrack instance as the SL Enqueue buffer size is basically enough for dropout-free playback, only using the full size can avoid stutter upon (re)start of playback. Here are the various buffer sizes on different track/sink rate when on Bluetooth audio on Android O: aptX @ 48kHz: Sink rate: 48000 Hz 44100 Hz: 10632 frames (241.09 ms) 48000 Hz: 11544 frames (240.50 ms) 88200 Hz: 21216 frames (240.54 ms) 96000 Hz: 23088 frames (240.50 ms) 176400 Hz: 42384 frames (240.27 ms) 192000 Hz: 46128 frames (240.25 ms) SBC/AAC/aptX @ 44.1kHz: Sink rate: 44100 Hz 44100 Hz: 10776 frames (244.35 ms) 48000 Hz: 11748 frames (244.75 ms) 88200 Hz: 21552 frames (244.35 ms) 96000 Hz: 23448 frames (244.25 ms) 176400 Hz: 43056 frames (244.08 ms) 192000 Hz: 46848 frames (244.00 ms) The above results were produced with the following code: import android.media.AudioAttributes; import android.media.AudioFormat; import android.media.AudioTrack; class AudioInfo { public static void main(String[] args) { int nosr = AudioTrack.getNativeOutputSampleRate(3); System.out.printf("Sink rate: %d Hz\n", nosr); int[] rates = {44100,48000,88200,96000,176400,192000}; for (int rate: rates) { AudioAttributes aa = new AudioAttributes.Builder().setFlags(256).build(); AudioFormat af = new AudioFormat.Builder().setSampleRate(rate).build(); AudioTrack at = new AudioTrack(aa, af, 4, 1, 0); int sr = at.getSampleRate(); int bs = at.getBufferSizeInFrames(); float ms = bs * (float) 1000 / sr; at.release(); System.out.printf("%d Hz: %d frames (%.2f ms)\n", sr, bs, ms); } } } Therefore bumping the device buffer size to 250ms.
-rw-r--r--audio/out/ao_opensles.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/audio/out/ao_opensles.c b/audio/out/ao_opensles.c
index 756d6e7f55..559f3f201e 100644
--- a/audio/out/ao_opensles.c
+++ b/audio/out/ao_opensles.c
@@ -100,7 +100,7 @@ static void buffer_callback(SLBufferQueueItf buffer_queue, void *context)
pthread_mutex_unlock(&p->buffer_lock);
}
-#define DEFAULT_BUFFER_SIZE_MS 200
+#define DEFAULT_BUFFER_SIZE_MS 250
#define CHK(stmt) \
{ \