Make expansion interface interrupt updates thread-safe (fixes loss of audio in Super Mario Sunshine on lower-end systems.)

This commit is contained in:
fkane 2014-10-27 09:37:17 -04:00
parent 81dda593cd
commit c37aca70a7
2 changed files with 8 additions and 0 deletions

View File

@ -20,6 +20,7 @@ namespace ExpansionInterface
{
static int changeDevice;
static int updateInterrupts;
static CEXIChannel *g_Channels[MAX_EXI_CHANNELS];
void Init()
@ -43,6 +44,7 @@ void Init()
g_Channels[2]->AddDevice(EXIDEVICE_AD16, 0);
changeDevice = CoreTiming::RegisterEvent("ChangeEXIDevice", ChangeDeviceCallback);
updateInterrupts = CoreTiming::RegisterEvent("EXIUpdateInterrupts", UpdateInterruptsCallback);
}
void Shutdown()
@ -114,6 +116,11 @@ IEXIDevice* FindDevice(TEXIDevices device_type, int customIndex)
}
void UpdateInterrupts()
{
CoreTiming::ScheduleEvent_Threadsafe(0, updateInterrupts, 0);
}
void UpdateInterruptsCallback(u64 userdata, int cyclesLate)
{
// Interrupts are mapped a bit strangely:
// Channel 0 Device 0 generates interrupt on channel 0

View File

@ -27,6 +27,7 @@ void PauseAndLock(bool doLock, bool unpauseOnUnlock);
void RegisterMMIO(MMIO::Mapping* mmio, u32 base);
void UpdateInterruptsCallback(u64 userdata, int cyclesLate);
void UpdateInterrupts();
void ChangeDeviceCallback(u64 userdata, int cyclesLate);