IDirectMusicPort::SetDirectSound

The IDirectMusicPort::SetDirectSound method is used to override the default DirectSound object or buffer, or both, to which a port's wave data is streamed. It is also used to disconnect the port from DirectSound.

HRESULT SetDirectSound(
  LPDIRECTSOUND pDirectSound, 
  LPDIRECTSOUNDBUFFER pDirectSoundBuffer
);
 

Parameters

pDirectSound
IDirectSound interface of the DirectSound object to which the port is to be connected, or NULL to disconnect and release the existing DirectSound object.
pDirectSoundBuffer
IDirectSoundBuffer interface to connect the port to. This value can be NULL.

Return Values

If the method succeeds, the return value is S_OK.

If it fails, the method may return one of the following error values:

DMUS_E_ALREADY_ACTIVATED
E_INVALIDARG

Remarks

When the port is activated, the primary DirectSound buffer will be upgraded, if necessary, to support the sample rate and channel information for this port (specified in the DMUS_PORTPARAMS structure passed to IDirectMusic::CreatePort).

The buffer pointed to by pDirectSoundBuffer must be a secondary streaming buffer with a format that matches the sample rate and channel information for this port. If this parameter is NULL, then an appropriate IDirectSoundBuffer instance will be created internally.

Neither the IDirectSound nor the IDirectSoundBuffer may be changed once the port has been activated.

QuickInfo

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in dmusicc.h.

See Also

IDirectMusicPort::Activate, IDirectMusicPort::GetFormat, Integrating DirectMusic and DirectSound