Microsoft DirectX 8.1 (Visual Basic)

Buffer Management

The DirectSoundPrimaryBuffer8.GetCaps and DirectSoundSecondaryBuffer8.GetCaps methods retrieve the capabilities of a buffer.

Your application can use the DirectSoundPrimaryBuffer8.GetStatus or DirectSoundSecondaryBuffer8.GetStatus method to determine if the buffer is playing or if it has stopped.

You can use the DirectSoundPrimaryBuffer8.GetFormat or DirectSoundSecondaryBuffer8.GetFormat method to retrieve information about the format of the sound data in the buffer. You also can use the DirectSoundPrimaryBuffer8.SetFormat method to retrieve and set the format of the sound data in the primary buffer.

Note   There is no SetFormat method for DirectSoundSecondaryBuffer8. After a secondary buffer is created, its format is fixed. If you need a secondary buffer that uses another format, you must create a new sound buffer with this format.

Memory for a sound buffer can be lost in certain situations: for example, when buffers are located in sound card memory and another application gains control of the hardware resources. Loss can also occur when an application with the write-primary cooperative level moves to the foreground; in this case, DirectSound makes all other sound buffers lost so that the foreground application can write directly to the primary buffer.

The DSERR_BUFFERLOST error is raised when the DirectSoundSecondaryBuffer8.WriteBuffer or DirectSoundSecondaryBuffer8.Play method is called for a lost buffer. When the application that caused the loss either lowers its cooperative level from write-primary or moves to the background, other applications can attempt to reallocate the buffer memory by calling the DirectSoundSecondaryBuffer8.Restore method. If successful, this method restores the buffer memory and all other settings for the buffer, such as volume and pan settings. However, a restored buffer may not contain valid sound data, so the owning application should rewrite the data to the buffer.