CompuServe Thread

waveOutOpen && MM_WOM_x

1 messages in this thread
#30259From: Timothy A. DonnellyJul 8, 1994 7:48 AM
Vhanks for responding. >What window handle am I passing. (Frame, View, Derived) I am deriving a class directly from CWND and attempting to create a hidden child window of the Frame to handle the callbacks. This is the code I am using to Create the window and initialize the Callback process. By the way, I don't get the MM_WOM_OPEN either, even though the sound buffer plays properly via the waveWrite!!! BOOL CAudio::Init(CFile* bufFile, LPPCMWAVEFORMAT lpWFormat) { lpFile = bufFile; CRect r(0,0,0,0); if (!Create(AfxRegisterWndClass(0), "Audio", WS_CHILD, r, AfxGetMainWnd(), 1)) return FALSE; lpPCMWFormat = (LPPCMWAVEFORMAT) GlobalAllocPtr(GHND | GMEM_SHARE, sizeof(PCMWAVEFORMAT)); /*************************** copy waveform format data to a GMEM_SHAREd data block. The MM functions require Global Data tagged as GMEM_SHARE and the incoming parm could be local! ****************************/ _fmemcpy(lpPCMWFormat, lpWFormat, sizeof(PCMWAVEFORMAT)); /*************************** make sure we can play this format on this system **************************/ if (waveOutOpen(NULL, WAVE_MAPPER, (LPWAVEFORMAT) lpPCMWFormat, NULL, NULL, WAVE_FORMAT_QUERY) == 0) { //> zero is error code //OK open it for real if (waveOutOpen((LPHWAVEOUT) &hWaveOut, WAVE_MAPPER, (LPWAVEFORMAT) lpPCMWFormat, (UINT) m_hWnd, 0L, CALLBACK_WINDOW) == 0) { //OK, we can play it dwMaxData = bufFile->GetLength(); //get max data bufFile->SeekToBegin(); //Fill Data Buffers lpBuf1 = (LPBYTE) GlobalAllocPtr(GHND | GMEM_SHARE, AUDIO_BUF_SIZE); Buf1Len = FillAudioBuffer(lpBuf1, AUDIO_BUF_SIZE); if (Buf1Len < dwMaxData) { lpBuf2 = (LPBYTE) GlobalAllocPtr(GHND | GMEM_SHARE, AUDIO_BUF_SIZE); Buf2Len = FillAudioBuffer(lpBuf2, AUDIO_BUF_SIZE); } //make a WHeader block bDone = FALSE; lpWHeader = (LPWAVEHDR) GlobalAllocPtr(GHND | GMEM_SHARE, sizeof(WAVEHDR)); lpWHeader->lpData = (LPSTR) lpBuf1; lpWHeader->dwBufferLength = Buf1Len; lpWHeader->dwFlags = 0L; lpWHeader->dwLoops = 0L; waveOutPrepareHeader(hWaveOut, lpWHeader, sizeof(WAVEHDR)); if (waveOutWrite(hWaveOut, lpWHeader, sizeof(WAVEHDR))) bDone = TRUE; else return TRUE; } } return FALSE; } BEGIN_MESSAGE_MAP(CAudio, CWnd) //{{AFX_MSG_MAP(CAudio) //}}A