-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsoundcard_indicator.h
70 lines (56 loc) · 1.38 KB
/
soundcard_indicator.h
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
#ifndef __SCI_SOUNDCARD_INDICATOR_H_
#define __SCI_SOUNDCARD_INDICATOR_H_
#include "indicator.h"
#include "soundcard2c.h"
#include "clocktime.h"
#include "boost/thread.hpp"
#include <memory>
class soundcard_indicator :
public indicator
{
private:
protected:
reading current_raw_reading;
sci::soundcard2c s2c;
std::unique_ptr<boost::thread> thread;
void run( )
{
s2c.run();
}
public:
soundcard_indicator( bool swap_cd = false ) :
s2c( [this](uint64_t value)
{
reading r;
int64_t len = value & 0xFFFFF;
if( value & 0x100000 )
{
len *= -1;
}
// std::cout << "len = " << len << "\n";
// r.length = len * si::nano * si::meter;
auto rlen = len * boost::units::si::micro * boost::units::si::meter;
// rlen.foo();
// r.length.foo();
// std::cout << "rlen = " << rlen << "\n";
r.length = rlen;
r.read_at = now();
current_raw_reading.set(r);
// std::cout << "r.length = " << r.length << "\n";
// std::cout << "r.length = " << boost::units::engineering_prefix << r.length << "\n";
},-1,96000,swap_cd)
{
}
virtual reading raw_reading( ) const
{
auto ret = current_raw_reading.get();
return ret;
}
void start( )
{
s2c.init();
thread.reset( new boost::thread( &soundcard_indicator::run, this ) );
}
};
#endif // __SCI_SOUNDCARD_INDICATOR_H_
// vim: tabstop=4 shiftwidth=4 noexpandtab