-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f641cc7
commit 77a03c8
Showing
4 changed files
with
61 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#lang racket/base | ||
|
||
(require setup/collection-search | ||
ffi/unsafe) | ||
|
||
(provide callbacks-lib | ||
(struct-out stream-rec) | ||
;; no obvious way to provide names for the underscore | ||
;; version, add as needed... | ||
_stream-rec | ||
_stream-rec-pointer) | ||
|
||
(define not-false? (λ (x) x)) | ||
|
||
|
||
;; the library containing the C copying callbacks | ||
(define callbacks-lib | ||
(let () | ||
(or | ||
;; search in all portaudio/lib collection dirs: | ||
(collection-search | ||
'(lib "portaudio/lib") | ||
#:combine | ||
(λ (_ path) | ||
(ffi-lib (build-path path "callbacks") | ||
#:fail (λ () #f))) | ||
#:break? | ||
not-false?) | ||
;; also look in "standard locations". useful | ||
;; for people building executables. | ||
(ffi-lib "callbacks")))) | ||
|
||
;; STREAMING CALLBACK STRUCT | ||
|
||
(define-cstruct _stream-rec | ||
(;; the number of frames in the circular buffer | ||
[buffer-frames _int] | ||
;; the circular buffer | ||
[buffer _pointer] | ||
;; the last frame read by the callback | ||
[last-frame-read _uint] | ||
;; the offset of the last byte read by the callback. | ||
[last-offset-read _uint] | ||
;; the last frame written by Racket | ||
[last-frame-written _uint] | ||
;; the offset of the last byte written by Racket. | ||
[last-offset-written _uint] | ||
;; number of faults: | ||
[fault-count _int] | ||
;; a pointer to a 4-byte cell; when it's nonzero, | ||
;; the supplying procedure should shut down, and | ||
;; free this cell. If it doesn't get freed, well, | ||
;; that's four bytes wasted until the next store-prompt. | ||
[all-done _pointer])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters