fix directsound loop on unfocus #45
Call GameArea::Pause and ::Resume in MainFrame::OnActivate based on focus state if the pauseWhenInactive config option is set. Also stop/play the primary dsound buffer in pause()/resume() in dsound.cpp, not onlyu the secondary, this may not be necessary but it doesn't hurt.
This commit is contained in:
parent
fcc34394c1
commit
f10e2e9904
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue