Audio Driver Support for the WMA Pro-over-S/PDIF Format -
Audio Driver Support for the WMA Pro-over-S/PDIF Format
WinHEC 2004 Version - April 8, 2004
This paper provides information about Windows Driver Model (WDM) audio drivers for the Microsoft® Windows® family of operating systems. It provides guidelines for hardware vendors to enhance the drivers for their Windows audio devices to play Windows Media® Audio Professional (WMA Pro) audio streams in digital pass-through mode over a Sony/Phillips digital interface format (S/PDIF) link.
This information applies for the following operating systems:
Microsoft Windows 98
Microsoft Windows Millennium Edition
Microsoft Windows 2000
Microsoft Windows XP
Microsoft Windows Server™ 2003
Microsoft Windows codenamed “Longhorn”
Future versions of this preview information will be provided in the Windows Longhorn Driver Kit (WLDK).
The current version of this paper is maintained on the Web at:
This paper provides information about Windows Driver Model (WDM) audio drivers for the Microsoft® Windows® family of operating systems. It describes hardware and software components that are needed to play a Windows Media Audio Professional (WMA Pro) digital audio stream through an external decoding device.
WMA Pro is the first WMA stream format that supports 5.1- and 7.1-channel digital audio. Hardware vendors for audio devices with Sony/Phillips digital interface format (S/PDIF) ports can apply the techniques described in this paper to enhance their audio drivers to support digital pass-through transmission of WMA Pro streams to external devices. Typical applications include streaming the contents of a WMA Pro audio recording from a Windows personal computer to the audio/video (A/V) receiver for a home theater system with a set of surround speakers.
Operating System Support
Software support for the WMA Pro audio stream format became available with the release of the Microsoft Windows Media 9 Series technology in 2003. This technology can be installed on computers that run Windows Server 2003, Windows XP, Windows 2000, Windows Millennium Edition (Windows Me), and Windows 98.
Microsoft DirectShow® support for the WMA Pro format became available with the release of DirectX® version 9.0b in 2003. This DirectX release can be installed on computers that run Windows Server 2003, Windows XP, Windows Me, Windows 2000, and Windows 98.
WDM audio driver support for formats that are not pulse code modulation (PCM) formats, such as AC-3 and WMA Pro, is available in Windows Server 2003, Windows XP, and Windows Me. The following operating system updates also provide the same support for non-PCM formats:
Windows 2000 Service Pack 2 (SP2)
Windows 98 Second Edition with installation of the Windows SE 9724 (or later) hotfix and DirectX 7 or later.
For more information about hotfixes for Windows 98 Second Edition, see the Windows Driver Development Kit (DDK) documentation. For more information about non-PCM support, see Non-PCM Wave Formats and WDM Audio Drivers at http://www.microsoft.com/whdc/hwdev/tech/audio/default.mspx.
How to Provide Feedback
To provide feedback about this document, send e-mail to firstname.lastname@example.org.
Definition of Terms
Advanced Cluster Computer Consortium. An audio standard developed by Dolby Laboratories for delivering a 5.1-channel audio signal as a stream of compressed digital data.
Audio/video receiver. A device for receiving and decoding a digital stream that contains audio or video information.
An input or output connection on the abstract representation of an audio device that a WDM audio driver exposes to clients. An audio pin can serve as a sink or a source for a digital audio stream.
A technique for transmitting a stream of encoded data over a digital interface in a manner that does not require the sending and receiving devices to understand the stream encoding.
A globally unique identifier (GUID) that identifies the data format for an audio stream. The GUID value is contained in the WAVEFORMATEXTENSIBLE structure that specifies the format. For information about WAVEFORMATEXTENSIBLE, see the Windows DDK documentation.
The portion of a WDM audio driver that handles the hardware-specific functions of an audio device on a Peripheral Component Interconnect (PCI) adapter or other internal-bus adapter. A port driver, which is supplied by the operating system as part of the PortCls system driver (portcls.sys), performs the generic system functions for the device. For more information, see the Windows DDK documentation.
Sony/Philips digital interface format. A standard for digital connection of consumer audio devices. S/PDIF is substantially identical to the IEC 60958 Type II standard.
A numerical tag identifying the data format for an audio stream. The tag value is contained in the WAVEFORMATEX structure that specifies the format. In Windows 98 Second Edition, Windows Me, and Windows 2000 and later, WAVEFORMATEX is obsolete; audio drivers should use WAVEFORMATEXTENSIBLE instead. For more information, see the Windows DDK documentation.
Windows Driver Model. A driver model based on the Microsoft Windows NT driver model. WDM provides a model for writing kernel-mode drivers and minidrivers. WDM is the primary model for audio drivers in Windows 2000 and later, and in Windows 98 Second Edition and Windows Me.
Windows Media Audio Professional. An audio standard developed by Microsoft Corporation for delivering a 5.1- or 7.1-channel audio signal as a stream of compressed digital data.
An audio device in a personal computer can send a digital audio stream to an external device such as an A/V receiver over a digital interface such as S/PDIF. In a typical home theater system, the A/V receiver might drive a set of surround speakers and accept a 5.1- or 7.1-channel digital audio stream through the S/PDIF connector. The stream can either be in PCM format or in a compressed format such as AC-3 or WMA Pro.
A/V receivers that support AC-3 became available around 1997. A/V receivers that support WMA Pro became available in 2003.
In Windows Me and in Windows XP and later, the Windows audio application programming interfaces (APIs) and WDM audio architecture support non-PCM audio data formats. With the appropriate updates, support for non-PCM formats can be added to earlier Windows releases (Windows 2000 SP2 and, with the appropriate hotfix and DirectX 7, Windows 98 Second Edition). Miniport drivers for audio devices that have external S/PDIF pass-through jacks can expose this capability on an audio pin with the appropriate wave-format tag, as shown in the following table.
AC-3 over S/PDIF
WMA Pro over S/PDIF
Some audio drivers and some audio content use wave-format tag value 0x0240 or 0x0241 instead of 0x0092 to indicate AC-3 over S/PDIF.
If a driver exposes a new audio format, that format is automatically available to clients of the Microsoft DirectSound® and waveOut APIs. The same is not true with DirectShow. By design, the DirectShow renderer limits its support for non-PCM formats to ensure adequate test coverage:
In Windows Me and in Windows XP and earlier, DirectShow support for non-PCM formats is restricted to AC-3 playback with the three AC-3 wave-format tags mentioned previously (0x0092, 0x0240, and 0x0241).
Beginning with the release of DirectX 9.0b, DirectShow support for WMA Pro playback is also available (wave-format tag 0x164).
Similar to PCM and AC-3 streams, a WMA Pro stream can be delivered over an S/PDIF link to an A/V receiver that drives a set of surround speakers. Beginning with the Windows Media Player 9 Series, the media player has been updated to send a WMA Pro stream to an A/V receiver or other WMA decoder in digital pass-through mode. Driver writers need only to add the new WMA Pro-over-S/PDIF wave-format tag to their existing data ranges for non-PCM pass-through formats such as AC-3-over-S/PDIF. For information about data ranges, see the Windows DDK documentation.
Finally, Microsoft plans to augment its universal serial bus (USB) and IEEE 1394 audio class drivers to support digital pass-through transmission of non-PCM audio stream formats such as WMA Pro and AC-3. Currently, no date is available for a release, hotfix, or service pack incorporating this support.
S/PDIF Pass-Through Operation
The WMA Pro and AC-3 audio formats both transmit audio streams in units called synchronization (sync) frames. Each sync frame contains its own header and can be decoded independently of the other sync frames in the stream. At a 48-kHz sample rate, for example, a WMA Pro sync frame contains enough data to play for 2048 sample clock periods. At this same rate, an AC-3 sync frame contains enough data for 1536 sample clock periods.
S/PDIF is defined primarily for transmitting PCM data, but it can easily be adapted to transmit non-PCM data. The principle of S/PDIF pass-through operation is that non-PCM data can pass through the S/PDIF link as though it were PCM data.
For example, consider the problem of disguising a 48-kHz, 5.1-channel WMA Pro stream as PCM data. During playback, a complete WMA Pro sync frame must be transmitted every 2048 ticks of the 48-kHz sample clock. The size of a WMA Pro sync frame can vary, but it never exceeds 8192 bytes. To meet these constraints, each sync frame can be disguised as a block of 2048 samples of 48-kHz, 2-channel, 16-bit PCM data. For this particular PCM format, the rate at which successive PCM blocks are transmitted matches the required transmission rate for the corresponding sync frames. Because the PCM block occupies exactly 8192 bytes, the sync frame always fits into the space allocated for the PCM block. The audio application can pad with zeros any remaining space between the end of a sync frame and the end of the corresponding 8192-byte PCM block.
An example application of S/PDIF pass-through transmission is shown in the following figure.
S/PDIF Pass-Through Operation
The figure shows a personal computer connected to an external A/V receiver through a coaxial cable. The cable connects the S/PDIF output port on the computer’s audio device to the S/PDIF input port on the A/V receiver.
At the left edge of the figure, an audio application inserts a sync frame from a WMA Pro audio stream into the beginning of an 8192-byte buffer. (This buffer size is used purely for ease of illustration; in practice, a buffer size of 4096 bytes or 10240 bytes, for example, might be used instead.) The application fills any remaining space in the buffer with zeros. The audio driver programs the S/PDIF output port to transmit the contents of the buffer as though they were 8192 bytes of PCM data.
Similarly, the S/PDIF input port on the A/V receiver receives the padded WMA Pro sync frame as though it were 8192 bytes of PCM data. The input port loads the data into an input buffer, which in this example also has a size of 8192 bytes. The decoder extracts the WMA Pro sync frame from the input buffer, decodes it into a 5.1-channel audio stream, and plays the stream through the surround speakers on the right edge of the figure.
To let the decoder on the other end of the connection know that the audio stream is in a non-PCM format, the audio driver should set the /AUDIO bit on the S/PDIF transceiver. The decoder reads this bit from the S/PDIF channel-status block to determine whether the data stream is encoded in a non-PCM format. Setting this bit is the only thing special that the driver needs to do to accommodate the non-PCM stream. In every other way, the driver treats the stream as though it contains PCM data.
A number of consumer devices support digital pass-through operation over S/PDIF connections, but other digital interfaces such as USB and IEEE 1394 can also be adapted for pass-through transmission of non-PCM data to external audio decoders.
Declaring Non-PCM Data Ranges
The following wave-format tag definitions appear in header file mmreg.h in the Platform SDK for Windows XP SP2 and later:
#define WAVE_FORMAT_WMA_SPDIF 0x0164
#define WAVE_FORMAT_DOLBY_AC3_SPDIF 0x0092
As discussed earlier, WAVE_FORMAT_WMA_SPDIF and WAVE_FORMAT_DOLBY_AC3_SPDIF are the wave-format tags for the WMA Pro-over-S/PDIF and AC-3-over-S/PDIF formats.
A wave miniport driver can use the DEFINE_WAVEFORMATEX_GUID macro in header file ksmedia.h to define the corresponding format-subtype GUIDs:
The miniport driver loads these format-subtype GUIDs into WAVEFORMATEXTENSIBLE structures to specify the WMA Pro-over-S/PDIF and AC-3-over-S/PDIF formats. In addition, the miniport driver uses format-subtype GUIDs in the KSDATARANGE_AUDIO structures that specify the data ranges for an audio pin. A wave miniport driver provides a list of data ranges for every pin factory. For information about the WAVEFORMATEXTENSIBLE and KSDATARANGE_AUDIO structures, see the Windows DDK documentation.
The following code example shows an array of data ranges for a pin factory that can play both WMA Pro-over-S/PDIF and AC-3-over-S/PDIF data formats:
// Specify four data ranges for this pin factory:
// 1. AC-3-over-S/PDIF at a 48-kHz sample rate
// 2. WMA Pro-over-S/PDIF at 48 kHz
// 3. WMA Pro-over-S/PDIF at 44.1 kHz
// 4. 16-bit, 2-channel PCM-over-S/PDIF at 48 kHz
// Note: The PCM data range (4) is commented out to enable
// the non-PCM data ranges. See main text for explanation.
The first data range in the code example specifies an AC-3-over-S/PDIF data format. When AC-3 data passes through an S/PDIF link in digital form without being decoded, it can be passed through the link in exactly the same manner as a two-channel, 16-bit, 48-kHz PCM stream. In fact, when specifying an AC-3-over-S/PDIF data range, the format subtype GUID is the only thing that differentiates the AC-3 data range from a PCM data range.
In the preceding code example, the second and third data ranges specify WMA Pro-over-S/PDIF data formats at sample rates of 48 kHz and 44.1 kHz. With these two options, an audio application can play a WMA Pro audio stream recorded at either of these two sample rates, assuming that the external decoder can also handle the sample rate.
The last of the four array elements in the code example is a PCM data range. This particular data range is commented out to avoid exposing both PCM and non-PCM data ranges in the same pin factory. When configuring an audio device in Windows, the SysAudio system driver reserves one pin instance in every pin factory that can play a PCM stream. This behavior ensures that one PCM pin instance is always available for KMixer, the system's kernel-mode software mixer, to use. In this example, however, the driver can create only a single instance of the pin, and to prevent that pin instance from being reserved for KMixer, the PCM data range must be omitted. For information about SysAudio and KMixer, see the Windows DDK documentation.
A pin factory that can play a non-PCM format such as WMA Pro or AC-3 is likely to allow creation of only a single pin instance. If a pin factory were to allow two instances of a non-PCM pin to be created, the device would have to mix the streams entering the two pins, and hardware mixing of non-PCM formats is a complex operation that personal computer audio devices typically do not support.
If an audio device contains two or more physical S/PDIF ports, the miniport driver typically provides a pin factory for each port, but each factory is again likely to allow creation of only a single pin instance.
Before a client can play an audio stream through a non-PCM pin instance, the client must negotiate with the audio driver to identify a common stream format that both the client and pin instance support. This negotiation is carried out by the audio driver's data-intersection handler. For simple PCM formats, a miniport driver can rely on the default data-intersection handler in the system-supplied port driver to perform the negotiation. However, a miniport driver with a non-PCM pin factory must supply its own custom data-intersection handler.
When implementing a data-intersection handler for the three non-PCM data ranges in the preceding code example, the driver developer must design the handler not only to recognize the WMA Pro-over-S/PDIF and AC-3-over-S/PDIF formats but also to distinguish between the 48-kHz and 44.1-kHz WMA Pro-over-S/PDIF data ranges. For more information about data-intersection handlers, see the Windows DDK documentation.
Call to Action
For driver developers:
To support a Windows audio device with S/PDIF pass-through capability, enhance your wave miniport driver by adding a pin factory that supports pass-through transmission of non-PCM audio formats. That pin should support WMA Pro over S/PDIF (wave-format tag 0x0164) in addition to AC‑3 over S/PDIF (wave-format tags 0x0092, 0x0240, and 0x0241).
For miniport drivers that already support non-PCM formats such as AC-3 over S/PDIF, simply add the WMA Pro-over-S/PDIF wave-format tag to the list of supported formats for the existing non-PCM pin factory.
If you have questions about this paper, send e-mail to email@example.com.