locked
How to retrieve the current audio device state in metro app?

    Question

  • Hi,

          IMMDevice::GetState method can retrieve the current audio device state in  desktop app, but this method only applies to desktop apps, metro app can not use this method, so  how to retrieve the current audio device state in metro app?

          Any help will be appreciated!    
    • Changed type happyrabbit Wednesday, May 23, 2012 3:29 AM no preferred answer
    Thursday, May 10, 2012 9:14 AM

Answers

  • I'm sorry HappyRabbit but at this time you cannot get the device state like you can in a desktop app.

    -James


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

    Friday, May 18, 2012 9:41 PM
    Moderator
  • Hello HappyRabbit,

    There is no mechanism built into the WinRT API to allow a developer to directly control APOs instantiated in the global audio pipeline. This is by design. Applications should not have access to these resources. These resources should only be enabled and disabled by the user.

    I hope this helps,

    James 


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

    Monday, June 11, 2012 11:49 PM
    Moderator

All replies

  • Hello HappyRabbit,

    Try using this property: "System.Devices.Connected"

    How to retrieve additional properties for a device or PnP object
    http://msdn.microsoft.com/en-us/library/windows/apps/hh464997.aspx

    I hope this helps,

    James


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

    Thursday, May 10, 2012 11:14 PM
    Moderator
  • Thanks James Dailey.

    But the property "System.Devices.Connected" is container property , if you  retrieve  device interface property "System.Devices.Connected" or device property  "System.Devices.Connected", it returns nothing.

    And the container property "System.Devices.Connected" is not correspond to the audio device state. Using audio container may find many audio device, for example, Speaker, S/PDIF or Microphone and so on.

    I had a test: if I disable 5-High Definiton Audio Device - Speaker, it's container property "System.Devices.Connected" retrieve False, if I enable the Speaker device, the property "System.Devices.Connected" retrieve True. But some plugged-in USB audio devices always retrieve True if I use the same operation.

    If I use the AQS filter string "System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#False", it retrieves all interface disable devices include disconnected devices.

    I can not get the audio device state by the canonical properties in metro app. please help me! thanks in advance.

    Best Regards,

    HappyRabbit.

    Friday, May 11, 2012 1:25 AM
  • Hi, James Dailey,

    I try the test again, the result is normal. Whether I disable or enable the Speaker device, the conatiner  property "System.Devices.Connected" always retrieves True. so it may be a bug in win8 beta version.

    http://msdn.microsoft.com/zh-cn/library/ms679040(v=VS.85).aspx

    pdwState

    [out]  Pointer to a DWORD variable into which the method writes the current state of the device. The device-state value is one of the following DEVICE_STATE_XXX constants:

    DEVICE_STATE_ACTIVE

    DEVICE_STATE_DISABLED

    DEVICE_STATE_NOTPRESENT

    DEVICE_STATE_UNPLUGGED

    Can I get the DEVICE_STATE_UNPLUGGED audio device state in metro app? and how to get it?

    best regards.

    HappyRabbit.   



    Friday, May 11, 2012 9:56 AM
  • Hello HappyRabbit,

    Are you disabling the device or removing the device from the system. If the device is still connected to the system but disabled I would expect the behavior that you are seeing. Try removing the device from the system (unplug it) and try the test again.  Can you please confirm.

    -James


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

    Friday, May 11, 2012 9:24 PM
    Moderator
  • Hello James.

    Whether the DEVICE_STATE_UNPLUGGED audio device state can be got in metro app when a headset is plugged in? if can, how to get it?

    Best regards,

    HappyRabbit.


    Monday, May 14, 2012 1:13 AM
  • Hello HappyRabbit,

    Are you talking about jack-presence detection: when a plug is inserted into or removed from a jack?

    -James


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

    Monday, May 14, 2012 8:48 PM
    Moderator
  • Hello, James,

    I am not talking about jack-presence detection.

    In win8 desktop mode, Look in the lower right hand corner next to the clock. You should see a white speaker icon. Right click it, and select "playback devices."

    You should be brought to a menu with speakers, digital audio, etc...

    Right click anywhere in the menu, and make sure "Show disabled devices" and "show disconnected devices" are checked.

    Then you can see that the audio device (for example speakers, digital audio, etc...) have the device state (for example, not plugged in, ready, disable, etc...).

    So my question is as followings about win8 metro style mode:

    Can I get the audio plalyback or recording devices state in metro app?Can I get all disabled audio devices in metro app? if can, how to do it?

    Best regards,

    HappyRabbit.

    Wednesday, May 16, 2012 2:13 AM
  • Hello HappyRabbit,

    Thank you very much for your patience. I think that I finally understand exactly what information you are trying to query from the system. I honestly don't know if this information is available. I will talk with some of the other audio developers on the team and see if they know specifically if this information is available. I do need to let you know that it may take a couple of weeks for me to respond so please be patient. If you don't hear from me by June 4th please bump this post.

    Thanks,

    James


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

    Thursday, May 17, 2012 12:37 AM
    Moderator
  • Hello HappyRabbit,

    Only 'active' endpoints have software audio devices created for them. So 'Unplugged' and 'Not Present' audio devices should not show up when enumerating audio devices in WinRT. What is the reason that you are using "System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#False” to attempt to get the disabled and unplugged devices?

    Just to be clear this is not a scenario we expected developers to need to cover so we did not add an equivelant of the  IMMDevice::GetState method.

    Thanks,

    James


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

    Friday, May 18, 2012 12:15 AM
    Moderator
  • Hello James,

    we are ready to develop a custom Metro style device app for USB audio device. So I need to get the audio device state information and list all disabled devices to control or show them like Desktop app.  Can I do it? How to do it?

    Best regards,

    HappyRabbit.

    Friday, May 18, 2012 2:52 AM
  • I'm sorry HappyRabbit but at this time you cannot get the device state like you can in a desktop app.

    -James


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

    Friday, May 18, 2012 9:41 PM
    Moderator
  • Hello James,

    If we can not emulate the disable audio endpoints in metro style mode, when the custom Metro style device app launches, we can not enable the disable audio endpoints. Please tell us how to find a way to enable the disable audio endpoint?

    Another problem,  if EQ APO effect is enable  ,and we can not get/set APO effect,  it may result in APO effect overlapping problem. For example, if EQ APO effect is enable  in metro style mode , because we can not get/set APO effect,  a custom Metro style device app may also contain EQ effect, then the EQ effect is overlapping, Please tell us how to solve this problem?

    Best regards,

    HappyRabbit.


    • Edited by happyrabbit Monday, May 21, 2012 8:04 AM
    • Marked as answer by happyrabbit Wednesday, May 23, 2012 1:35 AM
    • Unmarked as answer by happyrabbit Wednesday, May 23, 2012 1:45 AM
    Monday, May 21, 2012 2:12 AM
  • Hello James,

    If we can not emulate the disable audio endpoints in metro style mode, when the custom Metro style device app launches, we can not enable the disable audio endpoints. Please tell us how to find a way to enable the disable audio endpoint?

    Another problem,  if EQ APO effect is enable  ,and we can not get/set APO effect,  it may result in APO effect overlapping problem. For example, if EQ APO effect is enable  in metro style mode , because we can not get/set APO effect,  a custom Metro style device app may also contain EQ effect, then the EQ effect is overlapping, Please tell us how to solve this problem?

    Best regards,

    HappyRabbit.


    Hello,

    As for the above problems, someone can help me?

    Any answer is greatly appreciated.

    - HappyRabbit.


    Wednesday, May 23, 2012 3:23 AM
  • Have you looked into XAudio2?
    Tuesday, June 05, 2012 3:44 AM
    Moderator
  • Hello Eric,

    http://msdn.microsoft.com/en-us/library/windows/hardware/ff536376

    A GFX sAPO is an sAPO(System Effects Audio Processing Objects) whose processing algorithm globally affects the audio streams from all the applications that channel their audio data through the audio engine.

    http://msdn.microsoft.com/en-us/library/windows/apps/ee415735.aspx

    XAPOs are used in XAudio2 by attaching them to voices. Each XAudio2 voice has an effect chain containing zero or more audio effects.

    As mentioned above, XAudio2 uses XAPOs by attaching them to voices, it cannot create custom GFX sAPO.

    http://msdn.microsoft.com/en-us/library/windows/apps/Hh700365.aspx
    Be aware that custom extensions are only accessible to the application they are created and registered in.  They are not accessible to other applications.

    Using media extensions also cannot create custom GFX sAPO in metro style mode.

    So in metro style mode, is there any way to  control custom GFX sAPO for my USB sound card like sound effect manager(CPL) in desktop mode? if there is, how to do it?

    HappyRabbit.



    Wednesday, June 06, 2012 3:24 AM
  • Hi,

    Any update for this question? Any answer is greatly appreciated.

    Best wishes - HappyRabbit

    Friday, June 08, 2012 1:40 AM
  • Hello HappyRabbit,

    There is no mechanism built into the WinRT API to allow a developer to directly control APOs instantiated in the global audio pipeline. This is by design. Applications should not have access to these resources. These resources should only be enabled and disabled by the user.

    I hope this helps,

    James 


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

    Monday, June 11, 2012 11:49 PM
    Moderator