mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Fixed annoying sound when pausing/shutting down (please test for ALL backends) (couldn't do this for CoreAudio and PulseAudio too)
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4676 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -51,7 +51,8 @@ void AOSound::SoundLoop()
|
||||
{
|
||||
soundCriticalSection.Enter();
|
||||
m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2);
|
||||
ao_play(device, (char*)realtimeBuffer, numBytesToRender);
|
||||
if(!g_muted)
|
||||
ao_play(device, (char*)realtimeBuffer, numBytesToRender);
|
||||
soundCriticalSection.Leave();
|
||||
|
||||
if (! threadData)
|
||||
@ -105,4 +106,12 @@ AOSound::~AOSound() {
|
||||
// FIXME: crashes dolphin
|
||||
// ao_shutdown();
|
||||
}
|
||||
|
||||
void AOSound::Mute(bool bMute) {
|
||||
if((bMute && g_muted) || (!bMute && !g_muted))
|
||||
return;
|
||||
|
||||
g_muted = bMute;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -64,6 +64,8 @@ public:
|
||||
|
||||
virtual void Update();
|
||||
|
||||
virtual void Mute(bool bMute);
|
||||
|
||||
#else
|
||||
public:
|
||||
AOSound(CMixer *mixer) : SoundStream(mixer) {}
|
||||
|
@ -67,7 +67,7 @@ void AlsaSound::SoundLoop()
|
||||
// nakee: What is the optimal value?
|
||||
int frames_to_deliver = 4096;
|
||||
m_mixer->Mix(reinterpret_cast<short *>(mix_buffer), frames_to_deliver);
|
||||
int rc = snd_pcm_writei(handle, mix_buffer, frames_to_deliver);
|
||||
int rc = g_muted ? 1337 : snd_pcm_writei(handle, mix_buffer, frames_to_deliver);
|
||||
if (rc == -EPIPE)
|
||||
{
|
||||
// Underrun
|
||||
@ -180,6 +180,13 @@ bool AlsaSound::AlsaInit()
|
||||
NOTICE_LOG(AUDIO, "ALSA successfully initialized.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
void AlsaSound::Mute(bool bMute) {
|
||||
if((bMute && g_muted) || (!bMute && !g_muted))
|
||||
return;
|
||||
|
||||
g_muted = bMute;
|
||||
}
|
||||
|
||||
void AlsaSound::AlsaShutdown()
|
||||
{
|
||||
|
@ -47,6 +47,8 @@ public:
|
||||
|
||||
virtual void Update();
|
||||
|
||||
virtual void Mute(bool bMute);
|
||||
|
||||
private:
|
||||
bool AlsaInit();
|
||||
void AlsaShutdown();
|
||||
|
@ -192,3 +192,16 @@ void DSound::Stop()
|
||||
soundSyncEvent.Shutdown();
|
||||
thread = NULL;
|
||||
}
|
||||
|
||||
void DSound::Mute(bool bMute) {
|
||||
if((bMute && g_muted) || (!bMute && !g_muted))
|
||||
return;
|
||||
|
||||
if(bMute)
|
||||
dsBuffer->Stop();
|
||||
else
|
||||
dsBuffer->Play(0, 0, DSBPLAY_LOOPING);
|
||||
|
||||
g_muted = bMute;
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,7 @@ public:
|
||||
virtual void SetVolume(int volume);
|
||||
virtual void Stop();
|
||||
virtual void Clear();
|
||||
virtual void Mute(bool bMute);
|
||||
static bool isValid() { return true; }
|
||||
virtual bool usesMixer() const { return true; }
|
||||
virtual void Update();
|
||||
|
@ -30,6 +30,8 @@ bool OpenALStream::Start()
|
||||
ALCdevice *pDevice = NULL;
|
||||
bool bReturn = false;
|
||||
|
||||
g_uiSource = 0;
|
||||
|
||||
pDeviceList = new ALDeviceList();
|
||||
if ((pDeviceList) && (pDeviceList->GetNumDevices()))
|
||||
{
|
||||
@ -125,6 +127,9 @@ void OpenALStream::SoundLoop()
|
||||
alSourceQueueBuffers(uiSource, 1, &uiBuffers[iLoop]);
|
||||
}
|
||||
//*/
|
||||
|
||||
g_uiSource = uiSource;
|
||||
|
||||
alSourcePlay(uiSource);
|
||||
err = alGetError();
|
||||
|
||||
@ -173,5 +178,17 @@ void OpenALStream::SoundLoop()
|
||||
|
||||
}
|
||||
|
||||
void OpenALStream::Mute(bool bMute) {
|
||||
if((bMute && g_muted) || (!bMute && !g_muted))
|
||||
return;
|
||||
|
||||
if(bMute && g_uiSource)
|
||||
alSourceStop(g_uiSource);
|
||||
else if(g_uiSource)
|
||||
alSourcePlay(g_uiSource);
|
||||
|
||||
g_muted = bMute;
|
||||
}
|
||||
|
||||
#endif //HAVE_OPENAL
|
||||
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
virtual void SoundLoop();
|
||||
virtual void Stop();
|
||||
virtual void Clear();
|
||||
virtual void Mute(bool bMute);
|
||||
static bool isValid() { return true; }
|
||||
virtual bool usesMixer() const { return true; }
|
||||
virtual void Update();
|
||||
@ -63,6 +64,7 @@ private:
|
||||
Common::Event soundSyncEvent;
|
||||
|
||||
short realtimeBuffer[OAL_BUFFER_SIZE];
|
||||
ALuint g_uiSource;
|
||||
#else
|
||||
public:
|
||||
OpenALStream(CMixer *mixer, void *hWnd = NULL): SoundStream(mixer) {}
|
||||
|
@ -32,9 +32,10 @@ protected:
|
||||
volatile int threadData;
|
||||
bool m_logAudio;
|
||||
WaveFileWriter g_wave_writer;
|
||||
bool g_muted;
|
||||
|
||||
public:
|
||||
SoundStream(CMixer *mixer) : m_mixer(mixer), threadData(0) {}
|
||||
SoundStream(CMixer *mixer) : m_mixer(mixer), threadData(0), g_muted(false) {}
|
||||
virtual ~SoundStream() { delete m_mixer;}
|
||||
|
||||
static bool isValid() { return false; }
|
||||
@ -45,6 +46,7 @@ public:
|
||||
virtual void Stop() {}
|
||||
virtual void Update() {}
|
||||
virtual void Clear() {}
|
||||
virtual void Mute(bool bMute) {}
|
||||
virtual void StartLogAudio(const char *filename) {
|
||||
if (! m_logAudio) {
|
||||
m_logAudio = true;
|
||||
|
Reference in New Issue
Block a user