Move formatting list of properties to a separate function

This commit is contained in:
Milan Zamazal 2022-06-16 07:30:52 +02:00
parent 2c421bb990
commit b7a83c81c1

View File

@ -207,11 +207,13 @@ Note this interface may not work with all PipeWire versions.")
(defun pw-cli--format-property (property) (defun pw-cli--format-property (property)
(format "%s: %s" (car property) (pw-cli--format-property-value (cdr property)))) (format "%s: %s" (car property) (pw-cli--format-property-value (cdr property))))
(defun pw-cli--format-properties (properties)
(concat "{ " (mapconcat #'pw-cli--format-property properties ", ") " }"))
(defun pw-cli--set-parameter (object-id parameter value) (defun pw-cli--set-parameter (object-id parameter value)
(let* ((formatted (mapconcat #'pw-cli--format-property value ", ")) (let* ((formatted (pw-cli--format-properties value)))
(param-value (concat "{ " formatted " }")))
(call-process pw-cli-command nil pw-cli-command nil (call-process pw-cli-command nil pw-cli-command nil
"set-param" (number-to-string object-id) parameter param-value))) "set-param" (number-to-string object-id) parameter formatted)))
(cl-defmethod pw-access-set-properties ((_class pw-cli-accessor) node-id properties) (cl-defmethod pw-access-set-properties ((_class pw-cli-accessor) node-id properties)
(pw-cli--set-parameter node-id "Props" properties)) (pw-cli--set-parameter node-id "Props" properties))