2 ; Toplevel configuration for the ALSA Ordinary Mixer Interface
4 ; Copyright (c) 2003 Jaroslav Kysela <perex@perex.cz>
5 ; License: GPL v2 (http://www.gnu.org/licenses/gpl.html)
8 (defun sndo_include (hctl stream)
9 (setq info (Acall "ctl_card_info" (Acall "hctl_ctl" hctl)))
10 (if (= (Aerror info) 0)
12 (setq info (Aresult info))
13 (setq driver (cdr (assq "driver" (unsetq info))))
14 (setq file (concat (path "data") "/alsa/cards/" (snd_card_alias driver) "/sndo" stream "-mixer.alisp"))
15 (setq r (include file))
16 (when (= r -2) (Asyserr "unable to find file " file))
18 (setq r (Aerror info))
20 (unsetq info driver file r)
23 (defun sndo_mixer_open_fcn (hctl stream pcm)
24 (setq fcn (concat "sndo" stream "_mixer_open"))
25 (setq r (if (exfun fcn) (funcall fcn hctl pcm) 0))
27 (setq hctls (if hctls (cons hctls (cons hctl)) hctl))
32 (defun sndo_mixer_open_hctl (name stream pcm)
33 (setq hctl (Acall "hctl_open" name nil))
34 (setq r (Aerror hctl))
36 (setq hctl (Aresult hctl))
37 (setq r (sndo_include hctl stream))
39 (setq r (sndo_mixer_open_fcn hctl stream pcm))
40 (Acall "hctl_close" hctl)
46 (defun sndo_mixer_open_virtual (name stream pcm)
47 (setq file (concat (path "data") "/alsa/virtual/" name "/sndo" stream "-mixer.alisp"))
48 (setq r (include file))
49 (when (= r -2) (Asyserr "unable to find file " file))
50 (when (= r 0) (setq r (sndo_mixer_open_fcn nil stream pcm)))
54 (defun sndo_mixer_open1 (name stream)
55 (if (compare-strings name 0 2 "hw:" 0 2)
56 (sndo_mixer_open_hctl name stream nil)
57 (sndo_mixer_open_virtual name stream nil)
61 (defun sndo_mixer_open (pname cname)
62 (setq r (sndo_mixer_open1 pname "p"))
63 (when (= r 0) (setq r (sndo_mixer_open1 cname "c")))
64 (when (!= r 0) (sndo_mixer_close))
65 (unsetq sndo_mixer_open
66 sndo_mixer_open_pcm sndo_mixer_open_pcm1
67 sndo_mixer_open_virtual sndo_mixer_open_fcn
71 (defun sndo_mixer_open_pcm1 (pcm stream)
72 (setq info (Acall "pcm_info" pcm))
73 (setq r (Aerror info))
75 (setq info (Aresult info))
76 (setq card (cdr (assq "card" info)))
79 (sndo_mixer_open_virtual (Acall "pcm_name" pcm) stream pcm)
80 (sndo_mixer_open_hctl (format "hw:%i" card) stream pcm)
87 (defun sndo_mixer_open_pcm (ppcm cpcm)
88 (setq r (sndo_mixer_open_pcm1 ppcm "p"))
89 (when (= r 0) (setq r (sndo_mixer_open_pcm1 cpcm "c")))
90 (when (!= r 0) (sndo_mixer_close))
91 (unsetq sndo_mixer_open
92 sndo_mixer_open_pcm sndo_mixer_open_pcm1
93 sndo_mixer_open_virtual sndo_mixer_open_fcn
97 (defun sndo_mixer_close1 (hctl stream)
100 (setq fcn (concat "sndo" stream "_mixer_close"))
101 (when (exfun fcn) (funcall fcn hctl))
103 (Acall "hctl_close" hctl)
108 (defun sndo_mixer_close nil
109 (sndo_mixer_close1 (nth 1 hctls) "c")
110 (sndo_mixer_close1 (nth 0 hctls) "p")
111 (snd_card_alias_unset)
115 (include (concat (path "data") "/alsa/cards/aliases.alisp"))