From 4d9897c5aa5376f89e0d5ed1534536f680939e0d Mon Sep 17 00:00:00 2001 From: Daniel Scally Date: Tue, 10 Jan 2023 11:58:04 +0000 Subject: lib: Add video_source_type enumeration Add an enum to struct video_source that details the type of source we're dealing with. This will be used to make decisions about buffer allocation and handling in a more explicit way. Use the video_source_type associated with a video_source to decide on the appropriate allocation function and buffer handler at stream on time. This is a more explicit method than relying on the presence of the .alloc_buffers op and allows more flexibility. Reviewed-by: Kieran Bingham Signed-off-by: Daniel Scally --- lib/stream.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'lib/stream.c') diff --git a/lib/stream.c b/lib/stream.c index 63ccb1b..4a562a5 100644 --- a/lib/stream.c +++ b/lib/stream.c @@ -7,6 +7,7 @@ * Contact: Laurent Pinchart */ +#include #include #include #include @@ -183,10 +184,19 @@ static int uvc_stream_start(struct uvc_stream *stream) { printf("Starting video stream.\n"); - if (stream->src->ops->alloc_buffers) + switch (stream->src->type) { + case VIDEO_SOURCE_DMABUF: + video_source_set_buffer_handler(stream->src, uvc_stream_source_process, + stream); return uvc_stream_start_alloc(stream); - else + case VIDEO_SOURCE_STATIC: return uvc_stream_start_no_alloc(stream); + default: + fprintf(stderr, "invalid video source type\n"); + break; + } + + return -EINVAL; } static int uvc_stream_stop(struct uvc_stream *stream) @@ -288,8 +298,4 @@ void uvc_stream_set_video_source(struct uvc_stream *stream, struct video_source *src) { stream->src = src; - - if (stream->src->ops->alloc_buffers) - video_source_set_buffer_handler(src, uvc_stream_source_process, - stream); } -- cgit v1.2.3