Quote:Original post by Demirug
This doesn’t make sense at all. DirectSound doesn’t support aggregation. If you pass anything else the NULL there it should return an error.
Yup - that's what confuses me [smile]
I can only assume that this is undocumented, weird internal behaviour that I'm seeing. I've made a sample app that almost shows what's going on - except CreateSoundBuffer() is returning E_INVALIDARG in my code, and it succeeds when called through OLE on my desktop (I'm on my laptop now):
#define INITGUID#include <windows.h>#include <dsound.h>typedef HRESULT (WINAPI *LPDllGetClassObject)(REFCLSID rclsid, REFIID riid, LPVOID* ppv);DEFINE_GUID(MyGuid, 0x279afa83, 0x4981, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60);int main(int, char**){ HMODULE hDll = LoadLibrary("dsound.dll"); if(!hDll) return -1; LPDllGetClassObject pfn = (LPDllGetClassObject)GetProcAddress(hDll, "DllGetClassObject"); if(!pfn) return -1; IDirectSound* pDSound = NULL; HRESULT h = pfn(CLSID_DirectSound, IID_IClassFactory, (void**)&pDSound); if(FAILED(h)) return -1; char buffer[512]; memset(buffer, 0, sizeof(buffer)); IUnknown* pUnknown = (IUnknown*)buffer; IDirectSoundBuffer** ppBuffer = (IDirectSoundBuffer**)&MyGuid; h = pDSound->CreateSoundBuffer(NULL, ppBuffer, pUnknown); if(FAILED(h)) return -1;}
The IUnknown stuff there looks like what I see inside my proxy DLL - a pointer which is non-null, but with a null vtable.
I don't understand why this sample code doesn't work, but what appears to be the same code works on my desktop.
I thought it might be me casting an interface pointer wrongly, and screwing up the vtable - and ending up calling the wrong function, but I can't see how that would happen...
I'll have another tinker with this tomorrow morning (It's nearly midnight here, and I'm knackered and ill)...
Ok, I got annoyed and came back to it. It seems like the buffer pointer passed in is a pointer to a GUID, and only this GUID works. The above code now succeeds and has the exact same effect as what I'm seeing - the pUnknown pointer becomes intialised to a seemingly valid interface.
[Edited by - Evil Steve on October 9, 2007 5:09:07 PM]