Problems getting QSound working on Pi 2



  • I'm working on a private project on a Pi 2 using Qt. I prefer using a cross compiler and so I followed the following tutorial to get the cross compiler working https://wiki.qt.io/RaspberryPi2EGLFS

    For the project I need a simple sound output. So my first try was using QMediaPlayer. To get this working on the Pi I had to also compile QtMultimedia. In the tutorial it is mentioned, that QtMultimedia does not fully work with videos and camera, but as I only need sound, I figured this should do it. With QMediaPlayer the sound did work, and I only got some warnings regarding volume control on the console (I did not write them down, so I can't say what they were exactly).

    However I need a gapless loop of a sound, and QMediaPlayer does not support that, so I switched to QSound. After using QSound, the sound did not playback at all, but I got the following error message:
    PulseAudioService: pa_context_connect() failed

    So I searched for a solution of that problem and stumbled over http://linux-tips.com/t/raspberyy-qt5-audio-play/374 where the following buildroot was suggested: https://github.com/pbouda/buildroot-qt-dev

    Testing with that buildroot the sound using QSound did again not work. This time the error message is:
    using null output device, none available

    Output of aplay -l:
    aplay: device_list:268: no soundcards found...

    So can anyone point me in a direction on how to solve the error on either of those two solutions, or point me to a tutorial on how to get a working combination of SD-card image and cross compiler for Qt and QSound?



  • I have solved my problem by myself. So if anyone has the same problem. Here is the way I found my solution and at the end (last line of text) the solution, which will probably work for the first tutorial, too.

    I have tried again using this tutorial https://www.ics.com/blog/configuring-qt-creator-raspberry-pi
    So I have used Qt 5.7.0 in my current try. Because this caused errors during compile of some webengine stuff, i only compiled qtbase and qtmultimedia (using make module-qtbase and make module-qtmultimedia). Also you should use make install from the according sub directories.

    However after getting that solution to work, I got the same error message from the first tutorial
    PulseAudioService: pa_context_connect() failed

    So I googled for that error message and found http://askubuntu.com/questions/70560/why-am-i-getting-this-connection-to-pulseaudio-failed-error#
    In the answers and comments there I found the following comment:

    ps. could you also post the result of 'cat /var/log/syslog | grep pulseaudio' – ovangle Nov 17 '11 at 9:51

    In the log I found the following error:
    org.bluez.Manager.GetProperties() failed: org.freedesktop.DBus.Error.UnknownMethod: Method "GetProperties" with signature "" on interface "org.bluez.Manager" doesn't exist

    Googling after that error led me here: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=148395
    And there I found this answer:
    by spl23 » Mon May 16, 2016 9:11 pm
    Officially, PulseAudio requires X to be running - a standard install of PulseAudio launches the pulseaudio daemon only when the desktop is launched.

    If you want to use Pulse from a command-line without launching the desktop, you will need to start the daemon manually before you attempt to connect a Bluetooth device (type "pulseaudio -D" at the CLI prompt).
    ...

    Using the command pulseaudio -D before starting my application solved the issue and now the sound is working.


Log in to reply