Android: Fix race/crash when switching away/back to the emulation activity
This commit is contained in:
parent
80a377d45a
commit
7ce55ca800
|
@ -447,6 +447,11 @@ void AndroidHostInterface::SurfaceChanged(ANativeWindow* surface, int format, in
|
|||
wi.surface_height = height;
|
||||
|
||||
m_display->ChangeRenderWindow(wi);
|
||||
|
||||
if (surface && System::GetState() == System::State::Paused)
|
||||
System::SetState(System::State::Running);
|
||||
else if (!surface && System::IsRunning())
|
||||
System::SetState(System::State::Paused);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -523,7 +528,8 @@ void AndroidHostInterface::SetControllerAxisState(u32 index, s32 button_code, fl
|
|||
false);
|
||||
}
|
||||
|
||||
void AndroidHostInterface::RefreshGameList(bool invalidate_cache, bool invalidate_database, ProgressCallback* progress_callback)
|
||||
void AndroidHostInterface::RefreshGameList(bool invalidate_cache, bool invalidate_database,
|
||||
ProgressCallback* progress_callback)
|
||||
{
|
||||
m_game_list->SetSearchDirectoriesFromSettings(m_settings_interface);
|
||||
m_game_list->Refresh(invalidate_cache, invalidate_database, progress_callback);
|
||||
|
|
|
@ -29,7 +29,6 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
|||
private SharedPreferences mPreferences;
|
||||
private boolean mWasDestroyed = false;
|
||||
private boolean mStopRequested = false;
|
||||
private boolean mWasPausedOnSurfaceLoss = false;
|
||||
private boolean mApplySettingsOnSurfaceRestored = false;
|
||||
private String mGameTitle = null;
|
||||
private EmulationSurfaceView mContentView;
|
||||
|
@ -128,10 +127,6 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
|||
AndroidHostInterface.getInstance().surfaceChanged(holder.getSurface(), format, width, height);
|
||||
updateOrientation();
|
||||
|
||||
if (holder.getSurface() != null && !hadSurface && AndroidHostInterface.getInstance().isEmulationThreadPaused() && !mWasPausedOnSurfaceLoss) {
|
||||
AndroidHostInterface.getInstance().pauseEmulationThread(false);
|
||||
}
|
||||
|
||||
if (mApplySettingsOnSurfaceRestored) {
|
||||
AndroidHostInterface.getInstance().applySettings();
|
||||
mApplySettingsOnSurfaceRestored = false;
|
||||
|
@ -159,8 +154,6 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
|||
if (!mStopRequested)
|
||||
AndroidHostInterface.getInstance().saveResumeState(true);
|
||||
|
||||
mWasPausedOnSurfaceLoss = AndroidHostInterface.getInstance().isEmulationThreadPaused();
|
||||
AndroidHostInterface.getInstance().pauseEmulationThread(true);
|
||||
AndroidHostInterface.getInstance().surfaceChanged(null, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -124,6 +124,9 @@ bool OpenGLHostDisplay::DownloadTexture(const void* texture_handle, u32 x, u32 y
|
|||
|
||||
void OpenGLHostDisplay::SetVSync(bool enabled)
|
||||
{
|
||||
if (m_gl_context->GetWindowInfo().type == WindowInfo::Type::Surfaceless)
|
||||
return;
|
||||
|
||||
// Window framebuffer has to be bound to call SetSwapInterval.
|
||||
GLint current_fbo = 0;
|
||||
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, ¤t_fbo);
|
||||
|
|
|
@ -234,6 +234,9 @@ bool VulkanHostDisplay::DownloadTexture(const void* texture_handle, u32 x, u32 y
|
|||
|
||||
void VulkanHostDisplay::SetVSync(bool enabled)
|
||||
{
|
||||
if (!m_swap_chain)
|
||||
return;
|
||||
|
||||
// This swap chain should not be used by the current buffer, thus safe to destroy.
|
||||
g_vulkan_context->WaitForGPUIdle();
|
||||
m_swap_chain->SetVSync(enabled);
|
||||
|
|
Loading…
Reference in New Issue