aboutsummaryrefslogtreecommitdiff
path: root/src/conf/sndo-mixer.alisp
blob: b125b6e7861f5ee07d7b4c3ccd259ce991f4bb6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
;
; 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)
    (progn
      (setq info (Aresult info))
      (setq driver (cdr (assq "driver" (unsetq info))))
      (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))
    )
    (setq r (Aerror info))
  )
  (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)
    (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 info card r)
)

(defun sndo_mixer_open (ppcm cpcm)
  (setq r (sndo_mixer_open1 ppcm "p"))
  (when (= r 0) (setq r (sndo_mixer_open1 cpcm "c")))
  (when (!= r 0) (sndo_mixer_close))
  (unsetq sndo_mixer_open sndo_mixer_open1
          sndo_mixer_open_virtual sndo_mixer_open_fcn
	  sndo_include r)
)

(defun sndo_mixer_close1 (hctl stream)
  (when hctl
    (progn
      (setq fcn (+ "sndo" stream "_mixer_close"))
      (when (exfun fcn) (call fcn hctl))
      (unsetq fcn)
      (Acall "hctl_close" hctl)
    )
  )
)

(defun sndo_mixer_close nil
  (sndo_mixer_close1 (nth 1 hctls) "c")
  (sndo_mixer_close1 (nth 0 hctls) "p")
  (unsetq hctls)
)

(include (+ (path "data") "/alsa/cards/aliases.alisp"))