Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Yocto + Qt5 + Alsa + RaspberryPi + USB Audio

Yocto + Qt5 + Alsa + RaspberryPi + USB Audio

Scheduled Pinned Locked Moved Solved Mobile and Embedded
7 Posts 2 Posters 4.4k Views
  • 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.
  • E Offline
    E Offline
    electronicsengineer8
    wrote on last edited by electronicsengineer8
    #1

    I want to set up audio output for my raspberry pi with Yocto [2.6.1], I have configured Yocto in local.conf

    IMAGE_INSTALL_append = " gstreamer1.0  gstreamer1.0-meta-base gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer-plugins-ugly"
    
    IMAGE_INSTALL_append = " alsa-lib alsa-utils alsa-plugin alsa-tools"
    
    PACKAGECONFIG_append_pn-qtmultimedia = " gstreamer alsa"
    

    When i test audio with aplay and wav file, i can heard sound (successfully).
    Then, i try to play trough Qt with QMediaPlayer (c++) and Audio QML, i can not heard anything and I got following message

    Could not open audio device for playback

    That my code:

    Audio{
    id: fileAudio
    source: "qrc:///Computer-Magic.mp3"
    onStatusChanged: testLabel.text = "File Audio Status: " + status + " - " + "Volume: " + volume
    onError: console.log(errorString)
    onBufferProgressChanged: console.log("Buffer Progress: "+ bufferProgress)
    onAvailabilityChanged: console.log("Availability: "+ availability)
    }
    

    But, when I test with examples software from qt code (audiooutput), I can heard beep sound testing (the software have option to select audio device).
    I guess the problem is qt don't know which one audio device to use.

    How to set default audio device output globally in qt, so QMediaPlayer and QML Audio can run?

    Thank's

    update:
    That is result when i run my qt software

    root@raspberrypi0-wifi:~# ./QtTest
    Unable to query physical screen size, defaulting to 100 dpi.
    To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).
    Device name: "default"
    Device name: "default:CARD=Set"
    Device name: "sysdefault:CARD=Set"
    Device name: "front:CARD=Set"
    Device name: "surround21:CARD=Set,DEV=0"
    Device name: "surround40:CARD=Set,DEV=0"
    Device name: "surround41:CARD=Set,DEV=0"
    Device name: "surround50:CARD=Set,DEV=0"
    Device name: "surround51:CARD=Set,DEV=0"
    Device name: "surround71:CARD=Set,DEV=0"
    Device name: "iec958:CARD=Set,DEV=0"
    Warning: "Could not open audio device for playback."

    1 Reply Last reply
    0
    • Cleiton BuenoC Offline
      Cleiton BuenoC Offline
      Cleiton Bueno
      wrote on last edited by
      #2

      Add pulseaudio in PACKAGECONFIG_append_pn-qtmultimedia and install pulseaudio and its tools in IMAGE_INSTALL


      Cleiton Bueno

      Blog | Linkedin | B2Open

      E 1 Reply Last reply
      0
      • E Offline
        E Offline
        electronicsengineer8
        wrote on last edited by electronicsengineer8
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • Cleiton BuenoC Cleiton Bueno

          Add pulseaudio in PACKAGECONFIG_append_pn-qtmultimedia and install pulseaudio and its tools in IMAGE_INSTALL


          Cleiton Bueno

          Blog | Linkedin | B2Open

          E Offline
          E Offline
          electronicsengineer8
          wrote on last edited by
          #4

          @Cleiton-Bueno

          Thank for your reply.
          I'v tested with your suggestion before, but still problem. I got following message

          "PulseAudioService: pa_context_connect() failed"

          when i run

          ps -ae | grep pulseaudio
          

          or

          opkg list-installed | grep pulse
          

          the result is nothing. maybe pulseaudio not completely installed.

          Cleiton BuenoC 1 Reply Last reply
          0
          • E electronicsengineer8

            @Cleiton-Bueno

            Thank for your reply.
            I'v tested with your suggestion before, but still problem. I got following message

            "PulseAudioService: pa_context_connect() failed"

            when i run

            ps -ae | grep pulseaudio
            

            or

            opkg list-installed | grep pulse
            

            the result is nothing. maybe pulseaudio not completely installed.

            Cleiton BuenoC Offline
            Cleiton BuenoC Offline
            Cleiton Bueno
            wrote on last edited by
            #5

            @electronicsengineer8 check that DISTRO_FEATURES is with pulseaudio in the list and install the packages below in the IMAGE_INSTALL, something like below:

            DISTRO_FEATURES_append = "pulseaudio dbus systemd"
             
            
            IMAGE_INSTALL_append = "qtmultimedia qtmultimedia-plugins qtmultimedia-qmlplugins dbus pulseaudio-pulseaudio-server pulseaudio-misc pulseaudio-module-dbus-protocol alsa-utils"
            

            If using Systemd, add this below:
            PACKAGECONFIG_append_pn-pulseaudio = "systemd"


            Cleiton Bueno

            Blog | Linkedin | B2Open

            E 1 Reply Last reply
            0
            • Cleiton BuenoC Cleiton Bueno

              @electronicsengineer8 check that DISTRO_FEATURES is with pulseaudio in the list and install the packages below in the IMAGE_INSTALL, something like below:

              DISTRO_FEATURES_append = "pulseaudio dbus systemd"
               
              
              IMAGE_INSTALL_append = "qtmultimedia qtmultimedia-plugins qtmultimedia-qmlplugins dbus pulseaudio-pulseaudio-server pulseaudio-misc pulseaudio-module-dbus-protocol alsa-utils"
              

              If using Systemd, add this below:
              PACKAGECONFIG_append_pn-pulseaudio = "systemd"


              Cleiton Bueno

              Blog | Linkedin | B2Open

              E Offline
              E Offline
              electronicsengineer8
              wrote on last edited by
              #6

              @Cleiton-Bueno
              Thanks a lot, finally the audio device work like charm. I can hear the voice.

              I change pulseaudio-pulseaudio-server to pulseaudio-server.

              Then, a bit configuration after flashing because my system not run x11, That is the instruction

              https://unix.stackexchange.com/questions/105964/launch-a-fake-minimal-x-session-for-pulseaudio-dbus

              Drl Sherif Omran
              I had the same issue yesterday, using Pulse audio for raspberrypi 0 W with DBus in a headless environment create with yocto without x11 and no systemd, you need to run and export dbus before you run pulseaudio.
              
              if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
                   echo "Starting dbus" 
                   export $(dbus-launch)
              fi
              In etc/pulse/client.conf, please enable allow-autospawn-for-root = yes
              
              Run pulseaudio -v to check if there's another problem in your config. Don't use --system switch because it won't be correct.
              
              pulseaudio -D --disallow-exit
              
              1 Reply Last reply
              0
              • Cleiton BuenoC Offline
                Cleiton BuenoC Offline
                Cleiton Bueno
                wrote on last edited by
                #7

                Nice @electronicsengineer8.

                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