diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index 11ca2388..3a2fada0 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -423,18 +423,14 @@ void consoleWin_t::winActiveChanged(void) { if ( !soundUseGlobalFocus ) { - fceuWrapperLock(); if ( hdl->isActive() ) { - int vol; - g_config->getOption("SDL.Sound.Volume", &vol); - FCEUI_SetSoundVolume(vol); + FCEUD_MuteSoundOutput(false); } else { - FCEUI_SetSoundVolume(0); + FCEUD_MuteSoundOutput(true); } - fceuWrapperUnLock(); } } } diff --git a/src/drivers/Qt/dface.h b/src/drivers/Qt/dface.h index f33e146f..1459ddc8 100644 --- a/src/drivers/Qt/dface.h +++ b/src/drivers/Qt/dface.h @@ -13,6 +13,7 @@ void WriteSound(int32 *Buffer, int Count); int KillSound(void); uint32 GetMaxSound(void); uint32 GetWriteSound(void); +void FCEUD_MuteSoundOutput(bool value); void SilenceSound(int s); /* DOS and SDL */ diff --git a/src/drivers/Qt/sdl-sound.cpp b/src/drivers/Qt/sdl-sound.cpp index 9665d002..b2056164 100644 --- a/src/drivers/Qt/sdl-sound.cpp +++ b/src/drivers/Qt/sdl-sound.cpp @@ -46,6 +46,7 @@ static unsigned int s_SampleRate = 44100; static double noiseGate = 0.0; static double noiseGateRate = 0.010; static bool noiseGateActive = true; +static bool muteSoundOutput = false; static int s_mute = 0; @@ -63,17 +64,20 @@ fillaudio(void *udata, { char bufStarveDetected = 0; static int16_t sample = 0; + char mute; //unsigned int starve_lp = nes_shm->sndBuf.starveCounter; int16 *tmps = (int16*)stream; len >>= 1; - if ( EmulationPaused || noiseGateActive ) + mute = EmulationPaused || muteSoundOutput; + + if ( mute || noiseGateActive ) { // This noise gate helps avoid abrupt snaps in audio // when pausing emulation. while (len) { - if (EmulationPaused) + if (mute) { noiseGate -= noiseGateRate; @@ -506,3 +510,8 @@ FCEUD_SoundToggle(void) FCEU_DispMessage("Sound mute on.",0); } } + +void FCEUD_MuteSoundOutput( bool value ) +{ + muteSoundOutput = value; +}