我运行以下代码:
void SoundOut()
{
HWAVEOUT wo;
WAVEHDR whdr;
whdr.dwBufferLength = std::vector<SampleType>::size() * m_format.nBlockAlign;
whdr.lpData = reinterpret_cast<LPSTR>(&(std::vector<SampleType>::front()));
whdr.dwFlags = 0;
cout << "waveOpen result " << waveOutOpen(&wo, WAVE_MAPPER, &m_format, 0, 0, CALLBACK_NULL) << endl;;
cout << "waveOutPrepareHeader" << waveOutPrepareHeader(wo, &whdr, sizeof(WAVEHDR)) << endl;;
cout << "waveOutWrite" << waveOutWrite(wo, &whdr, sizeof(WAVEHDR)) << endl;;
cout << "waveOutUnprepareHeader" << waveOutUnprepareHeader(wo, &whdr, sizeof(WAVEHDR)) << endl;;
cout << "waveOutClose" << waveOutClose(wo) << endl;;
};
标准输出如下所示:
waveOpen result 0
waveOutPrepareHeader 0
waveOutWrite 0
waveOutUnprepareHeader 33
waveOutClose 33
根据 SOUNDWIN.H 文件,代码 33 表示 WAVERR_STILLPLAYING。但是没有听到任何声音,waveOutWrite 立即返回(将 88000 个样本写入声卡)。建议这个立即返回意味着代码 33,但是为什么 waveOutWrite 立即返回并且什么也没听到?
通常,为什么 waveOutWrite 成功完成并且没有任何声音?
去哪里看?