我正在使用 waveInProc 回调进行音频采样。问题是,当我尝试停止采样并关闭音频设备时,我在回调中没有收到任何消息 - 尝试了 waveInStop、waveInClose、waveInReset。
请建议。10xs,那鸿
HWAVEIN hWaveIn
waveInOpen(&hWaveIn,WAVE_MAPPER,&waveform,(DWORD)waveInProc,0, CALLBACK_FUNCTION);
waveInStart(hWaveIn);
waveInStop(hWaveIn); //OR
waveInClose(hWaveIn); //OR
waveInReset(hWaveIn); //OR
更新:这是代码:
开始:
waveInOpen(&hWaveIn,WAVE_MAPPER,&waveform,(DWORD)waveInProc,0, CALLBACK_FUNCTION);
waveInPrepareHeader(hWaveIn,pWaveHdr1,sizeof(WAVEHDR));
waveInAddBuffer(hWaveIn,pWaveHdr1,sizeof(WAVEHDR));
waveInStart(hWaveIn);
void CALLBACK waveInProc( HWAVEIN hwi, UINT uMsg, DWORD dwInstance,
DWORD dwParam1, DWORD dwParam2 )
{
if (uMsg == WIM_OPEN)
{
return;
}
if (uMsg == WIM_DATA)
{
//process data
waveInAddBuffer(hWaveIn,(PWAVEHDR)dwParam1,sizeof(WAVEHDR));
return;
}
if (uMsg == WIM_CLOSE) //NOT GETTING THIS MSG
{
printf("*****************got WIM_CLOSE\n");
}
}
那么如何停止采样并关闭音频设备呢?
这是代码:开始:
waveInOpen(&hWaveIn,WAVE_MAPPER,&waveform,(DWORD)waveInProc,0, CALLBACK_FUNCTION);
waveInPrepareHeader(hWaveIn,pWaveHdr1,sizeof(WAVEHDR));
waveInAddBuffer(hWaveIn,pWaveHdr1,sizeof(WAVEHDR));
waveInStart(hWaveIn);
void CALLBACK waveInProc( HWAVEIN hwi, UINT uMsg, DWORD dwInstance,
DWORD dwParam1, DWORD dwParam2 )
{
if (uMsg == WIM_OPEN)
{
return;
}
if (uMsg == WIM_DATA)
{
//process data
waveInAddBuffer(hWaveIn,(PWAVEHDR)dwParam1,sizeof(WAVEHDR));
return;
}
if (uMsg == WIM_CLOSE) //NOT GETTING THIS MSG
{
printf("*****************got WIM_CLOSE\n");
}
}
那么如何停止采样并关闭音频设备呢?
10xs,那鸿