Original Post
Hi all, I'm trying to get my copy of Dungeon Keeper 2 to work properly. I noticed that some sounds stutter, and I've seen this happen before in my own engine. It's caused by my on-board audio (And it occurs on other on-board audio too) not handing hardware sound buffer notifications properly. The fix is pretty simple - Don't create a hardware sound buffer; create a software one instead. So, I'm trying to write my own dsound.dll to act as a proxy between Dungeon Keeper 2 and the real DirectSound DLL. I've done this before with D3D, but I've never had to deal with this OLE and COM aggregation crap before. The problem is that DK2 doesn't call DirectSoundCreate(), it uses DllGetClassObject() to get a CLSID_DirectSound interface, and then calls CreateSoundBuffer() with the pUnkOuter parameter non-NULL, and I don't know how to handle that. This is what I have just now (Which I know is wrong): My question is, what should I do to handle this aggregation? I had a quick look on Google, but I really didn't understand much. I understand the concept of aggregation, but not the implementation details. Essentially, all I want to do is have my own IDirectSoundBuffer version (DSoundBufferWrapper) returned instead of the real one. Using my above code, I get calls like so:
HRESULT WINAPI DSoundWrapper::CreateSoundBuffer(LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER* ppDSBuffer, LPUNKNOWN pUnkOuter)
{
HRESULT hResult = m_pDSound->CreateSoundBuffer(pcDSBufferDesc, ppDSBuffer, pUnkOuter);
if(SUCCEEDED(hResult))
{
DSoundBufferWrapper* pWrapper = new DSoundBufferWrapper(*ppDSBuffer);
*ppDSBuffer = pWrapper;
}
return hResult;
}
Quote:So, my question is - how do I handle this? And/or does anyone have any good links I could read? Cheers, Steve [Edited by - Evil Steve on October 10, 2007 3:31:21 AM]
DllGetClassObject(): I return 0x01b70e80 CreateSoundBuffer(NULL, 0x0013c780 (-> 0x279afa83), 0x0013bdf0 (-> 0x00000000)): Returns pUnkOuter of 0x034a1338, my buffer allocated at 0x01b723c8 IDirectSound::Release() DllGetClassObject(): I return 0x01b70e80 CreateSoundBuffer(NULL, 0x180242e8 (-> 0x279afa83), 0x0013c784 (-> 0x01b70e80)): Returns pUnkOuter of 0x034a193c, my buffer allocated 0x01b723fc Crashes in this call deteferencing the ppDSBuffer pointer.