Skip to content

Commit

Permalink
subsystem: add audio dir
Browse files Browse the repository at this point in the history
Add audio dir with ContaineFile with all packages required for
quadlets when the subject is add initial audio support.

Signed-off-by: Douglas Schilling Landgraf <[email protected]>
  • Loading branch information
dougsland committed Nov 11, 2024
1 parent 5826e1c commit b4635b1
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 33 deletions.
39 changes: 9 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,36 +211,9 @@ git clone https://github.com/containers/qm.git && cd qm
make qm_dropin_mount_bind_sound
sudo dnf install -y rpmbuild/RPMS/noarch/qm_mount_bind_sound-0.6.7-1.fc40.noarch.rpm

# To check if your system is using PulseAudio: pactl info
$ pactl info
Server String: /run/user/1000/pulse/native
Library Protocol Version: 35
Server Protocol Version: 35
Is Local: yes
Client Index: 118
Tile Size: 65472
User Name: douglas
Host Name: fedora
Server Name: PulseAudio (on PipeWire 1.0.8)
Server Version: 15.0.0
Default Sample Specification: float32le 2ch 48000Hz
Default Channel Map: front-left,front-right
Default Sink: alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink
Default Source: alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_6__source
Cookie: 9108:667a

# Install PuseAudio (pactl) and alsa-utils (aplay) in the QM partition
sudo dnf --installroot /usr/lib/qm/rootfs install pulseaudio-utils alsa-utils -y

# Restart QM container (if already running)
sudo podman restart qm

# Showing /dev/snd data inside QM
sudo podman exec -it qm bash
controlC0 hwC0D0 hwC1D2 pcmC0D7p pcmC0D9p pcmC1D0p pcmC1D3p pcmC1D5p pcmC1D7c timer
controlC1 hwC1D0 pcmC0D3p pcmC0D8p pcmC1D0c pcmC1D31p pcmC1D4p pcmC1D6c seq
```

### Step 2: Identify Sound Cards

After installing the drop-in and restarting QM, you need to identify which sound card in the Linux system will be used in QM. If you're familiar with your sound card setup feel free to skip this step.
Expand Down Expand Up @@ -301,19 +274,25 @@ Inside QM, run the following command:
```bash
podman exec -it qm bash
bash-# podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
76dacaa9a89e quay.io/qm-images/audio:latest sleep infinity 7 hours ago Up 7 hours systemd-audio
bash-# podman exec -it systemd-audio bash
Execute the audio test within the nested container, and the sound will be output through the physical speakers of your computer—or, in this case, the car's multimedia soundbox.
bash-# speaker-test -D hw:1,0 -c 2 -r 48000
```

This command runs a test with:
Params:

```bash
hw:1,0: sound card 1, device 0
-c 2: two channels (stereo)
-r 48000: sample rate of 48 kHz
```

If you want to test different sample rates, change the `-r` parameter to other values (e.g., 44100 for 44.1 kHz or 96000 for 96 kHz) to see which ones are supported by the hardware.

## Creating your own drop-in QM sub-package

We recommend using the existing drop-in files as a guide and adapting them to your specific needs. However, here are the step-by-step instructions:
Expand Down
8 changes: 5 additions & 3 deletions rpm/qm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
###########################################
# subpackage QM - ROS2 Rolling version #
###########################################
%define enable_qm_ros2_rolling 1%{?u_enable_qm_ros2_rolling}
%define enable_qm_ros2_rolling 0%{?u_enable_qm_ros2_rolling}

###########################################
# subpackage QM - mount bind /dev/ttyUSB0 #
Expand Down Expand Up @@ -158,9 +158,9 @@ sed -i 's/^install: man all/install:/' Makefile
%install
# Create the directory for drop-in configurations
install -d %{buildroot}%{_sysconfdir}/containers/containers.conf.d
install -d %{buildroot}%{rootfs_qm}%{_sysconfdir}/containers/systemd
install -d %{buildroot}%{_sysconfdir}/qm/containers/containers.conf.d


####################################################################
################# QM Window Manager ################################
####################################################################
Expand Down Expand Up @@ -241,7 +241,8 @@ install -d %{buildroot}%{_sysconfdir}/qm/containers/containers.conf.d
%if %{enable_qm_mount_bind_sound}
# first step - add drop-in file in /etc/containers/containers.d.conf/qm_dropin_mount_bind_snd.conf
# to QM container mount bind /dev/snd
install -m 644 %{_builddir}/qm-%{version}/etc/qm/containers/containers.conf.d/qm_dropin_mount_bind_snd.conf %{buildroot}%{_sysconfdir}/containers/containers.conf.d/qm_dropin_mount_bind_snd.conf
install -m 644 %{_builddir}/qm-%{version}/subsystems/audio/audio.container %{buildroot}%{rootfs_qm}%{_sysconfdir}/containers/systemd/audio.container
install -m 644 %{_builddir}/qm-%{version}%{_sysconfdir}/qm/containers/containers.conf.d/qm_dropin_mount_bind_snd.conf %{buildroot}%{_sysconfdir}/containers/containers.conf.d/qm_dropin_mount_bind_snd.conf

# second step - add drop-in file in /etc/qm/containers/containers.d.conf/qm_dropin/mount_bind_snd.conf
# to nested containers in QM env mount bind it in /dev/snd
Expand Down Expand Up @@ -479,6 +480,7 @@ additional drop-in configurations.
%files -n qm_mount_bind_sound
%{_sysconfdir}/containers/containers.conf.d/qm_dropin_mount_bind_snd.conf
%{_sysconfdir}/qm/containers/containers.conf.d/qm_dropin_mount_bind_snd.conf
%{rootfs_qm}%{_sysconfdir}/containers/systemd/audio.container
%endif

#######################################
Expand Down
12 changes: 12 additions & 0 deletions subsystems/audio/ContainerFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# ContainerFile used to create the image available at quay.io/qm-images/audio:latest
#
# How to build
# ==================
# podman login quay.io
# podman build -t quay.io/qm-images/audio:latest -f ContainerFile
# podman push quay.io/qm-images/audio:latest
FROM fedora:latest

RUN dnf -y install pulseaudio-utils alsa-utils procps-ng wireplumber pavucontrol \
&& dnf clean all && rm -rf /var/cache/dnf
CMD ["sleep", "infinity"]
9 changes: 9 additions & 0 deletions subsystems/audio/audio.container
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Audio Container
After=network.target

[Container]
Image=quay.io/qm-images/audio:latest

[Install]
WantedBy=multi-user.target

0 comments on commit b4635b1

Please sign in to comment.