-
Notifications
You must be signed in to change notification settings - Fork 2
/
Capture.cpp
94 lines (76 loc) · 1.8 KB
/
Capture.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "Common.h"
void Extension::CaptureRecalculateSettings()
{
Input.BlockAlign = Input.Channels * Input.Bits / 8;
Input.Format = alureGetSampleFormat(Input.Channels, Input.Bits, 0);
}
/* Actions */
void Extension::CaptureSetFrequency(int Frequency)
{
Input.Frequency = Frequency;
}
void Extension::CaptureSetChannels(int Channels)
{
Input.Channels = Channels == 2 ? 2 : 1;
}
void Extension::CaptureSetBits(int Bits)
{
Input.Bits = Bits == 16 ? 16 : 8;
}
void Extension::CaptureSetBufferSize(int BufferSamples)
{
Input.BufferSamples = max(32, BufferSamples);
}
void Extension::CaptureDeviceOpen(const char* Name)
{
//Make sure that we are not recording right now.
if(Input.Recording || Input.Device)
return;
CaptureRecalculateSettings();
//Open a recording device based on the settings.
Input.Device = alcCaptureOpenDevice(Name, Input.Frequency, Input.Format, Input.BufferSamples*Input.Bits/8*Input.Channels);
}
void Extension::CaptureDeviceClose()
{
if(Input.Device)
{
CaptureStop();
alcCaptureCloseDevice(Input.Device);
Input.Device = 0;
}
}
void Extension::CaptureDeviceEnumerate()
{
for(Input.EnumeratedDevice = Input.DeviceList; *Input.EnumeratedDevice; Input.EnumeratedDevice += strlen(Input.EnumeratedDevice))
Runtime.GenerateEvent(6);
Input.EnumeratedDevice = "";
}
void Extension::CaptureStart()
{
if(Input.Device && !Input.Recording)
{
alcCaptureStart(Input.Device);
Input.Recording = true;
}
}
void Extension::CaptureStop()
{
if(Input.Device && Input.Recording)
{
alcCaptureStop(Input.Device);
Input.Recording = false;
}
}
/* Expressions */
int Extension::CaptureDataGetAddress()
{
return (int)CaptureBuffer;
}
int Extension::CaptureDataGetBytes()
{
return CaptureAvailableBytes;
}
char* Extension::CaptureDeviceGetEnumerated()
{
return (char*)Input.EnumeratedDevice;
}