diff --git a/source/Configuration/PageSound.cpp b/source/Configuration/PageSound.cpp index 1be8e722..1681de02 100644 --- a/source/Configuration/PageSound.cpp +++ b/source/Configuration/PageSound.cpp @@ -139,11 +139,9 @@ void CPageSound::DlgOK(HWND hWnd) const DWORD dwSpkrVolume = SendDlgItemMessage(hWnd, IDC_SPKR_VOLUME, TBM_GETPOS, 0, 0); const DWORD dwMBVolume = SendDlgItemMessage(hWnd, IDC_MB_VOLUME, TBM_GETPOS, 0, 0); - if (SpkrSetEmulationType(hWnd, newSoundType)) - { - DWORD dwSoundType = (soundtype == SOUND_NONE) ? REG_SOUNDTYPE_NONE : REG_SOUNDTYPE_WAVE; - REGSAVE(TEXT(REGVALUE_SOUND_EMULATION), dwSoundType); - } + SpkrSetEmulationType(newSoundType); + DWORD dwSoundType = (soundtype == SOUND_NONE) ? REG_SOUNDTYPE_NONE : REG_SOUNDTYPE_WAVE; + REGSAVE(TEXT(REGVALUE_SOUND_EMULATION), dwSoundType); // NB. Volume: 0=Loudest, VOLUME_MAX=Silence SpkrSetVolume(dwSpkrVolume, VOLUME_MAX); diff --git a/source/Speaker.cpp b/source/Speaker.cpp index aae48a18..1cae26c3 100644 --- a/source/Speaker.cpp +++ b/source/Speaker.cpp @@ -241,6 +241,18 @@ void SpkrInitialize () else { g_bSpkrAvailable = Spkr_DSInit(); + if (!g_bSpkrAvailable) + { + GetFrame().FrameMessageBox( + TEXT("The emulator is unable to initialize a waveform ") + TEXT("output device. Make sure you have a sound card ") + TEXT("and a driver installed and that Windows is ") + TEXT("correctly configured to use the driver. Also ") + TEXT("ensure that no other program is currently using ") + TEXT("the device."), + TEXT("Configuration"), + MB_ICONEXCLAMATION | MB_SETFOREGROUND); + } } // @@ -280,32 +292,13 @@ void SpkrReset() //============================================================================= -BOOL SpkrSetEmulationType (HWND window, SoundType_e newtype) +void SpkrSetEmulationType (SoundType_e newtype) { SpkrDestroy(); // GH#295: Destroy for all types (even SOUND_NONE) soundtype = newtype; if (soundtype != SOUND_NONE) SpkrInitialize(); - - if (soundtype != newtype) - switch (newtype) { - - case SOUND_WAVE: - MessageBox(window, - TEXT("The emulator is unable to initialize a waveform ") - TEXT("output device. Make sure you have a sound card ") - TEXT("and a driver installed and that windows is ") - TEXT("correctly configured to use the driver. Also ") - TEXT("ensure that no other program is currently using ") - TEXT("the device."), - TEXT("Configuration"), - MB_ICONEXCLAMATION | MB_SETFOREGROUND); - return 0; - - } - - return 1; } //============================================================================= diff --git a/source/Speaker.h b/source/Speaker.h index 253ff6e8..f3d93e0e 100644 --- a/source/Speaker.h +++ b/source/Speaker.h @@ -21,7 +21,7 @@ void SpkrDestroy (); void SpkrInitialize (); void SpkrReinitialize (); void SpkrReset(); -BOOL SpkrSetEmulationType (HWND window, SoundType_e newSoundType); +void SpkrSetEmulationType (SoundType_e newSoundType); void SpkrUpdate (DWORD); void SpkrUpdate_Timer(); DWORD SpkrGetVolume();