diff options
author | Chris Robinson <[email protected]> | 2023-01-13 05:40:13 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-01-13 05:40:13 -0800 |
commit | f601638dd61ccd6d1e980389dff508cefe0483ed (patch) | |
tree | d8eea4ff6e786424508c2bf0a89eefaa75af93fd | |
parent | 63921a94bcc8c0ea135e0b0058291e6185cd5871 (diff) |
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.
-rw-r--r-- | alc/backends/pulseaudio.cpp | 20 |
1 files 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<uint8_t*>(buf), todo, 0x80); - break; - case PA_SAMPLE_ALAW: - std::fill_n(static_cast<uint8_t*>(buf), todo, 0xD5); - break; - case PA_SAMPLE_ULAW: - std::fill_n(static_cast<uint8_t*>(buf), todo, 0x7f); - break; - default: - std::fill_n(static_cast<uint8_t*>(buf), todo, 0x00); - break; - } + mDevice->renderSamples(buf, static_cast<uint>(todo/mFrameSize), mSpec.channels); pa_stream_write(mStream, buf, todo, pa_xfree, 0, PA_SEEK_RELATIVE); } |