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
+15 -9
View File
@@ -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 ... */
+5 -5
View File
@@ -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;
@@ -5,8 +5,8 @@
#include "SDL_Thread.h"
#include "DSoundHelpers.h"
struct IDirectSound8;
struct IDirectSoundBuffer8;
struct IDirectSound;
struct IDirectSoundBuffer;
class RageSound_DSound: public RageSoundDriver
{
@@ -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
{