54b79dffa8
* Abstract SteadyClockCore to follow Nintendo changes in 4.x This is the ground work for 4.0.0 support * Implement TickBasedSteadyClockCore Preparation for the ephemeral clock. * Refactor SystemClockCore to follow 4.0.0 changes * Implement EphemeralNetworkSystemClock * Implement GetSnapshotClock & GetSnapshotClockFromSystemClockContext * Implement CalculateStandardUserSystemClockDifferenceByUser & CalculateSpanBetween * Remove an outdated comment & unused import * Fix a nit and GetClockSnapshot * Address comment
56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
using Ryujinx.HLE.HOS.Kernel.Threading;
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Time.Clock
|
|
{
|
|
abstract class SystemClockCore
|
|
{
|
|
private SteadyClockCore _steadyClockCore;
|
|
private SystemClockContext _context;
|
|
|
|
public SystemClockCore(SteadyClockCore steadyClockCore)
|
|
{
|
|
_steadyClockCore = steadyClockCore;
|
|
_context = new SystemClockContext();
|
|
|
|
_context.SteadyTimePoint.ClockSourceId = steadyClockCore.GetClockSourceId();
|
|
}
|
|
|
|
public virtual SteadyClockCore GetSteadyClockCore()
|
|
{
|
|
return _steadyClockCore;
|
|
}
|
|
|
|
public virtual ResultCode GetSystemClockContext(KThread thread, out SystemClockContext context)
|
|
{
|
|
context = _context;
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
public virtual ResultCode SetSystemClockContext(SystemClockContext context)
|
|
{
|
|
_context = context;
|
|
|
|
return ResultCode.Success;
|
|
}
|
|
|
|
public abstract ResultCode Flush(SystemClockContext context);
|
|
|
|
public bool IsClockSetup(KThread thread)
|
|
{
|
|
ResultCode result = GetSystemClockContext(thread, out SystemClockContext context);
|
|
|
|
if (result == ResultCode.Success)
|
|
{
|
|
SteadyClockCore steadyClockCore = GetSteadyClockCore();
|
|
|
|
SteadyClockTimePoint steadyClockTimePoint = steadyClockCore.GetCurrentTimePoint(thread);
|
|
|
|
return steadyClockTimePoint.ClockSourceId == context.SteadyTimePoint.ClockSourceId;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|