Browse Source

Revert "[Audio] Tighten sink queue back pressure (#2840)"

This reverts commit 15becaa5a3.
pull/2935/head
lizzie 4 months ago
parent
commit
fd721859fe
  1. 20
      src/audio_core/sink/sink_stream.cpp
  2. 2
      src/audio_core/sink/sink_stream.h

20
src/audio_core/sink/sink_stream.cpp

@ -186,9 +186,11 @@ void SinkStream::ProcessAudioOutAndRender(std::span<s16> output_buffer, std::siz
frames_written = num_frames; frames_written = num_frames;
continue; continue;
} }
--queued_buffers;
lk.unlock();
// Successfully dequeued a new buffer.
{
std::unique_lock lk{release_mutex};\
queued_buffers--;
}
release_cv.notify_one(); release_cv.notify_one();
} }
@ -226,15 +228,9 @@ u64 SinkStream::GetExpectedPlayedSampleCount() {
void SinkStream::WaitFreeSpace(std::stop_token stop_token) { void SinkStream::WaitFreeSpace(std::stop_token stop_token) {
std::unique_lock lk{release_mutex}; std::unique_lock lk{release_mutex};
auto can_continue = [this]() {
return paused || queued_buffers < max_queue_size;
};
release_cv.wait_for(lk, std::chrono::milliseconds(10), can_continue);
if (queued_buffers > max_queue_size + 10) {
release_cv.wait(lk, stop_token, can_continue);
release_cv.wait_for(lk, std::chrono::milliseconds(5), [this]() { return paused || queued_buffers < max_queue_size; });
if (queued_buffers > max_queue_size + 3) {
release_cv.wait(lk, stop_token, [this] { return paused || queued_buffers < max_queue_size; });
} }
} }

2
src/audio_core/sink/sink_stream.h

@ -240,7 +240,7 @@ private:
/// Ring buffer of the samples waiting to be played or consumed /// Ring buffer of the samples waiting to be played or consumed
Common::RingBuffer<s16, 0x10000> samples_buffer; Common::RingBuffer<s16, 0x10000> samples_buffer;
/// Audio buffers queued and waiting to play /// Audio buffers queued and waiting to play
Common::SPSCQueue<SinkBuffer, 0x10000> queue;
Common::SPSCQueue<SinkBuffer, 0x40000> queue;
/// The currently-playing audio buffer /// The currently-playing audio buffer
SinkBuffer playing_buffer{}; SinkBuffer playing_buffer{};
/// The last played (or received) frame of audio, used when the callback underruns /// The last played (or received) frame of audio, used when the callback underruns

Loading…
Cancel
Save