blob: 54771c940e171da4eccb87745e20be4939686a18 (
plain)
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
|
#pragma once
#include "config.h"
#include "debug.h"
#include "log.h"
#include <libreichwein/file.h>
#include <chrono>
#include <alsa/asoundlib.h>
#include <fmt/format.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std::string_literals;
class PCM
{
public:
PCM(Config& config);
~PCM();
void click(std::chrono::duration<double> offset);
// generate 1 buffer size
void generate();
int fd();
// write from buffer to ALSA PCM
void write();
bool wait_for_event();
bool write_available();
private:
Config& m_config;
int err;
snd_pcm_t *handle;
int npfd;
struct pollfd* pfd;
std::vector<uint16_t> m_data;
int32_t m_phase;
int16_t buffer[nframes];
};
|