PROGRAMMER'S GUIDEStream system library
BackForward
Stream system library

4. Overview of stream access


4.1 Streams and stream groups

(1) Stream
A group of sectors that have the same subheader (FN, CN, SM, CI) and are basically processed in the same way is called a stream. It does not have to be physically contiguous sectors.

(2) Stream group
By interleaving and recording multiple streams, such as audio and video, related streams can be accessed in synchronization. A set of related streams in this way is called a stream group.

4.2 Stream range

The range of the stream is defined in the following two ways.

(1) Stream open by file
You can open the stream by specifying the file identifier (STM_OpenFid). In this case, the range of the stream is from the start frame address of the file to the end frame address.
The end frame address is actually calculated from the start frame address and the total number of sectors in the file. If the file is interleaved, it is calculated as if it was recorded with a fixed interleaving factor (fixed interleaving).

(2) Stream open by directly specifying the frame address range
The user can open the stream by directly specifying the frame address range of the stream (STM_OpenFrange). In this case, the specified range becomes the stream range as it is.
The frame address range specifies the first frame address and the number of physical sectors.

4.3 Stream access procedure

Follow the steps below to access the stream.

Figure 4.1 Stream access procedure

The access image of the stream is shown below.

Figure 4.2 Overview of stream access

(a) Start playback
Of the streams belonging to the stream group, playback starts from stream A, which has the start FAD at the front.

(b) seek
When there are no more streams to play, move the pickup to the start position of the next stream (stream B) and play it.

(c) Loop
After playing the final stream (stream C), move the pickup to the start position of the loop start stream (default is the frontmost stream) and play it. The number of times the pickup is moved to the loop start stream in this way is called the number of loops.

(d) Aperture, buffer partition
The buffer partition is allocated one-to-one with the stream.
Sector data that meets the stream key conditions is stored in the buffer partition. Sector data that does not meet the conditions will be sent to the next aperture.

(e) Data transfer
When the server function is called, the transfer start position set for each stream is compared with the current playback position, and if there is a stream that has reached the transfer start position, data transfer is attempted once to the specified transfer area. ..
If the transfer register or DMA becomes in use during the transfer, the server function will be terminated at that point, and the next time, data transfer will be attempted from the following stream.

(f) User registration transfer function
By registering a transfer function, you can transfer data while processing it, such as decompressing compressed data.

(g) User-specific buffer management
If you do not set the transfer area or transfer function, the application program itself can manage the data in the CD buffer.

(h) Transfer gate
You can temporarily stop or resume the stream flow by opening and closing the transfer gate. If the transfer gate is closed, the stream data will be stored in the CD buffer.

4.4 Branch playback

A playback method that allows you to know which stream to play next while playing a certain stream is called branch playback. Branch playback can be realized by setting the loop stream as the first stream (STM_SetLoop) and specifying not to reload during loop playback (STM_OpenFid, STM_OpenFrange).

Figure 4.3 Branch playback

In this case as well, the previous stream is read in order, but when the final stream is finished reading, the frontmost, unread stream starts to be read. In Figure 4.3, you can read ABCD in that order by opening B while reading A, C while reading B, and D while reading C. Even if the playback ranges overlap like B and D, the data of B will not be read.
For Figure 4.3, we need some time for the pickup to move from stream B to stream C. To avoid such wasted time as much as possible, the stream playback order should be arranged from the front to the back of the disc.

4.5 Resident stream

If you want to retrieve a relatively short stream repeatedly as needed, you can open it as a resident stream (STM_OpenResi). By using a resident stream, the same data can be made resident in the CD buffer in advance instead of being read from the CD many times.

(1) Reading the resident stream
The file specified as the resident stream is read into the CD buffer only once. It is not read when returning to the loop start stream and repeating access. Therefore, the first time a stream is accessed, playback must start short of the range of files in the resident stream.
Note that if you open a resident stream while accessing the stream, it will not be read into the CD buffer if the playback position exceeds the range of the resident stream.

Figure 4.4 Reading a resident stream

(2) Transfer start frame address of the resident stream
Once stored in the CD buffer as a resident stream, it can be transferred at any time. This timing is performed by setting the transfer start frame address for the resident stream (STM_SetTrFad).
The playback position advances according to normal stream access, and when the set transfer start frame address is exceeded, the resident stream data is transferred. Also, for resident streams, the stream data is not deleted from the CD buffer even after it has been transferred to the host area.

(3) Use of SIMM file and SCSI file (during debugging)
For SIMM files and SCSI files, it can only be used as a resident stream.
If the specified file is a SIMM file or a SCSI file, it will not be resident in the CD buffer and will be read for each access.

4.6 Precautions when adding / changing settings during CD playback

The stream system allows you to dynamically change settings such as the stream key while playing a CD. However, after requesting processing to the CD block, there will be a certain delay before the settings become effective.
Therefore, the following function must be issued at least 10 sectors before the target position.

Figure 4.5 Timing of function issuance

(1) A function with a delay before the setting becomes effective
Table 4.2 Delayed Functions
 function
 Function name
 Opening a stream by file identifier
 STM_OpenFid
 Opening a stream by playback range
 STM_OpenFrange
 Opening a resident stream
 STM_OpenResi
 Stream close
 STM_Close
 Stream key settings
 STM_SetKey
 Aperture and CD buffer partition connection
 STM_ConnectCdbuf


BackForward
PROGRAMMER'S GUIDEStream system library
Copyright SEGA ENTERPRISES, LTD., 1997