MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
Timing.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Contributors to the Media eXchange Layer project.
2// SPDX-License-Identifier: Apache-2.0
3
5#include <mxl/platform.h>
7
8namespace mxl::lib
9{
11 Timepoint currentTime(Clock clock) noexcept
12 {
13 auto result = Timepoint{};
14
15 std::timespec ts;
16 if (::clock_gettime(detail::clockToId(clock), &ts) == 0)
17 {
18 result = asTimepoint(ts) + detail::getClockOffset(clock);
19 }
20 return result;
21 }
22
24 {
25 auto result = Timepoint{};
26
27 std::timespec ts;
28 if (::timespec_get(&ts, TIME_UTC) != 0)
29 {
30 result = asTimepoint(ts);
31 }
32 return result;
33 }
34}
constexpr clockid_t clockToId(Clock clock) noexcept
constexpr Duration getClockOffset(Clock clock) noexcept
constexpr Timepoint asTimepoint(std::timespec const &timepoint) noexcept
Definition Timing.hpp:236
Timepoint currentTimeUTC() noexcept
Definition Timing.cpp:23
#define MXL_EXPORT
Definition platform.h:9
auto const currentTime
Definition test_time.cpp:58