Out of boredom, and because it was on my todo list, I decided to mess around with DSound's audio capture stuff - I figured I'd have a quickie 8bit/8khz voip application put together in a day, two at the most... nothing serious, just something quick and fun.

I can create the IDirectSoundCapture interface, and I can create IDirectSoundCaptureBuffer, but when I QueryInterface the capturebuffer for IID_IDirectSoundNotify (for setting up some buffer events) it fails, telling me no, the interface is not supported (80004002).

I took the liberty of checking the GUIDs, and they all look fine (December SDK).

Furthermore, I can only create a default IDirectSoundCapture device (using NULL as the device identifier) - the two GUIDS relating to "systemwide" and "default voice" capture devices don't work for me, and again, the GUIDs look ok.

Note that I am using the DirectSoundCaptureCreate8 api to obtain my initial device, not that it should make a shred of difference how I obtained my object..

Does anyone know what the heck is going on here, or have an idea?
Posted on 2006-04-27 00:16:03 by Homer
i reply in C style, it worked for me in 2005; errorcheck removed:
(may be you queried the wrong interface)
IDirectSoundCapture8       *dsc;
IDirectSoundCaptureBuffer8 *capture;
IDirectSoundNotify8        *notify;
DSCBUFFERDESC bdesc;

DirectSoundCaptureCreate8(_DSDEVID_DefaultCapture, &dsc);
// fill the bdesc struct
dsc->CreateCaptureBuffer(bdesc, &capture);
capture->QueryInterface( _IID_IDirectSoundNotify, &notify);
Posted on 2006-04-27 10:45:33 by sapero
Notification positions are not supported on some old/bugged/strange/whatever drivers.

Here's how it's in the SDK:
HRESULT CreateCaptureBuffer(LPDIRECTSOUNDCAPTURE8 pDSC, 
好bsp; 好bsp; 好bsp; 好bsp; 好bsp; 好bsp; 好bsp; 好bsp; 好bsp; 好bsp; 好bsp; 好bsp; 好bsp; 好bsp; LPDIRECTSOUNDCAPTUREBUFFER8* ppDSCB8)
{
好bsp; HRESULT hr;
好bsp; DSCBUFFERDESC好bsp; 好bsp; 好bsp; 好bsp; 好bsp; 好bsp; 好bsp; 好bsp;dscbd;
好bsp; LPDIRECTSOUNDCAPTUREBUFFER好bsp; pDSCB;
好bsp; WAVEFORMATEX好bsp; 好bsp; 好bsp; 好bsp; 好bsp; 好bsp; 好bsp; 好bsp; wfx =
好bsp; 好bsp; {WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0};
好bsp; 好bsp; // wFormatTag, nChannels, nSamplesPerSec, mAvgBytesPerSec,
好bsp; 好bsp; // nBlockAlign, wBitsPerSample, cbSize

好bsp; if ((NULL == pDSC) || (NULL == ppDSCB8)) return E_INVALIDARG;
好bsp; dscbd.dwSize = sizeof(DSCBUFFERDESC);
好bsp; dscbd.dwFlags = 0;
好bsp; dscbd.dwBufferBytes = wfx.nAvgBytesPerSec;
好bsp; dscbd.dwReserved = 0;
好bsp; dscbd.lpwfxFormat = &wfx;
好bsp; dscbd.dwFXCount = 0;
好bsp; dscbd.lpDSCFXDesc = NULL;

好bsp; if (SUCCEEDED(hr = pDSC->CreateCaptureBuffer(&dscbd, &pDSCB, NULL)))
好bsp; {
好bsp; 好bsp; hr = pDSCB->QueryInterface(IID_IDirectSoundCaptureBuffer8, (LPVOID*)ppDSCB8);
好bsp; 好bsp; pDSCB->Release();好bsp;
好bsp; }
好bsp; return hr;
}


Make sure you create IDirectSoundCapture8 and IDirectSoundCaptureBuffer8.
Posted on 2006-04-27 11:28:42 by ti_mo_n
I'll see you and raise you.

Here's the source I used, extracted from testbed project.
I'm just posting the relevant stuff, which appears to mirror the code in the replies, so wtf is going on? :(


invoke DirectSoundCaptureCreate8,0,addr pDSC,NULL
.if eax==S_OK
invoke GetWaveFormatFromIndex, 0, addr wfx
m2m dscbd.dwBufferBytes , wfx.nAvgBytesPerSec;
lea eax,wfx
mov dscbd.lpwfxFormat,eax

