Package: mpdtoys Version: 0.25.0 Severity: normal Tags: patch X-Debbugs-Cc: Asher Gordon <[email protected]>
Dear Maintainer,
I have configured my MPD daemon to output through PulseAudio (the PA
server is running as my local user). After doing so, when the daemon is
stopped (no song playing or paused), the volume displays as 'n/a' in
'mpc status' and is returned as undef by the 'volume' method of the
Audio::MPD::Common::Status class in the Audio::MPD Perl library. I'm not
sure why this is--possibly due to a limitation in the PulseAudio
interface--but it breaks mpfade when the MPD daemon is stopped. mpfade
thinks the volume was changed manually, even though it wasn't, and thus
exits erroneously.
Here is the exact message:
$ mpfade 0.5 100
fading up from 0 to 100 over 30 seconds
manual volume change, aborting fade up
I've written a patch to fix this problem. Unfortunately, it's a bit of a
hack, but it should work. I took the liberty of adding a
debian/changelog entry in my name, but of course, feel free to put my
name in brackets and change the name at the bottom. The patch is as
follows:
From ab6adb95c0b3a744df326f3e4351e58fe7084d20 Mon Sep 17 00:00:00 2001 From: Asher Gordon <[email protected]> Date: Sun, 14 Feb 2021 04:51:29 -0500 Subject: [PATCH] mpfade: Fix setting volume for PulseAudio sound output. When MPD is configured to output sound through PulseAudio, it seems that the volume cannot be set or gotten unless a song is playing or paused (not stopped). This could be a bug in MPD, but more likely it is a limitation in the PulseAudio interface (I don't know much about that, so I'm not sure). In any case, this simple hack (unfortunately it cannot be called anything other than a hack) should fix it. We also may need to try to set the volume several times, because it seems it may not be possible to set the volume immediately after we start playing a song. --- debian/changelog | 6 ++++++ mpfade | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 5e07a73..b836200 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +mpdtoys (0.25.2) unstable; urgency=medium + + * mpfade: Fix setting volume for PulseAudio sound output. + + -- Asher Gordon <[email protected]> Sun, 14 Feb 2021 05:02:40 -0500 + mpdtoys (0.25.1) unstable; urgency=medium * QA upload. diff --git a/mpfade b/mpfade index 49adf17..49260a4 100755 --- a/mpfade +++ b/mpfade @@ -74,9 +74,23 @@ else { if (! defined $endpoint) { $endpoint=50; } - $mpd->volume($vol=0); + $vol=0; print "fading up from $vol to $endpoint over $seconds seconds\n"; $mpd->play; + + # Sometimes the volume is not defined unless a song is playing + # or paused (not stopped). This seems to happen for PulseAudio + # sound output. This little hack gets around that. + my $curvol; + my $iterations=0; + do { + $mpd->volume($vol); + $curvol=$mpd->status->volume; + if (++$iterations >= 10) { + die "error: cannot set volume to $vol\n"; + } + } until (defined $curvol && $curvol == $vol); + fade($endpoint, $seconds); } -- 2.30.0
Thanks,
Asher
-- System Information:
Debian Release: bullseye/sid
APT prefers testing-debug
APT policy: (500, 'testing-debug'), (500, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 5.10.0-3-amd64 (SMP w/2 CPU threads)
Kernel taint flags: TAINT_FIRMWARE_WORKAROUND
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages mpdtoys depends on:
ii libaudio-mpd-perl 2.004-2
ii perl 5.32.1-2
mpdtoys recommends no packages.
Versions of packages mpdtoys suggests:
ii libproc-daemon-perl 0.23-1
ii libstring-approx-perl 3.28-1+b3
ii libterm-readkey-perl 2.38-1+b2
ii mpd 0.22.4-1
-- no debconf information
--
I often quote myself; it adds spice to my conversation.
-- G. B. Shaw
--------
I prefer to send and receive mail encrypted. Please send me your
public key, and if you do not have my public key, please let me
know. Thanks.
GPG fingerprint: 38F3 975C D173 4037 B397 8095 D4C9 C4FC 5460 8E68
signature.asc
Description: PGP signature

