|
hello guys... im trying to write a small recording program. But waveInOpen fails with error code 11. Here is what I am trying.
LPHWAVEIN phWaveIn = NULL;
WAVEFORMATEX pcmWaveFormat;
::memset(&pcmWaveFormat, 0, sizeof(WAVEFORMATEX));
pcmWaveFormat.wFormatTag = WAVE_FORMAT_PCM;
pcmWaveFormat.nChannels = 1;
pcmWaveFormat.nSamplesPerSec = 11025L;
pcmWaveFormat.nAvgBytesPerSec = 11025L;
pcmWaveFormat.nBlockAlign = 1;
pcmWaveFormat.wBitsPerSample = 8;
MMRESULT rResult;
rResult = IsFormatSupported(&pcmWaveFormat, WAVE_MAPPER);
if(rResult != MMSYSERR_NOERROR) return;
rResult = ::waveInOpen(phWaveIn, WAVE_MAPPER, &pcmWaveFormat, 0, 0, CALLBACK_NULL);
if(rResult != MMSYSERR_NOERROR)
{
CString sErrorMsg;
if(rResult == MMSYSERR_ALLOCATED)
sErrorMsg = "Specified resource is already allocated.";
else if(rResult == MMSYSERR_BADDEVICEID)
sErrorMsg = "Specified device identifier is out of range.";
else if(rResult == MMSYSERR_NODRIVER)
sErrorMsg = "No device driver is present.";
else if(rResult == MMSYSERR_NOMEM)
sErrorMsg = "Unable to allocate or lock memory.";
else if(rResult == WAVERR_BADFORMAT)
sErrorMsg = "Attempted to open with an unsupported waveform-audio format.";
}
What could be wrong? Thanks
This world is going to explode due to international politics, SOON.
|
|
|
|
|
Your first parameter is supposed to be a pointer to a handle buffer, it should be:
HWAVEIN hWaveIn = NULL;
rResult = ::waveInOpen(&hWaveIn, WAVE_MAPPER, &pcmWaveFormat, 0, 0, CALLBACK_NULL);
|
|
|
|