Jump to content

MMAPG - Multimedia Logical Devices

From EDM2
Multimedia Application Programming Guide
  1. Introduction
  2. What's New...
  3. Multimedia Application Programming Environment
  4. Media Control Interface
  5. Multimedia Logical Devices
  6. Amplifier-Mixer Device
  7. Waveform Audio Device
  8. Sequencer Device
  9. CD Audio Device
  10. CD-XA Device
  11. Videodisc Device
  12. Digital Video Device
  13. Direct Interface Video Extensions (DIVE)
  14. Captioning
  15. OS/2 Multimedia Controls
  16. Multimedia I/O File Services
  17. Resource Interchange File Format (RIFF) Services
  18. Sample Application Programs
  19. Installing a Program Using MINSTALL
  20. Caption DLL
  21. High-Level Service API
  22. Notices
  23. Glossary

Reprint Courtesy of International Business Machines Corporation, © International Business Machines Corporation OS/2 multimedia represents audio adapters, CD-ROM drives, videodiscs and other real hardware devices as logical media devices that are managed by the Media Device Manager (MDM). Media devices are a logical representation of the function available from either a real hardware device, software emulation in combination with real hardware, or pure software emulation. The actual implementation is not relevant to an application, because the multimedia system provides device independence with the mciSendCommand and mciSendString interfaces.

The following logical devices are currently supported in this release of OS/2. Additional media devices may be available from IBM or from other companies as OS/2 multimedia is completely extensible at all levels.

  • Amplifier mixer
  • Waveform audio
  • MIDI sequencer
  • CD audio
  • CD-XA
  • Videodisc
  • Digital video

Frequently there is a one-to-one correspondence between a real hardware device, such as a CD-ROM drive and its associated media device. Other hardware may be represented as multiple logical devices. For example, a multi-function audio adapter can be represented as waveform audio, MIDI sequencer, and amplifier-mixer media devices.

The following sections describe the function and typical use of each media device, plus the software model presented to the application developer.

Multimedia Information and OS/2 Multimedia Connectors

A connector is a software representation of the physical way in which multimedia data moves from one device to another. Simple examples are the headphone jack on a CD-ROM player, or the speakers jack on an audio adapter. If an audio card has both a speaker and a line OUT jack, it is desirable to let an application choose the destination of the audio, while remaining independent from the actual hardware implementation.

OS/2 multimedia connectors provide this function by allowing an application to query which connectors are supported by a logical device, and manipulate whether or not information is flowing through the connector. The connectors for a logical device can be accessed either by number or by a symbolic connector type. When specifying a symbolic type such as microphone or line IN, a number can also be specified to select the first connector, second connector, and so on, of that specific connector type. The MCI_CONNECTORINFO message can be used to determine which connectors are supported by a device, whereas the MCI_CONNECTOR message can be used to enable, disable, or query the state of a particular connector.

Although connectors are typically associated with the representation of externally visible audio and video jacks on multimedia equipment, another category of connectors can represent the flow of information within a computer. For example, a connector on an audio adapter can be attached to the internal PC speaker. A more subtle example is the flow of digital audio information into an audio adapter. This information could come from a file, system memory, or another device. Connectors of this category are referred to as stream connectors to convey the idea of a logical stream of information flowing from one device to another.

Connector Types

Each connector is defined by specific type or name, so that applications can make requests symbolically instead of using an absolute connector number that is device dependent. If an application specifies only a connector type, then the default connector of that type is selected on the device. Both a type and a number may be specified to select connectors when more than one connector of the same type exists on a device.

The following table describes connector types and typical uses.

Connector Type Name Description
MCI_MIDI_STREAM_CONNECTOR Midi stream Digital input or output for the sequencer device. This information is typically streamed to an amplifier-mixer logical device.
MCI_CD_STREAM_CONNECTOR Cd stream Digital output from a CD-ROM drive capable of reading the CD-DA data directly off the disc. This information is typically streamed to an amplifier-mixer logical device.
MCI_XA_STREAM_CONNECTOR Xa stream The flow of digital audio information from a CD-ROM/XA drive capable of streaming the ADPCM data internally. This information is typically streamed to an amplifier-mixer logical device.
MCI_WAVE_STREAM_CONNECTOR Wave stream Digital input or output for the waveaudio device. This information is typically streamed to an amplifier-mixer logical device.
MCI_AMP_STREAM_CONNECTOR Amp stream The flow of information to an amplifier-mixer device. Typically this information comes from another logical device and can include MIDI, and various kinds of digital audio.
MCI_HEADPHONES_CONNECTOR Headphones The connector on the device labeled for, or typically used, to attach headphones to the device.
MCI_SPEAKERS_CONNECTOR Speakers The connector on the device labeled for, or typically used, to attach speakers to the device.
MCI_MICROPHONE_CONNECTOR Microphone The connector on the device labeled for, or typically used, to attach a microphone to the device.
MCI_LINE_IN_CONNECTOR Line in The connector on the device labeled for, or typically used to provide line level input to the device.
MCI_LINE_OUT_CONNECTOR Line out The connector on the device labeled for, or typically used, to provide line level output from the device.
MCI_VIDEO_IN_CONNECTOR Video in The connector on the device labeled for, or typically used to provide video input to the device.
MCI_VIDEO_OUT_CONNECTOR Video out The connector on the device labeled for, or typically used, to provide video output from the device.
MCI_PHONE_SET_CONNECTOR Phone set The connector on the device labeled for, or typically used, to attach a phone set to the device.
MCI_PHONE_LINE_CONNECTOR Phone line The connector on the device labeled for, or typically used, to attach an external phone line to the device.
MCI_AUDIO_IN_CONNECTOR Audio in The connector on the device labeled for, or typically used, to provide audio input to the device.
MCI_AUDIO_OUT_CONNECTOR Audio out The connector on the device labeled for, or typically used, to provide audio output from the device.
MCI_UNIVERSAL_CONNECTOR Universal A connector on a device which does not fall into any of the other categories. This connector type may be used to access device dependent function. The manufacturer of the device should define the exact use of this connector.

