From f601638dd61ccd6d1e980389dff508cefe0483ed Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 13 Jan 2023 05:40:13 -0800 Subject: Write proper samples when starting the PulseAudio stream Instead of silence, to ensure the number of samples written to PulseAudio is the same as the number mixed/rendered. --- alc/backends/pulseaudio.cpp | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp index 2c2eb743..eb41b683 100644 --- a/alc/backends/pulseaudio.cpp +++ b/alc/backends/pulseaudio.cpp @@ -965,27 +965,13 @@ void PulsePlayback::start() { MainloopUniqueLock plock{mMainloop}; - /* Write some (silent) samples to fill the buffer before we start feeding - * it newly mixed samples. + /* Write some samples to fill the buffer before we start feeding it newly + * mixed samples. */ if(size_t todo{pa_stream_writable_size(mStream)}) { void *buf{pa_xmalloc(todo)}; - switch(mSpec.format) - { - case PA_SAMPLE_U8: - std::fill_n(static_cast(buf), todo, 0x80); - break; - case PA_SAMPLE_ALAW: - std::fill_n(static_cast(buf), todo, 0xD5); - break; - case PA_SAMPLE_ULAW: - std::fill_n(static_cast(buf), todo, 0x7f); - break; - default: - std::fill_n(static_cast(buf), todo, 0x00); - break; - } + mDevice->renderSamples(buf, static_cast(todo/mFrameSize), mSpec.channels); pa_stream_write(mStream, buf, todo, pa_xfree, 0, PA_SEEK_RELATIVE); } -- cgit v1.2.3