More changes to the ordinary mixer API

This commit is contained in:
Jaroslav Kysela 2003-10-13 12:06:45 +00:00
parent 72c814db2a
commit ab61b62cb4
9 changed files with 576 additions and 234 deletions

View file

@ -1,3 +1,7 @@
;
; Toplevel configuration for the ALSA Ordinary Mixer Interface
;
(defun sndo_include (hctl stream)
(setq info (Acall "ctl_card_info" (Acall "hctl_ctl" hctl)))
(if (= (Aerror info) 0)
@ -7,75 +11,78 @@
(setq file (+ (path "data") "/alsa/cards/" (snd_card_alias driver) "/sndo" stream "-mixer.alisp"))
(setq r (include file))
(when (= r -2) (Asyserr "unable to find file " file))
(unsetq driver file r)
)
(setq r (Aerror info))
(unsetq info r)
)
(unsetq info driver file r)
)
(defun sndo_mixer_open_fcn (stream)
(setq fcn (+ "sndo" stream "_mixer_open"))
(setq r (if (exfun fcn) (call fcn hctl) 0))
(when (= r 0)
(setq hctls (if hctls (cons hctls (cons hctl)) hctl))
)
(unsetq fcn r)
)
(defun sndo_mixer_open_hctl (card stream)
(setq hctl (Acall "hctl_open" (+ "hw:" (str card)) nil))
(setq r (Aerror hctl))
(when (= r 0)
(setq hctl (Aresult hctl))
(setq r (sndo_include hctl stream))
(when (= r 0) (setq r (sndo_mixer_open_fcn stream)))
)
(unsetq hctl r)
)
(defun sndo_mixer_open_virtual (pcm stream)
(setq name (Acall "pcm_name" pcm))
(setq file (+ (path "data") "/alsa/virtual/" name "/sndo" stream "-mixer.alisp"))
(setq r (include file))
(when (= r -2) (Asyserr "unable to find file " file))
(when (= r 0) (setq r (sndo_mixer_open_fcn stream)))
(unsetq name file r)
)
(defun sndo_mixer_open1 (pcm stream)
(setq info (Acall "pcm_info" pcm))
(setq r (Aerror info))
(when (= r 0)
(progn
(setq info (Aresult info))
(setq card (cdr (assq "card" info)))
(setq r
(if (< card 0)
(+ (Acall "pcm_name" pcm) stream)
(+ "hw:" (str card))
)
(setq info (Aresult info))
(setq card (cdr (assq "card" info)))
(setq r
(if (< card 0)
(sndo_mixer_open_virtual pcm stream)
(sndo_mixer_open_hctl card stream)
)
(unsetq card)
)
)
(unsetq info r)
(unsetq info card r)
)
(defun sndo_mixer_open (ppcm cpcm)
(setq pname (sndo_mixer_open1 ppcm "p"))
(setq cname (sndo_mixer_open1 cpcm "c"))
(setq phctl (Acall "hctl_open" pname nil))
(if (= (Aerror phctl) 0)
(setq r (sndo_mixer_open1 ppcm "p"))
(when (= r 0) (setq r (sndo_mixer_open1 cpcm "c")))
(when (!= r 0) (sndo_mixer_close))
(unsetq r)
)
(defun sndo_mixer_close1 (hctl stream)
(when hctl
(progn
(setq phctl (Aresult phctl))
(setq chctl (Acall "hctl_open" cname nil))
(if (= (Aerror chctl) 0)
(progn
(setq chctl (Aresult chctl))
(setq hctls (cons phctl (cons chctl)))
(setq r (sndo_include phctl "p"))
(when (= r 0) (setq r (sndo_include chctl "c")))
(when (= r 0) (setq r (if (exfun sndop_mixer_open) (sndop_mixer_open phctl) 0)))
(when (= r 0)
(progn
(setq r (if (exfun sndoc_mixer_open) (sndoc_mixer_open chctl) 0))
(unless (= r 0) (sndop_close phctl))
)
)
(unless (= r 0) (sndo_close))
(unsetq phctl chctl)
(gc)
(unsetq r)
)
(progn
(Acall "hctl_close" (Aresult phctl))
(setq r (Aerror chctl))
(unsetq r)
)
)
(setq fcn (+ "sndo" stream "_mixer_close"))
(when (exfun fcn) (call fcn hctl))
(unsetq fcn)
(Acall "hctl_close" hctl)
)
(setq r (Aerror phctl))
(unsetq r)
)
)
(defun sndo_mixer_close nil
(cond (exfun sndop_close) (sndop_close (nth 0 hctls)))
(cond (exfun sndoc_close) (sndoc_close (nth 1 hctls)))
(Acall "hctl_close" (nth 0 hctls))
(Acall "hctl_close" (nth 1 hctls))
(sndo_mixer_close1 (nth 1 hctls) "c")
(sndo_mixer_close1 (nth 0 hctls) "p")
(unsetq hctls)
)