mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-08-10 00:52:16 +00:00
Improve frametiming for linux capture (#2333)
This commit is contained in:
@@ -1193,17 +1193,22 @@ namespace platf {
|
||||
capture(const push_captured_image_cb_t &push_captured_image_cb, const pull_free_image_cb_t &pull_free_image_cb, bool *cursor) override {
|
||||
auto next_frame = std::chrono::steady_clock::now();
|
||||
|
||||
sleep_overshoot_tracker.reset();
|
||||
|
||||
while (true) {
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
|
||||
if (next_frame > now) {
|
||||
std::this_thread::sleep_for((next_frame - now) / 3 * 2);
|
||||
std::this_thread::sleep_for(next_frame - now);
|
||||
}
|
||||
while (next_frame > now) {
|
||||
std::this_thread::sleep_for(1ns);
|
||||
now = std::chrono::steady_clock::now();
|
||||
now = std::chrono::steady_clock::now();
|
||||
std::chrono::nanoseconds overshoot_ns = now - next_frame;
|
||||
log_sleep_overshoot(overshoot_ns);
|
||||
|
||||
next_frame += delay;
|
||||
if (next_frame < now) { // some major slowdown happened; we couldn't keep up
|
||||
next_frame = now + delay;
|
||||
}
|
||||
next_frame = now + delay;
|
||||
|
||||
std::shared_ptr<platf::img_t> img_out;
|
||||
auto status = snapshot(pull_free_image_cb, img_out, 1000ms, *cursor);
|
||||
@@ -1412,17 +1417,22 @@ namespace platf {
|
||||
capture(const push_captured_image_cb_t &push_captured_image_cb, const pull_free_image_cb_t &pull_free_image_cb, bool *cursor) {
|
||||
auto next_frame = std::chrono::steady_clock::now();
|
||||
|
||||
sleep_overshoot_tracker.reset();
|
||||
|
||||
while (true) {
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
|
||||
if (next_frame > now) {
|
||||
std::this_thread::sleep_for((next_frame - now) / 3 * 2);
|
||||
std::this_thread::sleep_for(next_frame - now);
|
||||
}
|
||||
while (next_frame > now) {
|
||||
std::this_thread::sleep_for(1ns);
|
||||
now = std::chrono::steady_clock::now();
|
||||
now = std::chrono::steady_clock::now();
|
||||
std::chrono::nanoseconds overshoot_ns = now - next_frame;
|
||||
log_sleep_overshoot(overshoot_ns);
|
||||
|
||||
next_frame += delay;
|
||||
if (next_frame < now) { // some major slowdown happened; we couldn't keep up
|
||||
next_frame = now + delay;
|
||||
}
|
||||
next_frame = now + delay;
|
||||
|
||||
std::shared_ptr<platf::img_t> img_out;
|
||||
auto status = snapshot(pull_free_image_cb, img_out, 1000ms, *cursor);
|
||||
|
||||
Reference in New Issue
Block a user