DSClockSync

Synchronizes the DataStreamer clock.

Synopsis

int32 DSClockSync (DSStreamCBPtr streamCBPtr, MemPoolPtr msgPoolPtr, unsigned long nowTime)

Description

Sends a clock synchronization message to all current subscribers to a stream. DSClockSync() defines a subscriber message subMsg containing the new time value, then calls DSSetClock() directly to reset the DataStreamer clock and broadcasts the synchronization message to the subscribers. The broadcast of the synchronization message is asynchronous to the completion of DSClockSync().

DSClockSync() uses the pool of messages specified by msgPoolPtr, allocating a synchronization message for each subscriber to the specified stream.

Clock time in the DataStreamer is measured in standard Portfolio audio clock ticks (the DataStreamer does not change the rate of the audio clock or the duration of audio ticks). Since the DataStreamer does not own the audio clock, however, external tasks can affect the DataStreamer clock by altering the state of the audio clock.

Since the DataStreamer and acquisition threads determine stream positioning and data flushing by the DataStreamer clock, resetting the clock can affect the loading of streamed data chunks adversely. The DataStreamer clock is normally reset only when a new stream is opened. Streams can be started and stopped without requiring the DataStreamer clock to be reset (see DSStartStream() and DSStopStream()).

The Control subscriber usually synchronizes the clock. Any subscriber, however, may set the clock (the audio subscriber normally sets the clock).

Arguments

streamCBPtr
Pointer to the stream context block.
msgPoolPtr
Pointer to a pool of messages.
nowTime
New clock time, measured relative to the start of the stream specified by streamCBPtr.

Messages

The members of
subMsg are set to the following values:

subMsg.whatToDo
kStreamOpSync
subMsg.privatePtr
NULL
subMsg.msg.sync.clock
nowTime

Return Value

Value
Error Condition
0
None
kDSNotRunning
Stream not running
These values are returned if the DataStreamer encounters an error while processing the message request:

kDSNoMsgErr
Could not allocate a synchronization message for each stream subscriber
kDSNoReplyPortErr
Could not locate item of the reply port
(Portfolio error code)
SendMsg() failed
See "Error Messages" in the 3DO Portfolio Reference Manual for a listing of error messages returned by SendMsg().

Associated Files

DataStreamLib.h

See Also

DSSetClock, OwnAudioClock, SendMsg