android: audio: Audio stretching is only useful with lower framerates, disable it when fullspeed.

This commit is contained in:
bunnei 2020-05-15 22:16:14 -04:00
parent 8928837ed0
commit 66e6c9581d

View File

@ -8,6 +8,7 @@
#include <android/native_window_jni.h>
#include "audio_core/dsp_interface.h"
#include "common/file_util.h"
#include "common/logging/log.h"
#include "common/microprofile.h"
@ -167,6 +168,20 @@ static Core::System::ResultStatus RunCitra(const std::string& filepath) {
SCOPE_EXIT({ TryShutdown(); });
// Audio stretching on Android is only useful with lower framerates, disable it when fullspeed
Core::TimingEventType* audio_stretching_event{};
const s64 audio_stretching_ticks {msToCycles(500)};
audio_stretching_event = system.CoreTiming().RegisterEvent(
"AudioStretchingEvent", [&](u64, s64 cycles_late) {
if (Settings::values.enable_audio_stretching) {
Core::DSP().EnableStretching(Core::System::GetInstance().GetAndResetPerfStats().emulation_speed < 0.95);
}
system.CoreTiming().ScheduleEvent(audio_stretching_ticks - cycles_late, audio_stretching_event);
});
system.CoreTiming().ScheduleEvent(audio_stretching_ticks, audio_stretching_event);
// Start running emulation
while (is_running) {
if (!pause_emulation) {
system.RunLoop();