Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt6 linux: no audio output via QAudioSink
Forum Updated to NodeBB v4.3 + New Features

Qt6 linux: no audio output via QAudioSink

Scheduled Pinned Locked Moved Solved General and Desktop
audio deviceqt6
8 Posts 2 Posters 704 Views 1 Watching
  • 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.
  • A Offline
    A Offline
    Audetto
    wrote on 10 Dec 2024, 19:50 last edited by
    #1

    Hi, I am porting my app to Qt6 and struggling to make QAudioSink produce any sound.
    I am on Ubuntu 24.04, using Qt 6.4.2

    After various checks I think the issue is in the default choice of the audio device.

    Qt5's default is: alsa_output.pci-0000_00_1b.0.analog-stereo

    On Qt6 I can only get one of these

    Built-in Audio Analog Stereo
    Built-in Audio Digital Stereo (HDMI)

    These are the real hardware devices which are already managed by alsa / pulse / pipewire, and cannot be used directly.
    Qt5 plays a virtual alsa device which is mixed by the audio system.

    How do I do the same in Qt6? I've read about QT_MEDIA_BACKEND=gstreamer or ffmpeg but it makes no difference.

    Andrea

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 15 Dec 2024, 19:52 last edited by
      #2

      Hi,

      How did you set that environment variable ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Audetto
        wrote on 1 Feb 2025, 18:54 last edited by Audetto 2 Jan 2025, 18:55
        #3

        Finally found a solution.

        It is a change in behaviour between Qt5 and Qt6.

        When the QIODevice produces 0 bytes, in Qt6, the QAudioSink goes to IdleState and effectively stops, even if more data is available.

        https://github.com/qt/qtmultimedia/blob/c0c276b9013acac9214026c9645eee353d67f00e/src/multimedia/pulseaudio/qpulseaudiosink.cpp#L468

        One needs to emit readyRead(); when more data is available.

        In Qt5, nothing of the sort happens.

        https://github.com/qt/qtmultimedia/blob/5dc0ed6f5059b6ab81c3009cf72797a36ec5b211/src/plugins/pulseaudio/qaudiooutput_pulse.cpp#L477

        These are links to particular implementations of the output plugin, I have no way to know if this is the intended general behaviour, which anyway is not documented anywhere in https://doc.qt.io/qt-6/qaudiosink.html

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 1 Feb 2025, 19:20 last edited by
          #4

          The multimedia module has been fully rewritten for Qt 6.

          That said, the current behavior makes sens to me and I would say the Qt 5 implementation was wrong in that regard. How is the system supposed to know you are making new data available if you don't tell it ? The other option is to have an active polling which would just waste resources.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          A 1 Reply Last reply 1 Feb 2025, 19:23
          0
          • S SGaist
            1 Feb 2025, 19:20

            The multimedia module has been fully rewritten for Qt 6.

            That said, the current behavior makes sens to me and I would say the Qt 5 implementation was wrong in that regard. How is the system supposed to know you are making new data available if you don't tell it ? The other option is to have an active polling which would just waste resources.

            A Offline
            A Offline
            Audetto
            wrote on 1 Feb 2025, 19:23 last edited by
            #5

            @SGaist Don't disagree, but without looking into the source code, I would have never figured it out. A little mention of this in the linked page would help.

            1 Reply Last reply
            0
            • A Audetto has marked this topic as solved on 1 Feb 2025, 19:30
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 1 Feb 2025, 19:30 last edited by
              #6

              I am realizing I might be seeing this from the wrong perspective. Are you providing your own custom QIODevice ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • A Offline
                A Offline
                Audetto
                wrote on 1 Feb 2025, 19:59 last edited by
                #7

                Yes, Qt5 would never go in Idle, while Qt6 does. I know now how to wake it up.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 2 Feb 2025, 06:29 last edited by
                  #8

                  Then you're lucky it worked :-)
                  Good thing you can fix your QIODevice class !

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved