Looping Playback

You can control looping playback on a waveform-audio output device with the WAVEHDR structure passed into waveOutWrite.

    To loop playback

  1. Set the WHDR_BEGINLOOP flag in the dwFlags member of the WAVEHDR structure.

    This flag defines the beginning data block of a message loop.

  2. Set the number of loops in the dwLoops member of the same WAVEHDR structure.
  3. Pass this, and the remaining data blocks, to waveOutWrite.
  4. Pass the final data block to waveOutWrite with the WHDR_ENDLOOP flag set in the WAVEHDR structure.

    This causes your device to begin looping.

  5. Use waveOutBreakLoop to break out of the loop prematurely.

Note Loop a single block by setting the WHDR_BEGINLOOP and WHDR_ENDLOOP flags in the same WAVEHDR structure.