Err spStartReading (SPSound *startSound, const char *startMarkerName)
spStartPlaying()
, is a separate call so that starting the actual sound playback may be synchronized to some user event.
Normally this function is called while the player's SP_STATUS_F_READING status flag is cleared (see spGetPlayerStatus()
), in which case it merely begins reading at the specified location. The SP_STATUS_F_READING flag is then set. If the entire sound data to be played fits completely into the buffers, this flag is cleared again before this function returns.
This function can also be called while the SP_STATUS_F_READING flag is set in order to force the playback to a different location without waiting for a marker branch or decision function. This abnormal method of relocating sound playback will almost certainly produce unpleasant sound output, but there may be times when it is necessary. Note that this merely causes reading to begin at a new location. It does not does not flush the spooler. Anything buffered already will continue play.
// error checking omitted for brevity
{
const int32 playersigs = spGetPlayerSignalMask (player);
// read from beginning of one of the sounds
spStartReading (player, sound1, SP_MARKER_NAME_BEGIN);
// could wait for some event to trigger playback here
// begin playback
spStartPlayingVA (player,
AF_TAG_AMPLITUDE, 0x7fff,
TAG_END);
// service player until it's done
while (spGetPlayerStatus(player) & SP_STATUS_F_BUFFER_ACTIVE) {
const int32 sigs = WaitSignal (playersigs);
spService (player, playersigs);
}
}
spStartPlaying
(), spStop(), spService(), spGetPlayerStatus()