Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-108668

QAudioDevice shows incorrect (old Qt5) QMediaDevices usage

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.2.7, 6.4.3, 6.5.0
    • 6.4.1
    • Documentation
    • None
    • All
    • 70ce4a4d4 (dev), 6635bf85b (tqtc/lts-6.2), b93b9054f (6.4)
    • DaVinci 68

    Description

      In https://doc.qt.io/qt-6/qaudiodevice.html#details, the example showing how to enumerate all audio output devices contains the following code snippet:

      const auto deviceInfos = QMediaDevices::availableDevices(QAudioDevice::Output);
      for (const QAudioDevice &deviceInfo : deviceInfos)
          qDebug() << "Device: " << deviceInfo.description();
      

      This is not correct and appears to be a remnant of the Qt5 QAudioDeviceInfo API.

      QMediaDevices does not have an "availableDevices" method. The correct example should be:

      const auto deviceInfos = QMediaDevices::audioOutputs(); 
      for (const QAudioDevice &deviceInfo : deviceInfos)
          qDebug() << "Device: " << deviceInfo.description();
      

       

      It is especially important to get these examples correct because migrating QtMultimedia code from Qt5 to Qt6 is already fairly confusing as-is due to various reasons.

       

      Minor note: The variables should probably be named "devices" and "device" as well, just for consistency's sake (another Qt5 remnant, where these were QAudioDeviceInfos instead of QAudioDevices).

      Attachments

        For Gerrit Dashboard: QTBUG-108668
        # Subject Branch Project Status CR V

        Activity

          People

            andreas.eliasson Andreas Eliasson
            jasonc Jason Cipriani
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes