Allow the user to adjust the FPS limit
parent
6682324710
commit
184ed0a7ef
|
@ -68,6 +68,8 @@ struct screencopy {
|
||||||
bool have_linux_dmabuf;
|
bool have_linux_dmabuf;
|
||||||
uint32_t dmabuf_width, dmabuf_height;
|
uint32_t dmabuf_width, dmabuf_height;
|
||||||
uint32_t fourcc;
|
uint32_t fourcc;
|
||||||
|
|
||||||
|
double rate_limit;
|
||||||
};
|
};
|
||||||
|
|
||||||
void screencopy_init(struct screencopy* self);
|
void screencopy_init(struct screencopy* self);
|
||||||
|
|
|
@ -571,6 +571,7 @@ int wayvnc_usage(FILE* stream, int rc)
|
||||||
" -k,--keyboard=<layout> Select keyboard layout.\n"
|
" -k,--keyboard=<layout> Select keyboard layout.\n"
|
||||||
" -s,--seat=<name> Select seat by name.\n"
|
" -s,--seat=<name> Select seat by name.\n"
|
||||||
" -r,--render-cursor Enable overlay cursor rendering.\n"
|
" -r,--render-cursor Enable overlay cursor rendering.\n"
|
||||||
|
" -f,--max-fps=<fps> Set the rate limit (default 30).\n"
|
||||||
" -h,--help Get help (this text).\n"
|
" -h,--help Get help (this text).\n"
|
||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
|
@ -628,8 +629,9 @@ int main(int argc, char* argv[])
|
||||||
const char* seat_name = NULL;
|
const char* seat_name = NULL;
|
||||||
|
|
||||||
bool overlay_cursor = false;
|
bool overlay_cursor = false;
|
||||||
|
int max_rate = 30;
|
||||||
|
|
||||||
static const char* shortopts = "C:o:k:s:rh";
|
static const char* shortopts = "C:o:k:s:rf:h";
|
||||||
int drm_fd = -1;
|
int drm_fd = -1;
|
||||||
|
|
||||||
static const struct option longopts[] = {
|
static const struct option longopts[] = {
|
||||||
|
@ -638,6 +640,7 @@ int main(int argc, char* argv[])
|
||||||
{ "keyboard", required_argument, NULL, 'k' },
|
{ "keyboard", required_argument, NULL, 'k' },
|
||||||
{ "seat", required_argument, NULL, 's' },
|
{ "seat", required_argument, NULL, 's' },
|
||||||
{ "render-cursor", no_argument, NULL, 'r' },
|
{ "render-cursor", no_argument, NULL, 'r' },
|
||||||
|
{ "max-fps", required_argument, NULL, 'f' },
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
@ -663,6 +666,9 @@ int main(int argc, char* argv[])
|
||||||
case 'r':
|
case 'r':
|
||||||
overlay_cursor = true;
|
overlay_cursor = true;
|
||||||
break;
|
break;
|
||||||
|
case 'f':
|
||||||
|
max_rate = atoi(optarg);
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
return wayvnc_usage(stdout, 0);
|
return wayvnc_usage(stdout, 0);
|
||||||
default:
|
default:
|
||||||
|
@ -740,6 +746,7 @@ int main(int argc, char* argv[])
|
||||||
self.selected_output = out;
|
self.selected_output = out;
|
||||||
self.selected_seat = seat;
|
self.selected_seat = seat;
|
||||||
self.screencopy.wl_output = out->wl_output;
|
self.screencopy.wl_output = out->wl_output;
|
||||||
|
self.screencopy.rate_limit = max_rate;
|
||||||
|
|
||||||
self.keyboard_backend.virtual_keyboard =
|
self.keyboard_backend.virtual_keyboard =
|
||||||
zwp_virtual_keyboard_manager_v1_create_virtual_keyboard(
|
zwp_virtual_keyboard_manager_v1_create_virtual_keyboard(
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include "time-util.h"
|
#include "time-util.h"
|
||||||
#include "usdt.h"
|
#include "usdt.h"
|
||||||
|
|
||||||
#define RATE_LIMIT 30.0 // Hz
|
|
||||||
#define DELAY_SMOOTHER_TIME_CONSTANT 0.5 // s
|
#define DELAY_SMOOTHER_TIME_CONSTANT 0.5 // s
|
||||||
|
|
||||||
void screencopy_stop(struct screencopy* self)
|
void screencopy_stop(struct screencopy* self)
|
||||||
|
@ -231,7 +230,7 @@ static int screencopy__start(struct screencopy* self, bool is_immediate_copy)
|
||||||
|
|
||||||
uint64_t now = gettime_us();
|
uint64_t now = gettime_us();
|
||||||
double dt = (now - self->last_time) * 1.0e-6;
|
double dt = (now - self->last_time) * 1.0e-6;
|
||||||
double time_left = (1.0 / RATE_LIMIT - dt - self->delay) * 1.0e3;
|
double time_left = (1.0 / self->rate_limit - dt - self->delay) * 1.0e3;
|
||||||
|
|
||||||
self->status = SCREENCOPY_IN_PROGRESS;
|
self->status = SCREENCOPY_IN_PROGRESS;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue