Platform SDK: DirectX

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
Address of the 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
Address of the IDirectSoundBuffer interface to connect the port to. This value can be NULL.

Return Values

If the method succeeds, the return value is S_OK or DMUS_S_NOBUFFERCONTROL. See Remarks.

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

DMUS_E_ALREADY_ACTIVATED
E_INVALIDARG

Remarks

If a valid pointer is passed in pDirectSoundBuffer, the method returns DMUS_S_NOBUFFERCONTROL if control changes in the buffer such as pan and volume do not affect DirectMusic playback. This affects only WDM ports.

When the port is activated, the primary DirectSound buffer is 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, an appropriate IDirectSoundBuffer instance is created internally.

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

Requirements

  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