From 0ebffc0b7263d261c9de1f117a96d28447889dfd Mon Sep 17 00:00:00 2001 From: Yoni Rabkin Date: Mon, 19 Jun 2017 14:55:40 -0400 Subject: * lisp/emms-volume.el: Limits volume percentages Limits volume percentages between 0 and 100 by default. At least with the Solaris sink, attempting to set a volume outside this range will fail with a "connection terminated" error from pactl. trivial patch by David Michael --- lisp/emms-volume-pulse.el | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'lisp') diff --git a/lisp/emms-volume-pulse.el b/lisp/emms-volume-pulse.el index 8d95e30..7fc6de5 100644 --- a/lisp/emms-volume-pulse.el +++ b/lisp/emms-volume-pulse.el @@ -56,13 +56,9 @@ See full list of devices on your system by running (string :tag "Sink symbolic name")) :group 'emms-volume) -(defcustom emms-volume-pulse-max-volume 150 - "The sink to use for volume adjustment. - -See full list of devices on your system by running - pactl list short sinks" - :type '(choice (number :tag "Sink number") - (string :tag "Sink symbolic name")) +(defcustom emms-volume-pulse-max-volume 100 + "The maximum volume percentage." + :type 'integer :group 'emms-volume) @@ -73,7 +69,7 @@ See full list of devices on your system by running (output (shell-command-to-string (concat "pactl list sinks" "|" - "grep -E -e 'Sink' -e 'Name' -e '^[^a-zA-Z]*Volume'")))) + "grep -E -e 'Sink' -e 'Name' -e '^[^a-zA-Z]*Volume'")))) (string-to-number (car (reverse @@ -97,12 +93,13 @@ See full list of devices on your system by running ;;;###autoload (defun emms-volume-pulse-change (amount) - "Change amixer master volume by AMOUNT." + "Change PulseAudio volume by AMOUNT." (message "Volume is %s%%" (let ((pactl (or (executable-find "pactl") (error "pactl is not in PATH"))) - (next-vol (min (+ (emms-volume--pulse-get-volume) amount) - emms-volume-pulse-max-volume))) + (next-vol (max (min (+ (emms-volume--pulse-get-volume) amount) + emms-volume-pulse-max-volume) + 0))) (when (zerop (shell-command (format "%s set-sink-volume %s %s%%" pactl emms-volume-pulse-sink next-vol))) -- cgit v1.2.3