-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjbufferout.cpp
59 lines (46 loc) · 1.61 KB
/
jbufferout.cpp
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
#include "jbufferout.h"
void vrok::DriverJBufferOut::SetEvents(vrok::DriverJBufferOut::Events *events) {
m_events = events;
}
std::vector<vrok::Driver::DeviceInfo> vrok::DriverJBufferOut::GetDeviceInfo() {
DeviceInfo devInfo;
devInfo.name = "JNI";
devInfo.user_data = nullptr;
std::vector<DeviceInfo> devList;
devList.push_back(devInfo);
return devList;
}
std::string vrok::DriverJBufferOut::GetDefaultDevice() {
return "JNI";
}
bool vrok::DriverJBufferOut::SetDevice(std::string device) {
return true;
}
void vrok::DriverJBufferOut::ThreadStart() {
m_events->OnThreadStart();
}
void vrok::DriverJBufferOut::ThreadEnd() {
m_events->OnThreadEnd();
}
vrok::DriverJBufferOut::~DriverJBufferOut() { }
bool vrok::DriverJBufferOut::BufferConfigChange(BufferConfig *config) {
m_events->OnBufferConfigChange(config->frames, config->samplerate, config->channels);
int len = config->frames * config->channels;
if (m_tempBuffer.size() < len)
m_tempBuffer.resize(len);
Sleep(10);
return true;
}
bool vrok::DriverJBufferOut::DriverRun(Buffer *buffer) {
if (buffer->GetBufferType() == Buffer::Type::StreamEnd) {
DBG(0, "stream end received");
}
int len = buffer->GetBufferConfig()->frames * buffer->GetBufferConfig()->channels;
for (int i = 0; i < len; i++) {
m_tempBuffer[i] = double(buffer->GetData()[i]);
}
m_events->OnBuffer(m_tempBuffer.data(), buffer->GetBufferConfig()->frames, buffer->GetBufferType());
return true;
}
void vrok::DriverJBufferOut::Events::OnThreadStart() { }
void vrok::DriverJBufferOut::Events::OnThreadEnd() { }