2019-12-22 23:49:51 +01:00
|
|
|
// Copyright 2019 yuzu emulator team
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "core/hle/service/time/clock_types.h"
|
|
|
|
#include "core/hle/service/time/steady_clock_core.h"
|
|
|
|
#include "core/hle/service/time/system_clock_core.h"
|
|
|
|
|
2019-12-23 00:10:59 +01:00
|
|
|
namespace Core {
|
|
|
|
class System;
|
|
|
|
}
|
|
|
|
|
2019-12-22 23:49:51 +01:00
|
|
|
namespace Service::Time::Clock {
|
|
|
|
|
|
|
|
class StandardNetworkSystemClockCore final : public SystemClockCore {
|
|
|
|
public:
|
2021-05-16 07:46:30 +02:00
|
|
|
explicit StandardNetworkSystemClockCore(SteadyClockCore& steady_clock_core_)
|
|
|
|
: SystemClockCore{steady_clock_core_} {}
|
2019-12-22 23:49:51 +01:00
|
|
|
|
|
|
|
void SetStandardNetworkClockSufficientAccuracy(TimeSpanType value) {
|
|
|
|
standard_network_clock_sufficient_accuracy = value;
|
|
|
|
}
|
|
|
|
|
2020-04-18 02:02:42 +02:00
|
|
|
bool IsStandardNetworkSystemClockAccuracySufficient(Core::System& system) const {
|
2021-05-16 07:46:30 +02:00
|
|
|
SystemClockContext clock_ctx{};
|
|
|
|
if (GetClockContext(system, clock_ctx) != RESULT_SUCCESS) {
|
2019-12-23 00:10:59 +01:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
s64 span{};
|
2021-05-16 07:46:30 +02:00
|
|
|
if (clock_ctx.steady_time_point.GetSpanBetween(
|
2019-12-23 00:10:59 +01:00
|
|
|
GetSteadyClockCore().GetCurrentTimePoint(system), span) != RESULT_SUCCESS) {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
return TimeSpanType{span}.nanoseconds <
|
|
|
|
standard_network_clock_sufficient_accuracy.nanoseconds;
|
|
|
|
}
|
|
|
|
|
2019-12-22 23:49:51 +01:00
|
|
|
private:
|
|
|
|
TimeSpanType standard_network_clock_sufficient_accuracy{};
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Service::Time::Clock
|