From 46da55b1eafef7495204a6733193057853d6575a Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 21 Jun 2024 23:01:00 +0200 Subject: fm content: make sure to capture frame on damage and then no damage after fps frame timeout --- src/capture/xcomposite.c | 15 ++++++--------- src/capture/xcomposite_cuda.c | 12 +++++++++--- src/capture/xcomposite_vaapi.c | 12 +++++++++--- 3 files changed, 24 insertions(+), 15 deletions(-) (limited to 'src/capture') diff --git a/src/capture/xcomposite.c b/src/capture/xcomposite.c index c68acaa..3240ed8 100644 --- a/src/capture/xcomposite.c +++ b/src/capture/xcomposite.c @@ -285,15 +285,12 @@ void gsr_capture_xcomposite_tick(gsr_capture_xcomposite *self, AVCodecContext *v } } -bool gsr_capture_xcomposite_consume_damage(gsr_capture_xcomposite *self) { - if(self->damage_event) { - const bool damaged = self->damaged; - self->damaged = false; - //fprintf(stderr, "consume: %s\n", damaged ? "yes" : "no"); - return damaged; - } else { - return true; - } +bool gsr_capture_xcomposite_is_damaged(gsr_capture_xcomposite *self) { + return self->damage_event ? self->damaged : true; +} + +void gsr_capture_xcomposite_clear_damage(gsr_capture_xcomposite *self) { + self->damaged = false; } bool gsr_capture_xcomposite_should_stop(gsr_capture_xcomposite *self, bool *err) { diff --git a/src/capture/xcomposite_cuda.c b/src/capture/xcomposite_cuda.c index 01e1f12..c436221 100644 --- a/src/capture/xcomposite_cuda.c +++ b/src/capture/xcomposite_cuda.c @@ -76,9 +76,14 @@ static void gsr_capture_xcomposite_cuda_tick(gsr_capture *cap, AVCodecContext *v gsr_capture_xcomposite_tick(&cap_xcomp->xcomposite, video_codec_context); } -static bool gsr_capture_xcomposite_cuda_consume_damage(gsr_capture *cap) { +static bool gsr_capture_xcomposite_cuda_is_damaged(gsr_capture *cap) { gsr_capture_xcomposite_cuda *cap_xcomp = cap->priv; - return gsr_capture_xcomposite_consume_damage(&cap_xcomp->xcomposite); + return gsr_capture_xcomposite_is_damaged(&cap_xcomp->xcomposite); +} + +static void gsr_capture_xcomposite_cuda_clear_damage(gsr_capture *cap) { + gsr_capture_xcomposite_cuda *cap_xcomp = cap->priv; + gsr_capture_xcomposite_clear_damage(&cap_xcomp->xcomposite); } static bool gsr_capture_xcomposite_cuda_should_stop(gsr_capture *cap, bool *err) { @@ -149,7 +154,8 @@ gsr_capture* gsr_capture_xcomposite_cuda_create(const gsr_capture_xcomposite_cud *cap = (gsr_capture) { .start = gsr_capture_xcomposite_cuda_start, .tick = gsr_capture_xcomposite_cuda_tick, - .consume_damage = gsr_capture_xcomposite_cuda_consume_damage, + .is_damaged = gsr_capture_xcomposite_cuda_is_damaged, + .clear_damage = gsr_capture_xcomposite_cuda_clear_damage, .should_stop = gsr_capture_xcomposite_cuda_should_stop, .capture = gsr_capture_xcomposite_cuda_capture, .capture_end = NULL, diff --git a/src/capture/xcomposite_vaapi.c b/src/capture/xcomposite_vaapi.c index b8d4544..3f27014 100644 --- a/src/capture/xcomposite_vaapi.c +++ b/src/capture/xcomposite_vaapi.c @@ -43,9 +43,14 @@ static void gsr_capture_xcomposite_vaapi_tick(gsr_capture *cap, AVCodecContext * gsr_capture_xcomposite_tick(&cap_xcomp->xcomposite, video_codec_context); } -static bool gsr_capture_xcomposite_vaapi_consume_damage(gsr_capture *cap) { +static bool gsr_capture_xcomposite_vaapi_is_damaged(gsr_capture *cap) { gsr_capture_xcomposite_vaapi *cap_xcomp = cap->priv; - return gsr_capture_xcomposite_consume_damage(&cap_xcomp->xcomposite); + return gsr_capture_xcomposite_is_damaged(&cap_xcomp->xcomposite); +} + +static void gsr_capture_xcomposite_vaapi_clear_damage(gsr_capture *cap) { + gsr_capture_xcomposite_vaapi *cap_xcomp = cap->priv; + gsr_capture_xcomposite_clear_damage(&cap_xcomp->xcomposite); } static bool gsr_capture_xcomposite_vaapi_should_stop(gsr_capture *cap, bool *err) { @@ -103,7 +108,8 @@ gsr_capture* gsr_capture_xcomposite_vaapi_create(const gsr_capture_xcomposite_va *cap = (gsr_capture) { .start = gsr_capture_xcomposite_vaapi_start, .tick = gsr_capture_xcomposite_vaapi_tick, - .consume_damage = gsr_capture_xcomposite_vaapi_consume_damage, + .is_damaged = gsr_capture_xcomposite_vaapi_is_damaged, + .clear_damage = gsr_capture_xcomposite_vaapi_clear_damage, .should_stop = gsr_capture_xcomposite_vaapi_should_stop, .capture = gsr_capture_xcomposite_vaapi_capture, .capture_end = NULL, -- cgit v1.2.3