Default Audio Endpoint Selection in Windows 7 - 2

Default Audio Endpoint Selection in Windows 7

March 30, 2010

Abstract

The Windows® 7 audio subsystem uses an algorithm with enhanced heuristics for default audio endpoint selection. This paper describes these heuristics and how the Windows 7 audio subsystem uses them to select the default audio endpoint. For you to best understand the new Windows 7 selection mechanism, this paper also explains how default audio endpoint selection occurs in Windows Vista®. The target audience of this paper is OEMs and IHVs.

This information applies to the Windows 7 operating system.

References and resources discussed here are listed at the end of this paper.

The current version of this paper is maintained on the Web at:
http://www.microsoft.com/whdc/device/audio/W7-DefAudioEndptSel.mspx

The information in this paper might eventually be provided in the Windows Driver Kit (WDK). If you encounter a conflict between this paper and the WDK, consider the WDK to be factually correct and this paper to be out of date.

For further information, contact:

Disclaimer: This document is provided “as-is”. Information and views expressed in this document, including URL and other Internet Web site references, may change without notice. You bear the risk of using it.

This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You may copy and use this document for your internal, reference purposes.

© 2010 Microsoft Corporation. All rights reserved.

Document History

Date / Change /
March 30, 2010 / First publication

Contents

Introduction 3

Basic Algorithm for Default Audio Endpoint Selection 4

The Endpoint Timestamp Property 4

Endpoint Timestamp Property Creation and Update in Windows Vista 5

Endpoint Timestamp Property Creation and Update on Windows 7 6

The Windows Vista Default Audio Endpoint Heuristic 7

The Windows 7 Default Audio Endpoint Heuristic 8

Windows 7 Heuristic Factors 8

Windows 7 Heuristic Details 10

Windows 7 Inbox Heuristic Settings 11

Inbox Heuristic Settings for the Default Console Audio Endpoint 11

Inbox Heuristic Settings for the Default Communication Audio Endpoint 14

Windows 7 OEM Heuristics Customization 16

Resources 16

Introduction

Most PC audio devices contain multiple logically independent audio features. In Windows Vista® and Windows® 7, each feature is exposed as a separate audio endpoint. Endpoints are listed in the Control Panel Sound application, as shown in the following example dialog box.

Only one audio endpoint at a time can be set as the default for a specific console or communications role.

The Windows Vista and Windows 7 audio subsystems use similar algorithms to determine the default audio endpoint. However, the Windows 7 algorithm uses a far more sophisticated heuristic for the following reasons:

·  Sometimes special-purpose audio applications iterate over all audio endpoints and select one with certain characteristics—such as support for digital formats or other special audio formats—before streaming audio data to it. (Most audio applications only use whatever is set as the default audio endpoint for audio streaming because this is the likely source from which end users want to hear their audio.)

·  The Windows 7 audio subsystem automatically redirects audio streams from the previous default audio endpoint to the new default audio endpoint if an application explicitly selects a new default audio endpoint as the streaming target endpoint. This new feature is called stream redirection.

This paper describes how the default audio endpoint is selected in Windows 7. For a better understanding of what’s new to Windows 7, default audio endpoint selection in Windows Vista is also explained. With the enabling of the Communications device role in Windows 7, the default Console audio endpoint can now be differentiated from the default Communications audio endpoint. How this differentiation occurs is also covered in this paper.

Basic Algorithm for Default Audio Endpoint Selection

The Windows Vista and Windows 7 audio subsystems use a similar algorithm to determine the default audio endpoint. The algorithm operates as follows:

·  Loops through all ACTIVE endpoints to find the endpoint with the most recent timestamp property. This property indicates the last time an endpoint was set as the default audio endpoint. The timestamp property is discussed in more detail in the next section of this paper.

·  If a time-stamped audio endpoint is found, returns it as the default audio endpoint.

·  If a time-stamped audio endpoint is not found, uses the default audio endpoint heuristic algorithm to determine the default audio endpoint. The heuristics for both Windows 7 and Windows Vista are discussed in detail later in this paper.

