# NewDataStream

Creates a data stream.

### Synopsis

`int32 NewDataStream (DSStreamCBPtr *pCtx, void* bufferListPtr, long bufferSize, long deltaPriority, long numSubsMsgs)`

### Description

Creates a new stream thread. The DataStreamer environment must be initialized with `InitDataStreaming()` before a new stream thread can be created.

The task priority of the stream thread is calculated in relation to the priority of its parent task. If `deltaPriority` is set to zero, the thread has the same priority as its parent task.

### Arguments

`pCtx`
  Pointer to the location to which the new stream context pointer should be returned.

`bufferListPtr`
  Pointer to a list of buffers the data stream process should use.

`bufferSize`
  Size of each buffer in the list.

`deltaPriority`
  Increase or decrease in task priority of the stream thread.

`numSubsMsgs`
  Number of subscriber messages allocated for the new stream thread.

### Return Value

Value
  Error Condition

(Value of `creatorStatus` field in context block of new stream thread)

0
  Could not allocate stack memory for new stream thread

`kDSNoMemErr`
  Could not allocate memory for the stream context

`kDSNoSignalErr`
  Could not allocate signal for thread initialization

`kDSSignalErr`
  Received incorrect initialization signal

(Portfolio error code)
  `CreateItem()` failed to create an item for the new stream thread

### Associated Files

DataStream.h

### See Also

`InitDataStreaming`