Click here to Skip to main content
       

C / C++ / MFC

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionWaveInOpen() returns error code 11memberAmbiguousName26 Jan '13 - 3:14 
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;
	//pcmWaveFormat.cbSize = 0;

	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.

AnswerRe: WaveInOpen() returns error code 11mvpRichard MacCutchan26 Jan '13 - 3:28 
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);

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 23 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid