diff --git a/Core/HLE/__sceAudio.cpp b/Core/HLE/__sceAudio.cpp index ee1da31645..4f74c7fe32 100644 --- a/Core/HLE/__sceAudio.cpp +++ b/Core/HLE/__sceAudio.cpp @@ -83,16 +83,18 @@ static inline s16 adjustvolume(s16 sample, int vol) { } void hleAudioUpdate(u64 userdata, int cyclesLate) { - __AudioUpdate(); - + // Schedule the next cycle first. __AudioUpdate() may consume cycles. CoreTiming::ScheduleEvent(usToCycles(audioIntervalUs) - cyclesLate, eventAudioUpdate, 0); + + __AudioUpdate(); } void hleHostAudioUpdate(u64 userdata, int cyclesLate) { + CoreTiming::ScheduleEvent(usToCycles(audioHostIntervalUs) - cyclesLate, eventHostAudioUpdate, 0); + // Not all hosts need this call to poke their audio system once in a while, but those that don't // can just ignore it. host->UpdateSound(); - CoreTiming::ScheduleEvent(usToCycles(audioHostIntervalUs) - cyclesLate, eventHostAudioUpdate, 0); } void __AudioInit() { diff --git a/Core/HLE/sceCtrl.cpp b/Core/HLE/sceCtrl.cpp index 157c1ce2fd..0c369c32b3 100644 --- a/Core/HLE/sceCtrl.cpp +++ b/Core/HLE/sceCtrl.cpp @@ -289,8 +289,9 @@ void __CtrlTimerUpdate(u64 userdata, int cyclesLate) // This only runs in timer mode (ctrlCycle > 0.) _dbg_assert_msg_(SCECTRL, ctrlCycle > 0, "Ctrl: sampling cycle should be > 0"); - __CtrlDoSample(); CoreTiming::ScheduleEvent(usToCycles(ctrlCycle), ctrlTimer, 0); + + __CtrlDoSample(); } void __CtrlInit() diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index e1a8b48a03..274d7268f0 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -602,6 +602,8 @@ void hleEnterVblank(u64 userdata, int cyclesLate) { } frameStartTicks = CoreTiming::GetTicks(); + CoreTiming::ScheduleEvent(msToCycles(vblankMs) - cyclesLate, leaveVblankEvent, vbCount + 1); + // Wake up threads waiting for VBlank u32 error; bool wokeThreads = false; @@ -623,8 +625,6 @@ void hleEnterVblank(u64 userdata, int cyclesLate) { // Trigger VBlank interrupt handlers. __TriggerInterrupt(PSP_INTR_IMMEDIATE | PSP_INTR_ONLY_IF_ENABLED | PSP_INTR_ALWAYS_RESCHED, PSP_VBLANK_INTR, PSP_INTR_SUB_ALL); - CoreTiming::ScheduleEvent(msToCycles(vblankMs) - cyclesLate, leaveVblankEvent, vbCount + 1); - gpuStats.numVBlanks++; numVBlanksSinceFlip++; diff --git a/Core/HLE/sceGe.cpp b/Core/HLE/sceGe.cpp index 8ac607bc2a..be146bd49f 100644 --- a/Core/HLE/sceGe.cpp +++ b/Core/HLE/sceGe.cpp @@ -264,6 +264,8 @@ void __GeCheckCycles(u64 userdata, int cyclesLate) CoreTiming::Advance(); } } + + // This may get out of step if we synced, but that's okay. CoreTiming::ScheduleEvent(usToCycles(geIntervalUs), geCycleEvent, 0); }