waveOutOpen
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: waveOutOpen

  1. #1
    Join Date
    Apr 2005
    Posts
    1,734

    waveOutOpen

    I am working on codac application in Windows 7. Now somewhere in the middle this application calls this "waveOutOpen" function. But function is generating this MMSYSERR_BADDEVICEID error. In my PC no speaker is attached. The inbuilt speaker is not working. So the volume bar shows cross. But when I attach a headphone in the jack the Cross gets removed from the volumebar, that means that sound drivers are installed. Can someone tell me why this error is coming?

    Code:
    mr = waveOutOpen((LPHWAVEOUT)&m_hWaveOut,WAVE_MAPPER,(tWAVEFORMATEX*)&m_wavFmt,0L,0L,0L);
    
    //if(mr != MMSYSERR_NOERROR)
    if(mr == MMSYSERR_BADDEVICEID)
    {
    	LPVOID lpMsgBuf;
    	FormatMessage( 
    		FORMAT_MESSAGE_ALLOCATE_BUFFER | 
    		FORMAT_MESSAGE_FROM_SYSTEM | 
    		FORMAT_MESSAGE_IGNORE_INSERTS,
    		NULL,
    		GetLastError(),
    		0, // Default language
    		(LPTSTR) &lpMsgBuf,
    		0,
    		NULL 
    	);
    
    	MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
    	return FALSE;
    	/*AfxMessageBox("Sound device open error !");
    	return FALSE;*/
    }
    Although it is strange that in GetLastError it says operation completed successfully

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,291

    Re: waveOutOpen

    Quote Originally Posted by maverick786us View Post
    I am working on codac application in Windows 7. Now somewhere in the middle this application calls this "waveOutOpen" function. But function is generating this MMSYSERR_BADDEVICEID error.
    ...
    Although it is strange that in GetLastError it says operation completed successfully
    Where did you read that GetLastError has anything to do with waveOutOpen function?
    It has nothing!
    waveOutOpen itself returns you the error code as it very clear states in the docs:
    waveOutOpen
    ...
    Return Values
    Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.
    ...
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center