Sound via 3.5mm jack on Raspberry Pi 4 within container

Hi,

I’m trying to setup a simple audio player within my application.
I’ve heard about balena-sound, but I want to integrate some audio into my application, so balena-sound will not help me with this. I’ve used it as an example though!

Starting at the beginning, I’m stuck already. I have an Alpine container (balenalib/raspberrypi4-64-alpine-node:12), where my application is running. I’ve added the alsa-utils package and tried to do the speaker-test via the 3.5mm jack. But not a sound is coming out of my speakers.

Checking with aplay, I’m getting the following output:

$ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
default:CARD=Headphones
    bcm2835 Headphones, bcm2835 Headphones
    Default Audio Device
sysdefault:CARD=Headphones
    bcm2835 Headphones, bcm2835 Headphones
    Default Audio Device

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7

So there is a bcm2835 Headphones card found.
I’ve seen people getting success with using amixer cset numid=3 1, but that command doesn’t succeed. Here’s the output of some amixer commands:

$ amixer cset numid=3 1
amixer: Cannot find the given element from control default

$ amixer contents
numid=2,iface=MIXER,name='Headphone Playback Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=1,iface=MIXER,name='Headphone Playback Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=-10239,max=400,step=0
  : values=400
  | dBscale-min=-102.39dB,step=0.01dB,mute=1

On other forums, I saw that there should be another card, the HDMI card. But it just shows the headphones.


Some details about the Pi itself:
Raspberry Pi 4 (64-bit image)
BalenaOS 2.73.1+rev1 (development image)
Supervisor v12.4.6

Contents of config.txt

dtoverlay=miniuart-bt
dtoverlay=pi3-miniuart-bt
enable_uart=1
arm_64bit=1
avoid_warnings=1
disable_splash=1
dtparam=i2c_arm=on
dtparam=spi=on
dtparam=audio=on
gpu_mem=16

Container is running privileged, UDEV and dbus are both enabled.


Any help would be welcome!

Okay so, skip all that.
Someone moved my Raspberry Pi and the 3.5mm jack was in the wrong Raspberry Pi.
So that wasted some hours of my life :upside_down_face:

Hah!
We’ve all been there - no worries!

1 Like