X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=lsp-alsa%2Flibasound.lsp;h=42d7f35d9e1a9776d55ddef05ca3e840f0084898;hb=4ec2385eae5c542c723ba17c0bb0682d71dcbf4e;hp=ef4a5711451d0275d6a0fae3b7932b54de010f22;hpb=0ed2bf5ca517ba1e4cab3b5978c4b3aee12fbb1c;p=rrq%2Flsp-utils.git 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"