How to negotiate an audio format for a Windows Audio Session API (WASAPI) client

The Windows Audio Session API (WASAPI) provides a family of interfaces for playing or recording audio. Chief among these are the IAudioClient, IAudioClient2, and IAudioClient3 interfaces. There is a Windows audio session (WASAPI) sample on GitHub, but in this blog post I want to dive into the nitty-gritty of one particular question: How do I…

0

Getting the schema for Windows Performance Recorder profiles

I was having some trouble authoring a Windows Performance Recorder profile by hand-editing the XML, and I wanted to check it against the schema. This MSDN page says “you can get the WPRControlProfiles.xsd file in %ProgramFiles(x86)%\Windows Kits\8.1\Windows Performance Toolkit”. That appears to no longer be true. I dug around a little and eventually found it. It’s…

2

Pulling ClickOnce applications from the client using a script

I have a bunch of internal Microsoft ClickOnce applications that I use all the time. But every time I clean install my machine I need to go look up all the application entry points and reinstall them. This got boring, so I wrote an executable that takes a URL on the command line, and then uses the System.Deployment.Application.InPlaceHostingManager…

0

Riffing on Raymond – incrementing the reference count on a smart pointer

Last Friday, Raymond Chen blogged about how to use a function that released one of its inputs with various smart pointer classes. He made two suggestions, and I offered a third: (Raymond) tell the smart pointer class to release ownership to the function (Raymond) use a different function that doesn’t release the input (Me) take…

4

Playing audio to the earpiece from a Windows Phone 8.1 universal app

Some time ago I blogged about the Windows Phone AudioRoutingManager API which allows you to put a “Speakerphone” and “Bluetooth” button in your Windows Phone app. A common question that I get now is “I’m trying to play audio to the earpiece from my app, but AudioRoutingManager::SetAudioEndpoint(AudioRoutingEndpoint_Earpiece) is failing.” It’s an interesting question, because Windows…

1

Using StrCmpLogicalW to sort strings the way the shell does

I have various scripts which use the “dir” command to enumerate files and then act on the most recent file that meets certain criteria. I noticed that “dir” and the Windows shell sometimes have different orders. For example, if I have a folder containing files { track1.mp3, track2.mp3, …, track9.mp3, track10.mp3, track11.mp3 } then the…

0

Walking the IDeviceTopology tree to see audio driver settings

I’ve blogged before about using the IDeviceTopology API to poke around the internal structure exposed by audio drivers. In particular, given an audio endpoint, you can map out all the knobs and widgets of all the signal paths that feed into that endpoint (for playback) or out of it (for recording.) A version of this…

2

Draining the WASAPI capture buffer fully

About six years ago I wrote a blog post about how to do WASAPI loopback capture. Since then, a few issues have come to light. One big issue is that we’re using MMCSS registration directly. Nowadays the much-preferred approach is to use a Media Foundation work queue; yes, you can use a Media Foundation work queue…

11

Troubleshooting default audio device heuristics

In Windows 7 we published a white paper which shows how Windows chooses which audio device should be the default. This remains true for Windows 8 and Windows 8.1. The six factors that are considered for each device are: Jack detection capability Whether KSJACK_DESCRIPTION2.JackCapabilities has the JACKDESC2_PRESENCE_DETECT_CAPABILITY flag set USB audio devices have jack detection capability…

1

A mental model for the Windows Phone AudioRoutingManager API

The Windows Phone SDK includes a Windows.Phone.Media.Devices.AudioRoutingManager API which I had occasion to use. The API allows apps that have communication audio streams (e.g., Voice over IP calls) to control whether the audio goes out over the earpiece, over the speakerphone, or over the Bluetooth headset. This might be done automatically, or might be used…

0