fix audout events being missed. (#683)

This commit is contained in:
ITotalJustice 2025-07-25 20:43:59 +01:00 committed by GitHub
parent e15a7181b4
commit 8d3dfbf370
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -105,12 +105,19 @@ static Result _audoutCmdNoInOutU32(Service* srv, u32 *out, u32 cmd_id) {
}
Result audoutWaitPlayFinish(AudioOutBuffer **released, u32* released_count, u64 timeout) {
// Wait on the buffer event handle
Result rc = eventWait(&g_audoutBufferEvent, timeout);
// Check if we already have a buffer free
eventClear(&g_audoutBufferEvent);
Result rc = audoutGetReleasedAudioOutBuffer(released, released_count);
if (R_SUCCEEDED(rc)) {
// Grab the released buffer
rc = audoutGetReleasedAudioOutBuffer(released, released_count);
// If the call didn't fail, but we don't have a buffer, wait until one is released
if (R_SUCCEEDED(rc) && !(*released_count)) {
// Wait on the buffer event handle
rc = eventWait(&g_audoutBufferEvent, timeout);
if (R_SUCCEEDED(rc)) {
// Grab the released buffer
rc = audoutGetReleasedAudioOutBuffer(released, released_count);
}
}
return rc;