Prerolling a stream allows the source stream handlers to start and fill the buffers. An application can then start the streams for better real-time response and initial synchronization of streams. This is accomplished by the SpiStartStream function with the SPI_START_PREROLL flag.
However, if a stream is already paused (STOP_PAUSED), the stream is already cued so there is no need to call SpiStartStream to refill the buffers. The following example illustrates how to check to see if a stream is in a paused state.
/************************************
* If the stream is paused, there is no
* sense in cueing it since the buffers
* are full anyway
**************************************/
if ( STRMSTATE == MCI_PAUSE ||
STRMSTATE == STOP_PAUSED )
{
/***********************************************
** If the stream is going the right way
** then we have the ability to avoid the cue
** since the buffers have been filled up before
** we did the pause
**********************************************/
if ( AMPMIX.ulOperation == OPERATION_RECORD &&
fCueInput )
{
ulpInstance->ulCreateFlag = PREROLL_STATE;
STRMSTATE = CUERECD_STATE;
return ( MCIERR_SUCCESS );
}
/*************************************************
* If the current stream is cued for playback and
* we have a cue_output request, our work is done
**************************************************/
else if ( AMPMIX.ulOperation == OPERATION_PLAY &&
fCueOutput )
{
ulpInstance->ulCreateFlag = PREROLL_STATE;
STRMSTATE = CUEPLAY_STATE;
return ( MCIERR_SUCCESS );
}
} /* If the stream may be in cue state */