Ardour
8.12
surfaces/us2400/timer.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2017 Ben Loftis <ben@harrisonconsoles.com>
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License along
15
* with this program; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
*/
18
19
#ifndef timer_h
20
#define timer_h
21
22
#ifdef _WIN32
23
#include "windows.h"
24
#else
25
#include <sys/time.h>
26
#endif
27
28
namespace
ArdourSurface
{
29
30
namespace
US2400
31
{
32
36
class
Timer
37
{
38
public
:
39
44
Timer
(
bool
shouldStart =
true
)
45
{
46
if
( shouldStart )
47
start
();
48
}
49
53
unsigned
long
start
()
54
{
55
_start
= g_get_monotonic_time();
56
return
_start
/ 1000;
57
}
58
63
unsigned
long
stop
()
64
{
65
_stop
= g_get_monotonic_time();
66
return
elapsed
();
67
}
68
72
unsigned
long
elapsed
()
const
73
{
74
if
(
running
)
75
{
76
uint64_t now = g_get_monotonic_time();
77
return
(now -
_start
) / 1000;
78
}
79
else
80
{
81
return
(
_stop
-
_start
) / 1000;
82
}
83
}
84
88
unsigned
long
restart
()
89
{
90
unsigned
long
retval =
stop
();
91
start
();
92
return
retval;
93
}
94
95
private
:
96
uint64_t
_start
;
97
uint64_t
_stop
;
98
bool
running
;
99
};
100
101
}
// US2400 namespace
102
}
// ArdourSurface namespace
103
104
#endif
ArdourSurface::US2400::Timer
Definition:
surfaces/us2400/timer.h:37
ArdourSurface::US2400::Timer::elapsed
unsigned long elapsed() const
Definition:
surfaces/us2400/timer.h:72
ArdourSurface::US2400::Timer::restart
unsigned long restart()
Definition:
surfaces/us2400/timer.h:88
ArdourSurface::US2400::Timer::running
bool running
Definition:
surfaces/us2400/timer.h:98
ArdourSurface::US2400::Timer::_start
uint64_t _start
Definition:
surfaces/us2400/timer.h:96
ArdourSurface::US2400::Timer::start
unsigned long start()
Definition:
surfaces/us2400/timer.h:53
ArdourSurface::US2400::Timer::_stop
uint64_t _stop
Definition:
surfaces/us2400/timer.h:97
ArdourSurface::US2400::Timer::Timer
Timer(bool shouldStart=true)
Definition:
surfaces/us2400/timer.h:44
ArdourSurface::US2400::Timer::stop
unsigned long stop()
Definition:
surfaces/us2400/timer.h:63
ArdourSurface
Definition:
cc121.h:71
PBD::DEBUG::US2400
DebugBits US2400
libs
surfaces
us2400
timer.h
Generated on Mon Mar 10 2025 20:26:30 for Ardour by
1.9.1