From 42891c5ba8718c4e5ceea73f1866081d8fef16b7 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Wed, 22 Oct 2014 16:29:13 +0200 Subject: [PATCH] Implement PUTF_DISCARD for some more displays --- src/video_display/dvs.c | 4 ++-- src/video_display/gl.cpp | 4 ++++ src/video_display/pipe.cpp | 5 +++-- src/video_display/sdl.cpp | 5 +++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/video_display/dvs.c b/src/video_display/dvs.c index 1b048925d..ccbe0784f 100644 --- a/src/video_display/dvs.c +++ b/src/video_display/dvs.c @@ -496,14 +496,14 @@ display_dvs_getf(void *state) return s->frame; } -int display_dvs_putf(void *state, struct video_frame *frame, int nonblock) +int display_dvs_putf(void *state, struct video_frame *frame, int flags) { struct state_hdsp *s = (struct state_hdsp *)state; assert(s->magic == HDSP_MAGIC); pthread_mutex_lock(&s->lock); - if(s->work_to_do && nonblock == PUTF_NONBLOCK) { + if(s->work_to_do && flags == PUTF_NONBLOCK) { pthread_mutex_unlock(&s->lock); return EWOULDBLOCK; } diff --git a/src/video_display/gl.cpp b/src/video_display/gl.cpp index 20c8e8e76..047847323 100644 --- a/src/video_display/gl.cpp +++ b/src/video_display/gl.cpp @@ -1023,6 +1023,10 @@ int display_gl_putf(void *state, struct video_frame *frame, int nonblock) } std::unique_lock lk(s->lock); + if (nonblock == PUTF_DISCARD) { + s->free_frame_queue.push(frame); + return 0; + } if (s->frame_queue.size() >= MAX_BUFFER_SIZE && nonblock == PUTF_NONBLOCK) { s->free_frame_queue.push(frame); return 1; diff --git a/src/video_display/pipe.cpp b/src/video_display/pipe.cpp index 6036e61cd..eb5dcba0e 100644 --- a/src/video_display/pipe.cpp +++ b/src/video_display/pipe.cpp @@ -84,10 +84,11 @@ struct video_frame *display_pipe_getf(void *state) int display_pipe_putf(void *state, struct video_frame *frame, int flags) { - UNUSED(flags); struct state_pipe *s = (struct state_pipe *) state; - s->delegate->frame_arrived(frame); + if (flags != PUTF_DISCARD) { + s->delegate->frame_arrived(frame); + } return TRUE; } diff --git a/src/video_display/sdl.cpp b/src/video_display/sdl.cpp index 3db5d8987..df2a7f759 100644 --- a/src/video_display/sdl.cpp +++ b/src/video_display/sdl.cpp @@ -558,6 +558,11 @@ int display_sdl_putf(void *state, struct video_frame *frame, int nonblock) return 0; } + if (nonblock == PUTF_DISCARD) { + vf_free(frame); + return 0; + } + std::unique_lock lk(s->lock); if (s->frame_queue.size() >= MAX_BUFFER_SIZE && nonblock == PUTF_NONBLOCK) { vf_free(frame);