restructuring
[rrq/lsp-utils.git] / lsp-alsa / pcm-dispatch.lsp
1 ;; This is the main script for the pcm-dispatch tool
2 ;; last main-arg nominates the configuration file
3
4 (load "lsp-utils.lsp")
5
6 ; load contexts libasound and ALSA
7 (load "libasound.lsp")
8
9 (setf
10  CONFIGFILE (println (main-args -1))
11  CONFIGTEXT (read-file CONFIGFILE)
12  CONFIG (println (read-expr CONFIGTEXT))
13  PCM-LIST (println (rest (assoc "PCM-LIST" CONFIG)))
14  )
15
16 (define (open-pcm PCM)
17   (ALSA:snd_pcm_open PCM libasound:SND_PCM_STREAM_PLAYBACK 0))
18
19 ;; Find first usable PCM
20 (setf PCM (unless (dolist (PCM PCM-LIST (open-pcm PCM)))
21             (die 1 "No PCM available")))
22
23 (println (list 'PCM PCM))
24
25