From fad1fa4e3d86c0530226a22842957b7bedf5c7e3 Mon Sep 17 00:00:00 2001 From: ayuanx Date: Sat, 12 Dec 2009 22:30:53 +0000 Subject: [PATCH] Improved XTra.KrazzY's Mute-On-Pause a bit, so it won't cost any CPU time when it is not used. Revert old Zelda-TP hack, though it really shouldn't be there... git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4684 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/AudioCommon/Src/AOSoundStream.cpp | 20 +++++++------- Source/Core/AudioCommon/Src/AOSoundStream.h | 2 -- .../Core/AudioCommon/Src/AlsaSoundStream.cpp | 23 ++++++++++------ Source/Core/AudioCommon/Src/AlsaSoundStream.h | 3 +-- Source/Core/AudioCommon/Src/DSoundStream.cpp | 24 ++++++----------- Source/Core/AudioCommon/Src/DSoundStream.h | 1 - Source/Core/AudioCommon/Src/OpenALStream.cpp | 26 ++++++++----------- Source/Core/AudioCommon/Src/OpenALStream.h | 1 - Source/Core/AudioCommon/Src/SoundStream.h | 1 - Source/Core/Core/Src/Core.cpp | 1 + .../Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp | 4 +-- Source/Plugins/Plugin_DSP_HLE/Src/main.cpp | 6 ----- 12 files changed, 48 insertions(+), 64 deletions(-) diff --git a/Source/Core/AudioCommon/Src/AOSoundStream.cpp b/Source/Core/AudioCommon/Src/AOSoundStream.cpp index 85766495be..e09a4cff29 100644 --- a/Source/Core/AudioCommon/Src/AOSoundStream.cpp +++ b/Source/Core/AudioCommon/Src/AOSoundStream.cpp @@ -19,9 +19,12 @@ #include "AOSoundStream.h" #include "Mixer.h" +#include "../../../PluginSpecs/pluginspecs_dsp.h" #if defined(HAVE_AO) && HAVE_AO +extern DSPInitialize g_dspInitialize; + void AOSound::SoundLoop() { uint_32 numBytesToRender = 256; @@ -85,8 +88,14 @@ void AOSound::Update() void AOSound::Clear() { - memset(realtimeBuffer, 0, sizeof(realtimeBuffer)); - + if(!*g_dspInitialize.pEmulatorState) + { + g_muted = false; + } + else + { + g_muted = true; + } Update(); } @@ -107,11 +116,4 @@ AOSound::~AOSound() { // ao_shutdown(); } -void AOSound::Mute(bool bMute) { - if((bMute && g_muted) || (!bMute && !g_muted)) - return; - - g_muted = bMute; -} - #endif diff --git a/Source/Core/AudioCommon/Src/AOSoundStream.h b/Source/Core/AudioCommon/Src/AOSoundStream.h index 9f6fd20b9b..dbe0a09471 100644 --- a/Source/Core/AudioCommon/Src/AOSoundStream.h +++ b/Source/Core/AudioCommon/Src/AOSoundStream.h @@ -64,8 +64,6 @@ public: virtual void Update(); - virtual void Mute(bool bMute); - #else public: AOSound(CMixer *mixer) : SoundStream(mixer) {} diff --git a/Source/Core/AudioCommon/Src/AlsaSoundStream.cpp b/Source/Core/AudioCommon/Src/AlsaSoundStream.cpp index dfc23300b0..3f74c4993c 100644 --- a/Source/Core/AudioCommon/Src/AlsaSoundStream.cpp +++ b/Source/Core/AudioCommon/Src/AlsaSoundStream.cpp @@ -17,12 +17,14 @@ #include "Common.h" #include "Thread.h" - +#include "../../../PluginSpecs/pluginspecs_dsp.h" #include "AlsaSoundStream.h" #define BUFFER_SIZE 4096 #define BUFFER_SIZE_BYTES (BUFFER_SIZE*2*2) +extern DSPInitialize g_dspInitialize; + AlsaSound::AlsaSound(CMixer *mixer) : SoundStream(mixer), thread_data(0), handle(NULL) { mix_buffer = new u8[BUFFER_SIZE_BYTES]; @@ -53,6 +55,18 @@ void AlsaSound::Stop() thread = NULL; } +void AlsaSound::Clear() +{ + if(!*g_dspInitialize.pEmulatorState) + { + g_muted = false; + } + else + { + g_muted = true; + } +} + void AlsaSound::Update() { // don't need to do anything here. @@ -180,13 +194,6 @@ 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() { diff --git a/Source/Core/AudioCommon/Src/AlsaSoundStream.h b/Source/Core/AudioCommon/Src/AlsaSoundStream.h index df4e206baa..75f48541c1 100644 --- a/Source/Core/AudioCommon/Src/AlsaSoundStream.h +++ b/Source/Core/AudioCommon/Src/AlsaSoundStream.h @@ -37,6 +37,7 @@ public: virtual bool Start(); virtual void SoundLoop(); virtual void Stop(); + virtual void Clear(); static bool isValid() { return true; @@ -47,8 +48,6 @@ public: virtual void Update(); - virtual void Mute(bool bMute); - private: bool AlsaInit(); void AlsaShutdown(); diff --git a/Source/Core/AudioCommon/Src/DSoundStream.cpp b/Source/Core/AudioCommon/Src/DSoundStream.cpp index 35dbf4f6e6..11911f4dcc 100644 --- a/Source/Core/AudioCommon/Src/DSoundStream.cpp +++ b/Source/Core/AudioCommon/Src/DSoundStream.cpp @@ -19,7 +19,6 @@ #include #include #include "DSoundStream.h" - #include "../../../PluginSpecs/pluginspecs_dsp.h" extern DSPInitialize g_dspInitialize; @@ -172,9 +171,14 @@ void DSound::Update() void DSound::Clear() { - memset(realtimeBuffer, 0, sizeof(realtimeBuffer)); - - Update(); + if(!*g_dspInitialize.pEmulatorState) + { + dsBuffer->Play(0, 0, DSBPLAY_LOOPING); + } + else + { + dsBuffer->Stop(); + } } void DSound::Stop() @@ -193,15 +197,3 @@ void DSound::Stop() 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; -} - diff --git a/Source/Core/AudioCommon/Src/DSoundStream.h b/Source/Core/AudioCommon/Src/DSoundStream.h index 1877a8b43e..cad273d268 100644 --- a/Source/Core/AudioCommon/Src/DSoundStream.h +++ b/Source/Core/AudioCommon/Src/DSoundStream.h @@ -79,7 +79,6 @@ 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(); diff --git a/Source/Core/AudioCommon/Src/OpenALStream.cpp b/Source/Core/AudioCommon/Src/OpenALStream.cpp index 6d72158413..57d4bcaa17 100644 --- a/Source/Core/AudioCommon/Src/OpenALStream.cpp +++ b/Source/Core/AudioCommon/Src/OpenALStream.cpp @@ -17,12 +17,15 @@ #include "aldlist.h" #include "OpenALStream.h" +#include "../../../PluginSpecs/pluginspecs_dsp.h" #if defined HAVE_OPENAL && HAVE_OPENAL #define AUDIO_NUMBUFFERS (4) //#define AUDIO_SERVICE_UPDATE_PERIOD (20) +extern DSPInitialize g_dspInitialize; + bool OpenALStream::Start() { ALDeviceList *pDeviceList = NULL; @@ -96,9 +99,14 @@ void OpenALStream::Update() void OpenALStream::Clear() { - memset(realtimeBuffer, 0, sizeof(realtimeBuffer)); - - Update(); + if(!*g_dspInitialize.pEmulatorState) + { + alSourcePlay(g_uiSource); + } + else + { + alSourceStop(g_uiSource); + } } THREAD_RETURN OpenALStream::ThreadFunc(void* args) @@ -178,17 +186,5 @@ 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 diff --git a/Source/Core/AudioCommon/Src/OpenALStream.h b/Source/Core/AudioCommon/Src/OpenALStream.h index 61deb32781..229af1226c 100644 --- a/Source/Core/AudioCommon/Src/OpenALStream.h +++ b/Source/Core/AudioCommon/Src/OpenALStream.h @@ -51,7 +51,6 @@ 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(); diff --git a/Source/Core/AudioCommon/Src/SoundStream.h b/Source/Core/AudioCommon/Src/SoundStream.h index ed11f77b19..111eaecc06 100644 --- a/Source/Core/AudioCommon/Src/SoundStream.h +++ b/Source/Core/AudioCommon/Src/SoundStream.h @@ -46,7 +46,6 @@ 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; diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 87038d9f48..010946b84e 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -579,6 +579,7 @@ void SetState(EState _State) break; case CORE_RUN: CCPU::EnableStepping(false); + CPluginManager::GetInstance().GetDSP()->DSP_ClearAudioBuffer(); break; default: PanicAlert("Invalid state"); diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp index 78fe02af88..9288769245 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp @@ -145,13 +145,11 @@ bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress) // AyuanX: this is still dubious because m_FileLength // isn't updated on the fly when write happens s32 NewSeekPosition = SeekPosition; -/* - if (m_FileLength > 0 && SeekPosition > m_FileLength && Mode == 0) + if (m_FileLength > 0 && SeekPosition > (s32)m_FileLength && Mode == 0) { NewSeekPosition = SeekPosition % m_FileLength; } INFO_LOG(WII_IPC_FILEIO, "FileIO: New Seek Pos: 0x%08x, Mode: %i (%s)", NewSeekPosition, Mode, m_Name.c_str()); -*/ // Set seek mode int seek_mode[3] = {SEEK_SET, SEEK_CUR, SEEK_END}; diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp index d8ce82ef00..963b8e643f 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/main.cpp @@ -317,10 +317,6 @@ unsigned short DSP_ReadControlRegister() void DSP_Update(int cycles) { - // Handle muting - if(g_bMuted && !*g_dspInitialize.pEmulatorState && soundStream) - soundStream->Mute(g_bMuted = false); - // This is called OFTEN - better not do anything expensive! CDSPHandler::GetInstance().Update(cycles); } @@ -372,6 +368,4 @@ void DSP_ClearAudioBuffer() { if (soundStream) soundStream->Clear(); - if(*g_dspInitialize.pEmulatorState && soundStream && !g_bMuted) - soundStream->Mute(g_bMuted = true); }