OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 // The TimeScheduler class keeps track of periodic events. It is non-drifting | |
12 // and keeps track of any missed periods so that it is possible to catch up. | |
13 // (compare to a metronome) | |
14 #include "rtc_base/criticalsection.h" | |
15 | |
16 #ifndef MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_TIME_SCHEDULER_H_ | |
17 #define MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_TIME_SCHEDULER_H_ | |
18 | |
19 namespace webrtc { | |
20 | |
21 class TimeScheduler { | |
22 public: | |
23 TimeScheduler(const int64_t periodicityInMs); | |
24 ~TimeScheduler() = default; | |
25 | |
26 // Signal that a periodic event has been triggered. | |
27 int32_t UpdateScheduler(); | |
28 | |
29 // Set updateTimeInMs to the amount of time until UpdateScheduler() should | |
30 // be called. This time will never be negative. | |
31 int32_t TimeToNextUpdate(int64_t& updateTimeInMS) const; | |
32 | |
33 private: | |
34 rtc::CriticalSection _crit; | |
35 | |
36 bool _isStarted; | |
37 int64_t _lastPeriodMark; // In ns | |
38 | |
39 int64_t _periodicityInMs; | |
40 int64_t _periodicityInTicks; | |
41 uint32_t _missedPeriods; | |
42 }; | |
43 } // namespace webrtc | |
44 | |
45 #endif // MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_TIME_SCHEDULER_H_ | |
OLD | NEW |