From f566105ab5236db3644863832577e3699110a2fd Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Sun, 29 Aug 2021 18:22:25 +0000 Subject: [PATCH] Remove nvnc_set_render_fn --- include/common.h | 1 - include/display.h | 1 - include/neatvnc.h | 2 -- src/display.c | 6 ------ src/server.c | 51 +++++------------------------------------------ 5 files changed, 5 insertions(+), 56 deletions(-) diff --git a/include/common.h b/include/common.h index 1293bc3..ee7f68b 100644 --- a/include/common.h +++ b/include/common.h @@ -98,7 +98,6 @@ struct nvnc { struct nvnc_common common; int fd; struct aml_handler* poll_handle; - struct aml_idle* dispatch_handler; struct nvnc_client_list clients; char name[256]; void* userdata; diff --git a/include/display.h b/include/display.h index 924a3ea..74527f7 100644 --- a/include/display.h +++ b/include/display.h @@ -29,5 +29,4 @@ struct nvnc_display { struct nvnc* server; uint16_t x_pos, y_pos; struct nvnc_fb* buffer; - nvnc_render_fn render_fn; }; diff --git a/include/neatvnc.h b/include/neatvnc.h index 0824e90..dbe8c4f 100644 --- a/include/neatvnc.h +++ b/include/neatvnc.h @@ -49,7 +49,6 @@ typedef void (*nvnc_client_fn)(struct nvnc_client*); typedef void (*nvnc_damage_fn)(struct pixman_region16* damage, void* userdata); typedef bool (*nvnc_auth_fn)(const char* username, const char* password, void* userdata); -typedef void (*nvnc_render_fn)(struct nvnc_display*, struct nvnc_fb*); typedef void (*nvnc_cut_text_fn)(struct nvnc*, const char* text, uint32_t len); typedef void (*nvnc_fb_release_fn)(struct nvnc_fb*, void* userdata); @@ -114,7 +113,6 @@ void nvnc_display_unref(struct nvnc_display*); struct nvnc* nvnc_display_get_server(const struct nvnc_display*); -void nvnc_display_set_render_fn(struct nvnc_display* self, nvnc_render_fn fn); void nvnc_display_set_buffer(struct nvnc_display*, struct nvnc_fb*); void nvnc_display_damage_region(struct nvnc_display*, diff --git a/src/display.c b/src/display.c index 00d7bc0..3bda45f 100644 --- a/src/display.c +++ b/src/display.c @@ -77,12 +77,6 @@ void nvnc_display_set_buffer(struct nvnc_display* self, struct nvnc_fb* fb) nvnc_fb_hold(fb); } -EXPORT -void nvnc_display_set_render_fn(struct nvnc_display* self, nvnc_render_fn fn) -{ - self->render_fn = fn; -} - EXPORT void nvnc_display_damage_region(struct nvnc_display* self, const struct pixman_region16* region) diff --git a/src/server.c b/src/server.c index 1e78efe..cb31139 100644 --- a/src/server.c +++ b/src/server.c @@ -1104,39 +1104,6 @@ static int bind_address(const char* name, uint16_t port, enum addrtype type) abort(); } -static bool nvnc__is_damaged(struct nvnc* self) -{ - struct nvnc_client* client; - LIST_FOREACH(client, &self->clients, link) - if (pixman_region_not_empty(&client->damage)) - return true; - - return false; -} - -static void on_main_dispatch(void* aml_obj) -{ - struct nvnc* self = aml_get_userdata(aml_obj); - struct nvnc_client* client; - - if (!nvnc__is_damaged(self)) - return; - - LIST_FOREACH(client, &self->clients, link) - if (client->is_updating) { - log_debug("Can't render yet: still encoding for client %p\n", - client); - return; - } - - struct nvnc_display* display = self->display; - if (display && display->render_fn) - display->render_fn(display, display->buffer); - - LIST_FOREACH(client, &self->clients, link) - process_fb_update_requests(client); -} - static struct nvnc* open_common(const char* address, uint16_t port, enum addrtype type) { aml_require_workers(aml_get_default(), -1); @@ -1163,19 +1130,8 @@ static struct nvnc* open_common(const char* address, uint16_t port, enum addrtyp if (aml_start(aml_get_default(), self->poll_handle) < 0) goto poll_start_failure; - self->dispatch_handler = aml_idle_new(on_main_dispatch, self, NULL); - if (!self->dispatch_handler) - goto new_idle_failure; - - if (aml_start(aml_get_default(), self->dispatch_handler) < 0) - goto idle_start_failure; - return self; -idle_start_failure: - aml_unref(self->dispatch_handler); -new_idle_failure: - aml_stop(aml_get_default(), self->poll_handle); poll_start_failure: aml_unref(self->poll_handle); handle_failure: @@ -1226,7 +1182,6 @@ void nvnc_close(struct nvnc* self) LIST_FOREACH_SAFE (client, &self->clients, link, tmp) client_unref(client); - aml_stop(aml_get_default(), self->dispatch_handler); aml_stop(aml_get_default(), self->poll_handle); unlink_fd_path(self->fd); close(self->fd); @@ -1238,7 +1193,6 @@ void nvnc_close(struct nvnc* self) } #endif - aml_unref(self->dispatch_handler); aml_unref(self->poll_handle); free(self); } @@ -1251,6 +1205,7 @@ static void on_write_frame_done(void* userdata, enum stream_req_status status) nvnc_fb_release(client->current_fb); nvnc_fb_unref(client->current_fb); client->current_fb = NULL; + process_fb_update_requests(client); client_unref(client); } @@ -1338,6 +1293,7 @@ static void finish_fb_update(struct nvnc_client* client, struct vec* frame) nvnc_fb_unref(client->current_fb); client->current_fb = NULL; vec_destroy(frame); + process_fb_update_requests(client); client_unref(client); } @@ -1477,6 +1433,9 @@ void nvnc__damage_region(struct nvnc* self, const struct pixman_region16* damage if (client->net_stream->state != STREAM_STATE_CLOSED) pixman_region_union(&client->damage, &client->damage, (struct pixman_region16*)damage); + + LIST_FOREACH(client, &self->clients, link) + process_fb_update_requests(client); } EXPORT