mov pDSCaptureBuffer,0
ICall pDSC::IDirectSoundCapture8.CreateCaptureBuffer, addr dscbd, addr pDSCaptureBuffer, NULL
.if eax==S_OK
DbgText "Created CaptureBuffer"
.else
DbgText "Failed CreateCaptureBuffer"
.endif

mov pDSNotify,0
ICall pDSCaptureBuffer::IDirectSoundCaptureBuffer8.QueryInterface,addr IID_IDirectSoundNotify,addr pDSNotify
DbgHex eax
.if FAILED(eax)
DbgText "Failed Query for DSNotify"
.else
DbgText "ok QueryInterface"
.endif

.else
DbgText "Failed DirectSoundCaptureCreate8"
.endif


and the function I used to select a wav format (note: I chose nIndex=0, which is 1 channel 8 bit 8khz)


GetWaveFormatFromIndex proc nIndex, pwfx
LOCAL iSampleRate,iType

mov eax,nIndex
shr eax,2
mov iSampleRate,eax
.if eax==0
mov eax, 8000
.elseif eax==1
mov eax,  11025
.elseif eax==2
mov eax,  22050
.elseif eax==3
mov eax,  44100
.endif
mov ebx,pwfx
mov .WAVEFORMATEX.nSamplesPerSec,eax

mov eax,nIndex
xor edx,edx
mov ebx,4
div ebx
mov iType,edx
.if edx==0
mov eax, 8
mov ecx, 1
.elseif edx==1
mov eax, 16
mov ecx, 1
.elseif edx==2
mov eax, 8
mov ecx, 2
.elseif edx==3
mov eax, 16
mov ecx, 2
.endif
mov ebx,pwfx
mov .WAVEFORMATEX.wBitsPerSample,ax
mov .WAVEFORMATEX.nChannels,cx

shr eax,3
mul .WAVEFORMATEX.nChannels
mov .WAVEFORMATEX.nBlockAlign,ax

mul .WAVEFORMATEX.nSamplesPerSec
mov .WAVEFORMATEX.nAvgBytesPerSec,eax
ret
GetWaveFormatFromIndex endp


Can anyone see the fundamental difference, assuming that the GUIDs are all correct?

Posted on 2006-04-27 12:21:24 by Homer
Are you sure you're quering for IDirectSoundNotify8 ?

(0B0210783h, 089CDh, 011D0h, 0AFh, 008h, 000h, 0A0h, 0C9h, 025h, 0CDh, 016h)

If the buffer IS being created, then it has to support Notification Positions, regardless of the buffer's format.
Posted on 2006-04-27 15:23:30 by ti_mo_n

From DSound.inc:
IID_IDirectSoundNotify   byte 0b0h,21h,7,83h, 89h,0cdh, 11h,0d0h, 0afh, 8, 0, 0a0h, 0c9h, 25h, 0cdh, 16h


As I was saying, the guids all look ok..
Wait - I do have a funky audio driver installed, but I still doubt thats the problem.

Attached is the test executable.. ignore the GUI, look at the debug output.
Here's the debug output I am seeing:

Created CaptureBuffer
eax = 80004002h
Failed Query for DSNotify


Attachments:
Posted on 2006-04-27 17:22:55 by Homer
0B0210783h, 089CDh, 011D0h, 0AFh, 008h, 000h, 0A0h, 0C9h, 025h, 0CDh, 016h

is equal to

083h, 007h, 021h, 0B0h, 0CDh, 089h, 0D0h, 011h, 0AFh, 008h, 000h, 0A0h, 0C9h, 025h, 0CDh, 016h

not

0b0h,21h,7,83h, 89h,0cdh, 11h,0d0h, 0afh, 8, 0, 0a0h, 0c9h, 25h, 0cdh, 16h

Maybe that's the case?
Posted on 2006-04-27 20:01:39 by ti_mo_n
Hey, YOU ARE CORRECT !!! (kicking self) - usually I describe GUIDs using a macro - I have no idea why I described the DSound guids as byte strings, or why I assumed that guids were simple a series of 16 linear bytes when I put that include together (its been so long..)

I'll fix all the guids in DSound.inc and send a copy to Biterider for redistribution in the next version release of OA32 :)

Thanks for the heads up  8)

It's a pity there's not more people using these DX9 headers to help identify and correct such silly translation errors.. it's now typically some months between me finding problems, does that mean that we're almost bugfree now, or does it mean that I screw with a lot more of the esoteric stuff than the average joker?
Posted on 2006-04-28 00:45:03 by Homer
I'm glad I could help :)
Posted on 2006-04-28 10:10:07 by ti_mo_n