-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlow-level.lisp
72 lines (55 loc) · 1.76 KB
/
low-level.lisp
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
(in-package #:org.shirakumo.fraf.flac.cffi)
(defvar *here* #.(or *compile-file-pathname* *load-pathname* *default-pathname-defaults*))
(defvar *static* (make-pathname :name NIL :type NIL :defaults (merge-pathnames "static/" *here*)))
(pushnew *static* cffi:*foreign-library-directories*)
(define-foreign-library libflac
(:darwin (:or #+X86 "mac32-libflac.dylib"
#+X86-64 "mac64-libflac.dylib"
"libflac.dylib" "libflac.so"))
(:unix (:or #+X86 "lin32-libflac.so"
#+X86-64 "lin64-libflac.so"
"libflac.so"))
(:windows (:or #+X86 "win32-libflac.dll"
#+X86-64 "win64-libflac.dll"
"libflac.dll" "flac.dll"))
(t (:default "flac")))
(use-foreign-library libflac)
(defctype flac-file :pointer)
(defcenum error
:no-error
:open-failed
:bad-file
:seek-too-far
:seek-failed)
(defcfun (open-file "flac_open") error
(path :string)
(file :pointer))
(defcfun (free-file "flac_free") :void
(file :pointer))
(defcfun (channels "flac_channels") :uint8
(file :pointer))
(defcfun (sample-rate "flac_sample_rate") :uint32
(file :pointer))
(defcfun (bits-per-sample "flac_bits_per_sample") :uint8
(file :pointer))
(defcfun (sample-count "flac_sample_count") :uint64
(file :pointer))
(defcfun (frame-count "flac_frame_count") :uint64
(file :pointer))
(defcfun (read-s16 "flac_read_s16") :uint64
(data :pointer)
(samples :uint64)
(file :pointer))
(defcfun (read-s32 "flac_read_s32") :uint64
(data :pointer)
(samples :uint64)
(file :pointer))
(defcfun (read-f32 "flac_read_f32") :uint64
(data :pointer)
(samples :uint64)
(file :pointer))
(defcfun (seek "flac_seek") error
(sample :uint64)
(file :pointer))
(defcfun (strerror "flac_strerror") :string
(error error))