locked
waveoutopen crashes on 64 bit system RRS feed

  • Question

  • Hello There,

    I am using winmm library for audio output. but in windows 7 64 bit system my application is crashes on waveoutopen api. How to manage this api with 32 and 64bit?

    Thanks and Regards.

    • Moved by Helen Zhao Friday, March 16, 2012 6:39 AM (From:Visual C++ General)
    Wednesday, March 14, 2012 1:12 PM

All replies

  • There are 2 winmm libraries. On W7 x64 the 32bit version should be in "C:\Windows\SysWOW64", the 64bit version should be in "C:\Windows\System32".
    Wednesday, March 14, 2012 1:20 PM
  • Hello Roosens,

    I got that there are individual directories according to bits. The answer I am looking for is if there is any way to use same code for both bitrate systems. Another thing is, I have solved the issue by passing NULL, NULL, CALLBACK_NULL as last three arguments of waveOutOpen api. And this is not crashing my app in 64 bit system. In my case, some how, I do not need to use callback so this change is fine for me. but what if I need to use the callback function. Do I need to use winmm from SysWOW64? Is this the only way to handle waveOutOpen?

    Thanks and Regards.

    Thursday, March 15, 2012 8:59 AM
  • Hello Sam

    I suggest you to use:
    1 Compiled for x86
     1.1 Windows x86: "C:\Windows\System32"
     1.2 Windows x64: 
    "C:\Windows\SysWOW64"
    2 Compiled for x64
     2.1 Windows x86: won't work
     2.2 Windows x86: 
    "C:\Windows\System32"

    Thursday, March 15, 2012 9:46 AM
  • Hello Roosens

    i got the same problem. I use vb2005. I have the following declaration:

    Private Declare Ansi Function waveOutOpen Lib "winmm.dll" (ByRef hWaveOut As IntPtr, ByVal uDeviceID As Integer, ByVal format() As Byte, ByVal dwCallback As WaveDelegate, ByRef fPlaying As Integer, ByVal dwFlags As Integer) As Integer

    I compile my source for x86. So how can I switch between the two dll (in SysWOW64 and in System32) in my code if my application run on a x86 or a x64 system?

    Thank you and Regards

    Thursday, March 15, 2012 9:55 AM
  • Hello Ciambarlan

    You could use http://msdn.microsoft.com/en-us/library/system.environment.is64bitoperatingsystem.aspx
    t
    o load from a different location...

    Thursday, March 15, 2012 10:25 AM
  • Thank you Roosens,

    but I need to know how I can load the right winmm.dll in my declaration. I try to specify the complete path of the winmm.dll, but it doesn't work...

    Thank you very much

    Regards

    Thursday, March 15, 2012 11:31 AM
  • I don't know vb.NET. I would suspect that the CLR selects the correct probing path for you, but if you have that issue it doesn't.
    This may help do load the specific directory from path: http://stackoverflow.com/questions/530143/can-net-pinvoke-dynamically-load-a-native-dll-from-a-user-specified-directory
    Thursday, March 15, 2012 1:21 PM
  • Hi,

    According to the descriptions of the issue, I'd like to move this thread to "Media Foundation Development for Windows Desktop Forum" for better support.

    Thanks for your understanding.
    Helen Zhao


    Helen Zhao [MSFT]
    MSDN Community Support | Feedback to us


    • Edited by Helen Zhao Friday, March 16, 2012 6:38 AM
    Friday, March 16, 2012 3:16 AM
  • The CLR *does* select the right DLL when you don't specify a path.  Unless you only intend to run this program on your specific computer, specifying a full path is not a good idea.  Windows isn't always installed in "c:\windows".

    I use the definitions from http://windowsmedianet.sourceforge.net/ and it works correctly for me in x64.

    Friday, March 16, 2012 6:57 AM
  • Hello Roosens,

    I got that there are individual directories according to bits. The answer I am looking for is if there is any way to use same code for both bitrate systems. Another thing is, I have solved the issue by passing NULL, NULL, CALLBACK_NULL as last three arguments of waveOutOpen api. And this is not crashing my app in 64 bit system. In my case, some how, I do not need to use callback so this change is fine for me. but what if I need to use the callback function. Do I need to use winmm from SysWOW64? Is this the only way to handle waveOutOpen?

    Thanks and Regards.

    I have this exact problem and unfortunately I cannot give up on using the CALLBACK like sam18. Is there a solution for this yet.

    I am using Windows 7 Enterprise SP1 64 bit. 

    Monday, September 16, 2013 6:31 AM
  • I've found the problem. It was in our own code

    mmRes = waveInOpen(&m_hwi, m_nDeviceID, &wfx, (DWORD)waveInProc, (DWORD)this, CALLBACK_FUNCTION);

    Here 4th and 5th parameters were expected as DWORD_PTR but here they were being cast to DWORD. Since sizeof(DWORD) is 4 and sizeof(DWORD_PTR) is 8 on an 64 bit architecture this led to truncation and hence the crash.

    So the correct code is:

    mmRes = waveInOpen(&m_hwi, m_nDeviceID, &wfx, (DWORD_PTR)waveInProc, (DWORD_PTR)this, CALLBACK_FUNCTION);
    

    • Proposed as answer by nazilliefesi Monday, September 16, 2013 10:31 AM
    Monday, September 16, 2013 10:31 AM
  • DWORD_PTR solves my problem.

    Thanks!

    George

    Saturday, October 25, 2014 5:30 AM