Fix pause/next-frame

Pause only sound on menu open on Windows, and resume on menu close if
emulator is not paused.

This is to avoid DirectSound looping on menu open.

Fix #788
Fix #1077

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2023-03-30 00:22:54 +00:00
parent d3f8cc1714
commit 3cef52b72d
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
2 changed files with 9 additions and 23 deletions

View File

@ -104,7 +104,7 @@ bool DirectSound::init(long sampleRate)
return false; return false;
} }
if (FAILED(hr = pDirectSound->SetCooperativeLevel((HWND)wxGetApp().frame->GetHandle(), DSSCL_EXCLUSIVE))) { if (FAILED(hr = pDirectSound->SetCooperativeLevel((HWND)wxGetApp().frame->GetHandle(), DSSCL_PRIORITY))) {
wxLogError(_("Cannot SetCooperativeLevel %08x"), hr); wxLogError(_("Cannot SetCooperativeLevel %08x"), hr);
return false; return false;
} }

View File

@ -1143,32 +1143,18 @@ void MainFrame::MenuPopped(wxMenuEvent& evt)
evt.Skip(); evt.Skip();
} }
// Pause game if menu pops up. // On Windows, opening the menubar will stop the app, but DirectSound will
// // loop, so we pause audio here.
// This is a feature most people don't like, and it causes problems with
// keyboard game keys on mac, so we will disable it for now.
//
// On Windows, there will still be a pause because of how the windows event
// model works, in addition the audio will loop with SDL, so we still pause on
// Windows.
//
// TODO: This needs to be fixed properly.
//
void MainFrame::SetMenusOpened(bool state) void MainFrame::SetMenusOpened(bool state)
{ {
if ((menus_opened = state)) { menus_opened = state;
#ifdef __WXMSW__ #ifdef __WXMSW__
paused = true; if (menus_opened)
panel->Pause(); soundPause();
else if (!paused)
soundResume();
#endif #endif
}
else {
#ifdef __WXMSW__
paused = false;
pause_next = false;
panel->Resume();
#endif
}
} }
// ShowModal that also disables emulator loop // ShowModal that also disables emulator loop