Fix dsound looping when moving/resizing window

Add MOVE_START/MOVE_END events to detect when the window is moved or
resized and pause sound on Windows to prevent the DirectSound driver
from looping.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2023-04-13 13:47:17 +00:00
parent 93fbb5618d
commit 36e88fafb6
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
2 changed files with 18 additions and 0 deletions

View File

@ -824,6 +824,8 @@ EVT_DROP_FILES(MainFrame::OnDropFile)
// for window geometry
EVT_MOVE(MainFrame::OnMove)
EVT_MOVE_START(MainFrame::OnMoveStart)
EVT_MOVE_END(MainFrame::OnMoveEnd)
EVT_SIZE(MainFrame::OnSize)
// For tracking menubar state.
@ -879,6 +881,20 @@ void MainFrame::OnMove(wxMoveEvent&) {
}
}
// On Windows pause sound when moving and resizing the window to prevent dsound
// from looping.
void MainFrame::OnMoveStart(wxMoveEvent&) {
#ifdef __WXMSW__
soundPause();
#endif
}
void MainFrame::OnMoveEnd(wxMoveEvent&) {
#ifdef __WXMSW__
soundResume();
#endif
}
void MainFrame::OnSize(wxSizeEvent& event)
{
wxFrame::OnSize(event);

View File

@ -382,6 +382,8 @@ private:
void OnMenu(wxContextMenuEvent&);
// window geometry
void OnMove(wxMoveEvent& event);
void OnMoveStart(wxMoveEvent& event);
void OnMoveEnd(wxMoveEvent& event);
void OnSize(wxSizeEvent& event);
// Load a named wxDialog from the XRC file
wxDialog* LoadXRCDialog(const char* name);