]> rhodes.io Git - squeeze-el.git/commitdiff
Christophe Weblog Wiki Code Publications Music
clamp volume to between 0 and 100
authorChristophe Rhodes <csr21@cantab.net>
Tue, 25 Mar 2014 09:30:54 +0000 (09:30 +0000)
committerChristophe Rhodes <csr21@cantab.net>
Tue, 25 Mar 2014 14:28:11 +0000 (14:28 +0000)
doesn't handle muted players yet

squeeze.el

index 95bfdf140f358be70e5d1de1e16a4e825629fb68..bcdf4e2e055bf1c23490bdf551c3a729ae6c8554 100644 (file)
                   ((string= current "1") "0"))))))
 
 (defun squeeze-update-mixer-volume (player value)
-  (let ((current (squeeze-player-volume player)))
+  (let ((current (squeeze-player-volume player))
+        (number (string-to-number value)))
     (if (string-match "^[-+]" value)
-        (when current
-          (setf (squeeze-player-volume player) (+ current (string-to-number value))))
-      (setf (squeeze-player-volume player) (string-to-number value)))))
+        (setf (squeeze-player-volume player)
+              (and current (max 0 (min 100 (+ current number)))))
+      (setf (squeeze-player-volume player) number))))
 
 (defun squeeze-update-state-from-line (string)
   (cond