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;
}
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);
return false;
}

View File

@ -1143,32 +1143,18 @@ void MainFrame::MenuPopped(wxMenuEvent& evt)
evt.Skip();
}
// Pause game if menu pops up.
//
// 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.
//
// On Windows, opening the menubar will stop the app, but DirectSound will
// loop, so we pause audio here.
void MainFrame::SetMenusOpened(bool state)
{
if ((menus_opened = state)) {
menus_opened = state;
#ifdef __WXMSW__
paused = true;
panel->Pause();
if (menus_opened)
soundPause();
else if (!paused)
soundResume();
#endif
}
else {
#ifdef __WXMSW__
paused = false;
pause_next = false;
panel->Resume();
#endif
}
}
// ShowModal that also disables emulator loop