From 94752f8314148f4d298492fc1ccfe12b91030535 Mon Sep 17 00:00:00 2001 From: Squall Leonhart Date: Sun, 13 Apr 2025 03:58:40 +1000 Subject: [PATCH] [FAudio]Correct the behavior of device_changed check Fixes the behavior to take the timeout into account properly, fixing the throttled behavior so that it matches (or strives to) the configured value instead of being stuck at <90% --- src/wx/audio/internal/faudio.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/wx/audio/internal/faudio.cpp b/src/wx/audio/internal/faudio.cpp index f896f9b5..17d0dfc5 100644 --- a/src/wx/audio/internal/faudio.cpp +++ b/src/wx/audio/internal/faudio.cpp @@ -59,6 +59,17 @@ int FAGetDev(FAudio* fa) { class FAudio_BufferNotify : public FAudioVoiceCallback { public: + FAudio_BufferNotify() { + OnBufferEnd = &FAudio_BufferNotify::StaticOnBufferEnd; + OnVoiceProcessingPassStart = &FAudio_BufferNotify::StaticOnVoiceProcessingPassStart; + OnVoiceProcessingPassEnd = &FAudio_BufferNotify::StaticOnVoiceProcessingPassEnd; + OnStreamEnd = &FAudio_BufferNotify::StaticOnStreamEnd; + OnBufferStart = &FAudio_BufferNotify::StaticOnBufferStart; + OnLoopEnd = &FAudio_BufferNotify::StaticOnLoopEnd; + OnVoiceError = &FAudio_BufferNotify::StaticOnVoiceError; + } + ~FAudio_BufferNotify() = default; + // Waits for the buffer end event to be signaled for 10 seconds. // Returns true if the buffer end event was signaled, false if the wait timed out. bool WaitForSignal() { @@ -71,17 +82,6 @@ public: return was_signaled; } - FAudio_BufferNotify() { - OnBufferEnd = &FAudio_BufferNotify::StaticOnBufferEnd; - OnVoiceProcessingPassStart = &FAudio_BufferNotify::StaticOnVoiceProcessingPassStart; - OnVoiceProcessingPassEnd = &FAudio_BufferNotify::StaticOnVoiceProcessingPassEnd; - OnStreamEnd = &FAudio_BufferNotify::StaticOnStreamEnd; - OnBufferStart = &FAudio_BufferNotify::StaticOnBufferStart; - OnLoopEnd = &FAudio_BufferNotify::StaticOnLoopEnd; - OnVoiceError = &FAudio_BufferNotify::StaticOnVoiceError; - } - ~FAudio_BufferNotify() = default; - private: // Signals that the buffer end event has occurred. void SignalBufferEnd() { @@ -391,7 +391,7 @@ void FAudio_Output::write(uint16_t* finalWave, int) { // the maximum number of buffers is currently queued if (!coreOptions.speedup && coreOptions.throttle && !gba_joybus_active) { // wait for one buffer to finish playing - if (notify.WaitForSignal()) { + if (!notify.WaitForSignal()) { device_changed = true; } } else { @@ -511,4 +511,4 @@ std::unique_ptr CreateFAudioDriver() { } } // namespace internal -} // namespace audio \ No newline at end of file +} // namespace audio