80.3.7 Stopping, Pausing, and Restarting Playback

While a waveform is playing, you can stop or pause playback. Once playback has been paused, you can restart it. Windows provides the following functions for controlling waveform playback:

Function Description

waveOutPause Pauses playback on a waveform output device.
waveOutReset Stops playback on a waveform output device and marks all pending data blocks as done.
waveOutRestart Resumes playback on a paused waveform output device.

Use waveOutPause to pause a waveform device that is currently playing. To resume playback on a paused device, use waveOutRestart. These functions take a single parameter: the waveform output device handle returned by waveOutOpen. Pausing a waveform device might not be instantaneous—the driver can finish playing the current block before pausing playback.

Generally, as soon as the first waveform data block is sent using waveOutWrite, the waveform device begins playing. If you don't want the waveform to start playing immediately, call waveOutPause before calling waveOutWrite. Then, when you want to begin playing the waveform, call waveOutRestart.

To stop a waveform from playing, use waveOutReset. This function differs from waveOutPause in that it also marks all pending data blocks as being done. You can't restart a device that has been stopped with waveOutReset by using waveOutRestart—you must use waveOutWrite to send the first data block to resume playback on the device.