This paper introduces the method of using WINDOWSAPI to play PCM audio, which is similar to the principle of using WINDOWSAPI to obtain recording audio in the previous article, where the specific function and structure parameters are not detailed, the same parts are omitted, and only the main functional part code is introduced. As shown below:
1. Waveoutgetnumdevs
2. Waveoutgetdevcaps
3. Waveoutopen
callback function:
void CALLBACK Playcallback (hwaveout hwaveout, UINT umsg, DWORD dwinstance, DWORD dwParam1, DWORD dwParam2);
4. Waveoutprepareheader
5. Waveoutwrite: Start playback immediately after execution, the callback function will be invoked when the current buffer playback completes
Here you need to note:
In order to be able to achieve the continuous playback effect, in the 4th part of the need to prepare two or more than two playback data.
Interested friends can compare the previous article by manually debugging the example described in this article.