From: Ralph Ronnquist Date: Wed, 26 Apr 2023 12:46:00 +0000 (+1000) Subject: Expand higher API (set config string). X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=4ec2385eae5c542c723ba17c0bb0682d71dcbf4e;p=rrq%2Flsp-utils.git Expand higher API (set config string). --- diff --git a/lsp-alsa/libasound.lsp b/lsp-alsa/libasound.lsp index ef4a571..42d7f35 100644 --- a/lsp-alsa/libasound.lsp +++ b/lsp-alsa/libasound.lsp @@ -2,9 +2,6 @@ ;; providing a higher level ALSA API over a lower level libasound API ;; on top of a libc API. -;; This implementation expects lib-utils.lsp to be loaded beforehand -;; for providing the and functions. - ;;===================================================================== ; The libc context is an API towards libc.so.6 dynamic library which ; offers the basic C functions @@ -40,7 +37,7 @@ (if (exec "find /lib /usr/lib -name 'libasound.so*' -type f") (constant 'LIB ($it 0)) (die 1 "Cannot find libasound.so")) -(when (ENV "LOG") (println "Using " LIB)) +(when (env "LOG") (println "Using " LIB)) ;; == Global functions ; https://alsa-project.org/alsa-doc/alsa-lib/group___global.html @@ -156,10 +153,16 @@ ;;; PCM API -;; Opens a PCM +;; Opens a named PCM and return handle (define (snd_pcm_open NAME STREAM-TYPE MODE) - (let ((PCM (pack "Lu" 0))) - (when (= (libasound:snd_pcm_open (address PCM) NAME STREAM-TYPE MODE)) - ((unpack "Lu" PCM) 0)))) + (let ((DATA (pack "Lu" 0))) + (when (= (libasound:snd_pcm_open (address DATA) NAME STREAM-TYPE MODE)) + ((unpack "LuLu" (address DATA)) 0)))) + +;; Set the value of given path as given. +(define (set_config_string PATH VALUE) + (let ((DATA (pack "Lu" 0)) (TREE (libasound:snd_config@))) + (when (= (libasound:snd_config_search TREE PATH (address DATA))) + (libasound:snd_config_set_string ((unpack "Lu" DATA) 0) VALUE)))) "libasound.lsp"