A Connector Example Using the IBM M-Audio Adapter

The following figure illustrates how the capabilities of an audio card might be modeled as an OS/2 amplifier-mixer device using connectors. This example uses the IBM M-Audio Capture and Playback Adapter, however a model can easily be defined for any manufacturer's audio card. The number and type of connectors may vary.

In this particular model, the speakers(1) connector is the default speakers connector and represents the physical speaker jack on the M-Audio card. The speakers(2) connector represents the internal connection to the PC speaker. The amp stream connector represents the flow of digital information to and from the audio card.

Establishing Connections between Devices

A connection is the establishment of a flow of information from one device connector to a compatible connector on another device. One example of a connection is the attachment of a speaker to an audio card with speaker wire. Typically, an application might enable the speaker connector on an audio card, causing the flow of information out of the speaker connector. If you have connected the wire, then the audio is heard. In this case the multimedia system must rely on a person to make the actual connection.

Another category of connection exists where the connection is made internally in the computer, typically through the transfer of digital information from one media device to another. For instance, the waveaudio media device has a connection to its associated amplifier mixer device.

Default and Device Context Connections

Device connections are usually automatically established by the media device when the device is opened. The choice of connection is determined by a default established during installation of the media driver, and can be re-established using the MCI_DEFAULT_CONNECTION message.

Once opened, the media device may open and connect to another media device to provide the complete function of the originally opened device to the application. This is transparent to the calling application. One example is the waveaudio device, which uses a connected amplifier-mixer device to actually produce sound from the digital audio stream. The waveaudio device also uses the services of the amplifier-mixer device to set the volume.

While some services of the connected device can be surfaced in the definition of the originally opened device, the connected device can also provide some extended features beyond those required by the original device. If the application wishes to access these extended features, it can get the handle to the particular device context or instance of the connected device, using the MCI_CONNECTION message.

Note the subtle difference between a default connection and a device context connection. A default connection is the name of a connected device, whereas a device context connection is the actual handle to a particular instance of an opened device. An example of this is a waveaudio01 device that has a default connection to an ampmix01 device. When the waveaudio01 device is opened, it automatically opens the ampmix01 device, creating an instance of each device. Because devices may be shared in OS/2 multimedia, the waveaudio01 device can be opened again by another application and two new instances will be created. Although the default connection is the same in both cases, the device context connections are different.

Connectors Supported by Media Drivers

Each implementation of a media device defines the connectors that it supports. This information is maintained in the media driver and can vary with the underlying hardware.

The following table lists each media device and the connector types applicable to each device. The actual number and types of connectors in each device can vary from one implementation to another.

Device Type Connectors
ampmix amp stream, headphones, speakers, microphone, line in, line out
cdaudio cd stream, headphones
cdxa xa stream
digitalvideo headphones, speakers, microphone, line in, line out, audio in, audio out
headphones audio in
microphone audio out
sequencer midi stream, headphones, speakers, line out
videodisc video out, line out
speakers audio in
waveaudio wave stream, headphones, speakers, microphone, line in, line out

Allowable Connections for Connector Types

For a connection to exist between two media devices, the connectors on each device must be of compatible types. For instance, a connection could be established between the line OUT connector on one device and the line IN connector on another device, however a connection between line OUT and video IN is prohibited. This mechanism will eliminate the majority of incorrect connections. The following table lists the allowable connections based on connector types. These connections are allowed in either direction. Please note that this table should be read as meaning that a device which has a connector of the type in the first column can connect to a device which has a connector of the type in the second column.

Connector Type Compatible Connector Type(s)
amp stream wave stream, midi stream, cd stream, xa stream
line in line out, audio out
audio in headphones, speakers, line out
video in video out
headphones audio in, line in
speakers audio in, line in
microphone audio out
phone line phone set

The connections in the table shown above are based on connector types, not device types. The list of connections might appear incorrect if the connector types are misinterpreted as device types. For example, 'headphones <-> audio in' might be misinterpreted as meaning that headphones can be connected to an audio input. Referring to however, we see that the HEADPHONE device has a connector of type audio in. This connector is analogous to the plug on the headphones and, from the perspective of the headphones, it is input. We also see that the AMPMIX and CDAUDIO devices have connectors of type headphones. The connection is correct, because headphones can be connected to either the CD player (CDAUDIO) or to the audio adapter (AMPMIX).