Sunshine0.0.5917
Sunshine 0.0.5917
Self-hosted game stream host for Moonlight.
Loading...
Searching...
No Matches
Go to the documentation of this file.
1
5#pragma once
6
7// standard includes
8#include <chrono>
9#include <optional>
10
11namespace platf::kms {
21 public:
27 explicit empty_plane_timer_t(std::chrono::steady_clock::duration delay):
28 delay_ {delay} {
29 }
30
38 bool update(bool has_fb, std::chrono::steady_clock::time_point now) {
39 if (has_fb) {
40 empty_since_.reset();
41 return false;
42 }
43 if (!empty_since_) {
44 empty_since_ = now;
45 }
46 return now - *empty_since_ >= delay_;
47 }
48
55 std::chrono::steady_clock::duration empty_for(std::chrono::steady_clock::time_point now) const {
56 return empty_since_ ? now - *empty_since_ : std::chrono::steady_clock::duration::zero();
57 }
58
59 private:
60 std::chrono::steady_clock::duration delay_;
61 std::optional<std::chrono::steady_clock::time_point> empty_since_;
62 };
63} // namespace platf::kms
bool update(bool has_fb, std::chrono::steady_clock::time_point now)
Record whether the plane has a framebuffer now.
Definition kms_plane.h:38
std::chrono::steady_clock::duration empty_for(std::chrono::steady_clock::time_point now) const
How long the plane has had no framebuffer.
Definition kms_plane.h:55
empty_plane_timer_t(std::chrono::steady_clock::duration delay)
Construct a timer.
Definition kms_plane.h:27