Why does this second call fail?

Started by
22 comments, last by Gyannea 20 years, 2 months ago
I have a section of code that initializes a direct sound capture object then buffer and then a notify object for that buffer: --------------------------- [All of this works] if(FAILED(pdsRXOb->CreateCaptureBuffer(&dsRXbd, &pdsRXBufOb, NULL))) // Create the capture buffer { return FALSE; } dsRXBufCaps.dwSize = sizeof(DSCBCAPS); // Get the capture buffer capabilities if(FAILED(pdsRXBufOb->GetCaps(&dsRXBufCaps))) { return FALSE; } // Create Notification interface for the capture buffer if(FAILED(pdsRXBufOb->QueryInterface(IID_IDirectSoundNotify, (void **)&pdsRXNotifyOb))) { return(FALSE); } ---------------------------------------------- It works fine. At least it compiles and executes. However, then I initialize a direct sound object, a secondary buffer and then try to place a notify object on that buffer. The notification object fails when executed. ---------------------------------------------- // Create the DirectSound buffer [This works] if(FAILED(pdsTXOb->CreateSoundBuffer(&dsTXbd, &pdsTXSecBufOb, NULL))) { return(FALSE); } // Create Notification interface for the send buffer [FAILS!!] if(FAILED(pdsTXSecBufOb->QueryInterface(IID_IDirectSoundNotify, (void **)&pdsTXNotifyOb))) { return(FALSE); } ----------------------------------------- Any ideas why I can''t create a notify object on the send buffer? Brian Reinhold
Brian Reinhold
Advertisement
The error return value is "E_NOINTERFACE" but that seems hard to believe given that the capture buffer works, the computer (1 year old Gateway) and soundcard (Soundblaster Live) are modern.

I tried using the outdated initialization method on the buffer but that gives "already initialized" so that obviously is not a solution.

It''s hard to know where to go from here!

I wanted to put the receive and send activities in a single high priority thread using a WaitForMulipleEvents() function to handle the two actions.

Does it make any sense that the interface would be available for the capture but not the play option? If anything, I would assume the reverse!

Not first creating the capture notify object doesn''t change things either!



Brian Reinhold
Brian Reinhold
Try using IID_IDirectSoundNotify8.
Dave, it didn''t work. Same error...no interface. How could that be? I thought the primary purpose of having the notify event thing was for streaming playback. I don''t even know where to turn.


Brian Reinhold
Brian Reinhold
According to MSDN, the CreateSoundBuffer method returns an IDirectSoundBuffer interface. You have to QueryInterface to get an IDirectSoundBuffer8 interface. Once you have a pointer to IDirectSoundBuffer8, you should be able to get your notify pointer via IID_IDirectSoundNotify8. I''m just guessing since I''m at work and can''t reference my own code, so this may not help.
That step of querying the DirectSoundBuffer interface to get the DirectSoundBuffer8 interface I have not done.

I have just created the Direct Sound object,
and from that created a DirectSoundBuffer object.

Wonder what the GUID idnetifier is called?

Brian
Brian Reinhold
IID_IDirectSoundBuffer8
I still get the same error, even though I can query the directsoundbuffer interface to get the ''8'' version. But I can''t query the ''8'' version to get the notify object.

I used DirectSoundCreate8 on the ''8'' version of the direct sound object. Maybe I should keep it at no ''8''?

This is crazy. I wish I could see an example, but the SDK doesn''t have one for directsound...just directsoundcapture. At least that which I can find!

Brian
Brian Reinhold
You definitely want the ''8'' version of the Create function.

I''ll see if I can find my notification code when I get home (unless someone else here has any suggestions).
Dave,

If I add the flag "DSBCAPS_CTRLPOSITIONNOTIFY" in the DSBCAPS structure in my above code when creating the DirectSound object, then the notify interface is able to be created as written above, without all the ''8'' options. Why I need to do this for the DirectSound object and NOT the DirectSoundCapture object is something which I don''t understand.

Whether the notify event action will work, on the other hand, I have not tried. Now at least I will be able to proceed.

It is quite frustrating and it cost me a whole day! Thanks for your help. I DO wish there was more information somewhere on DirectSound and subsets. There is certainly PLENTY on DirectX in the graphics part!

Brian Reinhold
Brian Reinhold

This topic is closed to new replies.

Advertisement