From 3251309a10c341dcfb2fc5935756b0be0de9d9c7 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 21 Dec 2002 02:19:59 +0000 Subject: [PATCH] use fake sounds --- .../src/arch/Sound/RageSoundDriver_DSound.cpp | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp b/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp index 9fad22e2be..aed84a4f8b 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_DSound.cpp @@ -38,15 +38,15 @@ void RageSound_DSound::MixerThread() { InitThreadData("Mixer thread"); VDCHECKPOINT; - + + /* SOUNDMAN will be set once RageSoundManager's ctor returns and + * assigns it; we might get here before that happens, though. */ + while(!SOUNDMAN && !shutdown) Sleep(10); + while(!shutdown) { VDCHECKPOINT; Sleep(10); - /* SOUNDMAN will be set once RageSoundManager's ctor returns and - * assigns it; we might get here before that happens, though. */ - if(!SOUNDMAN) continue; - VDCHECKPOINT; LockMutex L(SOUNDMAN->lock); for(unsigned i = 0; i < stream_pool.size(); ++i) @@ -195,6 +195,20 @@ RageSound_DSound::RageSound_DSound() /* Try to set primary mixing privileges */ hr = ds8->SetCooperativeLevel(GetDesktopWindow(), DSSCL_PRIORITY); + { + /* Don't bother wasting time trying to create buffers if we're + * emulated. This also gives us better diagnostic information. */ + DSCAPS Caps; + Caps.dwSize = sizeof(Caps); + HRESULT hr; + if(FAILED(hr = ds8->GetCaps(&Caps))) + LOG->Warn(hr_ssprintf(hr, "ds8->GetCaps failed")); + else if(Caps.dwFlags & DSCAPS_EMULDRIVER) + { + ds8->Release(); + throw "Driver unusable (emulated device)"; + } + } /* Create a bunch of streams and put them into the stream pool. */ for(int i = 0; i < 32; ++i) { @@ -253,7 +267,8 @@ void RageSound_DSound::StartMixing(RageSound *snd) if(i == stream_pool.size()) { /* We don't have a free sound buffer. XXX fake it */ - ASSERT(0); + SOUNDMAN->AddFakeSound(snd); + return; } /* Give the stream to the playing sound and remove it from the pool. */