MMAPG - CD-XA Device
Reprint Courtesy of International Business Machines Corporation, © International Business Machines Corporation
CD-XA Disc Formats
The CD-XA media driver provides access to devices that support CD-ROM/XA discs. CD-XA (Compact Disc-Extended Architecture) refers to a storage format that accommodates interleaved storage of audio, video and standard file system data. CD-XA data is stored in a file system format on the discs, and playback control is managed by the CD-XA media device in cooperation with the amplifier-mixer device.
CD-XA takes advantage of a special ADPCM audio compression mechanism that not only yields a low data rate but also enables more audio data to be stored on a disc than that allowed by a CD-DA disc. ADPCM (Adaptive Delta Pulse Code Modulation) is an audio compression technique that allows up to a 16 to 1 compression of audio data.
By compressing the audio data (in some cases to 1/16 the size of CD-DA data) it now becomes possible to record multiple audio tracks on a single disc. With CD-XA level C, recorded in stereo, it is possible to interleave 8 different audio tracks on a single disc. With CD-XA level C, recorded in mono, this number climbs to 16 different tracks on a single disc.
The following table summarizes the different compression levels available with CD-XA and compares them to CD-DA.
| Type | Audio | Video | File Sys | Data Rate Per Sec | One Sec of Audio Data | Spec |
|---|---|---|---|---|---|---|
| CD-DA | 16-bit PCM at 44.1 kHz | No | No | 172KB | Stereo: 172KB | Red Book |
| CD-DA+G | 16-bit PCM at 44.1 kHz | 288 x 192 LUT4 | No | 172KB | Stereo: 172KB | Red Book |
| CD-ROM | No | No | Yes | 150KB | N/A | High Sierra, ISO 9660, Yellow Book |
| CD-XA Level B | 4-bit ADPCM at 37.8 kHz | 320 x 200 640 x 480 LUT1, 4 or 8 | Yes | 150KB | Mono: 18.75KB Stereo: 37.5KB | Green Book |
| CD-XA Level C | 4-bit ADPCM at 18.9 kHz | 320 x 200 640 x 480 LUT1, 4 or 8 | Yes | 150KB | Mono: 9.4KB Stereo: 18.75KB | Green Book |
CD-XA Data Types
The CD-XA media device can play four streams of CD-XA data types simultaneously from the same CD-XA file. CD-XA data streams are set up by specifying the following flags with MCI_SET:
| Flag | CD-XA Stream Data Type |
|---|---|
| MCI_CDXA_AUDIO_DEVICE | CD-XA audio channel to an audio adapter. |
| MCI_CDXA_AUDIO_BUFFER | CD-XA audio channel to an audio memory playlist. |
| MCI_CDXA_VIDEO_BUFFER | CD-XA video channel to a video memory playlist. |
| MCI_CDXA_DATA_BUFFER | CD-XA data channel to a data memory playlist. |
In the future IBM may provide the capability of setting up additional streams to more than one audio device, or more than one audio, video, or data buffer playlist.
If a channel contains data of more than one CD-XA data type (data and video), and an MCI_SET is done, only data of the type specified is returned. For example, suppose an MCI_SET message is sent with MCI_CDXA_VIDEO_BUFFER, channel 0, and a playlist specified. Although channel 0 contains sectors of both audio and video, only the video sectors are sent to the memory playlist buffers specified with the MCI_SET. If your application wants to retrieve the audio sectors from channel 0, it must do another MCI_SET, this time specifying MCI_CDXA_AUDIO_BUFFER, channel 0, and a playlist that is different from the one specified for the video data. The audio would then be sent to the playlist specified for MCI_CDXA_AUDIO_BUFFER, and the video sectors would be sent to the playlist specified for MCI_CDXA_VIDEO_BUFFER.
Using the CD-XA Device
When an MCI_OPEN or MCI_LOAD request is made, it is recommended that a drive letter not be included as part of the element name. If a drive letter is specified, it must match the drive letter of the open device; otherwise, the error MCI_FILE_NOT_FOUND is returned.
Setting Up the Primary Stream
The first stream is set up by calling MCI_SET with one of the four target specifications:
- MCI_CDXA_AUDIO_DEVICE
- MCI_CDXA_AUDIO_BUFFER
- MCI_CDXA_VIDEO_BUFFER
- MCI_CDXA_DATA_BUFFER
The first stream to be set up is called the primary stream, because it controls much of the operation of the CD-XA device. When stream control operations are done on the CD-XA media device, they are done to the primary stream. For example, when an MCI_SEEK is done, only the primary stream is seeked. This makes sense because the media is the same for all streams, and seeking one of the streams affects the disc position for all the other streams.
Because the primary stream is the control focus for the entire device, if an MCI_SET is done while the MCI_SET_OFF flag is in effect for the primary stream, the device is stopped. If the MCI_SET is done on a secondary stream, only that secondary stream is stopped.
If an MCI_SET with MCI_SET_ON is not done before an MCI_PLAY, MCI_CUE, or MCI_SEEK is sent, the first audio channel found on the CD-XA file is used as the default and is set up as the primary stream using the MCI_CDXA_AUDIO_DEVICE. It is recommended that an MCI_SET be sent for the primary stream before an MCI_PLAY, MCI_CUE or MCI_SEEK. It is also recommended that MCI_CDXA_AUDIO_DEVICE be used as the primary stream, because seeking and playing with FROM and TO positions specified can only be done on a stream to an audio device. The video, data and audio buffers do not have seek or time capability. When CD-XA data types are streamed to memory playlists, this operation is done as a data transport and does not have a real timing aspect associated with it.
When an MCI_SET with MCI_CDXA_AUDIO_DEVICE is done, the audio quality level is set by the media device, based on the quality level found in the first sector. The audio quality level must be constant within a channel within a single file when streamed to an audio device.
The valid range for audio channels is 0-15. The valid range for video and data channels is 0-31. These ranges are defined by CD-XA specifications. MCIERR_OUTOFRANGE is returned if the channel specified on the MCI_SET is outside the range.
The channel assigned to a secondary target specification can be changed without closing the CD-XA media device. To do this, your application calls MCI_SET with the MCI_SET_OFF flag for that channel and then calls MCI_SET with the MCI_SET_ON flag and the new channel number.
XA Stream Connector
The XA stream connector represents the flow of XA ADPCM audio from the CD-XA device to its associated amplifier-mixer (ampmix) device. During playback, the CD-XA device sends audio information from a CD-ROM/XA disc to the ampmix device for subsequent conversion into audio that can be heard through conventional speakers or headphones.
Although volume control is provided by the CD-XA device, the device actually uses the services provided by the ampmix device to modify the perceived volume level. If other advanced audio-shaping features are required, the application can retrieve the device ID of the ampmix device using the MCI_CONNECTION message.
Changing the Disc
If the user ejects a disc while the CD-XA device is playing, the device is stopped. When the CD-XA device detects that the disc has been changed and a file was opened on the previous disc, it closes the current CD-XA file and resets to the default state of the device. Following the reset, the CD-XA device returns MCIERR_MEDIA_CHANGED on the first command following detection of the disc change.
To avoid the interruption of play by the ejection of the disc, the application can disable a manual eject with an MCI_SET command before beginning playback.
CD-XA Command Messages
| Message | Description |
|---|---|
| MCI_CLOSE | Closes the CD-XA device. |
| MCI_CONNECTOR | Enables or disables a connector, queries its state or identifies its type. |
| MCI_CUE | Cues the device for minimum delay in playback. |
| MCI_GETDEVCAPS | Gets device capabilities. |
| MCI_INFO | Fills a buffer with: Product name/model, Serial number (UPC), and filename. |
| MCI_LOAD | Loads a data element into the CD-XA device. |
| MCI_OPEN | Initializes the CD-XA device. |
| MCI_PAUSE | Suspends the current playback action. |
| MCI_PLAY | Starts playing audio data from the device element. Can specify start/stop positions. |
| MCI_RESUME | Resumes playing from a paused state. |
| MCI_SEEK | Moves to the specified position in the device element. |
| MCI_SET | Sets audio attributes: channel identification, volume, audio output, door control, and time format. |
| MCI_SET_CUEPOINT | Sets a cue point. |
| MCI_SET_POSITION_ADVISE | Sets a position change notification request. |
| MCI_SET_SYNC_OFFSET | Sets a synchronization offset. |
| MCI_STATUS | Receives status on items: volume, media presence, mode, position, and channel destination. |
| MCI_STOP | Stops playing the CD-XA device. |