From 102ea55f20c0795e72c03efdca5ada47af828d19 Mon Sep 17 00:00:00 2001 From: magumagu Date: Thu, 27 Mar 2014 16:00:14 -0700 Subject: [PATCH] Move mixer construction to AudioCommon.cpp. --- Source/Core/AudioCommon/AudioCommon.cpp | 7 ++++++- Source/Core/AudioCommon/AudioCommon.h | 2 +- Source/Core/Core/HW/DSPHLE/DSPHLE.cpp | 5 +---- Source/Core/Core/HW/DSPLLE/DSPLLE.cpp | 5 +---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Source/Core/AudioCommon/AudioCommon.cpp b/Source/Core/AudioCommon/AudioCommon.cpp index 874ef461b5..70ee8333c6 100644 --- a/Source/Core/AudioCommon/AudioCommon.cpp +++ b/Source/Core/AudioCommon/AudioCommon.cpp @@ -26,8 +26,13 @@ SoundStream *soundStream = nullptr; namespace AudioCommon { - SoundStream *InitSoundStream(CMixer *mixer, void *hWnd) + SoundStream *InitSoundStream(void *hWnd) { + unsigned int AISampleRate, DACSampleRate; + AudioInterface::Callback_GetSampleRate(AISampleRate, DACSampleRate); + delete soundStream; + CMixer *mixer = new CMixer(AISampleRate, DACSampleRate, 48000); + // TODO: possible memleak with mixer std::string backend = SConfig::GetInstance().sBackend; diff --git a/Source/Core/AudioCommon/AudioCommon.h b/Source/Core/AudioCommon/AudioCommon.h index a44d9ef6b5..0a5eb9f5c6 100644 --- a/Source/Core/AudioCommon/AudioCommon.h +++ b/Source/Core/AudioCommon/AudioCommon.h @@ -14,7 +14,7 @@ extern SoundStream *soundStream; namespace AudioCommon { - SoundStream *InitSoundStream(CMixer *mixer, void *hWnd); + SoundStream *InitSoundStream(void *hWnd); void ShutdownSoundStream(); std::vector GetSoundBackends(); bool UseJIT(); diff --git a/Source/Core/Core/HW/DSPHLE/DSPHLE.cpp b/Source/Core/Core/HW/DSPHLE/DSPHLE.cpp index 77284665c3..5f79722638 100644 --- a/Source/Core/Core/HW/DSPHLE/DSPHLE.cpp +++ b/Source/Core/Core/HW/DSPHLE/DSPHLE.cpp @@ -262,10 +262,7 @@ void DSPHLE::DSP_WriteMailBoxLow(bool _CPUMailbox, unsigned short _Value) void DSPHLE::InitMixer() { - unsigned int AISampleRate, DACSampleRate; - AudioInterface::Callback_GetSampleRate(AISampleRate, DACSampleRate); - delete soundStream; - soundStream = AudioCommon::InitSoundStream(new CMixer(AISampleRate, DACSampleRate, 48000), m_hWnd); + soundStream = AudioCommon::InitSoundStream(m_hWnd); if (!soundStream) PanicAlert("Error starting up sound stream"); // Mixer is initialized m_InitMixer = true; diff --git a/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp b/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp index 796df42734..074f3773bf 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp @@ -181,10 +181,7 @@ void DSPLLE::Shutdown() void DSPLLE::InitMixer() { - unsigned int AISampleRate, DACSampleRate; - AudioInterface::Callback_GetSampleRate(AISampleRate, DACSampleRate); - delete soundStream; - soundStream = AudioCommon::InitSoundStream(new CMixer(AISampleRate, DACSampleRate, 48000), m_hWnd); + soundStream = AudioCommon::InitSoundStream(m_hWnd); if (!soundStream) PanicAlert("Error starting up sound stream"); // Mixer is initialized m_InitMixer = true;