server: Keep a count of clients that use damage

h264-encoding
Andri Yngvason 2021-12-25 15:46:58 +00:00
parent 55beea3464
commit c5a5437a9e
2 changed files with 16 additions and 0 deletions

View File

@ -113,6 +113,8 @@ struct nvnc {
nvnc_auth_fn auth_fn;
void* auth_ud;
#endif
uint32_t n_damage_clients;
};
void nvnc__damage_region(struct nvnc* self,

View File

@ -105,6 +105,11 @@ static void client_close(struct nvnc_client* client)
LIST_REMOVE(client, link);
stream_destroy(client->net_stream);
if (client->encoder) {
client->server->n_damage_clients -=
!(client->encoder->impl->flags &
ENCODER_IMPL_FLAG_IGNORES_DAMAGE);
}
encoder_destroy(client->encoder);
pixman_region_fini(&client->damage);
free(client->cut_text.buffer);
@ -560,6 +565,11 @@ static void process_fb_update_requests(struct nvnc_client* client)
if (!client->encoder || encoding != encoder_get_type(client->encoder)) {
int width = server->display->buffer->width;
int height = server->display->buffer->height;
if (client->encoder) {
server->n_damage_clients -=
!(client->encoder->impl->flags &
ENCODER_IMPL_FLAG_IGNORES_DAMAGE);
}
encoder_destroy(client->encoder);
client->encoder = encoder_new(encoding, width, height);
if (!client->encoder) {
@ -572,6 +582,10 @@ static void process_fb_update_requests(struct nvnc_client* client)
client->encoder->on_done = on_encoder_push_done;
client->encoder->userdata = client;
}
server->n_damage_clients +=
!(client->encoder->impl->flags &
ENCODER_IMPL_FLAG_IGNORES_DAMAGE);
}
enum encoder_kind kind = encoder_get_kind(client->encoder);