From a386bf58d625eb755df50765f0c50da2d0472f74 Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Tue, 25 Mar 2014 09:30:54 +0000 Subject: [PATCH] clamp volume to between 0 and 100 doesn't handle muted players yet --- squeeze.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 -- 2.39.5