-
Notifications
You must be signed in to change notification settings - Fork 0
/
AlsaMinder.hpp
59 lines (41 loc) · 1.76 KB
/
AlsaMinder.hpp
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
#ifndef ALSAMINDER_HPP
#define ALSAMINDER_HPP
#include <string>
#include <stdexcept>
#include <sstream>
#include <iomanip>
#include <memory>
#include <cmath>
using namespace std;
#include <alsa/asoundlib.h>
#include "DevMinder.hpp"
class AlsaMinder : public DevMinder {
public:
static const int PERIOD_FRAMES = 4800; // 40 periods per second for FCD Pro +; 20 periods per second for FCD Pro
static const int BUFFER_FRAMES = 131072; // 128K appears to be max buffer size in frames; this is 0.683 s for FCD Pro+, 1.365 s for FCD Pro
protected:
int numFD; // number of file descriptors required for polling on this
// device
unsigned short revents; // demangled version of revent returned after poll()
snd_pcm_t * pcm; // handle to open pcm device
snd_pcm_uframes_t buffer_frames; // buffer size given to us by ALSA (we attempt to specify
// it)
snd_pcm_uframes_t period_frames; // period size given to us by ALSA (we attempt to specify
// it)
public:
virtual int hw_open();
virtual bool hw_is_open();
AlsaMinder(const string &devName, int rate, unsigned int numChan, const string &label, double now);
~AlsaMinder();
virtual int hw_getNumPollFDs ();
virtual int hw_getPollFDs (struct pollfd *pollfds);
virtual int hw_handleEvents ( struct pollfd *pollfds, bool timedOut);
virtual int hw_getFrames (int16_t *buf, int numFrames, double & frameTimestamp);
protected:
virtual void delete_privates();
virtual int hw_do_start();
virtual int hw_do_stop();
virtual int hw_do_restart();
virtual bool hw_running(double timeNow);
};
#endif // ALSAMINDER_HPP