-
Notifications
You must be signed in to change notification settings - Fork 2
/
extern.h
76 lines (67 loc) · 1.7 KB
/
extern.h
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
#include "audioout.h"
#include "fir.h"
#include "player.h"
#include "preamp.h"
#include "threadpool.h"
vrok::Player *pl;
vrok::DriverAudioOut *out;
vrok::EffectFIR *pre;
vrok::EffectFIR *pre1;
ThreadPool *pool;
static vrok::Player *plx = NULL;
void NextTrackCallback(void *user) { }
extern "C" {
void CreateContext() {
pl = new vrok::Player;
out = new vrok::DriverAudioOut;
pre = new vrok::EffectFIR;
pre1 = new vrok::EffectFIR;
pool = new ThreadPool(1);
}
vrok::Resource *CreateResource(const char *filename) {
vrok::Resource *res = new vrok::Resource();
res->_filename = std::string(filename);
return res;
}
void DestroyResource(vrok::Resource *resource) {
delete resource;
}
void RegisterSource(BufferGraph::Point *parent, BufferGraph::Point *source) {
parent->RegisterSource(source);
}
void RegisterSink(BufferGraph::Point *parent, BufferGraph::Point *sink) {
parent->RegisterSource(sink);
}
vrok::Player *CreatePlayer() {
pre->RegisterSource(pl);
pre->RegisterSink(out);
pl->RegisterSink(pre);
out->RegisterSource(pre);
out->Preallocate();
pl->Preallocate();
pre->Preallocate();
// pre1->Preallocate();
pool->RegisterWork(0, pl);
pool->RegisterWork(0, pre);
pool->RegisterWork(0, out);
pl->SetNextTrackCallback(NextTrackCallback, nullptr);
pool->CreateThreads();
return pl;
}
void JoinPlayer() {
pool->JoinThreads();
}
void SubmitForPlayback(vrok::Resource *resource) {
pl->SubmitForPlayback(resource);
}
void SubmitForPlaybackNow(vrok::Resource *resource) {
pl->SubmitForPlaybackNow(resource);
}
void DeleteContext() {
delete pl;
delete out;
delete pre;
delete pool;
delete pre1;
}
}