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

Streaming audio from source to sink fails in Qt6, succeeds in Qt5

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2: Important P2: Important
    • 6.5.0, 6.6.0
    • 6.4.1
    • Multimedia
    • None
    • Windows
    • cb8cb4923 (dev), 983aea3d9 (6.5)

      The following program:

       

      int main (int argc, char **argv) {
      
          QCoreApplication a(argc, argv);
      
          for (auto in : QMediaDevices::audioInputs()) qDebug() << "in" << in.description();
          for (auto out : QMediaDevices::audioOutputs()) qDebug() << "out" << out.description();
      
          // adjust indices for your system
          QAudioDevice indev = QMediaDevices::audioInputs()[1];
          QAudioDevice outdev = QMediaDevices::audioOutputs()[0];
      
          QAudioFormat format = outdev.preferredFormat();
          QAudioSource *input = new QAudioSource(indev, format);
          QAudioSink *output = new QAudioSink(outdev, format);
      
          QObject::connect(input, &QAudioSource::stateChanged, [&](auto state){qDebug()<<"input"<<state<<input->error();});
          QObject::connect(output, &QAudioSink::stateChanged, [&](auto state){qDebug()<<"output"<<state<<output->error();});
      
      #if 0
          // this produces silence
          QIODevice *iod = input->start();
          output->setBufferSize(input->bufferSize());
          output->start(iod);
      #else
          // this produces buffer repeats
          QIODevice *iod = output->start();
          input->setBufferSize(output->bufferSize());
          input->start(iod);
      #endif
          // setBufferSize above has no effect.
      
      }

      Fails to stream the QAudioSource to the QAudioSink in Qt 6.4.1, but the equivalent code succeeds in Qt 5.15.

      If the input is opened first, then only silence results. No errors are reported.

      If the output is opened first, then buffer section repeats are heard (the audio plays, but it is chopped up out of order), and UnderrunErrors are repeatedly encountered.

      With Qt 5.15.2, both strategies succeed.

      Could be related to – or even identical to – https://bugreports.qt.io/browse/QTBUG-108672.

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

            piotr Piotr Srebrny (Inactive)
            jasonc Jason Cipriani
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There is 1 open Gerrit change