Tanoda
RealtimeClock.cs
Go to the documentation of this file.
1/*
2* NatCorder
3* Copyright (c) 2020 Yusuf Olokoba.
4*/
5
6using System;
7using System.Diagnostics;
8using System.Runtime.CompilerServices;
9
11{
15 public sealed class RealtimeClock : IClock
16 {
17 #region --Client API--
18
23 public long timestamp
24 {
25 [MethodImpl(MethodImplOptions.Synchronized)]
26 get
27 {
28 var time = stopwatch.Elapsed.Ticks * 100L;
29 if (!stopwatch.IsRunning)
30 stopwatch.Start();
31 return time;
32 }
33 }
34
38 public bool paused
39 {
40 [MethodImpl(MethodImplOptions.Synchronized)]
41 get => !stopwatch.IsRunning;
42 [MethodImpl(MethodImplOptions.Synchronized)]
43 set => (value ? (Action) stopwatch.Stop : stopwatch.Start)();
44 }
45
50 {
51 stopwatch = new Stopwatch();
52 }
53
54 #endregion
55
56 private readonly Stopwatch stopwatch;
57 }
58}
Realtime clock for generating timestamps
long timestamp
Current timestamp in nanoseconds. The very first value reported by this property will always be zero.
RealtimeClock()
Create a realtime clock.
Clock for generating recording timestamps. Clocks are important for synchronizing audio and video tra...
Definition: IClock.cs:14