locked
Losing audio from XAudio2 after (dis)connecting headphones

    Question

  • In the application I'm working on, when I connect or disconnect my headphones in my laptop (T410s) - I lose the audio and disconnecting/connecting them back doesn't seem to help. Neither does recreating all the source voices. What am I missing?


    Filip Skakun

    Wednesday, October 17, 2012 7:43 PM

Answers

  • This is the way that WIndows Core Audio works. If you disconnect the headphones or speakers, the audio device is 'removed' from the system.

    For XAUDIO2, this means handling it via the OnCriticalError notification, destroying, and recreating your audio graph.

    • Marked as answer by Filip Skakun Wednesday, October 24, 2012 9:36 PM
    Wednesday, October 24, 2012 6:57 PM

All replies

  • I guess everyone's preparing for //BUILD/ and meanwhile my bug is in the air and I can't release my app by 10/26... :)

    Filip Skakun

    Tuesday, October 23, 2012 5:36 AM
  • This is the way that WIndows Core Audio works. If you disconnect the headphones or speakers, the audio device is 'removed' from the system.

    For XAUDIO2, this means handling it via the OnCriticalError notification, destroying, and recreating your audio graph.

    • Marked as answer by Filip Skakun Wednesday, October 24, 2012 9:36 PM
    Wednesday, October 24, 2012 6:57 PM
  • Thanks Chuck! That sucks a bit, but I guess I'll just have to deal with it then.

    Filip Skakun

    Wednesday, October 24, 2012 9:37 PM
  • Yeah, sorry. We were trying to find a more elegant way to handle this scenario for some time, but there are a lot of variables: you could have a different audio device, the new device could have a different number of channels, etc.

    The Marble Maze sample provides an example of how you might handle this.

    Thursday, October 25, 2012 5:46 PM
  • It's OK, I see how this could have been a lower priority scenario and one that's harder to fix. Does it work the same way in Windows 7/Windows 8 desktop?

    Filip Skakun

    Thursday, October 25, 2012 5:47 PM
  • Yes. The issue is the same on Windows Vista, Windows 7, Windows 8, and Windows RT.
    Thursday, October 25, 2012 6:54 PM
  • Ah, that changes things. You had plenty of time. Now I am angry you don't have a built-in workaround! :)

    But then again I guess the point of the whole DirectX is not to make developers' lives easier. That does make things harder for anyone who does not have a big team to do all the DirectX work. I now see how XNA made sense for people and how there is a void where there should be a simpler media platform for indie developers.

    Filip Skakun

    Thursday, October 25, 2012 7:24 PM