-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenALDataFetcher.h
More file actions
43 lines (33 loc) · 914 Bytes
/
OpenALDataFetcher.h
File metadata and controls
43 lines (33 loc) · 914 Bytes
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
#pragma once
#include <vector>
#include <string>
#include <cstddef>
#include <functional>
#include <memory>
#include <stdexcept>
#include <chrono>
#include <AL/al.h>
#include <AL/alc.h>
#include "util.h"
class OpenALDataFetcher {
public:
OpenALDataFetcher(
ALCuint sample_rate,
ALCsizei buffer_size,
const std::function<size_t(const std::vector<std::string>&)> &device_matcher
);
~OpenALDataFetcher();
ALCint UpdateData();
void GetData(float buffer[]);
void ReloadDevice();
double device_timeout = 0.1;
private:
void BuildDeviceList();
using clock = std::chrono::steady_clock;
ALCuint sample_rate;
ALCsizei internal_buffer_size;
std::function<size_t(const std::vector<std::string> &device_list)> device_matcher;
ALCdevice *device = NULL;
std::unique_ptr<short[]> internal_buffer;
std::vector<std::string> device_list;
};