[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%
This commit is contained in:
Squall Leonhart 2025-04-13 03:58:40 +10:00 committed by GitHub
parent 3c32bad886
commit 94752f8314
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 13 deletions

View File

@ -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<SoundDriver> CreateFAudioDriver() {
}
} // namespace internal
} // namespace audio
} // namespace audio