]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix volume refresh bug in mpc
authorjohn muhl <jm@pub.pink>
Fri, 26 Jan 2024 03:23:45 +0000 (21:23 -0600)
committerEshel Yaron <me@eshelyaron.com>
Sat, 10 Feb 2024 08:42:59 +0000 (09:42 +0100)
* lisp/mpc.el (mpc-volume-refresh): Only refresh volume when mpd
is playing.  When stopped or paused, volume is nil.  (Bug#68785)

(cherry picked from commit 4330eb2864181e49ace5736665c45d8683a5ce1d)

lisp/mpc.el

index 9577e0f2f424917ec8892ec1802efda342b90bbb..768c70c2e3a22bd646ac661e2fd68d2ef1ea7672 100644 (file)
@@ -1867,11 +1867,14 @@ A value of t means the main playlist.")
 (defvar mpc-volume nil) (put 'mpc-volume 'risky-local-variable t)
 
 (defun mpc-volume-refresh ()
-  ;; Maintain the volume.
-  (setq mpc-volume
-        (mpc-volume-widget
-         (string-to-number (cdr (assq 'volume mpc-status)))))
-  (let ((status-buf (mpc-proc-buffer (mpc-proc) 'status)))
+  "Maintain the volume."
+  (let ((status-buf (mpc-proc-buffer (mpc-proc) 'status))
+        (status-vol (cdr (assq 'volume mpc-status))))
+    ;; If MPD is paused or stopped the volume is nil.
+    (when status-vol
+      (setq mpc-volume
+            (mpc-volume-widget
+             (string-to-number status-vol))))
     (when (buffer-live-p status-buf)
       (with-current-buffer status-buf (force-mode-line-update)))))