diff --git a/Source/Core/Core/Src/CoreTiming.cpp b/Source/Core/Core/Src/CoreTiming.cpp index 0a8e79a338..35311f8154 100644 --- a/Source/Core/Core/Src/CoreTiming.cpp +++ b/Source/Core/Core/Src/CoreTiming.cpp @@ -400,22 +400,37 @@ void ProcessFifoWaitEvents() { MoveEvents(); - while (first) + if (!first) + return; + + if (first->time <= globalTimer && first->fifoWait) { - if ((first->time <= globalTimer) && first->fifoWait) - { - - Event* evt = first; - first = first->next; - event_types[evt->type].callback(evt->userdata, (int)(globalTimer - evt->time)); - FreeEvent(evt); + Event *next = first->next; + event_types[first->type].callback(first->userdata, (int)(globalTimer - first->time)); + FreeEvent(first); + first = next; + } + + if (!first) + return; + + Event *prev = first; + Event *ptr = prev->next; + while (ptr) + { + if (ptr->time <= globalTimer && ptr->fifoWait) + { + prev->next = ptr->next; + event_types[ptr->type].callback(ptr->userdata, (int)(globalTimer - ptr->time)); + FreeEvent(ptr); + ptr = prev->next; } else { - break; + prev = ptr; + ptr = ptr->next; } } - } void MoveEvents() diff --git a/Source/Core/Core/Src/CoreTiming.h b/Source/Core/Core/Src/CoreTiming.h index 7d5a89c846..7514727fc8 100644 --- a/Source/Core/Core/Src/CoreTiming.h +++ b/Source/Core/Core/Src/CoreTiming.h @@ -57,7 +57,7 @@ void UnregisterAllEvents(); // userdata MAY NOT CONTAIN POINTERS. userdata might get written and reloaded from disk, // when we implement state saves. void ScheduleEvent(int cyclesIntoFuture, int event_type, u64 userdata=0); -void ScheduleEvent_Threadsafe(int cyclesIntoFuture, int event_type, u64 userdata=0, bool fifoWait=false); +void ScheduleEvent_Threadsafe(int cyclesIntoFuture, int event_type, u64 userdata=0, bool fifoWait=true); void ScheduleEvent_Threadsafe_Immediate(int event_type, u64 userdata=0); // We only permit one event of each type in the queue at a time.