From 33d56f50a44863d482665cf2f38c4264424f6184 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Thu, 7 Nov 2013 09:24:56 -0800 Subject: [PATCH] Re-plumb window handle to the dsound backend. Reverts parts of commit 71c01d83ab614b9e0c421d03ca694713dbabff48. Fixes issue 6800 --- Source/Core/AudioCommon/Src/AudioCommon.cpp | 4 ++-- Source/Core/AudioCommon/Src/AudioCommon.h | 2 +- Source/Core/AudioCommon/Src/DSoundStream.h | 4 ++-- Source/Core/Core/Src/Core.cpp | 4 ++-- Source/Core/Core/Src/DSPEmulator.h | 3 ++- Source/Core/Core/Src/HW/DSPHLE/DSPHLE.cpp | 5 +++-- Source/Core/Core/Src/HW/DSPHLE/DSPHLE.h | 2 +- Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp | 5 +++-- Source/Core/Core/Src/HW/DSPLLE/DSPLLE.h | 2 +- 9 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Source/Core/AudioCommon/Src/AudioCommon.cpp b/Source/Core/AudioCommon/Src/AudioCommon.cpp index acb9f95067..c8c37ea891 100644 --- a/Source/Core/AudioCommon/Src/AudioCommon.cpp +++ b/Source/Core/AudioCommon/Src/AudioCommon.cpp @@ -23,7 +23,7 @@ SoundStream *soundStream = nullptr; namespace AudioCommon { - SoundStream *InitSoundStream(CMixer *mixer) + SoundStream *InitSoundStream(CMixer *mixer, void *hWnd) { // TODO: possible memleak with mixer @@ -33,7 +33,7 @@ namespace AudioCommon else if (backend == BACKEND_NULLSOUND && NullSound::isValid()) soundStream = new NullSound(mixer); else if (backend == BACKEND_DIRECTSOUND && DSound::isValid()) - soundStream = new DSound(mixer); + soundStream = new DSound(mixer, hWnd); else if (backend == BACKEND_XAUDIO2) { if (XAudio2::isValid()) diff --git a/Source/Core/AudioCommon/Src/AudioCommon.h b/Source/Core/AudioCommon/Src/AudioCommon.h index 8ff5ff38e1..9c49293a48 100644 --- a/Source/Core/AudioCommon/Src/AudioCommon.h +++ b/Source/Core/AudioCommon/Src/AudioCommon.h @@ -40,7 +40,7 @@ union UDSPControl namespace AudioCommon { - SoundStream *InitSoundStream(CMixer *mixer); + SoundStream *InitSoundStream(CMixer *mixer, void *hWnd); void ShutdownSoundStream(); std::vector GetSoundBackends(); bool UseJIT(); diff --git a/Source/Core/AudioCommon/Src/DSoundStream.h b/Source/Core/AudioCommon/Src/DSoundStream.h index 8778c7e863..a872e79181 100644 --- a/Source/Core/AudioCommon/Src/DSoundStream.h +++ b/Source/Core/AudioCommon/Src/DSoundStream.h @@ -48,7 +48,7 @@ class DSound : public SoundStream bool WriteDataToBuffer(DWORD dwOffset, char* soundData, DWORD dwSoundBytes); public: - DSound(CMixer *mixer, void *_hWnd = NULL) + DSound(CMixer *mixer, void *_hWnd) : SoundStream(mixer) , bufferSize(0) , currentPos(0) @@ -71,7 +71,7 @@ public: #else public: - DSound(CMixer *mixer) + DSound(CMixer *mixer, void *_hWnd) : SoundStream(mixer) {} #endif diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 88c0376cb2..ea54163c30 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -388,8 +388,8 @@ void EmuThread() OSD::AddMessage("Dolphin " + g_video_backend->GetName() + " Video Backend.", 5000); - if (!DSP::GetDSPEmulator()->Initialize(_CoreParameter.bWii, - _CoreParameter.bDSPThread)) + if (!DSP::GetDSPEmulator()->Initialize(g_pWindowHandle, + _CoreParameter.bWii, _CoreParameter.bDSPThread)) { HW::Shutdown(); g_video_backend->Shutdown(); diff --git a/Source/Core/Core/Src/DSPEmulator.h b/Source/Core/Core/Src/DSPEmulator.h index 207818cbca..45b2b30c8c 100644 --- a/Source/Core/Core/Src/DSPEmulator.h +++ b/Source/Core/Core/Src/DSPEmulator.h @@ -15,7 +15,7 @@ public: virtual bool IsLLE() = 0; - virtual bool Initialize(bool bWii, bool bDSPThread) = 0; + virtual bool Initialize(void *hWnd, bool bWii, bool bDSPThread) = 0; virtual void Shutdown() = 0; virtual void DoState(PointerWrap &p) = 0; @@ -35,6 +35,7 @@ public: protected: SoundStream *soundStream; + void *m_hWnd; }; DSPEmulator *CreateDSPEmulator(bool HLE); diff --git a/Source/Core/Core/Src/HW/DSPHLE/DSPHLE.cpp b/Source/Core/Core/Src/HW/DSPHLE/DSPHLE.cpp index 3897fd6e86..501bc2a0dd 100644 --- a/Source/Core/Core/Src/HW/DSPHLE/DSPHLE.cpp +++ b/Source/Core/Core/Src/HW/DSPHLE/DSPHLE.cpp @@ -42,8 +42,9 @@ struct DSPState } }; -bool DSPHLE::Initialize(bool bWii, bool bDSPThread) +bool DSPHLE::Initialize(void *hWnd, bool bWii, bool bDSPThread) { + m_hWnd = hWnd; m_bWii = bWii; m_pUCode = NULL; m_lastUCode = NULL; @@ -265,7 +266,7 @@ void DSPHLE::InitMixer() unsigned int AISampleRate, DACSampleRate; AudioInterface::Callback_GetSampleRate(AISampleRate, DACSampleRate); delete soundStream; - soundStream = AudioCommon::InitSoundStream(new HLEMixer(this, AISampleRate, DACSampleRate, 48000)); + soundStream = AudioCommon::InitSoundStream(new HLEMixer(this, AISampleRate, DACSampleRate, 48000), m_hWnd); if(!soundStream) PanicAlert("Error starting up sound stream"); // Mixer is initialized m_InitMixer = true; diff --git a/Source/Core/Core/Src/HW/DSPHLE/DSPHLE.h b/Source/Core/Core/Src/HW/DSPHLE/DSPHLE.h index 44248fd88f..6627b9dc2a 100644 --- a/Source/Core/Core/Src/HW/DSPHLE/DSPHLE.h +++ b/Source/Core/Core/Src/HW/DSPHLE/DSPHLE.h @@ -16,7 +16,7 @@ class DSPHLE : public DSPEmulator { public: DSPHLE(); - virtual bool Initialize(bool bWii, bool bDSPThread) override; + virtual bool Initialize(void *hWnd, bool bWii, bool bDSPThread) override; virtual void Shutdown() override; virtual bool IsLLE() override { return false ; } diff --git a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp index 9b9364947b..af747815d1 100644 --- a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp +++ b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp @@ -130,8 +130,9 @@ void DSPLLE::dsp_thread(DSPLLE *dsp_lle) } } -bool DSPLLE::Initialize(bool bWii, bool bDSPThread) +bool DSPLLE::Initialize(void *hWnd, bool bWii, bool bDSPThread) { + m_hWnd = hWnd; m_bWii = bWii; m_bDSPThread = bDSPThread; m_InitMixer = false; @@ -184,7 +185,7 @@ void DSPLLE::InitMixer() unsigned int AISampleRate, DACSampleRate; AudioInterface::Callback_GetSampleRate(AISampleRate, DACSampleRate); delete soundStream; - soundStream = AudioCommon::InitSoundStream(new CMixer(AISampleRate, DACSampleRate, 48000)); + soundStream = AudioCommon::InitSoundStream(new CMixer(AISampleRate, DACSampleRate, 48000), m_hWnd); if(!soundStream) PanicAlert("Error starting up sound stream"); // Mixer is initialized m_InitMixer = true; diff --git a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.h b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.h index 5ae0fd6a74..71addf77b0 100644 --- a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.h +++ b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.h @@ -14,7 +14,7 @@ class DSPLLE : public DSPEmulator { public: DSPLLE(); - virtual bool Initialize(bool bWii, bool bDSPThread); + virtual bool Initialize(void *hWnd, bool bWii, bool bDSPThread); virtual void Shutdown(); virtual bool IsLLE() { return true; }