Japanese
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. They do not need to be physically contiguous sectors.

(2)Stream group
By interleaving and recording multiple streams, like audio and video, you can synchronize and access related streams. A collection of related streams like this is called a stream group.

4.2 Stream range

The range of a stream is specified in two ways:

(1) Stream open by file
You can open a stream by specifying a file identifier (STM_OpenFid). In this case, the stream range is from the start frame address of the file to the end frame address.
The ending frame address is actually calculated from the starting frame address and the total number of sectors in the file. In the case of interleaved files, calculations are made assuming that they are recorded with a constant interleaving factor (fixed interleaving).

(2) Open stream by directly specifying frame address range
Users can open a stream by directly specifying the frame address range of the stream (STM_OpenFrange). In this case, the specified range becomes the stream range.
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

An image of stream access is shown below.

Figure 4.2 Overview of stream access

(a) Start playing
Among the streams belonging to the stream group, playback starts from stream A whose start FAD is furthest forward.

(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
When you finish playing the last stream (stream C), move the pickup to the start position of the loop start stream (default is the forwardmost stream) and start playing. The number of times the pickup is moved to the loop start stream in this way is called the loop number.

(d) Aperture, buffer section
Buffer partitions are allocated one-to-one with streams.
Sector data that meets the stream key conditions is stored in the buffer section. Sector data that does not meet the conditions is sent to the next aperture.

(e) Data transfer
When the server function is called, it compares the transfer start position set for each stream with the current playback position, and if there is a stream that has reached the transfer start position, it attempts to transfer data to the specified transfer area once. .
If the transfer register or DMA is in use during a transfer, the server function will end at that point and the next time it will try to transfer data from the next 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 a transfer area or transfer function, the CD buffer data can be managed by the application program itself.

(h) Transfer gate
Stream flow can be temporarily stopped and restarted by opening and closing transfer gates. If the transfer gate is closed, the stream data is 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 stream is called branch playback. Branch playback can be achieved by setting the loop stream as the first stream (STM_SetLoop) and specifying that it will not be reloaded during loop playback (STM_OpenFid, STM_OpenFrange).

Figure 4.3 Branch playback

In this case as well, the stream is read in order starting from the previous stream, but after reading the last stream, it starts reading the most forward stream that has not been read yet. In Figure 4.3, if you open B while loading A, C while loading B, and D while loading C, you can read in the order ABCD. Even if the playback ranges of B and D overlap, the data of B will not be read.
In Figure 4.3, the time required for the pickup to move from stream B to stream C is required. To minimize this kind of wasted time, the streams should be played 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 resident streams, you can make the same data resident in the CD buffer in advance, instead of reading it from the CD over and over again.

(1) Reading resident stream
Files specified as resident streams are read into the CD buffer only once. It will not be read if you return to the loop start stream and repeat the access. Therefore, the first time the stream is accessed, playback must begin before the file range of the resident stream.
When opening a resident stream in the middle of accessing a stream, be careful because if the playback position exceeds the range of the resident stream, it will not be read into the CD buffer.

Figure 4.4 Loading a resident stream

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

(3)Using SIMM files and SCSI files (when debugging)
For SIMM files and SCSI files, they can only be used as resident streams.
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 each time it is accessed.

4.6 Precautions when adding or changing settings while playing a CD

The stream system allows you to dynamically change settings such as the stream key while playing a CD. However, after requesting processing to 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) Functions that require a delay before the settings become effective
Table 4.2 Functions with delays
 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
 Closing the stream
 STM_Close
 Stream key settings
 STM_SetKey
 Connection of aperture and CD buffer compartment
 STM_ConnectCdbuf


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