Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Duplicate device name returned from QAudioDeviceInfo::availableDevices

    General and Desktop
    3
    3
    210
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • _
      _Henning_ last edited by _Henning_

      Hi,

      I am trying to list the available devices on my system and output them:

      QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
      for (const QAudioDeviceInfo & dev : devices)
      output(dev.deviceName());

      I don't understand why two devices are returned on my system with the same name but different properties:

      Microphone (High Definition Audio Device)
      sample rates: 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200, 96000, 192000,
      channel counts: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
      sample size: 8, 16, 24, 32, 48, 64,
      codecs: audio/pcm,
      byte order: 1,
      sample type: 1, 2, 3,

      Microphone (High Definition Audio Device)
      sample rates: 44100,
      channel counts: 2,
      sample size: 8, 16, 24, 32, 64,
      codecs: audio/pcm,
      byte order: 1,
      sample type: 1, 3,

      The documentation (https://doc.qt.io/qt-5/qaudiodeviceinfo.html#deviceName) states that the device name should be unique.
      Of course I can workaround the problem somehow, I was just thinking if I don't understand something or if this is a qt but I should report.

      (a little bit off-topic: how do I convert the enum values to strings ? Of course I searched how to do this but all solutions I found required the Q_ENUM macro but the macro is not present in the QAudioFormat class where the enums are declared).

      I am on Windows10/MSVC2019 16.5.2/Qt 5.14.2 msvc2017_64

      Any help is appreciated.

      Regards,
      Henning

      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @_Henning_ last edited by

        @_Henning_ said in Duplicate device name returned from QAudioDeviceInfo::availableDevices:

        how do I convert the enum values to strings ?

        Not elegant but works:

        QString strValue;
        switch(value) {
        case ENUM_VALUE_1:
        strValue = "ENUM_VALUE_1";
        break;
        case...
        }
        

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 1
        • XMuli
          XMuli last edited by XMuli

          Hi, did you solve it later? It's now 2023.05 and I came across that I'm still to the same problem.

          Using QAudioDeviceInfo::availableDevices on Qt5.15.2 + MSVC 2022 gets duplicate names, but using MinGW compilation does not.(Windows 10 22H2)

          1 Reply Last reply Reply Quote 0
          • First post
            Last post