This repository has been archived by the owner on Jun 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
audio.rkt
49 lines (40 loc) · 1.43 KB
/
audio.rkt
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
#lang racket/base
; audio.rkt
; contains stuff to manipulate audio 'n' stuff
(require libopenal-racket
libtoxcore-racket/av
"tox.rkt")
(provide (all-defined-out)
close-device!
destroy-context!
delete-sources!
gen-sources
set-current-context
stop-source)
(define cur-calls (make-hash))
(define device (open-device #f))
(define context (create-context device))
(void (set-current-context context))
; csettings is another struct, so we can get even more information from there
(struct friend-call (call-index friend-id csettings type alsource)
#:transparent #:mutable)
(define do-add-call
(λ (call-index friend-id csettings type)
(let ([fd (friend-call call-index friend-id csettings type (car (gen-sources 1)))])
(hash-set! cur-calls call-index fd))))
(define add-new-call
(λ (mav call-index)
(let* ([friend-id (get-peer-id my-av call-index 0)]
[csettings (get-peer-csettings my-av call-index friend-id)]
[type (ToxAvCSettings-call-type csettings)])
(do-add-call call-index friend-id csettings type))))
(define friend-call-id
(λ (call-index)
(friend-call-friend-id (hash-ref cur-calls call-index))))
#;(define friend-call-name
(λ (mtox call-index)
(let ([id (friend-call-id call-index)])
(get-name mtox id))))
(define (do-delete-call call-index)
(av-hangup my-av call-index)
(hash-remove! cur-calls call-index))