forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsession_policy.cpp
More file actions
30 lines (26 loc) · 1005 Bytes
/
Copy pathsession_policy.cpp
File metadata and controls
30 lines (26 loc) · 1005 Bytes
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
#include "context_core/context_core.h"
namespace {
constexpr double kDefaultGapSeconds = 300.0;
constexpr const char *kVersion = "1.0.0";
} // namespace
extern "C" double ctx_session_default_gap_seconds(void) {
return kDefaultGapSeconds;
}
extern "C" int ctx_should_open_new_session(int has_last_segment,
double last_segment_ended_at,
double next_segment_started_at,
double gap_seconds) {
if (has_last_segment == 0) {
return 1;
}
const double gap = next_segment_started_at - last_segment_ended_at;
if (!(gap > 0.0)) {
// Also catches NaN, which every comparison below would answer "no" to anyway — but
// spelling it as "not greater than zero" makes that deliberate rather than incidental.
return 0;
}
return gap > gap_seconds ? 1 : 0;
}
extern "C" const char *ctx_core_version(void) {
return kVersion;
}