# DSStopStream

Stops a stream.

### Synopsis

`int32 DSStopStream (Item msgItem, DSRequestMsgPtr reqMsg, DSStreamCBPtr streamCBPtr, unsigned long stopOptions)`

### Description

Sends a message requesting the DataStreamer to stop the specified stream. While the stream is running, the stream thread repeatedly distributes data chunks from its buffers to its subscribers and then refills them with succeeding chunks of stream data.

`DSStopStream()` sets the members of the message data structure required to start the stream. (The message is the `DSRequestMsg` identified by `reqMsg`.) If a message is specified, `DSStopStream()` sends the message and returns immediately. If no message is specified (if `reqMsg` is `NULL`), `DSStopStream()` creates a message, sends it to the DataStreamer, and waits until the message has been received before returning.

### Arguments

`msgItem`
  Item of the request message.

`reqMsg`
  Pointer to the `DSRequestMsg` message that is formatted and sent to the DataStreamer. A value of `NULL` forces creation of an internal `DSRequestMsg` message and synchronous operation.

`streamCBPtr`
  Pointer to the stream context block.

`stopOptions`
  `SOPT_FLUSH` to flush the stream buffers after stopping, otherwise zero.

### Messages

The members of `reqMsg` are set to the following values:

`whatToDo`
  kDSOpStopStream

`msg.getChannel.streamType`

`msg.getChannel.channelNumber`

`msg.getChannel.channelStatusPtr`

### Return Value

Value
  Error Condition

0
  None

These values are returned if the DataStreamer encounters an error while processing the message request:

`kDSInvalidDSRequest`
  Invalid message (whatToDo set to invalid value)

`kDSNoReplyPortErr`
  Could not locate item of the reply port

-1
  Could not locate pointer to msgItem

(Portfolio error code)
  `SendMsg()` or `WaitPort()` failed

The DataStreamer checks the validity of messages only if message checking is enabled when the DataStreamer is compiled (if the `VALIDATE_REQUEST_CODE` symbol is enabled).

See "Error Messages" in the 3DO Portfolio Reference Manual for a listing of error messages returned by `SendMsg()` and `WaitPort()`.

### Associated Files

DataStreamLib.h

### See Also

`DSStartStream`