diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 0fabf0ac..ed141d0e 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -272,12 +272,7 @@ video_buffer_on_frame_available(struct video_buffer *vb, void *userdata) { (void) vb; (void) userdata; - static SDL_Event new_frame_event = { - .type = EVENT_NEW_FRAME, - }; - - // Post the event on the UI thread - SDL_PushEvent(&new_frame_event); + screen_on_frame_available(&screen); } bool diff --git a/app/src/screen.c b/app/src/screen.c index 5e757c9d..916ba773 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -654,3 +654,15 @@ screen_hidpi_scale_coords(struct screen *screen, int32_t *x, int32_t *y) { *x = (int64_t) *x * dw / ww; *y = (int64_t) *y * dh / wh; } + +void +screen_on_frame_available(struct screen *screen) { + (void) screen; + + static SDL_Event new_frame_event = { + .type = EVENT_NEW_FRAME, + }; + + // Post the event on the UI thread + SDL_PushEvent(&new_frame_event); +} diff --git a/app/src/screen.h b/app/src/screen.h index 8941416e..c3489c88 100644 --- a/app/src/screen.h +++ b/app/src/screen.h @@ -139,4 +139,9 @@ screen_convert_drawable_to_frame_coords(struct screen *screen, void screen_hidpi_scale_coords(struct screen *screen, int32_t *x, int32_t *y); +// Notify the screen that a new frame is available in the video_buffer. +// Called from a separate thread. +void +screen_on_frame_available(struct screen *screen); + #endif