locked
Win8.1: how to determine what device is switched?

    Question

  • I use XAudio2  to play sounds. How it works: it connects to device that reproduces sounds.

    But I see some strange problem: f.e. on Surface Pro. When I set headphones the system register it as separate device and marks them as the main output device. But if load speaker was included before XAudio2  works with them and play sound throw load speaker.

    How can I determine what device is switched(DeviceWatcher doesn't send this information)?

    • Moved by Jamles HezModerator Thursday, July 10, 2014 6:26 AM XAudio cannot be used directly by C#
    Wednesday, July 9, 2014 7:32 AM

Answers

  • Hi burusera,

    I'm not familiar with XAudio2 stuff, but I think this could be a system level setting, you could set the default callback device by control panel, if you set the headphone as the default one, even the load speaker included before, the sound/voice will be still played by your headphone.

    Anyway, I'm trying to find some API that can set a callback device by XAudio, this one looks to be a helper: How to: Use Source Voice Callbacks.

    But per IXAudio2 documentation mentioned: The DirectX SDK versions of XAUDIO2 included three member functions that are not present in the Windows 8 version: GetDeviceCount, GetDeviceDetails, and Initialize. These enumeration methods are no longer provided and standard Windows Audio APIs should be used for device enumeration instead.

    However, I saw a blog: http://blogs.windows.com/windows/b/buildingapps/archive/2014/05/15/real-time-audio-in-windows-store-and-windows-phone-apps.aspx

     WASAPI is a lower level API and will provide the low level access to the hardware and audio engine. While in XAudio2 you will deal with sound source objects (PC audio data) which you can instruct to play or loop through different mixer configurations, WASAPI allows you to receive notifications when capture data is available or render data is needed.

    I believe that if you use WASAPI should be much better.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, July 10, 2014 6:55 AM
    Moderator