Re-plumb window handle to the dsound backend.

Reverts parts of commit 71c01d83ab614b9e0c421d03ca694713dbabff48.
Fixes issue 6800
This commit is contained in:
Shawn Hoffman 2013-11-07 09:24:56 -08:00
parent ea2d8bf328
commit 33d56f50a4
9 changed files with 17 additions and 14 deletions

View File

@ -23,7 +23,7 @@ SoundStream *soundStream = nullptr;
namespace AudioCommon namespace AudioCommon
{ {
SoundStream *InitSoundStream(CMixer *mixer) SoundStream *InitSoundStream(CMixer *mixer, void *hWnd)
{ {
// TODO: possible memleak with mixer // TODO: possible memleak with mixer
@ -33,7 +33,7 @@ namespace AudioCommon
else if (backend == BACKEND_NULLSOUND && NullSound::isValid()) else if (backend == BACKEND_NULLSOUND && NullSound::isValid())
soundStream = new NullSound(mixer); soundStream = new NullSound(mixer);
else if (backend == BACKEND_DIRECTSOUND && DSound::isValid()) else if (backend == BACKEND_DIRECTSOUND && DSound::isValid())
soundStream = new DSound(mixer); soundStream = new DSound(mixer, hWnd);
else if (backend == BACKEND_XAUDIO2) else if (backend == BACKEND_XAUDIO2)
{ {
if (XAudio2::isValid()) if (XAudio2::isValid())

View File

@ -40,7 +40,7 @@ union UDSPControl
namespace AudioCommon namespace AudioCommon
{ {
SoundStream *InitSoundStream(CMixer *mixer); SoundStream *InitSoundStream(CMixer *mixer, void *hWnd);
void ShutdownSoundStream(); void ShutdownSoundStream();
std::vector<std::string> GetSoundBackends(); std::vector<std::string> GetSoundBackends();
bool UseJIT(); bool UseJIT();

View File

@ -48,7 +48,7 @@ class DSound : public SoundStream
bool WriteDataToBuffer(DWORD dwOffset, char* soundData, DWORD dwSoundBytes); bool WriteDataToBuffer(DWORD dwOffset, char* soundData, DWORD dwSoundBytes);
public: public:
DSound(CMixer *mixer, void *_hWnd = NULL) DSound(CMixer *mixer, void *_hWnd)
: SoundStream(mixer) : SoundStream(mixer)
, bufferSize(0) , bufferSize(0)
, currentPos(0) , currentPos(0)
@ -71,7 +71,7 @@ public:
#else #else
public: public:
DSound(CMixer *mixer) DSound(CMixer *mixer, void *_hWnd)
: SoundStream(mixer) : SoundStream(mixer)
{} {}
#endif #endif

View File

@ -388,8 +388,8 @@ void EmuThread()
OSD::AddMessage("Dolphin " + g_video_backend->GetName() + " Video Backend.", 5000); OSD::AddMessage("Dolphin " + g_video_backend->GetName() + " Video Backend.", 5000);
if (!DSP::GetDSPEmulator()->Initialize(_CoreParameter.bWii, if (!DSP::GetDSPEmulator()->Initialize(g_pWindowHandle,
_CoreParameter.bDSPThread)) _CoreParameter.bWii, _CoreParameter.bDSPThread))
{ {
HW::Shutdown(); HW::Shutdown();
g_video_backend->Shutdown(); g_video_backend->Shutdown();

View File

@ -15,7 +15,7 @@ public:
virtual bool IsLLE() = 0; 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 Shutdown() = 0;
virtual void DoState(PointerWrap &p) = 0; virtual void DoState(PointerWrap &p) = 0;
@ -35,6 +35,7 @@ public:
protected: protected:
SoundStream *soundStream; SoundStream *soundStream;
void *m_hWnd;
}; };
DSPEmulator *CreateDSPEmulator(bool HLE); DSPEmulator *CreateDSPEmulator(bool HLE);

View File

@ -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_bWii = bWii;
m_pUCode = NULL; m_pUCode = NULL;
m_lastUCode = NULL; m_lastUCode = NULL;
@ -265,7 +266,7 @@ void DSPHLE::InitMixer()
unsigned int AISampleRate, DACSampleRate; unsigned int AISampleRate, DACSampleRate;
AudioInterface::Callback_GetSampleRate(AISampleRate, DACSampleRate); AudioInterface::Callback_GetSampleRate(AISampleRate, DACSampleRate);
delete soundStream; 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"); if(!soundStream) PanicAlert("Error starting up sound stream");
// Mixer is initialized // Mixer is initialized
m_InitMixer = true; m_InitMixer = true;

View File

@ -16,7 +16,7 @@ class DSPHLE : public DSPEmulator {
public: public:
DSPHLE(); DSPHLE();
virtual bool Initialize(bool bWii, bool bDSPThread) override; virtual bool Initialize(void *hWnd, bool bWii, bool bDSPThread) override;
virtual void Shutdown() override; virtual void Shutdown() override;
virtual bool IsLLE() override { return false ; } virtual bool IsLLE() override { return false ; }

View File

@ -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_bWii = bWii;
m_bDSPThread = bDSPThread; m_bDSPThread = bDSPThread;
m_InitMixer = false; m_InitMixer = false;
@ -184,7 +185,7 @@ void DSPLLE::InitMixer()
unsigned int AISampleRate, DACSampleRate; unsigned int AISampleRate, DACSampleRate;
AudioInterface::Callback_GetSampleRate(AISampleRate, DACSampleRate); AudioInterface::Callback_GetSampleRate(AISampleRate, DACSampleRate);
delete soundStream; 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"); if(!soundStream) PanicAlert("Error starting up sound stream");
// Mixer is initialized // Mixer is initialized
m_InitMixer = true; m_InitMixer = true;

View File

@ -14,7 +14,7 @@ class DSPLLE : public DSPEmulator {
public: public:
DSPLLE(); DSPLLE();
virtual bool Initialize(bool bWii, bool bDSPThread); virtual bool Initialize(void *hWnd, bool bWii, bool bDSPThread);
virtual void Shutdown(); virtual void Shutdown();
virtual bool IsLLE() { return true; } virtual bool IsLLE() { return true; }