I got a snippet of code off of pocketpcdn.com for changing volume via waveOutSetVolume that returns an unknown error code. I'm putting the code below in the hope that someone out there has done this before and knows what the problem is.
The error code comes from waveOutOpen and is a value of 32. MMSYSERR_NOERROR = 0, MMSYSERR_INVALHANDLE = 5, MMSYSERR_NODRIVER = 6, MMSYSERR_NOMEM = 7, and MMSYSERR_NOTSUPPORTED = 8. This works on the desktop PC by just using the waveOutSetVolume with WAVE_MAPPER as the device.
Thanks for any help you might provide. -- GR
- Code:
void CWave::setSoundVolume(DWORD dwVolume)
{
#ifdef _DEBUG
extern FILE *g_fp;
#endif
#ifndef _WIN32_WCE
waveOutSetVolume((HWAVEOUT) WAVE_MAPPER, dwVolume);
#else
WAVEFORMATEX wf;
wf.wFormatTag = WAVE_FORMAT_PCM;
wf.nChannels = 1;
wf.nSamplesPerSec = 8000 * 1000;
wf.wBitsPerSample = 8;
wf.nBlockAlign = wf.nChannels * wf.wBitsPerSample / 8;
wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign;
wf.cbSize = 0;
HWAVEOUT hwo;
UINT devs = waveOutGetNumDevs();
for (UINT id = 0; id < devs; id++) {
MMRESULT mmr = waveOutOpen(&hwo, id, &wf, 0, 0, CALLBACK_NULL);
#ifdef _DEBUG
if(g_fp) { (void)fprintf(g_fp, "mmr = %d\n", mmr); (void)fflush(g_fp); }
if(g_fp) { (void)fprintf(g_fp, "MMSYSERR_NOERROR = %d\n", MMSYSERR_NOERROR); (void)fflush(g_fp); }
if(g_fp) { (void)fprintf(g_fp, "MMSYSERR_INVALHANDLE = %d\n", MMSYSERR_INVALHANDLE); (void)fflush(g_fp); }
if(g_fp) { (void)fprintf(g_fp, "MMSYSERR_NODRIVER = %d\n", MMSYSERR_NODRIVER); (void)fflush(g_fp); }
if(g_fp) { (void)fprintf(g_fp, "MMSYSERR_NOMEM = %d\n", MMSYSERR_NOMEM); (void)fflush(g_fp); }
if(g_fp) { (void)fprintf(g_fp, "MMSYSERR_NOTSUPPORTED = %d\n", MMSYSERR_NOTSUPPORTED); (void)fflush(g_fp); }
#endif
if (mmr == MMSYSERR_NOERROR) {
waveOutSetVolume(hwo, dwVolume);
waveOutClose(hwo);
break;
}
}
#endif
}
The error code comes from waveOutOpen and is a value of 32. MMSYSERR_NOERROR = 0, MMSYSERR_INVALHANDLE = 5, MMSYSERR_NODRIVER = 6, MMSYSERR_NOMEM = 7, and MMSYSERR_NOTSUPPORTED = 8. This works on the desktop PC by just using the waveOutSetVolume with WAVE_MAPPER as the device.
Thanks for any help you might provide. -- GR