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

QtMultimedia fails to play audio using MediaPlayer QML item, even though alsa and gstreamer can.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.8.2
    • Multimedia
    • Linux/Wayland

    Description

      Hi,
      I have come across this issue in my current project which is Yocto-RPi5 based work that involves a Qt/QML application which is supposed to play audio track using MediaPlayer QML item. I would like to play music through alsa in Linux, not pulseaudio.

      speaker-test, gst-launch, and aplay all work, I can hear sound from these commands:

      aplay /usr/share/sounds/alsa/Front_Center.wav
      
      gst-launch-1.0 audiotestsrc freq=1000 ! audioconvert ! audioresample ! alsasink
      
      speaker-test -t wav

      gstreamer-plugins-base compiled with alsa option, qtmultimedia compiled with alsa and gstreamer options:

      PACKAGECONFIG:append:pn-gstreamer1.0-plugins-base = " alsa"
      PACKAGECONFIG:append:pn-qtmultimedia = " alsa"
      PACKAGECONFIG:append:pn-qtmultimedia = " gstreamer"
      PACKAGECONFIG:remove:pn-qtmultimedia = "pulseaudio"
      PACKAGECONFIG:remove:pn-qtmultimedia = "ffmpeg" 

      I have a wm8960 device attached which has following configuration:

      # Set default card
      defaults.pcm.card 2
      defaults.ctl.card 2
      # Use samplerate for resampling
      defaults.pcm.rate_converter "samplerate"
      # Define default PCM for playback and capture
      pcm.!default {
      type asym
      playback.pcm "playback"
      capture.pcm "capture"
      }
      pcm.playback {
      type plug
      slave.pcm "dmixed"
      }
      pcm.capture {
      type plug
      slave.pcm "array"
      }
      pcm.dmixed {
      type dmix
      slave {
      pcm "hw:2,0" # Corrected from "hw:wm8960soundcard"
      rate 48000 # Ensure sample rate matches your hardware
      period_time 0
      period_size 1024
      buffer_size 4096
      }
      ipc_key 555555
      }
      pcm.array {
      type dsnoop
      slave {
      pcm "hw:2,0" # Corrected from "hw:wm8960soundcard"
      channels 2
      }
      ipc_key 666666
      } 

      aplay -l output:

      card 0: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
        Subdevices: 1/1
        Subdevice #0: subdevice #0
      card 1: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
        Subdevices: 1/1
        Subdevice #0: subdevice #0
      card 2: wm8960soundcard [wm8960-soundcard], device 0: 1f000a0000.i2s-wm8960-hifi wm8960-hifi-0 [1f000a0000.i2s-
      wm8960-hifi wm8960-hifi-0]
        Subdevices: 1/1
        Subdevice #0: subdevice #0

      However, with qtmultimedia I can not seem to have audio for some reason. I suspect that my device is not recognized by qtmultimedia or there is some config I need to do which I am missing.

      GST_DEBUG=3 QT_GSTREAMER_AUDIOSINK="alsasink device=hw:2,0" pi_launcher -platform wayland
      
      0:00:12.242944215   475 0x7fff54001240 FIXME             decodebin3 gstdecodebin3.c:2015:gst_decodebin_input_re
      quires_parsebin:<decodebin3-0:sink> parsebin not needed (matches output caps) !
      0:00:12.243285863   475 0x7fff54001240 FIXME             decodebin3 gstdecodebin3.c:1298:gst_decodebin_input_un
      block_streams:<decodebin3-0> Re-use existing input streams if/when possible
      0:00:12.243604270   475 0x7fff54001240 FIXME             decodebin3 gstdecodebin3.c:948:check_all_input_streams
      _for_eos:<multiqueue0:sink_0> Remove input stream
      0:00:12.247219252   475 0x7fff540012a0 WARN                    alsa pcm_hw.c:1801:snd_pcm_hw_open: alsalib erro
      r: open '/dev/snd/pcmC0D0p' failed (-524): Unknown error 524
      0:00:12.247359789   475 0x7fff540012a0 WARN                    alsa gstalsasink.c:903:gst_alsasink_open:<audios
      ink> Error -524 (Unknown error 524) calling snd_pcm_open (&alsa->handle, alsa->device, SND_PCM_STREAM_PLAYBACK,
       SND_PCM_NONBLOCK)
      0:00:12.247383030   475 0x7fff540012a0 WARN                    alsa gstalsasink.c:918:gst_alsasink_open:<audios
      ink> error: Could not open audio device for playback.
      0:00:12.247392733   475 0x7fff540012a0 WARN                    alsa gstalsasink.c:918:gst_alsasink_open:<audios
      ink> error: Playback open error on device 'sysdefault:CARD=vc4hdmi0': Unknown error 524
      0:00:12.247556085   475 0x555620883dc0 ERROR               gst-play gstplay.c:1084:error_cb:<play0> ERROR: from
       element /GstBin:audioOutput/GstAlsaSink:audiosink: Could not open audio device for playback.
      0:00:12.247575826   475 0x555620883dc0 ERROR               gst-play gstplay.c:1086:error_cb:<play0> Additional 
      debug info: /usr/src/debug/gstreamer1.0-plugins-base/1.24.10/ext/alsa/gstalsasink.c(918): gst_alsasink_open ():
       /GstBin:audioOutput/GstAlsaSink:audiosink:
      Playback open error on device 'sysdefault:CARD=vc4hdmi0': Unknown error 524
      0:00:12.247597418   475 0x555620883dc0 ERROR               gst-play gstplay.c:984:on_error:<play0> Error: Error
       from element /GstBin:audioOutput/GstAlsaSink:audiosink: Could not open resource for writing.
      Could not open audio device for playback.
      /usr/src/debug/gstreamer1.0-plugins-base/1.24.10/ext/alsa/gstalsasink.c(918[  702.208232] GPIO Button released:
       keycode=106
      ): gst_alsasink_open (): /GstBin:audioOutput/GstAlsaSink:audiosink:
      Playback open error on device 'sysdefault:CARD=vc4hdmi0': Unknown error 524 (gst-play-error-quark, 0)
      0:00:12.247582678   475 0x7fff540012a0 WARN                playsink gstplaysink.c:2947:gen_audio_chain:<playsin
      k> error: Configured audiosink audioOutput is not working.

      I am not sure if this is a known qt bug or if I am missing a configuration for qt to recognize my device. Any help is appreciated.

       

      Attachments

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

        Activity

          People

            qtmultimediateam Qt Multimedia Team
            moz Mustafa Ozcelikors
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes