Why would waveOutWrite() cause an exception in the debug heap?

前端 未结 9 1155
甜味超标
甜味超标 2021-02-05 16:51

While researching this issue, I found multiple mentions of the following scenario online, invariably as unanswered questions on programming forums. I hope that posting this here

9条回答
  •  梦毁少年i
    2021-02-05 17:30

    I solved the problem by polling the sound playback and delays:

    WAVEHDR header = { buffer, sizeof(buffer), 0, 0, 0, 0, 0, 0 };
    waveOutPrepareHeader(hWaveOut, &header, sizeof(WAVEHDR));
    waveOutWrite(hWaveOut, &header, sizeof(WAVEHDR));
    /*
    * wait a while for the block to play then start trying
    * to unprepare the header. this will fail until the block has
    * played.
    */
    while (waveOutUnprepareHeader(hWaveOut,&header,sizeof(WAVEHDR)) == WAVERR_STILLPLAYING) 
    Sleep(100);
    waveOutClose(hWaveOut);
    

    Playing Audio in Windows using waveOut Interface

提交回复
热议问题