1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-16 12:17:12 +00:00

ao_audiotrack: change buffer sizing logic

Previously number of channels was being ignored.

The buffer will now be between 75ms and 150ms

Signed-off-by: Aman Karmani <aman@tmm1.net>
This commit is contained in:
Aman Karmani 2021-10-19 14:39:48 -07:00 committed by sfan5
parent fa691e0f69
commit 06392e7ec1

View File

@ -721,8 +721,8 @@ static int init(struct ao *ao)
return -1;
}
int min = 0.200 * p->samplerate * af_fmt_to_bytes(ao->format);
int max = min * 3 / 2;
int min = 0.075 * p->samplerate * af_fmt_to_bytes(ao->format) * ao->channels.num;
int max = min * 2;
p->size = MPCLAMP(buffer_size * 2, min, max);
MP_VERBOSE(ao, "Setting bufferSize = %d (driver=%d, min=%d, max=%d)\n", p->size, buffer_size, min, max);
ao->device_buffer = p->size / af_fmt_to_bytes(ao->format);