There are four endpoint states: ACTIVE, UNPLUGGED, DISABLED, and NOT PRESENT. The audio subsystem considers only ACTIVE endpoints (in the present and enabled state) when it determines the default audio endpoint. Any events that cause an endpoint’s state to change from or to the ACTIVE state can potentially affect the current default audio endpoint. Such events include inserting an audio device, unplugging a device, and installing a new audio device. In response to such operations, the Windows audio subsystem runs the default audio endpoint heuristic algorithm to determine the new default audio endpoint.

The Endpoint Timestamp Property

An audio endpoint is created without a timestamp property. The Windows audio subsystem assigns a timestamp to the endpoint only when it is set as the default audio endpoint. An endpoint that is never set as the default endpoint does not have a timestamp property.

Endpoint Timestamp Property Creation and Update in Windows Vista

In Windows Vista, an endpoint’s timestamp property is created or updated only when it is specifically set as the default audio endpoint through one of the following methods:

·  End-user selection through the Control Panel Sound application.

An end user can designate an endpoint to be the default audio endpoint by right-clicking the target endpoint and then selecting Set as Default Device, as shown in the following screen shot.

In response to this user action, the audio subsystem gets the current timestamp and creates a timestamp property if it does not exist or updates the existing timestamp property.

·  Audio driver installation.

In Windows Vista, an audio driver package can use the SetupPreferredAudioDevices INF directive to establish its installed audio endpoints as the new default audio endpoints. All endpoints that are created from the section that contains this INF directive have their default endpoint timestamp property updated with the installation time.

For details, see “SetupPreferredAudioDevices” on the MSDN Web site.

Endpoint Timestamp Property Creation and Update on Windows 7

In Windows 7, an endpoint’s timestamp property is created or updated only when it is specifically set as the default audio endpoint through the Control Panel Sound application. The basic default device selection operation is similar to that of Windows Vista, but as shown in the following screen shot, a new Set as Default Communications Device option was added.

The new Communications device role was added in Windows 7 to help communication-centric applications provide a better communication experience for device selection. To support this new role, each endpoint now has a separate timestamp property for each device role, as follows:

·  When the end user selects Set Default Device for an endpoint, the audio subsystem creates or updates the timestamp property for the default Console device role.

·  When the end user selects Set as Default Communications Device for an endpoint, the audio subsystem creates or updates the Communications timestamp.

With this new flexibility, different device roles can be set to different audio devices.

To accommodate these changes, the following modified algorithm describes how Windows 7 determines a default audio endpoint for any specific role:

·  The audio subsystem loops through all the ACTIVE endpoints with a matching device role to find the endpoint with the most recent timestamp property. The timestamp property indicates the last time an endpoint was set as the default audio endpoint.

·  If such an audio endpoint is found, it is returned as the default audio endpoint.

·  Otherwise, the audio subsystem resorts to the system default audio endpoint heuristic algorithm to determine the default audio endpoint.

Support for SetupPreferredAudioDevices was removed from Windows 7 because of the following non-deterministic nature:

·  Although each physical audio device can expose multiple audio features or endpoints (such as a microphone, a speaker, and a headphone), SetupPreferredAudioDevices does not allow control at the audio endpoint level.

·  The default audio endpoint settings that result from this INF directive are affected by the order in which its driver exposes an audio endpoint. The last exposed endpoint overrides all previous settings.

The Windows 7 Media Class Installer ignores this directive when it installs audio drivers. Therefore, when an audio driver is installed on Windows 7, the endpoints on the device do not necessarily become the default audio endpoint as they did on Windows Vista. You should update your Windows 7 audio driver INF files accordingly.

The Windows Vista Default Audio Endpoint Heuristic

The system default audio endpoint heuristic algorithm is quite simple in Windows Vista. The only property that the audio subsystem uses is the endpoint’s form factor. The AudioEndpointBuilder service assigns each form factor type a relative priority value or rank value. The audio subsystem uses this rank value to prioritize the endpoints for the selection of the default audio endpoint. When there are multiple endpoints from which to select, the audio subsystem chooses the endpoint that has the best rank as the default device. There are two sets of rank settings: one for render endpoints and one for capture endpoints.

The priority order, from highest to lowest priority, for render endpoints is as follows:

