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

QtMultimedia, QAudioInput, default device: volume() and setVolume() don't work as expected

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Fixed
    • Affects Version/s: 5.8.0, 5.9.0
    • Fix Version/s: 5.11.1
    • Component/s: Multimedia
    • Labels:
      None
    • Environment:
      Windows 7, Qt 5.9.1 (and also verified in PyQt5)

      Description

      Reading the volume from the default input device always returns 0. Trying to write to it also does not work.

      This seems to be a regression compared to Qt 5.7 and might be connected with a change in behavior of how the default device is determined. Instead of just taking the first device from the list of all devices, something more clever is done. Unlike Qt 5.7 the device's name in PyQt5.8+ is "Default Input Device" instead of the actual name.

      Here is some code I ran on Windows 7 with Qt 5.9.1 and which shows the problem. The variable v0 should reflect the current volume settings but it's always 0.0. And the variable v1 should be 0.5 after the volume was set to 0.5 in the previous step, but it's always 0.0.

      #include <iostream>
      #include <QAudioInput>
      
      using namespace std;
      
      int main()
      {
          QAudioInput* audio;
          {
              QAudioFormat format;
              // Set up the desired format, for example:
              format.setSampleRate(8000);
              format.setChannelCount(1);
              format.setSampleSize(8);
              format.setCodec("audio/pcm");
              format.setByteOrder(QAudioFormat::LittleEndian);
              format.setSampleType(QAudioFormat::UnSignedInt);
      
              QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice();
              if (!info.isFormatSupported(format)) {
                  cout << "Default format not supported, trying to use the nearest.";
                  format = info.nearestFormat(format);
              }
      
              audio = new QAudioInput(format);
      
              qreal v0 = audio->volume();
              cout << "v0 = " << v0 << endl; // v0 is always 0.0
      
              audio->setVolume(qreal(0.5));
              qreal v1 = audio->volume();
              cout << "v1 = " << v1 << endl; // v1 is always 0.0 (should be 0.5)
          }
      }
      
      

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              valentyn.doroshchuk Valentyn Doroshchuk
              Reporter:
              e1i45 Elias
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes