locked
changing default audio output device in Win 7 via code RRS feed

  • Question

  • I want to be able to change the default audio device on the fly, without having to open the output device window, so I wanted to write a few lines which listen to a specific keystroke, and then set the default audio output device to the next non-default audio output device. I'm planning on doing this on Windows 7 using C# or C++. But so far I wasn't able to find anything useful in the Windows SDK or google.
    Sunday, February 27, 2011 8:26 PM

All replies

  • Only the user is allowed to modify their default audio device; there is no API to do this.  For your own application, you can enumerate an audio device using the MMDevice API and use that device when using the Media Foundation SAR or other audio renderering APIs regardless of what the default device is.
    Tuesday, March 29, 2011 7:31 PM
  • There is a way to specify where the output goes, but you can't specify the exact device. When setting up the SAR, you can specify whether to output. 

    the attribute you would be looking to set is MF_AUDIO_RENDERER_ATTRIBUTE_ENDPOINT_ROLE

    here is a link that describes what to do: http://msdn.microsoft.com/en-us/library/aa369729(v=VS.85).aspx

     

    Good luck, hopefully this is useful.

    Thursday, March 31, 2011 1:13 AM