·  Speakers

·  Sony/Phillips Digital InterFace (S/PDIF)

·  All other form factors (all are ranked equally)

For example, in a system that has a speakers endpoint and a S/PDIF endpoint, the system default audio endpoint heuristic algorithm selects the speakers endpoint as the default endpoint.

If there is more than one endpoint that has the same form factor, the audio subsystem selects the first one that it encounters.

The priority order, from highest to lowest priority, for capture endpoints is as follows:

·  Microphone

·  LineLevel

·  S/PDIF

·  Any other form factors (all are ranked equally)

Because most Windows Vista audio drivers use the SetupPreferredAudioDevices directive in their INF files, almost all endpoints have a timestamp property. For this reason, the Windows Vista system default audio endpoint heuristic algorithm is rarely used to determine the default audio endpoint.

The Windows 7 Default Audio Endpoint Heuristic

In Windows 7, a more flexible and sophisticated default device selection heuristic replaces the heuristic that is used in Windows Vista. This new heuristic uses more factors to select the default endpoint, which allows finer control on the relative priority order among endpoints that have various characteristics.

The following are some examples of how the enhanced default device selection heuristic works on Windows 7:

·  When the heuristic selects the default communications endpoint, it assigns higher priority to Bluetooth headphone endpoints than to onboard HD Audio headphones.

·  When it selects the default speaker endpoint, it assigns higher priority to speaker endpoints that have jack detection capability than to static speaker endpoints.

·  When it selects the default capture device, it assigns higher priority to front microphone endpoints than to microphones in the rear of a computer.

·  When it selects the default console render endpoint, it assigns higher priority to S/PDIF endpoints than to handset endpoints. When it selects the default communications render endpoint, it assigns higher priority to handset endpoints than to S/PDIF endpoints.

·  The heuristic can designate an endpoint that has specific characteristics to be the top priority or the lowest priority. For example, it can make a jack detection capable HD Audio headphone endpoint on the right of a computer be the highest priority default communication render device.

You can see from the preceding examples that the enhanced system default device heuristic algorithm in Windows 7 is flexible enough to have much more detailed control on the default device selection behavior. Heuristic details are provided in the next sections.

Windows 7 Heuristic Factors

The Windows 7 audio subsystem considers the following endpoint characteristics, or factors, to select the default audio endpoint:

·  Jack detection capability

·  Form factor

·  KSNodeType

·  Bus type

·  General location

·  Geometric location

Windows 7 defines a set of enum values for every supported endpoint factor and stores them in the registry. Detailed descriptions of these factors and their corresponding enumerant value sets follow.

Jack Detection Capability

An endpoint with this capability implies that audio drivers can notify the audio subsystem when the audio peripherial device that is connected to an endpoint is plugged in or unplugged. Audio endpoints that support jack detection capability are called dynamic endpoints, and those that do not provide this support are called static endpoints. To support jack detection capability, audio device drivers must support the KSPROPERTY_JACK_DESCRIPTION2 property. For more information about this property, see “KSPROPERTY_JACK_DESCRIPTION2” on the MSDN Web site.

Jack detection capability enum values /
Supported
NotSupported

The Windows 7 default audio device heuristic treats all USB audio endpoints as jack detection capable.

Form Factor

An audio endpoint’s form factor indicates the physical attributes of the audio endpoint device with which the user interacts, such as headphones, speakers, or S/PDIF. To determine an endpoint’s form factor, the audio subsystem uses built-in fixed logic to map the kernel streaming (KS) pin’s category (KSNodeType), which is exposed by the audio driver, to a specific form factor. For more information, see “Pin Category Property” on the MSDN Web site.

Endpoint form factor enum values /
RemoteNetworkDevice / Handset
Speakers / UnknownDigitalPassthrough
LineLevel / SPDIF
Headphones / UnknownFormFactor
Microphone / Headset
DigitalAudioDisplayDevice (defined to be same as HDMI)
KSNodeType

The audio driver selects the KSNodeType for a KS pin on an endpoint because the driver has detailed knowledge about the audio device that might be connected to an audio jack. Therefore, KsNodeType reveals more specific knowledge on the endpoint than its form factor does.