;; 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 <prog1> and <loginfo> functions.
-
;;=====================================================================
; The libc context is an API towards libc.so.6 dynamic library which
; offers the basic C functions
(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
;;; 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"