From a0b333865c18f446ec719f500fab2cf26f31218d Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 5 Jun 2013 12:13:52 -0700 Subject: [PATCH 1/2] Wake waiting threads on channel release. --- Core/HLE/__sceAudio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/HLE/__sceAudio.cpp b/Core/HLE/__sceAudio.cpp index d37a4610d0..71535d9a1f 100644 --- a/Core/HLE/__sceAudio.cpp +++ b/Core/HLE/__sceAudio.cpp @@ -203,7 +203,7 @@ inline void __AudioWakeThreads(AudioChannel &chan, int step) for (size_t w = 0; w < chan.waitingThreads.size(); ++w) { AudioChannelWaitInfo &waitInfo = chan.waitingThreads[w]; - waitInfo.numSamples -= hwBlockSize; + waitInfo.numSamples -= step; // If it's done (there will still be samples on queue) and actually still waiting, wake it up. if (waitInfo.numSamples <= 0 && __KernelGetWaitID(waitInfo.threadID, WAITTYPE_AUDIOCHANNEL, error) != 0) From 61f2fc4d3b3dea2a36d05bd7ec5e3e67b3495faa Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 5 Jun 2013 12:20:07 -0700 Subject: [PATCH 2/2] Return error to blocked audio threads on release. --- Core/HLE/__sceAudio.cpp | 10 +++++----- Core/HLE/__sceAudio.h | 4 ++-- Core/HLE/sceAudio.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Core/HLE/__sceAudio.cpp b/Core/HLE/__sceAudio.cpp index 71535d9a1f..fffaee12a4 100644 --- a/Core/HLE/__sceAudio.cpp +++ b/Core/HLE/__sceAudio.cpp @@ -197,7 +197,7 @@ u32 __AudioEnqueue(AudioChannel &chan, int chanNum, bool blocking) return ret; } -inline void __AudioWakeThreads(AudioChannel &chan, int step) +inline void __AudioWakeThreads(AudioChannel &chan, int result, int step) { u32 error; for (size_t w = 0; w < chan.waitingThreads.size(); ++w) @@ -209,7 +209,7 @@ inline void __AudioWakeThreads(AudioChannel &chan, int step) if (waitInfo.numSamples <= 0 && __KernelGetWaitID(waitInfo.threadID, WAITTYPE_AUDIOCHANNEL, error) != 0) { // DEBUG_LOG(HLE, "Woke thread %i for some buffer filling", waitingThread); - u32 ret = __KernelGetWaitValue(waitInfo.threadID, error); + u32 ret = result == 0 ? __KernelGetWaitValue(waitInfo.threadID, error) : SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED; __KernelResumeThreadFromWait(waitInfo.threadID, ret); chan.waitingThreads.erase(chan.waitingThreads.begin() + w--); @@ -217,9 +217,9 @@ inline void __AudioWakeThreads(AudioChannel &chan, int step) } } -void __AudioWakeThreads(AudioChannel &chan) +void __AudioWakeThreads(AudioChannel &chan, int result) { - __AudioWakeThreads(chan, 0x7FFFFFFF); + __AudioWakeThreads(chan, result, 0x7FFFFFFF); } // Mix samples from the various audio channels into a single sample queue. @@ -238,7 +238,7 @@ void __AudioUpdate() { if (!chans[i].reserved) continue; - __AudioWakeThreads(chans[i], hwBlockSize); + __AudioWakeThreads(chans[i], 0, hwBlockSize); if (!chans[i].sampleQueue.size()) { // ERROR_LOG(HLE, "No queued samples, skipping channel %i", i); diff --git a/Core/HLE/__sceAudio.h b/Core/HLE/__sceAudio.h index 2935a76b89..403c2f961f 100644 --- a/Core/HLE/__sceAudio.h +++ b/Core/HLE/__sceAudio.h @@ -29,7 +29,7 @@ void __AudioSetOutputFrequency(int freq); // May return SCE_ERROR_AUDIO_CHANNEL_BUSY if buffer too large u32 __AudioEnqueue(AudioChannel &chan, int chanNum, bool blocking); -void __AudioWakeThreads(AudioChannel &chan, int step); -void __AudioWakeThreads(AudioChannel &chan); +void __AudioWakeThreads(AudioChannel &chan, int result, int step); +void __AudioWakeThreads(AudioChannel &chan, int result); int __AudioMix(short *outstereo, int numSamples); diff --git a/Core/HLE/sceAudio.cpp b/Core/HLE/sceAudio.cpp index 6046b749be..85aa0ce5a8 100644 --- a/Core/HLE/sceAudio.cpp +++ b/Core/HLE/sceAudio.cpp @@ -42,7 +42,7 @@ void AudioChannel::DoState(PointerWrap &p) void AudioChannel::reset() { - __AudioWakeThreads(*this); + __AudioWakeThreads(*this, SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED); clear(); }