diff --git a/src/wx/dsound.cpp b/src/wx/dsound.cpp index 2ed26e26..0c11dceb 100644 --- a/src/wx/dsound.cpp +++ b/src/wx/dsound.cpp @@ -192,14 +192,16 @@ bool DirectSound::init(long sampleRate) void DirectSound::pause() { - if (dsbSecondary == NULL) - return; + for (auto buf : {dsbPrimary, dsbSecondary}) { + if (buf == NULL) + continue; - DWORD status; - dsbSecondary->GetStatus(&status); + DWORD status; + buf->GetStatus(&status); - if (status & DSBSTATUS_PLAYING) - dsbSecondary->Stop(); + if (status & DSBSTATUS_PLAYING) + buf->Stop(); + } } void DirectSound::reset() @@ -214,10 +216,12 @@ void DirectSound::reset() void DirectSound::resume() { - if (dsbSecondary == NULL) - return; + for (auto buf : {dsbPrimary, dsbSecondary}) { + if (buf == NULL) + return; - dsbSecondary->Play(0, 0, DSBPLAY_LOOPING); + buf->Play(0, 0, DSBPLAY_LOOPING); + } } void DirectSound::write(uint16_t* finalWave, int length) diff --git a/src/wx/wxvbam.cpp b/src/wx/wxvbam.cpp index 51ba3328..0777f84b 100644 --- a/src/wx/wxvbam.cpp +++ b/src/wx/wxvbam.cpp @@ -610,6 +610,15 @@ void MainFrame::OnActivate(wxActivateEvent& event) if (panel && focused) panel->SetFocus(); + + if (pauseWhenInactive) { + if (panel && focused) { + panel->Resume(); + } + else if (panel && !focused) { + panel->Pause(); + } + } } void MainFrame::OnDropFile(wxDropFilesEvent& event)