Re: waveInOpen cannot open device
- From: wanwan <ericwan78@xxxxxxxxx>
- Date: Wed, 6 Aug 2008 08:26:50 -0700 (PDT)
On Aug 6, 9:22 am, "Chris P." <m...@xxxxxxxxxxxx> wrote:
On Tue, 5 Aug 2008 15:21:37 -0400, Alessandro Angeli wrote:
Yes: functions provide error codes for a reason, unless
you're psychic of course. You might also want to what your
code does exactly and on what version of Windows.
Along with the complete format block that you are passing and the other
parameters. Basically that source code chunk. Basically you've done
something wrong and unless you show us what you've done we're not going to
be able to tell you.
--http://www.chrisnet.net/code.htm
[MS MVP for DirectShow / MediaFoundation]
I guess the best way is to show you what I did .sorry for having to do
it that way. I cut and pasted from my MFC application to below.
In the code, I exit the function with the first successful opening of
wave in device. The problem is that no device can open and the error
code doesn't match any of the error code constants. (in debug mode,
the error code is 11)
Please let me know what I did wrong.
WAVEFORMATEX wfx;
WAVEINCAPS wic;
HWAVEIN hwi;
wfx.wFormatTag = WAVE_FORMAT_PCM;
wfx.nChannels = 1;
wfx.nSamplesPerSec = 44100;
wfx.wBitsPerSample = 8;
wfx.nBlockAlign = wfx.wBitsPerSample*wfx.wBitsPerSample;
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec*wfx.nBlockAlign;
wfx.cbSize = 0;
MMRESULT res;
CString errmsg;
for (UINT i = 0; i < waveInGetNumDevs(); ++ i)
{
if(waveInGetDevCaps(i, &wic, sizeof WAVEINCAPS) == MMSYSERR_NOERROR)
{
if(wic.dwFormats&WAVE_FORMAT_4M08)
{
res = waveInOpen(&hwi, i, &wfx, (DWORD_PTR)waveInProc,
(DWORD_PTR)this,
CALLBACK_FUNCTION);
if(res == MMSYSERR_NOERROR)
{
return;
}
else if(res == MMSYSERR_ALLOCATED)
{
errmsg.Format("%d MMSYSERR_ALLOCATED", i);
AfxMessageBox(errmsg);
}
else if(res == MMSYSERR_BADDEVICEID)
{
errmsg.Format("%d MMSYSERR_BADDEVICEID", i);
AfxMessageBox(errmsg);
}
else if(res == MMSYSERR_NODRIVER)
{
errmsg.Format("%d MMSYSERR_NODRIVER", i);
AfxMessageBox(errmsg);
}
else if(res == MMSYSERR_NOMEM)
{
errmsg.Format("%d MMSYSERR_NOMEM", i);
AfxMessageBox(errmsg);
}
else if(res == WAVERR_BADFORMAT)
{
errmsg.Format("%d WAVERR_BADFORMAT", i);
AfxMessageBox(errmsg);
}
}
}
}
.
- Follow-Ups:
- Re: waveInOpen cannot open device
- From: wanwan
- Re: waveInOpen cannot open device
- References:
- waveInOpen cannot open device
- From: wanwan
- Re: waveInOpen cannot open device
- From: Alessandro Angeli
- Re: waveInOpen cannot open device
- From: Chris P.
- waveInOpen cannot open device
- Prev by Date: Re: How can I send data to my sound card?
- Next by Date: Re: waveInOpen cannot open device
- Previous by thread: Re: waveInOpen cannot open device
- Next by thread: Re: waveInOpen cannot open device
- Index(es):
Relevant Pages
|
Loading