Problems to get sound working with Yocto on the Raspberry Pi
-
wrote on 19 Jun 2022, 16:36 last edited by coldspark29
I previously had the sound working on the Raspbian installation where I compiled Qt manually. Now in the Yocto installation I can't get it to work, although I can play .wav file with
aplay
. Soasound.conf
andasound.state
should be configured right. I think that Qt uses gstreamer usually, but I also installed pulseaudio to make sure. None of it works.Here are the packages I have installed
IMAGE_INSTALL:append = " \ alsa-state \ alsa-utils \ gstreamer1.0 \ gstreamer1.0-libav \ gstreamer1.0-plugins-good \ gstreamer1.0-plugins-bad \ gstreamer1.0-plugins-ugly \ dbus \ pulseaudio-server \ pulseaudio-misc \ pulseaudio-module-dbus-protocol \ healthpi \ module-init-tools \ qtbase \ qtbase-examples \ qtbase-plugins \ qtbase-tools \ qtdeclarative \ qtdeclarative-plugins \ qtdeclarative-qmlplugins \ qtdeclarative-tools \ qtimageformats-plugins \ qtmultimedia \ qtmultimedia-plugins \ qtmultimedia-qmlplugins \ qtquickcontrols2 \ qtquicktimeline \ qtscript \ qtsvg \ qtsvg-plugins \ qtsystems \ qtsystems-qmlplugins \ qtsystems-tools \ pulseaudio \ " PACKAGECONFIG:append:pn-qtbase = " \ eglfs \ fontconfig \ kms \ " PACKAGECONFIG:append:pn-qtmultimedia = "\ pulseaudio \ gstreamer \ alsa \ " DISTRO_FEATURES:append = " \ eglfs \ linuxfb \ pulseaudio \ dbus \ "
The code I am using is as like this:
player = new QMediaPlayer{}; player->setMedia(QUrl::fromLocalFile("sounds/test.wav")); player->setVolume(100); player->play();
I am not sure what is missing here.
-
Hi,
Might be a silly question but are you sure your application is finding the file ?
-
wrote on 19 Jun 2022, 17:23 last edited by coldspark29
@SGaist I actually tried setting some non-existant file and QtMediaPlayer did not complain. So I am not sure. It does find all the other assets like images, so I am assuming that it finds the file as well. What is weird though it that I don't really need to have the other assets in the working directory as I used to when I was manually building the app for Raspian. Seems like they are somehow being compiled into the binary, which wasn't the case before. Confusing!
Any ideas how to debug this?
-
Did you put them in Qt's resources system ?
One thing you can do is start your application with the QT_DEBUG_PLUGINS environment variable set to 1 to see what is happening on the backend side.
-
Did you put them in Qt's resources system ?
One thing you can do is start your application with the QT_DEBUG_PLUGINS environment variable set to 1 to see what is happening on the backend side.
wrote on 19 Jun 2022, 18:02 last edited by@SGaist Yes, I just realized that the images are listed close to the .qml file, because I added them as assets. The sounds were not listed there, so I tried adding them as well. Unfortunately this did not work. I assume that those assets are only needed for QML and not for the C++ code.
I tried setting QT_DEBUG_PLUGINS and I don't see anything suspicious
-
Everything seems to load fine indeed.
Did you try to play that file with GStreamer directly like you did with aplay ?
-
wrote on 19 Jun 2022, 19:08 last edited by
I tried googling for a command, but I am always getting errors. Can you help me out here?
Also: when I check
player->availability()
orplayer->isAudioAvailable()
, both are false. Does this mean Qt can't find the file? -
What errors are you getting ?
The command should look like gst-play.
-
wrote on 19 Jun 2022, 19:20 last edited by coldspark29
I am trying
root@pi:~# gst-launch-1.0 filesrc location=/home/root/sounds/test.wav ! wavparse ! audioconvert ! audioresample ! alsasink WARNING: erroneous pipeline: no element "wavparse"
as documented here https://gstreamer.freedesktop.org/documentation/tools/gst-launch.html?gi-language=c
There is no gst-play on my system
-
Did you install all the GStreamer related package ? There might be one dedicated to these tools.
-
wrote on 19 Jun 2022, 19:33 last edited by
No, the qtmultimedia package installs only the bad
https://github.com/meta-qt5/meta-qt5/blob/master/recipes-qt/qt5/qtmultimedia_git.bb
Will manually install the good and the ugly as well...
-
wrote on 19 Jun 2022, 20:05 last edited by
Yes! I installed the good, bad, ugly and base plugins. Now I can not only play the files using the above command, but the Qt application can also play sound. Actually Yocto should take care of this. Weird.
-
I am guessing that the plugin may have changed from one package to another because it was deemed stable but was not when first introduced.
Can you check if installing only the good plugins is enough ?
-
I previously had the sound working on the Raspbian installation where I compiled Qt manually. Now in the Yocto installation I can't get it to work, although I can play .wav file with
aplay
. Soasound.conf
andasound.state
should be configured right. I think that Qt uses gstreamer usually, but I also installed pulseaudio to make sure. None of it works.Here are the packages I have installed
IMAGE_INSTALL:append = " \ alsa-state \ alsa-utils \ gstreamer1.0 \ gstreamer1.0-libav \ gstreamer1.0-plugins-good \ gstreamer1.0-plugins-bad \ gstreamer1.0-plugins-ugly \ dbus \ pulseaudio-server \ pulseaudio-misc \ pulseaudio-module-dbus-protocol \ healthpi \ module-init-tools \ qtbase \ qtbase-examples \ qtbase-plugins \ qtbase-tools \ qtdeclarative \ qtdeclarative-plugins \ qtdeclarative-qmlplugins \ qtdeclarative-tools \ qtimageformats-plugins \ qtmultimedia \ qtmultimedia-plugins \ qtmultimedia-qmlplugins \ qtquickcontrols2 \ qtquicktimeline \ qtscript \ qtsvg \ qtsvg-plugins \ qtsystems \ qtsystems-qmlplugins \ qtsystems-tools \ pulseaudio \ " PACKAGECONFIG:append:pn-qtbase = " \ eglfs \ fontconfig \ kms \ " PACKAGECONFIG:append:pn-qtmultimedia = "\ pulseaudio \ gstreamer \ alsa \ " DISTRO_FEATURES:append = " \ eglfs \ linuxfb \ pulseaudio \ dbus \ "
The code I am using is as like this:
player = new QMediaPlayer{}; player->setMedia(QUrl::fromLocalFile("sounds/test.wav")); player->setVolume(100); player->play();
I am not sure what is missing here.
wrote on 21 Mar 2023, 02:29 last edited by HaiHoang@coldspark29 Make sure all related plugins are installed:
gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly
and enable qt multimedia:
PACKAGECONFIG_append_pn-qtmultimedia = " gstreamer alsa"