Hi,
I am currently working on a project to convert a Boot2Qt 5.12 image developed by a previous team into a Torizon image. Unfortunately, only the final .img file was provided.
I am currently looking at how to set the sound levels of my Qt application, located in its own container.
In the Boot2Qt image, the global sounds were set using Amixer on the Headphone and PCM simple controls:
amixer set Headphone 100%
amixer set PCM 100%
However, running these commands on my own application container, at startup, outputs the following:
amixer: Unable to find simple control 'Headphone',0
amixer: Unable to find simple control 'PCM',0
PulseAudioService: pa_context_connect() failed
PulseAudioService: pa_context_connect() failed
PulseAudioService: pa_context_connect() failed
PulseAudioService: pa_context_connect() failed
PulseAudioService: pa_context_connect() failed
PulseAudioService: pa_context_connect() failed
PulseAudioService: pa_context_connect() failed
PulseAudioService: pa_context_connect() failed
Running the amixer command in my container does not show any Simple Control detected. Do I have to set them myself in TorizonCore, or did I miss a step in exposing the sound devices?
So far, all I’ve done is exposing the device /dev/snd to the container in my docker-compose file, as shown in the online articles.
Here are more information regarding my setup:
- Ixora Evaluation Board v1.2
- TorizonCore 6.1.0 Build 1
- Qt App in its own container
- Developing using the Torizon Extension on VS Code via Windows 10 machine.
Hi @anthonyabboud,
Could you please check if you have installed all the necessary packages inside your container? You should install libasound2
, libasound2-dev
, and alsa-utils
. It looks like these packages are missing from your container.
Please check this article for more information: How to play audio on TorizonCore using Alsa and C/C++ | Toradex Developer Center.
Best Regards,
Hiago.
Hi @hfranco.tx,
Running the command amixer -help
can confirm I have the package installed in the container.
Futhermore, the packages libasound2
and alsa-utils
.
Adding libasound2-dev
to my devpackages for compile time like mentioned in the article you linked or extrapackages did not help.
Thanks,
Anthony
Greetings @anthonyabboud,
When running amixer
in a container you need to specify the sound/audio card with the -c
flag. For example, first of all take note of the sound cards on the Apalis i.MX6:
0 [DWHDMI ]: dw-hdmi-ahb-aud - DW-HDMI
DW-HDMI rev 0x0a, irq 274
1 [imxspdif ]: imx-spdif - imx-spdif
imx-spdif
2 [imx6qapalissgtl]: imx6q-apalis-sg - imx6q-apalis-sgtl5000
imx6q-apalis-sgtl5000
The important things to take note is that for the Apalis i.MX6 the sound card we want is the last one imx6qapalissgtl
and that the index of this is 2.
Knowing this, in the container you can do something like:
root@apalis-imx6-05228985:/home/torizon# amixer -c 2 set Headphone unmuted 100%
Simple mixer control 'Headphone',0
Capabilities: pvolume pswitch pswitch-joined
Playback channels: Front Left - Front Right
Limits: Playback 0 - 127
Mono:
Front Left: Playback 127 [100%] [12.00dB] [on]
Front Right: Playback 127 [100%] [12.00dB] [on]
root@apalis-imx6-05228985:/home/torizon# amixer -c 2 set PCM 100%
Simple mixer control 'PCM',0
Capabilities: pvolume
Playback channels: Front Left - Front Right
Limits: Playback 0 - 192
Mono:
Front Left: Playback 192 [100%]
Front Right: Playback 192 [100%]
Using the -c
flag we specify the sound card via it’s index (which is 2 as I said previously). As you can see by specifying the right sound card these commands now work properly. I then used aplay
to play a test audio file to check and it seems to work. As a side-note you must also specify a sound card with aplay
as well like so:
aplay -D sysdefault:CARD=imx6qapalissgtl sample-15s.wav
Best Regards,
Jeremias
Hi @jeremias.tx,
I scanned my audio devices and found the following
torizon@fe14a7676983:/eclipse_qml$ aplay --list-devices
**** List of PLAYBACK Hardware Devices ****
card 0: DWHDMI [DW-HDMI], device 0: DW HDMI [dw-hdmi-ahb-audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: imx6qapalissgtl [imx6q-apalis-sgtl5000], device 0: HiFi sgtl5000-0 [HiFi sgtl5000-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: imxspdif [imx-spdif], device 0: S/PDIF PCM snd-soc-dummy-dai-0 [S/PDIF PCM snd-soc-dummy-dai-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
So following your explanation, the index I am looking to set would be 1. Since the order seems to vary from card to card, I’ll just type the card’s name itself in the command:
amixer -c imx6qapalissgtl set Headphone unmuted 100%
amixer -c imx6qapalissgtl set PCM 80%
This gives me the output
Simple mixer control 'Headphone',0
Capabilities: pvolume pswitch pswitch-joined
Playback channels: Front Left - Front Right
Limits: Playback 0 - 127
Mono:
Front Left: Playback 127 [100%] [12.00dB] [on]
Front Right: Playback 127 [100%] [12.00dB] [on]
Simple mixer control 'PCM',0
Capabilities: pvolume
Playback channels: Front Left - Front Right
Limits: Playback 0 - 192
Mono:
Front Left: Playback 154 [80%]
Front Right: Playback 154 [80%]
PulseAudioService: pa_context_connect() failed
PulseAudioService: pa_context_connect() failed
PulseAudioService: pa_context_connect() failed
PulseAudioService: pa_context_connect() failed
PulseAudioService: pa_context_connect() failed
PulseAudioService: pa_context_connect() failed
PulseAudioService: pa_context_connect() failed
PulseAudioService: pa_context_connect() failed
Testing a sound file via aplay command now successfully works. However, the sounds played from within my Qt application code do not.
I guess this solves half of my problem, but for the sake of my initial question in this topic I’ll still mark your comment as the solution.
Glad I could help. Unfortunatley, I’m not sure how much we can help with the specifics of Qt and your application.
Best Regards,
Jeremias