backport DirectSound8 -> DirectSound. However, we're still linking with DirectSound8. Will change this later...

This commit is contained in:
Chris Danford
2003-02-20 07:17:15 +00:00
parent ef46b26e5e
commit 6796e39be7
4 changed files with 24 additions and 18 deletions
+14 -8
View File
@@ -26,18 +26,24 @@ DSound::DSound()
{ {
HRESULT hr; HRESULT hr;
if(FAILED(hr=DirectSoundCreate8(NULL, &ds8, NULL))) // Initialize COM
RageException::ThrowNonfatal(hr_ssprintf(hr, "DirectSoundCreate8")); 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); DirectSoundEnumerate(EnumCallback, 0);
/* Try to set primary mixing privileges */ /* Try to set primary mixing privileges */
hr = ds8->SetCooperativeLevel(GetDesktopWindow(), DSSCL_PRIORITY); hr = ds->SetCooperativeLevel(GetDesktopWindow(), DSSCL_PRIORITY);
} }
DSound::~DSound() DSound::~DSound()
{ {
ds8->Release(); ds->Release();
CoUninitialize();
} }
bool DSound::IsEmulated() const bool DSound::IsEmulated() const
@@ -47,9 +53,9 @@ bool DSound::IsEmulated() const
DSCAPS Caps; DSCAPS Caps;
Caps.dwSize = sizeof(Caps); Caps.dwSize = sizeof(Caps);
HRESULT hr; 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. */ /* This is strange, so let's be conservative. */
return true; return true;
} }
@@ -100,11 +106,11 @@ DSoundBuf::DSoundBuf(DSound &ds, DSoundBuf::hw hardware,
format.lpwfxFormat = &waveformat; format.lpwfxFormat = &waveformat;
IDirectSoundBuffer *sndbuf_buf; IDirectSoundBuffer *sndbuf_buf;
HRESULT hr = ds.GetDS8()->CreateSoundBuffer(&format, &sndbuf_buf, NULL); HRESULT hr = ds.GetDS()->CreateSoundBuffer(&format, &sndbuf_buf, NULL);
if (FAILED(hr)) if (FAILED(hr))
RageException::ThrowNonfatal(hr_ssprintf(hr, "CreateSoundBuffer failed")); RageException::ThrowNonfatal(hr_ssprintf(hr, "CreateSoundBuffer failed"));
sndbuf_buf->QueryInterface(IID_IDirectSoundBuffer8, (LPVOID*) &buf); sndbuf_buf->QueryInterface(IID_IDirectSoundBuffer, (LPVOID*) &buf);
ASSERT(buf); ASSERT(buf);
/* I'm not sure this should ever be needed, but ... */ /* I'm not sure this should ever be needed, but ... */
+5 -5
View File
@@ -3,16 +3,16 @@
#include "SDL.h" #include "SDL.h"
struct IDirectSound8; struct IDirectSound;
struct IDirectSoundBuffer8; struct IDirectSoundBuffer;
class DSound class DSound
{ {
IDirectSound8 *ds8; IDirectSound *ds;
static BOOL CALLBACK EnumCallback( LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext); static BOOL CALLBACK EnumCallback( LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext);
public: public:
IDirectSound8 *GetDS8() const { return ds8; } IDirectSound *GetDS() const { return ds; }
bool IsEmulated() const; bool IsEmulated() const;
DSound(); DSound();
@@ -21,7 +21,7 @@ public:
class DSoundBuf class DSoundBuf
{ {
IDirectSoundBuffer8 *buf; IDirectSoundBuffer *buf;
int channels, samplerate, samplebits, writeahead; int channels, samplerate, samplebits, writeahead;
@@ -5,8 +5,8 @@
#include "SDL_Thread.h" #include "SDL_Thread.h"
#include "DSoundHelpers.h" #include "DSoundHelpers.h"
struct IDirectSound8; struct IDirectSound;
struct IDirectSoundBuffer8; struct IDirectSoundBuffer;
class RageSound_DSound: public RageSoundDriver class RageSound_DSound: public RageSoundDriver
{ {
@@ -5,8 +5,8 @@
#include "SDL_Thread.h" #include "SDL_Thread.h"
#include "DSoundHelpers.h" #include "DSoundHelpers.h"
struct IDirectSound8; struct IDirectSound;
struct IDirectSoundBuffer8; struct IDirectSoundBuffer;
class RageSound_DSound_Software: public RageSoundDriver class RageSound_DSound_Software: public RageSoundDriver
{ {