aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends/pipewire.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-11-22 23:54:01 -0800
committerChris Robinson <[email protected]>2022-11-22 23:54:01 -0800
commit4b67a1f667297fed2d0dc4a910800b76e6c02e10 (patch)
tree223de7ab82452909f4e7a769be48ace41707bc4a /alc/backends/pipewire.cpp
parent62e6051eb9eb0890a7d0014d051b003e7f670662 (diff)
Don't prematurely change ALCdevice::BufferSize
Diffstat (limited to 'alc/backends/pipewire.cpp')
-rw-r--r--alc/backends/pipewire.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp
index f979027e..c8e957b9 100644
--- a/alc/backends/pipewire.cpp
+++ b/alc/backends/pipewire.cpp
@@ -1487,10 +1487,11 @@ bool PipeWirePlayback::reset()
{
/* Scale the update size if the sample rate changes. */
const double scale{static_cast<double>(match->mSampleRate) / mDevice->Frequency};
+ const double numbufs{static_cast<double>(mDevice->BufferSize)/mDevice->UpdateSize};
mDevice->Frequency = match->mSampleRate;
mDevice->UpdateSize = static_cast<uint>(clampd(mDevice->UpdateSize*scale + 0.5,
64.0, 8192.0));
- mDevice->BufferSize = mDevice->UpdateSize * 2;
+ mDevice->BufferSize = static_cast<uint>(numbufs*mDevice->UpdateSize + 0.5);
}
if(!mDevice->Flags.test(ChannelsRequest) && match->mChannels != InvalidChannelConfig)
mDevice->FmtChans = match->mChannels;
@@ -1563,10 +1564,12 @@ bool PipeWirePlayback::reset()
return state == PW_STREAM_STATE_PAUSED;
});
- /* TODO: Update mDevice->BufferSize with the total known buffering delay
- * from the head of this playback stream to the tail of the device output.
+ /* TODO: Update mDevice->UpdateSize with the stream's quantum, and
+ * mDevice->BufferSize with the total known buffering delay from the head
+ * of this playback stream to the tail of the device output.
+ *
+ * This info is apparently not available until after the stream starts.
*/
- mDevice->BufferSize = mDevice->UpdateSize * 2;
plock.unlock();
mNumChannels = mDevice->channelsFromFmt();
@@ -1598,9 +1601,10 @@ void PipeWirePlayback::start()
});
/* HACK: Try to work out the update size and total buffering size. There's
- * no simple query for this, so we have to work it out from the stream time
- * info. The stream time info may also not be available right away, so we
- * have to wait until it is (up to about 2 seconds).
+ * no actual query for this, so we have to work it out from the stream time
+ * info, and assume it stays accurate with future updates. The stream time
+ * info may also not be available right away, so we have to wait until it
+ * is (up to about 2 seconds).
*/
int wait_count{100};
pw_stream_state state{PW_STREAM_STATE_STREAMING};