1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-25 22:18:30 +02:00

Pause all audio output when the game is unfocused

Some custom levels have their own custom music and sync that music to
scripted cutscenes, which is actually pretty impressive. However,
they've always run into a small thorn, which is that you can easily
desync the music by unfocusing the game, because the audio will keep
playing when the game is unfocused.

This should remove that thorn by pausing the audio on unfocus, and
resuming when focused, so that the music can no longer desync, but you
can still pause the game by unfocusing it.

This is yet another feature in VCE that hasn't been upstreamed until
now.
This commit is contained in:
Misa 2020-04-19 13:21:36 -07:00 committed by Ethan Lee
parent 2016ee1b60
commit 4bea40fc22

View File

@ -379,6 +379,9 @@ int main(int argc, char *argv[])
game.infocus = key.isActive;
if(!game.infocus)
{
Mix_Pause(-1);
Mix_PauseMusic();
FillRect(graphics.backBuffer, 0x00000000);
graphics.bprint(5, 110, "Game paused", 196 - help.glow, 255 - help.glow, 196 - help.glow, true);
graphics.bprint(5, 120, "[click to resume]", 196 - help.glow, 255 - help.glow, 196 - help.glow, true);
@ -390,6 +393,9 @@ int main(int argc, char *argv[])
}
else
{
Mix_Resume(-1);
Mix_ResumeMusic();
switch(game.gamestate)
{
case PRELOADER: