diff options
| author | JMC47 <JMC4789@gmail.com> | 2022-01-11 09:30:41 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-11 09:30:41 -0500 |
| commit | d32b13fb36e6616f7bb4a5a395c34ae2f2ada32b (patch) | |
| tree | 5bfc744d6f92364ac52f8be4beee8082c2ee67bd /Source/Core | |
| parent | 3da64875314e2a1743b8d6453403ef85e8b45eb4 (diff) | |
| parent | aa57eb57b163d0c4de2a8f9e5b0fea8f5cf17b75 (diff) | |
Merge pull request #10363 from JosJuice/systemtimers-dma-period
SystemTimers: Refactor, get rid of s_audio_dma_period
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Core/HW/SystemTimers.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/Source/Core/Core/HW/SystemTimers.cpp b/Source/Core/Core/HW/SystemTimers.cpp index 5f063a093e..ca96006fa9 100644 --- a/Source/Core/Core/HW/SystemTimers.cpp +++ b/Source/Core/Core/HW/SystemTimers.cpp @@ -81,11 +81,6 @@ CoreTiming::EventType* et_Throttle; u32 s_cpu_core_clock = 486000000u; // 486 mhz (its not 485, stop bugging me!) -// These two are badly educated guesses. -// Feel free to experiment. Set them in Init below. - -// This is a fixed value, don't change it -int s_audio_dma_period; // This is completely arbitrary. If we find that we need lower latency, // we can just increase this number. int s_ipc_hle_period; @@ -112,11 +107,16 @@ void DSPCallback(u64 userdata, s64 cyclesLate) CoreTiming::ScheduleEvent(DSP::GetDSPEmulator()->DSP_UpdateRate() - cyclesLate, et_DSP); } +int GetAudioDMACallbackPeriod() +{ + // System internal sample rate is fixed at 32KHz * 4 (16bit Stereo) / 32 bytes DMA + return s_cpu_core_clock / (AudioInterface::GetAIDSampleRate() * 4 / 32); +} + void AudioDMACallback(u64 userdata, s64 cyclesLate) { - int period = s_cpu_core_clock / (AudioInterface::GetAIDSampleRate() * 4 / 32); DSP::UpdateAudioDMA(); // Push audio to speakers. - CoreTiming::ScheduleEvent(period - cyclesLate, et_AudioDMA); + CoreTiming::ScheduleEvent(GetAudioDMACallbackPeriod() - cyclesLate, et_AudioDMA); } void IPC_HLE_UpdateCallback(u64 userdata, s64 cyclesLate) @@ -300,9 +300,6 @@ void Init() s_ipc_hle_period = GetTicksPerSecond() / freq; } - // System internal sample rate is fixed at 32KHz * 4 (16bit Stereo) / 32 bytes DMA - s_audio_dma_period = s_cpu_core_clock / (AudioInterface::GetAIDSampleRate() * 4 / 32); - Common::Timer::IncreaseResolution(); // store and convert localtime at boot to timebase ticks if (Config::Get(Config::MAIN_CUSTOM_RTC_ENABLE)) @@ -330,7 +327,7 @@ void Init() CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerHalfLine(), et_VI); CoreTiming::ScheduleEvent(0, et_DSP); - CoreTiming::ScheduleEvent(s_audio_dma_period, et_AudioDMA); + CoreTiming::ScheduleEvent(GetAudioDMACallbackPeriod(), et_AudioDMA); CoreTiming::ScheduleEvent(0, et_Throttle, Common::Timer::GetTimeUs()); CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerField(), et_PatchEngine); |
