Error querying 3DListenerInterface

Started by
2 comments, last by davethebrave 18 years, 5 months ago
Hi! I try to get the li3dListener Interface from my IDirectSound8. DSBUFFERDESC is filled with DSBCAPS_CTRL3D | BufferDesc.guid3DAlgorithm and DS3DALG_DEFAULT. the last hr allways gives me a E_NOINTERFACE. Any suggestions? [cpp] // Listener LPDIRECTSOUND3DLISTENER8 pListener; // Die IDirectSound8-Schnittstelle LPDIRECTSOUND8 pDSound; // Primärer Soundpuffer LPDIRECTSOUNDBUFFER pPrimaryBuffer; HWND hWnd = GetForegroundWindow(); HRESULT hr; DSBUFFERDESC BufferDesc; ZeroMemory(&BufferDesc, sizeof(DSBUFFERDESC)); BufferDesc.dwSize = sizeof(DSBUFFERDESC); BufferDesc.dwFlags = DSBCAPS_CTRL3D | DSBCAPS_PRIMARYBUFFER; BufferDesc.dwBufferBytes = 0; BufferDesc.dwReserved = 0; BufferDesc.lpwfxFormat = NULL; BufferDesc.guid3DAlgorithm = DS3DALG_DEFAULT; // DirectSound-Schnittstelle generieren hr = DirectSoundCreate8(NULL, &pDSound, NULL); // Kooperationsebene setzen hr = pDSound->SetCooperativeLevel(hWnd, DSSCL_PRIORITY); // Primären Soundpuffer erstellen hr = pDSound->CreateSoundBuffer(&BufferDesc, &pPrimaryBuffer, NULL); // Listener holen hr = pDSound->QueryInterface(IID_IDirectSound3DListener8, (LPVOID *)&pListener); [/cpp]
Advertisement
I put that stuff in a win32 project, and replaced the
HWND hWnd = GetForegroundWindow();
with the HWND I got from CreateWindow()


I also tried to run the example from
http://msdn.microsoft.com/library/en-us/directx9_c/Obtaining_the_3D_Listener.asp?frame=true

no change, and still no clue what´s wrong
hi,

You made sure that you put CoInitialize() in the front of all of this, right?
You also made sure that you put CoUnitnitialize() at the end of you program, right?

Hope this works,
ProgrammingNerd
argh...solved!

BAD: hr = pDSound->QueryInterface(IID_IDirectSound3DListener8, (LPVOID *)&pListener);
GOOD: hr = pDSound->QueryInterface(IID_IDirectSound3DListener8, (LPVOID *)pListener);

This topic is closed to new replies.

Advertisement