IDirectSound::DuplicateSoundBuffer

HRESULT DuplicateSoundBuffer(

LPDIRECTSOUNDBUFFER lpDsbOriginal,

LPLPDIRECTSOUNDBUFFER lplpDsbDuplicate);

Creates a new DirectSoundBuffer object that uses the same buffer memory as the original object.

·Returns DS_OK if successful, or one of the following error values otherwise:

DSERR_ALLOCATED

DSERR_INVALIDCALL

DSERR_INVALIDPARAM

DSERR_OUTOFMEMORY

DSERR_UNINITIALIZED

lpDsbOriginal

Address of the DirectSoundBuffer object to be duplicated.

lplpDsbDuplicate

Address of a pointer to the new DirectSoundBuffer object.

The new object can be used just like the original.

Initially, the duplicate buffer will have the same parameters as the original buffer. However, the application can change the parameters of each buffer independently, and each can be played or stopped without affecting the other.

If data in the buffer is changed through one object, the change will be reflected in the other object because the buffer memory is shared.

The buffer memory will be released when the last object referencing it is released.