locked
Handling headphones and device changes in Marble Maze sample

    Question

  • Hello,

    in the article: "Adding audio to the Marble Maze sample", there is a section:

    "Handling headphones and device changes"

    that teaches that a critical error will occur (call function) when someone plugs or unplugs headphone.

    I checked the code with Win RT 8.1 (2520) device, and the function:

    void  _stdcall AudioEngineCallbacks::OnCriticalError(HRESULT Error)
    {
        m_audio->SetEngineExperiencedCriticalError();
    }

    is never called when i plug or unplug the headphones from the jack. 

    The sound continues to run from the output the device used prior the program deployment.

    What is the problem? 

    Thanks


    Thursday, January 09, 2014 11:30 PM

Answers

  • Hello,

    If you are playing the audio via a removable audio device (i.e. a USB headphone) the audio should automatically be transferred to a non removable audio device if one is available (i.e. HW sound card). Otherwise the audio will not be transferred automatically and you will need to restart the audio engine.

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Saturday, January 11, 2014 1:36 AM
    Moderator
  • Hello,

    Unfortunately we do not have documented support for jack detection in Windows Store apps. Because of this there is no way to detect when the headphones are plugged in. We do have jack detection on the desktop and hopefully this functionality will eventually be ported to the WinRT APIs.

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Wednesday, January 15, 2014 12:14 AM
    Moderator

All replies

  • In my test, OnCriticalError only occurred if the device the app is currently using stops working.


    -Eric.

    Friday, January 10, 2014 4:10 PM
    Moderator
  • Thanks for the response. So, is there a way to detect whether some user plugs or unplugs the headphones, to redirect the app's audio output accordingly, without having to restart the audio engine manually?

    Thanks

    Friday, January 10, 2014 4:38 PM
  • Hello,

    If you are playing the audio via a removable audio device (i.e. a USB headphone) the audio should automatically be transferred to a non removable audio device if one is available (i.e. HW sound card). Otherwise the audio will not be transferred automatically and you will need to restart the audio engine.

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Saturday, January 11, 2014 1:36 AM
    Moderator
  • Hi, thanks for the response.

    In the Windows Phone if you plug non-usb wired headphones into the jack, the sound redirects automatically from the phone's speakers to the headphones without need for special programming in the app.

    Is this possible in the Windows Store (RT) app development? So I want to be able to detect that someone put his wired headphones into the jack, and redirect the sound there. Or i want always the sound to be redirected to the wires headphones whenever someone plugs them into the tablet.

    Thanks.

    Saturday, January 11, 2014 4:02 PM
  • Hello,

    Unfortunately we do not have documented support for jack detection in Windows Store apps. Because of this there is no way to detect when the headphones are plugged in. We do have jack detection on the desktop and hopefully this functionality will eventually be ported to the WinRT APIs.

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Wednesday, January 15, 2014 12:14 AM
    Moderator