Most hardware drivers for PCI and ISA/DMA audio devices are based on the Port Class library, which is accessible through the PortCls system driver (portcls.sys). In Windows 98/Me, and in Windows 2000 and later, PortCls is an audio port-class driver that Microsoft includes as part of the operating system. PortCls simplifies the driver writer's task by supplying a set of port drivers that implement most of the generic KS-filter functionality. The hardware vendor has to supply only a set of miniport drivers to handle the hardware-specific functions of an audio adapter.
Although hardware vendors do have other options for implementing KS filters for their audio devices, these options are both difficult and unnecessary for typical audio devices. A KS filter can be written to conform to either KS 1.0 (stream class driver) or KS 2.0 (AVStream), but a KS-1.0 filter cannot take advantages of improvements available only in AVStream, and an AVStream filter cannot run in Windows 98/Me or Windows 2000.
In contrast, the Port Class library has remained stable since Windows 98 Second Edition. The internal implementation of PortCls can evolve to take advantage of kernel streaming improvements in successive Windows releases while maintaining compatibility with existing drivers.
PortCls is implemented in system file portcls.sys as an export driver (a kernel-mode DLL) that provides kernel-streaming functionality for ISA/DMA and PCI audio device drivers. The portcls.sys file contains the following:
The hardware vendor for an audio device is responsible for providing an adapter driver. The adapter driver includes initialization and miniport-management code (including the DriverEntry function) and a collection of audio miniport drivers.
When the adapter driver loads, it creates a set of miniport driver objects and directs the PortCls system driver to create a corresponding set of port driver objects. (The code example in Subdevice Creation illustrates this process.) These port drivers are typically a subset of those that are available in the portcls.sys file. Each miniport driver binds itself to a matching port driver from portcls.sys to form a complete subdevice driver. The combination port-and-miniport subdevice driver is a kernel streaming (KS) filter (see Audio Filters). For example, a typical adapter driver might contain three miniport drivers: WavePci, DMusUART, and Topology (with IMiniportWavePci, IMiniportDMus, and IMiniportTopology interfaces). During initialization, these miniport drivers are bound to the WavePci, DMus, and Topology port drivers (with IPortWavePci, IPortDMus, and IPortTopology interfaces) that are contained in the portcls.sys file. Each of these three subdevice drivers takes the form of a KS filter. The three filters together expose the complete functionality of the audio adapter.
Typically, the port drivers provide the majority of the functionality for each class of audio subdevice. For example, the WaveCyclic port driver does most of the work that is required to stream audio data to a DMA-based audio device, whereas the miniport driver provides device-specific details such as the DMA address and device name.
Audio adapter drivers and miniport drivers are typically written in C++ and make extensive use of COM interfaces. The port/miniport architecture promotes modular design. Miniport driver writers should implement their driver as a C++ class derived from the IMiniport interface, which is defined in the header file portcls.h. At driver load time, the adapter driver instantiates one or more IMiniport-derived classes, along with corresponding IPort-derived classes, and binds them. Hardware initialization also takes place at driver load time—typically in the Init method of the IMiniport-derived class (for example, IMiniportWavePci::Init). For more information on COM implementations of audio miniport drivers, see COM in the Kernel.
The following diagram illustrates the relationship between port and miniport drivers and their position in the audio stack.

Relationship Between Port and Miniport Drivers
In the preceding figure, the shaded boxes represent driver components that the vendor provides. Note that the upper edge of each miniport driver interfaces to the lower edge of each port driver. For example, the WaveCyclic port driver exposes an IPortWaveCyclic interface to the WaveCyclic miniport driver, which exposes an IMiniportWaveCyclic interface to the port driver. This document occasionally refers to these simply as upper-edge and lower-edge interfaces.
The port class and AVStream class drivers are similar in that they are both WDM drivers, they support connection streaming architecture (CSA), and they interact with DirectShow® in the same manner. However, port class drivers differ from AVStream class drivers in the areas of multiprocessor handling and reentrancy. Port class drivers do the following:
The terminology for describing WDM audio ports and miniport drivers differs in some respects from the terms that are used for other classes of Windows® drivers. These differences are explained in WDM Audio Terminology.
This section discusses the following topics: