WinMM库在x64下无法录音

在x86程序中使用WinMM库录制音频没有问题,但是编译成x64程序,录制音频直接崩溃。


解决办法如下:

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);


https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/603f576d-4ba8-4aea-b464-e4c26ce56138/waveoutopen-crashes-on-64-bit-system?forum=mediafoundationdevelopment

你可能感兴趣的:(技术空间)