Copyright (c) Hyperion Entertainment and contributors.
RealTime Library
Realtime.library provides a convenient, higher-level interface to underlying hardware timers that is easy to use. Realtime.library also provides for the distribution of timing pulses to an unlimited number of client applications on a priority basis, thus supporting multitasking in the most robust manner possible.
Conductors and Playerlnfos
The realtime.library uses the Conductor structure to manage timing. There can be any number of Conductor structures, each of which represents a separate and independent timing context (i.e., a group of applications that wants to be synced together).
Each Conductor can have one or more client applications. A second structure called a PlayerInfo, is set up by cach client application that wants to get timing information from the Conductor. There is typically one Playerlnfo for each task that wants to get timing information (a task could have more than one but this would be unusual).
Both the Conductor and Playerlnfo structures follow the conventions of Release 2. You never create these structures by allocating and initializing them yourself. The system provides the functions to do this for you. Also the structures are read-only. To change the fields within these structures, use the system-provided functions and tags.
An application will usually create a single PlayerInfo structure and then attach it to a Conductor. If the Conductor does not yet exist, it will be created by the system. To create a PlayerInfo structure you call CreatePlayerO:
struct PlayerInfo *pi = IRealTime->CreatePlayer(Tag tag, ...);
This call takes a list of tag items that describe the attributes of the Playerlnfo structure you want to create. (A complete list of all the tags available can be found in the Autodoc for SetPlayerAttrs().) It returns a pointer to the PlayerInfo. Here’s a fragment showing how to set up a PlayerInfo:
struct PlayerInfo *pPlayerInfo = IRealTime->CreatePlayer( PLAYER_Name, "My_player", PLAYER_Conductor, "My_conductor", TAG_END); if (pPlayerInfo != NULL ) { // Your real-time application goes here... IRealTime->DeletePlayer(pPlayerInfo); }
In the code above, a PlayerInfo will be created with the name of "My_player". It will be attached to the Conductor structure named "My_conductor". If a Conductor structure named "My_conductor" does not already exist, the system will create one. Other applications could also attach their PlayerInfos to "My_conductor".
When your application finishes, you should delete any PlayerInfos you created by calling DeletePlayer(). The Conductor will be automatically deleted by the system (however this won’t happen until *all* the PlayerInfos attached to a Conductor are deleted).
Once you have a PlayerInfo and Conductor set up, you can obtain timing pulses for your application. Timing pulses come from underlying timer chips and are passed to your application through the Conductor.