-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.cpp
50 lines (41 loc) · 1005 Bytes
/
main.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
#include "AudioRecorder.h"
#include "AudioPlayer.h"
#include <string>
using namespace std;
int main(){
puts("==== Audio Player ====");
avdevice_register_all();
try {
AudioPlayer player{"testAudio.aac"};
player.OpenDevice();
player.PlayAndDecode();
}
catch (std::exception &e) {
fprintf(stderr,"[ERROR] %s\n", e.what());
exit(-1);
}
puts("END");
return 0;
}
int main1(){
puts("==== Audio Recorder ====");
avdevice_register_all();
AudioRecorder recorder{ "testAudio.aac","" };
try {
recorder.Open();
recorder.Start();
//record 10 seconds.
std::this_thread::sleep_for(10s);
recorder.Stop();
string reason = recorder.GetLastError();
if (!reason.empty()) {
throw std::runtime_error(reason);
}
}
catch (std::exception &e) {
fprintf(stderr,"[ERROR] %s\n", e.what());
exit(-1);
}
puts("END");
return 0;
}