From fcca1fa3f76e0b1d92b44bdc4e7510d9af2793c3 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 7 Nov 2020 22:03:09 +1000 Subject: [PATCH] Android: Empty audio buffers when returning from activity --- android/app/src/cpp/android_host_interface.cpp | 4 ++-- src/frontend-common/common_host_interface.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/android/app/src/cpp/android_host_interface.cpp b/android/app/src/cpp/android_host_interface.cpp index 754dfc7f8..66e58623f 100644 --- a/android/app/src/cpp/android_host_interface.cpp +++ b/android/app/src/cpp/android_host_interface.cpp @@ -473,9 +473,9 @@ void AndroidHostInterface::SurfaceChanged(ANativeWindow* surface, int format, in m_display->ChangeRenderWindow(wi); if (surface && System::GetState() == System::State::Paused) - System::SetState(System::State::Running); + PauseSystem(false); else if (!surface && System::IsRunning()) - System::SetState(System::State::Paused); + PauseSystem(true); } } diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp index 2288060a7..188f2f12d 100644 --- a/src/frontend-common/common_host_interface.cpp +++ b/src/frontend-common/common_host_interface.cpp @@ -164,7 +164,10 @@ void CommonHostInterface::PauseSystem(bool paused) return; System::SetState(paused ? System::State::Paused : System::State::Running); + if (!paused) + m_audio_stream->EmptyBuffers(); m_audio_stream->PauseOutput(paused); + OnSystemPaused(paused); UpdateSpeedLimiterState();