From: Christophe Rhodes Date: Tue, 25 Mar 2014 09:30:54 +0000 (+0000) Subject: clamp volume to between 0 and 100 X-Git-Url: http://christophe.rhodes.io/gitweb/?a=commitdiff_plain;h=a386bf58d625eb755df50765f0c50da2d0472f74;p=squeeze-el.git clamp volume to between 0 and 100 doesn't handle muted players yet --- diff --git a/squeeze.el b/squeeze.el index 95bfdf1..bcdf4e2 100644 --- a/squeeze.el +++ b/squeeze.el @@ -60,11 +60,12 @@ ((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