diff --git a/stepmania/src/arch/Sound/DSoundHelpers.cpp b/stepmania/src/arch/Sound/DSoundHelpers.cpp index d6d11b9628..6eed4e36f5 100644 --- a/stepmania/src/arch/Sound/DSoundHelpers.cpp +++ b/stepmania/src/arch/Sound/DSoundHelpers.cpp @@ -26,18 +26,24 @@ DSound::DSound() { HRESULT hr; - if(FAILED(hr=DirectSoundCreate8(NULL, &ds8, NULL))) - RageException::ThrowNonfatal(hr_ssprintf(hr, "DirectSoundCreate8")); - + // Initialize COM + if( hr = CoInitialize( NULL ) ) + RageException::ThrowNonfatal(hr_ssprintf(hr, "CoInitialize")); + + // Create IDirectSound using the primary sound device + if( FAILED( hr = DirectSoundCreate( NULL, &ds, NULL ) ) ) + RageException::ThrowNonfatal(hr_ssprintf(hr, "DirectSoundCreate")); + DirectSoundEnumerate(EnumCallback, 0); /* Try to set primary mixing privileges */ - hr = ds8->SetCooperativeLevel(GetDesktopWindow(), DSSCL_PRIORITY); + hr = ds->SetCooperativeLevel(GetDesktopWindow(), DSSCL_PRIORITY); } DSound::~DSound() { - ds8->Release(); + ds->Release(); + CoUninitialize(); } bool DSound::IsEmulated() const @@ -47,9 +53,9 @@ bool DSound::IsEmulated() const DSCAPS Caps; Caps.dwSize = sizeof(Caps); HRESULT hr; - if(FAILED(hr = ds8->GetCaps(&Caps))) + if(FAILED(hr = ds->GetCaps(&Caps))) { - LOG->Warn(hr_ssprintf(hr, "ds8->GetCaps failed")); + LOG->Warn(hr_ssprintf(hr, "ds->GetCaps failed")); /* This is strange, so let's be conservative. */ return true; } @@ -100,11 +106,11 @@ DSoundBuf::DSoundBuf(DSound &ds, DSoundBuf::hw hardware, format.lpwfxFormat = &waveformat; IDirectSoundBuffer *sndbuf_buf; - HRESULT hr = ds.GetDS8()->CreateSoundBuffer(&format, &sndbuf_buf, NULL); + HRESULT hr = ds.GetDS()->CreateSoundBuffer(&format, &sndbuf_buf, NULL); if (FAILED(hr)) RageException::ThrowNonfatal(hr_ssprintf(hr, "CreateSoundBuffer failed")); - sndbuf_buf->QueryInterface(IID_IDirectSoundBuffer8, (LPVOID*) &buf); + sndbuf_buf->QueryInterface(IID_IDirectSoundBuffer, (LPVOID*) &buf); ASSERT(buf); /* I'm not sure this should ever be needed, but ... */ diff --git a/stepmania/src/arch/Sound/DSoundHelpers.h b/stepmania/src/arch/Sound/DSoundHelpers.h index 238f0a4f11..3900b31a49 100644 --- a/stepmania/src/arch/Sound/DSoundHelpers.h +++ b/stepmania/src/arch/Sound/DSoundHelpers.h @@ -3,16 +3,16 @@ #include "SDL.h" -struct IDirectSound8; -struct IDirectSoundBuffer8; +struct IDirectSound; +struct IDirectSoundBuffer; class DSound { - IDirectSound8 *ds8; + IDirectSound *ds; static BOOL CALLBACK EnumCallback( LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext); public: - IDirectSound8 *GetDS8() const { return ds8; } + IDirectSound *GetDS() const { return ds; } bool IsEmulated() const; DSound(); @@ -21,7 +21,7 @@ public: class DSoundBuf { - IDirectSoundBuffer8 *buf; + IDirectSoundBuffer *buf; int channels, samplerate, samplebits, writeahead; diff --git a/stepmania/src/arch/Sound/RageSoundDriver_DSound.h b/stepmania/src/arch/Sound/RageSoundDriver_DSound.h index cf5a9640ed..ccb2ded4f4 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_DSound.h +++ b/stepmania/src/arch/Sound/RageSoundDriver_DSound.h @@ -5,8 +5,8 @@ #include "SDL_Thread.h" #include "DSoundHelpers.h" -struct IDirectSound8; -struct IDirectSoundBuffer8; +struct IDirectSound; +struct IDirectSoundBuffer; class RageSound_DSound: public RageSoundDriver { diff --git a/stepmania/src/arch/Sound/RageSoundDriver_DSound_Software.h b/stepmania/src/arch/Sound/RageSoundDriver_DSound_Software.h index 5fb07652b6..525ba7dfe8 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_DSound_Software.h +++ b/stepmania/src/arch/Sound/RageSoundDriver_DSound_Software.h @@ -5,8 +5,8 @@ #include "SDL_Thread.h" #include "DSoundHelpers.h" -struct IDirectSound8; -struct IDirectSoundBuffer8; +struct IDirectSound; +struct IDirectSoundBuffer; class RageSound_DSound_Software: public RageSoundDriver {