Is audio playback via ALSA supported in Qt5?
Asked Answered
E

3

11

I have a small C++ Qt program that uses a QAudioOutput instance to emit sound. It compiles & runs fine using Qt 4.8.5.

However, in Qt 5.0, 5.1, and 5.2, my application compiles, but does not work. I get the following error message while the constructor of the QAudioOutput instance is running:

Unable to create a connection to the pulseaudio context.

Also, the constructor does not return, so my program hangs.

I do not have pulseaudio running. ALSA is working fine, and this is what my program uses when compiled with Qt 4.8.5.

Inspecting the Qt5 “plugins/audio” directory, there is only “libqtmedia_pulse.so” there, the name of which suggests that it depends on pulseaudio.

My questions:

  • Is there still a backend for output to ALSA (without pulseaudio) in Qt 5+ ?
  • If yes, how do I make sure it is built? I do not see any configure options for that.
  • It appears to be a bug that the constructor of QAudioOutput hangs my app. Where can I report that?
Esquiline answered 14/11, 2013 at 18:30 Comment(1)
Did you build Qt yourself? You may have to enable the ALSA audio plugin to get it to work. It should definitely be supported, according to the Qt Multimedia Backends document. You can also take a look at the QAudioDeviceInfo Class to see which audio devices were recognized.Plummer
C
4

From Qt documentation wiki on Multimedia Backends:

Here is the list of the current audio backends:

Windows Multimedia
CoreAudio (Mac OS / iOS)
PulseAudio (Unix)
Alsa (Unix)
OpenSL ES (Android)
QNX

Only PulseAudio, CoreAudio, and QNX backends are actual plugins. The other backends are “#ifdef’ed” in the related classes.

So basically ALSA is not a plugin but must be selected when you configure Qt (if you build your own, which I assume you are).

From Qt documentation wiki on building Qt5 from git:

Qt Multimedia

You’ll need at least alsa-lib (>= 1.0.15) and gstreamer (>=0.10.24, but <1.0 for now [lists.qt-project.org]) with the base-plugins package.

Ubuntu/Debian:

sudo apt-get install libasound2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev

When configuring Qt I have lost count over the times when some feature was not compiled in because of missing dependencies. So make absolutely 100% sure that all dependencies are installed properly, and that all your configuration options are valid with the current configuration program (available options change even between minor versions)! Remember to look closely at output from build process (collect output in a file and search through it after build completes for any messages with "skipping" or "error" or such keywords.

OTOH, if you did not build your own Qt then I have no clue and you should disregard this answer.

Cowled answered 30/7, 2014 at 19:14 Comment(0)
A
0

Fix is present in Qt 5.4, commit eb75bf8e3bde3a9b3efc91b54aa4dc2e34a3cde4


I'm the Debian maintainer for Qt and today a user came with the same problem. The build logs show that alsa dependencies are there and it's being properly detected... :-/

Note 2014-12-03: the problem lies in plugins.pro: it doesn't builds the alsa plugin if pulseaudio support is found. Problem and patch by Chris Ruvolo, will push upstream later today.

Antipas answered 29/11, 2014 at 19:5 Comment(0)
C
0

Here, https://wiki.qt.io/Qt_5.13_Multimedia_Backends

enter image description here

Yes, I think Alsa also supports it.

Cahier answered 9/11, 2020 at 23:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.