DirectX SDK

DirectSoundBuffer.Stop

The DirectSoundBuffer.Stop method causes the sound buffer to stop playing.

object.Stop()

Parameters

object
Object expression that resolves to a DirectSoundBuffer object.

Error Codes

If the method fails, an error is raised and Err.Number may be set to one of the following error values:

DSERR_INVALIDPARAM
DSERR_PRIOLEVELNEEDED

Remarks

For secondary sound buffers, DirectSoundBuffer.Stop will set the current position of the buffer to the sample that follows the last sample played. This means that if the DirectSoundBuffer.Play method is called on the buffer, it will continue playing where it left off.

For primary sound buffers, if an application has the DSSCL_WRITEPRIMARY level, this method will stop the buffer and reset the current position to 0 (the beginning of the buffer). This is necessary because the primary buffers on most sound cards can play only from the beginning of the buffer.

However, if DirectSoundBuffer.Stop is called on a primary buffer and the application has a cooperative level other than DSSCL_WRITEPRIMARY, this method simply reverses the effects of DirectSoundBuffer.Play. It configures the primary buffer to stop if no secondary buffers are playing. If other buffers are playing in this or other applications, the primary buffer will not actually stop until they are stopped. This method is useful because playing the primary buffer consumes processing overhead even if the buffer is playing sound data with the amplitude of 0 decibels.

See Also

DirectSoundBuffer, DirectSoundBuffer.Play