Skip to content

fix audout events being missed. #683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions nx/source/services/audout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

if (R_SUCCEEDED(rc)) {
// Grab the released buffer
rc = audoutGetReleasedAudioOutBuffer(released, released_count);
// Check if we already have a buffer free
eventClear(&g_audoutBufferEvent);
Result 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;
Expand Down Expand Up @@ -203,7 +210,7 @@ Result audoutAppendAudioOutBuffer(AudioOutBuffer *Buffer) {
}

static Result _audoutRegisterBufferEvent(Event *BufferEvent) {
return _audoutCmdGetEvent(&g_audoutIAudioOut, BufferEvent, true, 4);
return _audoutCmdGetEvent(&g_audoutIAudioOut, BufferEvent, false, 4);
}

Result audoutGetReleasedAudioOutBuffer(AudioOutBuffer **Buffer, u32 *ReleasedBuffersCount) {
Expand Down