Ardour
9.0-pre0-384-ga76afae0e9
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
#include <glib.h>
23
24
#include <cstdint>
25
26
#ifdef _WIN32
27
#include "windows.h"
28
#else
29
#include <sys/time.h>
30
#endif
31
32
namespace
ArdourSurface
{
33
34
namespace
US2400
35
{
36
40
class
Timer
41
{
42
public
:
43
48
Timer
(
bool
shouldStart =
true
)
49
{
50
if
( shouldStart )
51
start
();
52
}
53
57
unsigned
long
start
()
58
{
59
_start
= g_get_monotonic_time();
60
return
_start
/ 1000;
61
}
62
67
unsigned
long
stop
()
68
{
69
_stop
= g_get_monotonic_time();
70
return
elapsed
();
71
}
72
76
unsigned
long
elapsed
()
const
77
{
78
if
(
running
)
79
{
80
uint64_t now = g_get_monotonic_time();
81
return
(now -
_start
) / 1000;
82
}
83
else
84
{
85
return
(
_stop
-
_start
) / 1000;
86
}
87
}
88
92
unsigned
long
restart
()
93
{
94
unsigned
long
retval =
stop
();
95
start
();
96
return
retval;
97
}
98
99
private
:
100
uint64_t
_start
;
101
uint64_t
_stop
;
102
bool
running
;
103
};
104
105
}
// US2400 namespace
106
}
// ArdourSurface namespace
107
108
#endif
ArdourSurface::US2400::Timer
Definition:
surfaces/us2400/timer.h:41
ArdourSurface::US2400::Timer::elapsed
unsigned long elapsed() const
Definition:
surfaces/us2400/timer.h:76
ArdourSurface::US2400::Timer::restart
unsigned long restart()
Definition:
surfaces/us2400/timer.h:92
ArdourSurface::US2400::Timer::running
bool running
Definition:
surfaces/us2400/timer.h:102
ArdourSurface::US2400::Timer::_start
uint64_t _start
Definition:
surfaces/us2400/timer.h:100
ArdourSurface::US2400::Timer::start
unsigned long start()
Definition:
surfaces/us2400/timer.h:57
ArdourSurface::US2400::Timer::_stop
uint64_t _stop
Definition:
surfaces/us2400/timer.h:101
ArdourSurface::US2400::Timer::Timer
Timer(bool shouldStart=true)
Definition:
surfaces/us2400/timer.h:48
ArdourSurface::US2400::Timer::stop
unsigned long stop()
Definition:
surfaces/us2400/timer.h:67
ArdourSurface
Definition:
cc121.h:71
PBD::DEBUG::US2400
DebugBits US2400
libs
surfaces
us2400
timer.h
Generated on Sat Nov 9 2024 06:31:49 for Ardour by
1.9.1