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()
|
void DirectSound::pause()
|
||||||
{
|
{
|
||||||
if (dsbSecondary == NULL)
|
for (auto buf : {dsbPrimary, dsbSecondary}) {
|
||||||
return;
|
if (buf == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
DWORD status;
|
DWORD status;
|
||||||
dsbSecondary->GetStatus(&status);
|
buf->GetStatus(&status);
|
||||||
|
|
||||||
if (status & DSBSTATUS_PLAYING)
|
if (status & DSBSTATUS_PLAYING)
|
||||||
dsbSecondary->Stop();
|
buf->Stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirectSound::reset()
|
void DirectSound::reset()
|
||||||
|
@ -214,10 +216,12 @@ void DirectSound::reset()
|
||||||
|
|
||||||
void DirectSound::resume()
|
void DirectSound::resume()
|
||||||
{
|
{
|
||||||
if (dsbSecondary == NULL)
|
for (auto buf : {dsbPrimary, dsbSecondary}) {
|
||||||
|
if (buf == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dsbSecondary->Play(0, 0, DSBPLAY_LOOPING);
|
buf->Play(0, 0, DSBPLAY_LOOPING);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirectSound::write(uint16_t* finalWave, int length)
|
void DirectSound::write(uint16_t* finalWave, int length)
|
||||||
|
|
|
@ -610,6 +610,15 @@ void MainFrame::OnActivate(wxActivateEvent& event)
|
||||||
|
|
||||||
if (panel && focused)
|
if (panel && focused)
|
||||||
panel->SetFocus();
|
panel->SetFocus();
|
||||||
|
|
||||||
|
if (pauseWhenInactive) {
|
||||||
|
if (panel && focused) {
|
||||||
|
panel->Resume();
|
||||||
|
}
|
||||||
|
else if (panel && !focused) {
|
||||||
|
panel->Pause();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::OnDropFile(wxDropFilesEvent& event)
|
void MainFrame::OnDropFile(wxDropFilesEvent& event)
|
||||||
|
|
Loading…
Reference in New Issue