Coverage report: /home/ellis/comp/core/ffi/alsa/pkg.lisp
Kind | Covered | All | % |
expression | 0 | 100 | 0.0 |
branch | 0 | 32 | 0.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; alsa.lisp --- low-level bindings to ALSA
7
(:use :cl :std :sb-alien)
8
(:import-from :sb-unix :off-t)
26
(define-alien-loader asound "/usr/lib/")
28
(define-alien-enum (snd-pcm-class int)
34
(define-alien-enum (snd-pcm-stream int)
38
(define-alien-enum (snd-pcm-access int)
40
:mmap-noninterleaved 1
45
;; incomplete list of formats
46
(define-alien-enum (snd-pcm-format int)
66
:iec958-subframe-le 18
67
:iec958-subframe-be 19
79
(define-alien-enum (snd-pcm-state int)
90
(defconstant %seek-set 0)
91
(defconstant %seek-cur 1)
92
(defconstant %seek-end 2)
94
(define-alien-type snd-pcm (* t))
95
(define-alien-type snd-output (* t))
97
(define-alien-type snd-pcm-stream int)
98
(define-alien-type snd-pcm-mode int)
100
(defar snd-pcm-open int (pcm (* snd-pcm)) (name c-string) (ty snd-pcm-stream) (mode snd-pcm-mode))
102
(defar snd-pcm-close int (pcm snd-pcm))
104
(defar snd-strerror c-string (errnum int))
108
(defar snd-pcm-set-params int
110
(format snd-pcm-format)
111
(access snd-pcm-access)
112
(channels unsigned-int)
115
(latency unsigned-int))
117
(defar snd-pcm-recover int
122
(define-alien-type snd-pcm-sframes long)
123
(define-alien-type snd-pcm-uframes unsigned-long)
125
(defar snd-pcm-writei snd-pcm-sframes
128
(size snd-pcm-uframes))
130
(defar snd-output-stdio-attach int
131
(outputp (* snd-output))
135
(defar snd-pcm-dump int
139
(define-alien-variable stdout (* t))
142
(defun alsa-element-type (type)
143
(cond ((equalp type '(signed-byte 16)) :int16)
144
((eql type 'single-float) :float)
145
((eql type 'double-float) :double)
146
((equalp type '(unsigned-byte 8)) :uint8)
147
((equalp type '(signed-byte 8)) :int8)
148
((equalp type '(unsigned-byte 16)) :uint16)
149
((equalp type '(unsigned-byte 32)) :uint32)
150
((equalp type '(signed-byte 32)) :int32)
151
(t (error "Invalid base type ~A" type))))
153
(defun alsa-format-type (element-type)
154
(cond ((eql element-type 'single-float) :float-le)
155
((eql element-type 'double-float) :float64-le)
156
((equalp element-type '(unsigned-byte 8)) :u8)
157
((equalp element-type '(signed-byte 8)) :8)
158
((equalp element-type '(unsigned-byte 16)) :u16-le)
159
((equalp element-type '(signed-byte 16)) :s16-le)
160
((equalp element-type '(unsigned-byte 32)) :u32-le)
161
((equalp element-type '(signed-byte 32)) :s32-le)
162
(t (error "Invalid base type ~A" element-type))))