aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-04-19 04:42:28 -0700
committerChris Robinson <[email protected]>2021-04-19 04:42:28 -0700
commitccb1355cc82fa964d951d8f8bb013e2040bfee89 (patch)
tree6e50eb8c5d510bc0d93f5823bf091c33e28accbe /alc
parent2b64008b3e565e4129784872002acd23d26580dd (diff)
Fill the PulseAudio buffer before uncorking playback
Diffstat (limited to 'alc')
-rw-r--r--alc/backends/pulseaudio.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp
index 448cce94..00365721 100644
--- a/alc/backends/pulseaudio.cpp
+++ b/alc/backends/pulseaudio.cpp
@@ -1033,34 +1033,34 @@ void PulsePlayback::start()
{
auto plock = mMainloop.getUniqueLock();
- pa_stream_set_write_callback(mStream, &PulsePlayback::streamWriteCallbackC, this);
- pa_operation *op{pa_stream_cork(mStream, 0, &PulseMainloop::streamSuccessCallbackC,
- &mMainloop)};
-
- /* Write some (silent) samples to fill the prebuf amount if needed. */
- if(size_t prebuf{mAttr.prebuf})
+ /* Write some (silent) samples to fill the buffer before we start feeding
+ * it newly mixed samples.
+ */
+ if(size_t todo{pa_stream_writable_size(mStream)})
{
- prebuf = minz(prebuf, pa_stream_writable_size(mStream));
-
- void *buf{pa_xmalloc(prebuf)};
+ void *buf{pa_xmalloc(todo)};
switch(mSpec.format)
{
case PA_SAMPLE_U8:
- std::fill_n(static_cast<uint8_t*>(buf), prebuf, 0x80);
+ std::fill_n(static_cast<uint8_t*>(buf), todo, 0x80);
break;
case PA_SAMPLE_ALAW:
- std::fill_n(static_cast<uint8_t*>(buf), prebuf, 0xD5);
+ std::fill_n(static_cast<uint8_t*>(buf), todo, 0xD5);
break;
case PA_SAMPLE_ULAW:
- std::fill_n(static_cast<uint8_t*>(buf), prebuf, 0x7f);
+ std::fill_n(static_cast<uint8_t*>(buf), todo, 0x7f);
break;
default:
- std::fill_n(static_cast<uint8_t*>(buf), prebuf, 0x00);
+ std::fill_n(static_cast<uint8_t*>(buf), todo, 0x00);
break;
}
- pa_stream_write(mStream, buf, prebuf, pa_xfree, 0, PA_SEEK_RELATIVE);
+ pa_stream_write(mStream, buf, todo, pa_xfree, 0, PA_SEEK_RELATIVE);
}
+ pa_stream_set_write_callback(mStream, &PulsePlayback::streamWriteCallbackC, this);
+ pa_operation *op{pa_stream_cork(mStream, 0, &PulseMainloop::streamSuccessCallbackC,
+ &mMainloop)};
+
mMainloop.waitForOperation(op, plock);
}