-->
The Windows audio engine runs at predetermined intervals that are referred to as the periodicity of the audio engine. In Windows 7 and later versions of Windows, the audio engine runs with a periodicity of 10ms by default. In Windows 7, you can use an INF file and a new registry key, PKEY_AudioEngine_OEMPeriod, to customize the periodicity for your audio device driver. This is a per endpoint setting.
The following excerpt from an INF file shows how to use the INF AddReg directive to customize the periodicity for an audio device driver.
Periodicity is specified as VT_BLOB. And the valid periodicity range is 50000-90000 (5-9ms) on even 10000 HNSTIME unit boundaries (for example, 50000, 60000, 70000, 80000 or 90000).
Audioengine was founded with a simple goal: Build products that sound great, are easy to use, and make people want to listen to music every day.
In the preceding excerpt from an INF file, the following REG_BINARY data is provided for customization:
The periodicity of 8ms is represented in HNSTIME units as 80000. In hexadecimal notation this value is represented as 0x013880. When this hexadecimal value is written four bits (nibbles) at a time, with least significant bits first, the result is 80,38,01. This is the value that is provided as a REG_BINARY data type.
Periodicity is specified as a VT_BLOB data type. This is represented by a decimal value of 65. In hexadecimal format 65 is represented by the value 41 and the preceding INF file excerpt shows the REG_BINARY data sequence with its first value of 41.
-->In Windows Vista and later, the PKEY_AudioEngine_OEMFormat property key identifies the default stream format for an audio endpoint device. Both rendering and capture devices have default formats. The global audio engine uses a device's default format to connect to the device for shared-mode operation. The INF file that installs the device loads the device's default format into the registry. The user can change the default format through the Windows multimedia control panel (Mmsys.cpl). Windows XP and previous versions of Windows do not support the PKEY_AudioEngine_OEMFormat property key.
An INF file specifies the default format for an audio endpoint device in the add-registry section for that device. The following INF example shows an add-registry section that loads the default format for an endpoint device into the registry.
The preceding example is taken from the file Sysfx.inf in the Sysfx audio sample in the Windows Driver Kit. The Strings section of this INF file contains the following definitions.
In the preceding example, the name of the add-registry section, OEMSettingsOverride.AddReg, is defined by an AddReg directive in an interface installation section in Sysfx.inf. The preceding example adds several properties of endpoint number 0 (identified by the string 'EP0') to the registry entry for the device interface. (If a device interface represents a wave filter with more than one endpoint, the additional endpoints are numbered 1, 2, and so on.) For more information about interface installation sections, see INF AddInterface Directive.
After the INF file has created the three property keys and loaded their associated values into the registry, applications can access the properties by obtaining the IPropertyStore interface for the endpoint device. Header file Mmdeviceapi.h in the Windows SDK contains C/C++ definitions of the three property keys. For more information about obtaining the IPropertyStore interface, see the description of the IMMDevice::OpenPropertyStore method in the Windows SDK documentation.
In the preceding INF example, the PKEY_AudioEndpoint_Association property key identifies the KS pin category GUID for the endpoint device. The PKEY_AudioEndpoint_ControlPanelProvider property key identifies the class GUID for the COM interface object that supplies the property values to the property page in Mmsys.cpl for the endpoint device. For more information about these property keys, see the Windows SDK documentation. For more information about KS pin category GUIDs, see Pin Category Property.
In the preceding INF example, the property value that is associated with the PKEY_AudioEngine_OEMFormat property key is a 48-byte REG_BINARY value that contains a serialized representation of the WAVEFORMATEX or WAVEFORMATEXTENSIBLE structure that describes the format. To calculate the REG_BINARY data value to associate with the PKEY_AudioEngine_OEMFormat property key, embed the WAVEFORMATEX or WAVEFORMATEXTENSIBLE structure in a PropVariant structure, and serialize the PropVariant structure by calling the StgSerializePropVariant function. For more information about the PropVariant structure and the StgSerializePropVariant function, see the Windows SDK documentation.
The following code example is a console application that prints the REG_BINARY data that appears in the preceding INF example.
The main function in the preceding code example creates a WAVEFORMATEXTENSIBLE structure to describe the default format. You can modify the main function to create a WAVEFORMATEX or WAVEFORMATEXTENSIBLE structure to describe the default format for your endpoint device.
The PrintSerializedFormat function in the preceding code example serializes the format description and prints the serialized format description as REG_BINARY data. You can copy the printed output produced by the function and paste it into your INF file.