Fix a potential crash/race condition.

If anything is behind, it might run __AudioWakeThreads() within
reschedule, and get confused.
This commit is contained in:
Unknown W. Brackets committed 2014-07-01 08:02:34 -07:00
1 parent 602daf5f8a
commit e505655c2b
1 file changed
+6 -1
+6 -1
View File
@@ -285,6 +285,7 @@ u32 __AudioEnqueue(AudioChannel &chan, int chanNum, bool blocking) {
inline void __AudioWakeThreads(AudioChannel &chan, int result, int step) {
u32 error;
bool wokeThreads = false;
for (size_t w = 0; w < chan.waitingThreads.size(); ++w) {
AudioChannelWaitInfo &waitInfo = chan.waitingThreads[w];
waitInfo.numSamples -= step;
@@ -295,7 +296,7 @@ inline void __AudioWakeThreads(AudioChannel &chan, int result, int step) {
// DEBUG_LOG(SCEAUDIO, "Woke thread %i for some buffer filling", waitingThread);
u32 ret = result == 0 ? __KernelGetWaitValue(waitInfo.threadID, error) : SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
__KernelResumeThreadFromWait(waitInfo.threadID, ret);
__KernelReSchedule("audio drain");
wokeThreads = true;
chan.waitingThreads.erase(chan.waitingThreads.begin() + w--);
}
@@ -303,6 +304,10 @@ inline void __AudioWakeThreads(AudioChannel &chan, int result, int step) {
else if (waitID == 0)
chan.waitingThreads.erase(chan.waitingThreads.begin() + w--);
}
if (wokeThreads) {
__KernelReSchedule("audio drain");
}
}
void __AudioWakeThreads(AudioChannel &chan, int result) {