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

REG: Qt6 Audio device enumeration fails on Linux system without pulseaudio or with pulseaudio disabled.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • None
    • 6.2.5, 6.5.1, 6.5.2, 6.5.3, 6.6.0, 6.6.1, 6.7.0 FF, 6.7.0 Beta1, 6.7.0 Beta2, 6.7.0, 6.8.0
    • Multimedia
    • Ubuntu 22.04.3 LTS (for system with pulseaudio and problems with pasuspender(1)) and Ubuntu 20.04.6 LTS (for "media and tv box" running without PulseAudio).
    • Linux/Wayland, Linux/X11, Linux/Yocto, Linux/Other display system

    Description

      On a Linux system without Pulseaudio, QtMultimedia device enumeration (e.g. Examples/Qt-6.6.0/multimedia/devices ) fails with the error message

      PulseAudioService: pa_context_connect() failed'

      After the above error message, the aforementioned 'devices' example app outputs an empty list of input and output audio devices.  However active and working audio devices are available (and work for audio output) as long as the old gstreamer backend enabled: see the related bug https://bugreports.qt.io/browse/QTBUG-114846 - however the Qt6 device enumeration code doesn't see them and just outputs the error about missing PulseAudio service.

      In other words, the Qt6 device enumeration code from 'devices' example or attachment add-to-main-cpp-device-enumeration.cpp ignores the environment variable 

      QT_MEDIA_BACKEND=gstreamer

      that allows QtMultimedia to find and use existing ALSA devices for sound output. These same ALSA devices should be enumerated for Qt6 just like they are with the Qt5 (see attachment add-to-main-cpp-device-enumeration.cpp ). 

      This is a regression because in Qt5, the equivalent device enumeration code does output a list of available output devices (see attachment qmlvideobug-515.txt ) and outputs no error about the missing PulseAudio service.

      The device enumeration code should, just like the audio-output code, be able to output audio to a PulseAudio based system and fall back to using ALSA if PulseAudio is missing or disabled, just like the gstreamer backend code already does (again, see QTBUG-114846).

      Note that I'm marking this bug applicable to other Linux systems in addition to "Linux/X11" because such systems (e.g. "Linux/Yocto", "Linux/Wayland", "Linux/other display system") are likely not to have PulseAudio installed and just use ALSA (or PipeWire) directly.

      Another aspect of this bug is if one runs the app on a system with PulseAudio, but disabled via pasuspender(1): pasuspender(1) is traditionally used if one is using a professional audio, music or A/V application that expects exclusive access to an audio device without interference from other apps, or notification sounds normally mixed via pulseaudio and played back on the system speakers. In such cases, QtMultimedia also needs to detect that pulseaudio has been disabled and fall-back to, for example, the ALSA device bound to 'sysdefault' . That's what the old gstreamer backend did automatically for audio playback in Qt5 and Qt6 up to 6.4.3...

      However, this is not the case with audio device enumeration just like it's not the case with missing audio output  when using the ffmpeg backend in 6.5.2 and 6.6.0 with either missing or suspended PulseAudio. When pasuspender(1) is active,  and therefore no audio can be output through PulseAudio devices, you still see the PulseAudio default device listed as an available audio output:

       

      $:/usr/local/src/build-qmlvideobug-Desktop_Qt_6_6_0_GCC_64bit-Release$ pasuspender -- env QT_MEDIA_BACKEND=gstreamer ./qmlvideobug -
      style Material 
      int main(int, char**) QtMultimedia+QQC2+Material Style Test App for Qt = 6.6.0 
      Audio devices detected: 
      
      Input 
      
      Output 
      Name:                         HDA NVidia Digital Stereo (HDMI) 
      Id:                           alsa_output.pci-0000_01_00.1.hdmi-stereo 
      Default:                      Yes 
      Preferred Format:             Int16 
      Preferred Rate:               44100 
      Preferred Channels:           2 
      Supported Formats:            UInt8 Int16 Int32 Float 
      Supported Rates:              1 - 384000 
      Supported Channels:           1 - 32
      

      What would be expected in the above case is for audio device enumeration to recognize PulseAudio is suspended and fall-back to enumerating ALSA devices. 

      The exact same app, run under Qt5 with pasuspender(1) active does output audio and enumerates the available ALSA audio output devices:

      $: /usr/local/src/build-qmlvideobug-Desktop_Qt_5_15_3_GCC_64bit-Release$ pasuspender -- ./qmlvideobug -style Material                
      Device name:  "default" 
      Device name:  "samplerate" 
      Device name:  "speexrate" 
      Device name:  "jack" 
      Device name:  "oss" 
      Device name:  "pulse" 
      Device name:  "upmix" 
      Device name:  "vdownmix" 
      Device name:  "hw:CARD=PCH,DEV=0" 
      Device name:  "hw:CARD=PCH,DEV=1" 
      Device name:  "plughw:CARD=PCH,DEV=0" 
      Device name:  "plughw:CARD=PCH,DEV=1" 
      Device name:  "front:CARD=PCH,DEV=0" 
      Device name:  "surround21:CARD=PCH,DEV=0" 
      Device name:  "surround40:CARD=PCH,DEV=0" 
      Device name:  "surround41:CARD=PCH,DEV=0" 
      Device name:  "surround50:CARD=PCH,DEV=0" 
      Device name:  "surround51:CARD=PCH,DEV=0" 
      Device name:  "surround71:CARD=PCH,DEV=0" 
      Device name:  "iec958:CARD=PCH,DEV=0" 
      Device name:  "dmix:CARD=PCH,DEV=0" 
      Device name:  "dmix:CARD=PCH,DEV=1" 
      Device name:  "usbstream:CARD=PCH" 
      Device name:  "hw:CARD=NVidia,DEV=3" 
      Device name:  "hw:CARD=NVidia,DEV=7" 
      Device name:  "hw:CARD=NVidia,DEV=8" 
      Device name:  "hw:CARD=NVidia,DEV=9" 
      Device name:  "plughw:CARD=NVidia,DEV=3" 
      Device name:  "plughw:CARD=NVidia,DEV=7" 
      Device name:  "plughw:CARD=NVidia,DEV=8" 
      Device name:  "plughw:CARD=NVidia,DEV=9" 
      Device name:  "hdmi:CARD=NVidia,DEV=0" 
      Device name:  "hdmi:CARD=NVidia,DEV=1" 
      Device name:  "hdmi:CARD=NVidia,DEV=2" 
      Device name:  "hdmi:CARD=NVidia,DEV=3" 
      Device name:  "dmix:CARD=NVidia,DEV=3" 
      Device name:  "dmix:CARD=NVidia,DEV=7" 
      Device name:  "dmix:CARD=NVidia,DEV=8" 
      Device name:  "dmix:CARD=NVidia,DEV=9" 
      Device name:  "usbstream:CARD=NVidia" 
      Device name:  "alsa_output.pci-0000_01_00.1.hdmi-stereo" 
      default device:  "alsa_output.pci-0000_01_00.1.hdmi-stereo" 
      int main(int, char**) QtMultimedia+QQC2+Material Style Test App for Qt = 5.15.3

      Attachments

        1. add-to-main-cpp-device-enumeration.cpp
          4 kB
        2. qmlvideobug-515.txt
          3 kB
        3. qtdevices-643.txt
          0.3 kB
        4. qtdevices-651.txt
          0.4 kB
        5. qtdevices-652.txt
          0.4 kB
        6. qtdevices-660.txt
          0.4 kB

        Activity

          People

            artemiy Artem Dyomin
            nielsmayer Niels Mayer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: