Return error to blocked audio threads on release.

This commit is contained in:
Unknown W. Brackets 2013-06-05 12:20:07 -07:00
parent a0b333865c
commit 61f2fc4d3b
3 changed files with 8 additions and 8 deletions

View file

@ -197,7 +197,7 @@ u32 __AudioEnqueue(AudioChannel &chan, int chanNum, bool blocking)
return ret; return ret;
} }
inline void __AudioWakeThreads(AudioChannel &chan, int step) inline void __AudioWakeThreads(AudioChannel &chan, int result, int step)
{ {
u32 error; u32 error;
for (size_t w = 0; w < chan.waitingThreads.size(); ++w) 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) if (waitInfo.numSamples <= 0 && __KernelGetWaitID(waitInfo.threadID, WAITTYPE_AUDIOCHANNEL, error) != 0)
{ {
// DEBUG_LOG(HLE, "Woke thread %i for some buffer filling", waitingThread); // 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); __KernelResumeThreadFromWait(waitInfo.threadID, ret);
chan.waitingThreads.erase(chan.waitingThreads.begin() + w--); 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. // Mix samples from the various audio channels into a single sample queue.
@ -238,7 +238,7 @@ void __AudioUpdate()
{ {
if (!chans[i].reserved) if (!chans[i].reserved)
continue; continue;
__AudioWakeThreads(chans[i], hwBlockSize); __AudioWakeThreads(chans[i], 0, hwBlockSize);
if (!chans[i].sampleQueue.size()) { if (!chans[i].sampleQueue.size()) {
// ERROR_LOG(HLE, "No queued samples, skipping channel %i", i); // ERROR_LOG(HLE, "No queued samples, skipping channel %i", i);

View file

@ -29,7 +29,7 @@ void __AudioSetOutputFrequency(int freq);
// May return SCE_ERROR_AUDIO_CHANNEL_BUSY if buffer too large // May return SCE_ERROR_AUDIO_CHANNEL_BUSY if buffer too large
u32 __AudioEnqueue(AudioChannel &chan, int chanNum, bool blocking); u32 __AudioEnqueue(AudioChannel &chan, int chanNum, bool blocking);
void __AudioWakeThreads(AudioChannel &chan, int step); void __AudioWakeThreads(AudioChannel &chan, int result, int step);
void __AudioWakeThreads(AudioChannel &chan); void __AudioWakeThreads(AudioChannel &chan, int result);
int __AudioMix(short *outstereo, int numSamples); int __AudioMix(short *outstereo, int numSamples);

View file

@ -42,7 +42,7 @@ void AudioChannel::DoState(PointerWrap &p)
void AudioChannel::reset() void AudioChannel::reset()
{ {
__AudioWakeThreads(*this); __AudioWakeThreads(*this, SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED);
clear(); clear();
} }