Vista / Win 7 WASAPI (Part 1 of X)

dstrimbu · 8148

0 Members and 1 Guest are viewing this topic.

Offline dstrimbu

  • Full Member
  • ***
    • Posts: 58
on: January 18, 2011, 04:12:48 PM
I've been reading a bit on MSDN this evening, regarding exclusive-mode audio streams in Windows Vista / Win 7.  The link to the article, should you be so inclined, is at: http://msdn.microsoft.com/en-us/library/dd370844(VS.85).aspx

The first statement that caught my eye was this one:

Applications that use exclusive-mode streams often do so because they require low latencies in the data paths between the audio endpoint devices and the application threads that access the endpoint buffers. Typically, these threads run at relatively high priority and schedule themselves to run at periodic intervals that are close to or the same as the periodic interval that separates successive processing passes by the audio hardware. During each pass, the audio hardware processes the new data in the endpoint buffers.

OK, I hate glitches in my audio.  The next interesting part is here:

In addition, USB audio devices rely on system software to transport data between application buffers and hardware buffers. To improve the performance of exclusive-mode applications that connect to audio devices that rely on the system for data transport, WASAPI automatically increases the priority of the system threads that transfer data between the applications and the hardware. WASAPI uses MMCSS to increase the thread priority. In Windows Vista, if a system thread manages data transport for an exclusive-mode audio playback stream with a PCM format and a device period of less than 10 milliseconds, WASAPI assigns the MMCSS task name "Pro Audio" to the thread. If the device period of the stream is greater than or equal to 10 milliseconds, WASAPI assigns the MMCSS task name "Audio" to the thread.

So, Windows does understand the concept of "Pro Audio".  :-)  That's interesting.  Based on my math, a 44.1khz DA stream should get assigned the "Pro Audio" tag.  So far so good.  Then, we need to assign exclusive mode to our USB audio device:

To change the exclusive-mode settings of a playback or recording device

1.) Right-click the speaker icon in the notification area, which is located on the right side of the taskbar, and select Playback Devices or Recording Devices. (As an alternative, run the Windows multimedia control panel, Mmsys.cpl, from a Command Prompt window. For more information, see Remarks in DEVICE_STATE_XXX Constants.)
2.) After the Sound window appears, select Playback or Recording. Next, select an entry in the list of device names, and click Properties.
3.) After the Properties window appears, click Advanced.
4.) To enable applications to use the device in exclusive mode, check the box labeled Allow applications to take exclusive control of this device. To disable exclusive-mode use of the device, clear the check box.
5.) If exclusive-mode use of the device is enabled, you can specify whether a request for exclusive control of the device will succeed if the device is currently playing or recording shared-mode streams. To give exclusive-mode applications priority over shared-mode applications, check the box labeled Give exclusive mode applications priority. To deny exclusive-mode applications priority over shared-mode applications, clear the check box.

OK, now set Foobar up to output via "WASAPI output support";  File menu, preferences, components.  If "WASAPI output support" doesn't exist, get the dll from the Foobar site and install it, then apply.  WASAPI output support should be in bold in the installed components listing as the default output device (at least, it is in Foobar 1.1.2 beta 3).

How does that sound?  Comments are welcomed.  If you're already running WASAPI output, make sure you set exclusive mode access for the USB DAC in Windows, per the 5 listed steps above...

YMMV,

-Don