Implemented sound use global focus in a different way so that it will mute physical audio without also muting avi/wav recording audio.

This commit is contained in:
mjbudd77 2021-08-31 17:18:46 -04:00
parent 934437dddc
commit bf3a02fe9b
3 changed files with 14 additions and 8 deletions

View File

@ -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();
}
}
}

View File

@ -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 */

View File

@ -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;
}