Set the same volume for all the related channels by default

This commit is contained in:
2022-06-06 20:16:39 +02:00
parent 998ca396cb
commit 146c9ea227
2 changed files with 39 additions and 14 deletions

View File

@@ -198,9 +198,11 @@ rather than using cached data to obtain the result."
(cdr (assoc "volume" parameters))
(nth port-id (cdr (assoc (if monitor-p "monitorVolumes" "channelVolumes") parameters)))))))
(defun pw-lib-set-volume (volume object)
(defun pw-lib-set-volume (volume object &optional single-p)
"Set the volume of PipeWire OBJECT to VOLUME.
VOLUME must be an integer in the range 0-100."
VOLUME must be an integer in the range 0-100.
If SINGLE-P is non-nil, set the volume only for a single channel,
otherwise set the volume to the same value for all the related channels."
(cl-destructuring-bind (node-p parameters monitor-p node-id port-id)
(pw-lib--object-parameters object)
(let* ((property (cond
@@ -211,8 +213,10 @@ VOLUME must be an integer in the range 0-100."
(value (if node-p
float-volume
(let ((orig-value (cdr (assoc property parameters))))
(cl-substitute float-volume nil orig-value
:test #'always :start port-id :count 1)))))
(if single-p
(cl-substitute float-volume nil orig-value
:test #'always :start port-id :count 1)
(make-list (length orig-value) float-volume))))))
(pw-access-set-properties pw-lib--accessor node-id (list (cons property value))))))
(defun pw-lib-set-default (object stored-p)