Alt+tab fix for ca9109be75 - call sound IdleTask in Atlas and swap buffers only once in Atlas.

- ca9109be75 moved SwapBuffers inside Render - this makes Atlas call it
twice in a row which might behave oddly (did not seem to though) and
anyways was wasteful.
- ca9109be75 moved IdleTask from the sound manager outside of Render.
This means atlas never called IdleTask, and this broke sounds after a
few seconds.

Reviewed By: Angen
Differential Revision: https://code.wildfiregames.com/D2029
This was SVN commit r22544.
This commit is contained in:
wraitii 2019-07-24 16:40:34 +00:00
parent a783f430d5
commit ae7e43ff19
5 changed files with 23 additions and 15 deletions

View File

@ -411,7 +411,16 @@ static void Frame()
if (g_SoundManager)
g_SoundManager->IdleTask();
Render();
if (ShouldRender())
{
Render();
{
PROFILE3("swap buffers");
SDL_GL_SwapWindow(g_VideoMode.GetWindow());
ogl_WarnIfError();
}
}
g_Profiler.Frame();

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2018 Wildfire Games.
/* Copyright (C) 2019 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -409,12 +409,7 @@ void CGame::Update(const double deltaRealTime, bool doInterpolate)
}
if (doInterpolate)
{
m_TurnManager->Interpolate(deltaSimTime, deltaRealTime);
if ( g_SoundManager )
g_SoundManager->IdleTask();
}
}
void CGame::Interpolate(float simFrameLength, float realFrameLength)

View File

@ -198,18 +198,17 @@ void GUI_DisplayLoadProgress(int percent, const wchar_t* pending_task)
g_GUI->GetActiveGUI()->SendEventToAll("GameLoadProgress", paramData);
}
void SwapBuffers()
bool ShouldRender()
{
PROFILE3("swap buffers");
SDL_GL_SwapWindow(g_VideoMode.GetWindow());
ogl_WarnIfError();
return !g_app_minimized && (g_app_has_focus || !g_VideoMode.IsInFullscreen());
}
void Render()
{
// Do not render if not focused while in fullscreen or minimised,
// as that triggers a difficult-to-reproduce crash on some graphic cards.
if (g_app_minimized || (!g_app_has_focus && g_VideoMode.IsInFullscreen()))
if (!ShouldRender())
return;
PROFILE3("render");
@ -347,8 +346,6 @@ void Render()
g_Profiler2.RecordGPUFrameEnd();
ogl_WarnIfError();
SwapBuffers();
}
ErrorReactionInternal psDisplayError(const wchar_t* UNUSED(text), size_t UNUSED(flags))

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2018 Wildfire Games.
/* Copyright (C) 2019 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -27,6 +27,8 @@ extern void GUI_DisplayLoadProgress(int percent, const wchar_t* pending_task);
extern void Render();
extern bool ShouldRender();
/**
* initialize global modules that are be needed before Init.
* must be called from the very beginning of main.

View File

@ -40,6 +40,7 @@
#include "simulation2/components/ICmpObstructionManager.h"
#include "simulation2/components/ICmpParticleManager.h"
#include "simulation2/components/ICmpPathfinder.h"
#include "soundmanager/ISoundManager.h"
extern void (*Atlas_GLSwapBuffers)(void* context);
@ -211,6 +212,10 @@ void AtlasViewGame::Update(float realFrameLength)
g_Game->Interpolate(actualFrameLength, realFrameLength);
}
// Run sound idle tasks every frame.
if (g_SoundManager)
g_SoundManager->IdleTask();
// Cinematic motion should be independent of simulation update, so we can
// preview the cinematics by themselves
g_Game->GetView()->GetCinema()->Update(realFrameLength);