10

I am writing my own API to perform some of the functionality of the SndVol system utility. I would like part of this API to be the ability to set the volume level of a given audio session.

SndVol displays a slider on the "Device" panel that the user can use to change the master volume level of the audio device as well as a slider for each audio session (on the "Applications" panel) that changes the volume level of the session:

Screenshot of SndVol Volume Mixer

If I drag the slider handle for one of the audio sessions, then SndVol is able to change the audio session's volume level. How does it do that?

I thought that it was possible using Windows Vista's Core Audio API, but I encountered the problem that although I am able to iterate audio sessions of a device using an IAudioSessionEnumerator, the IAudioSessionEnumerator only gives me access to IAudioSessionControl objects, but I need the IAudioClient object to obtain an ISimpleAudioVolume object that I can use to set the audio session volume level. Is it possible to get the IAudioClient object associated with an IAudioSessionControl object?

onteria_
  • 68,181
  • 7
  • 71
  • 64
Joseph Trebbien
  • 309
  • 1
  • 3
  • 8

2 Answers2

11

If you call QueryInterface on the IAudioSessionControl interface, you can often get access to an ISimpleAudioVolume.

Larry Osterman
  • 16,086
  • 32
  • 60
  • 3
    God, why must everything Microsoft be so convoluted.. ? – hauzer Apr 07 '14 at 21:55
  • 2
    @hauzer Sometimes it is a way to discourage moving to different platforms due to invested time learning the API and not wanting to relearn yet another learning curve elsewhere; sometimes it's just difficult to create simple naming conventions for functions or methods, particularly when dealing with OOP that may have a large object model. – Eugene C. Apr 21 '14 at 14:14
  • 1
    Not so much convoluted as undocumented. How would I know that these are often the same? – chowey Mar 20 '15 at 22:20
2

Larry Osterman, who works for Microsoft and worked on the new audio API stuff, wrote a series of blog posts about the new Vista/Win7 audio features. Here are a few links that might help:

A Quick Run-through the new Windows 7 Multimedia/Audio SDK Samples - Sample shows per-app volume control

Volume Control in Vista - Describes per-application volume control and other new audio features that were added in Vista/Win7

There's an index on the right side of the page; you can look at the Audio tagged items for some other articles that might help.

Ken White
  • 123,280
  • 14
  • 225
  • 444