mikebrady / shairport-sync

AirPlay and AirPlay 2 audio player
Other
7.3k stars 574 forks source link

[Problem]: ALSA volume control does not work with a Mixer device that does not have a dB volume scale #1853

Closed larsimmisch closed 6 months ago

larsimmisch commented 6 months ago

What happened?

First of all, thanks! I ❤️ shairport-sync and I've been using it for years.

On to the problem: I'm running shairport-sync (latest version from git) on a Raspberry Pi 4/Hifiberry AMP2. I use the Apple Remote.app to play music on my kitchen radio. On the server side, I use owntone-server.

When I use the ALSA supplied hardware mixer, I either get silence (with all volumes below 100%) or horrible noise (at 100%).

This is the configuration in /etc/shairprt-sync.conf when the problem is observed:

// These are parameters for the "alsa" audio back end.
alsa =
{
        output_device = "hw:CARD=sndrpihifiberry"; // the name of the alsa output device. Use "shairport-sync >
        mixer_control_name = "Master"; // the name of the mixer to use to adjust output volume. No default.>
};

The workaround is fairly simple, just commenting out the mixer_control_name (and using a software volume control) works.

It's not a serious problem, but I'd rather have just one (hardware) volume control.

Relevant log output

May 16 21:11:12 kuechenradio shairport-sync: warning: The hardware mixer specified -- "Master" -- does not have a dB volume scale.

System Information.

Configuration Information.

>> Display Config Start.

From "uname -a":
 Linux kuechenradio 6.1.29-v8-lci+ #2 SMP PREEMPT Wed May 31 21:22:29 BST 2023 aarch64 GNU/Linux

From /etc/os-release:
 Debian GNU/Linux 11 (bullseye)

From /sys/firmware/devicetree/base/model:
 Raspberry Pi 4 Model B Rev 1.2

Shairport Sync Version String:
 4.3.2-2-g165431a8-AirPlay2-smi10-OpenSSL-Avahi-ALSA-soxr-sysconfdir:/etc

Command Line:
 shairport-sync --displayConfig

Configuration File:
 /etc/shairport-sync.conf

Configuration File Settings:
 general :
 {
   name = "%H";
 };
 alsa :
 {
   output_device = "hw:CARD=sndrpihifiberry";
 };

>> Display Config End.
>> Goodbye!

PulseAudio or PipeWire installed?

How did you install Shairport Sync?

Built from source

Check previous issues

mikebrady commented 6 months ago

Thanks for the post and for the kind words.

Shairport Sync will not use a mixer with attenuation levels that are not calibrated in decibels (dB). This was a design decision taken early on to ensure that the transfer function -- from airplay volume to mixer attenuation -- was based known characteristics, and not on some arbitrary and unknown transfer function in the mixer itself.

This might be revisited in the future, but I'm afraid it's not a priority right now.

larsimmisch commented 6 months ago

Thank you - this makes sense to me and I mostly wrote this up for documentation.

For me it would have been nice if shairplay-sync had automatically fallen back to using the software mixer when it detected that the mixer does not support dB steps (after logging an appropriate warning). I'll see if I can come up with a PR but right now, the weather is just way too nice :-)

mikebrady commented 6 months ago

Let me look into that suggestion -- the fallback, not the weather 😏...