Skip to main content
gamedev.net
🔒 Locked

E_NOINTERFACE

Started by Crispy Feb 3, 2003 at 4:20 PM 1 replies 1.4k views
Original Post
Crispy
Crispy
Hi, I''m messing with DirectX for pretty much the first time now and I can''t figure out why the following bit of code produces an E_NOINTERFACE error:
  
LPDIRECTSOUND3DLISTENER Query3DListenerInterface()
{
   HRESULT ErrCode;
   DSBUFFERDESC BufferDescriptor;
   LPDIRECTSOUNDBUFFER PrimaryBuffer = NULL;
   LPDIRECTSOUND3DLISTENER Listener = NULL;

   //DirectSound is of type LPDIRECTSOUND8

   if(DirectSound == NULL)
   	return NULL;

   ZeroMemory(&BufferDescriptor, sizeof(DSBUFFERDESC));
   BufferDescriptor.dwSize = sizeof(DSBUFFERDESC);
   BufferDescriptor.dwFlags = DSBCAPS_CTRL3D | DSBCAPS_PRIMARYBUFFER;

   if((ErrCode = DirectSound->CreateSoundBuffer(&BufferDescriptor, &PrimaryBuffer, NULL)) != DS_OK)
     {
     DX8Error("Query3DListenerInterface -> CreateSoundBuffer", ErrCode);
     return NULL;
     }

   //error appears here:

   if((ErrCode = PrimaryBuffer->QueryInterface(IID_IDirectSound3DListener, (VOID**)&Listener)) != DS_OK)
     {
     PrimaryBuffer->Release();
     DX8Error("Query3DListenerInterface -> QueryInterface()", ErrCode);
     return NULL;
     }

   PrimaryBuffer->Release();

   return Listener;
}
  
Everything seems to be valid, but the interface isn''t found. Thanks for reading, Crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
bobobobo
bobobobo
This'll happen if you forget the DSBCAPS_CTRL3D flag in your primary buffer's DSBUFFERDESC:


[code] DSBUFFERDESC dsPrimaryBufferDesc;
ZeroMemory( &dsPrimaryBufferDesc, sizeof(DSBUFFERDESC) );

dsPrimaryBufferDesc.dwBufferBytes = 0;
dsPrimaryBufferDesc.dwFlags = DSBCAPS_PRIMARYBUFFER | // want this buffer to be primary buffer
DSBCAPS_CTRLVOLUME | // want to be able to control volume of this buffer
DSBCAPS_CTRL3D ; // !!!!! NEED THIS FLAG FOR 3D !!!!
dsPrimaryBufferDesc.dwReserved = 0; // reserved: must be 0
dsPrimaryBufferDesc.dwSize = sizeof(DSBUFFERDESC);
dsPrimaryBufferDesc.guid3DAlgorithm = GUID_NULL; // no 3D sound.. would be HRTF if using 3D sound
dsPrimaryBufferDesc.lpwfxFormat = NULL; // WAVEFORMATEX structure that specifies
// waveform format for this buffer.
// Must be NULL for primary buffers.

// Now CREATE the primary sound buffer
CHECK_HRESULT( directSound->CreateSoundBuffer( &dsPrimaryBufferDesc, &primarySoundBuffer, NULL ), "create primary sound buffer" ) ;[/code]
Evil Steve
Evil Steve
For audio it's recommended that you use [url="http://msdn.microsoft.com/en-us/library/windows/desktop/ee415813%28v=vs.85%29.aspx"]XAudio2[/url] instead of DirectSound.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.