Allowing for preroll delay

Preroll delay is the time lapse before a TPlayer can start playback or recording. This delay might be the result of a device getting up to speed, filling a buffer in RAM from a file on disk, or performing a seek operation on a sequential device. Instances of classes derived from TPlayer can return a time value that indicates the worst-case preroll delay that can occur. You can use this value to adjust synchronization with other players or time sources.

For example, if multiple player objects are synchronized to the same external clock, you must take their preroll delays into account to ensure that output from all of the players is available simultaneously. To allow for the preroll delay:

  1. Determine the maximum preroll time of all of the players.
  2. Set the controlling clock back by that amount of time.
All of the media objects will be ready to generate output after the maximum preroll time has elapsed on the controlling clock.

      TSyncableClock controller;
      // Make sure things do not play or preroll until start is called
      controller.Stop(); 
      // Synchronize the players to the external clock, controller.
      mediaPlayer1.SyncTo(controller); 
      mediaPlayer2.SyncTo(controller);
      
      //Find the largest preroll time of all the media objects.
      TTime maxPreroll;
      TTime nextPreroll;
      mediaPlayer1.GetPreroll(maxPreroll);
      mediaPlayer2.GetPreroll(nextPreroll);
      if (nextPreroll > maxPreroll) maxPreroll = nextPreroll;
      
      //Set the controller to the largest preroll
      controller.SetTime(- maxPreroll);
      
      //Start the playback
      mediaPlayer1.Play();
      mediaPlayer2.Play();
      controller.Start();

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker