From 3b1abffa2d9f0cf3cc5ca812dc5a3cb49eeb701e Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 2 Sep 2019 13:23:32 +0100 Subject: [PATCH] xrt: Refactor frameserver start stream arguments --- src/xrt/drivers/v4l2/v4l2_driver.c | 10 +++++----- src/xrt/drivers/v4l2/v4l2_interface.h | 4 +--- src/xrt/include/xrt/xrt_frameserver.h | 10 +++++++--- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/xrt/drivers/v4l2/v4l2_driver.c b/src/xrt/drivers/v4l2/v4l2_driver.c index 6b92e03d4..a123a2b47 100644 --- a/src/xrt/drivers/v4l2/v4l2_driver.c +++ b/src/xrt/drivers/v4l2/v4l2_driver.c @@ -572,7 +572,9 @@ v4l2_fs_configure_capture(struct xrt_fs *xfs, } static bool -v4l2_fs_stream_start(struct xrt_fs *xfs, uint32_t descriptor_index) +v4l2_fs_stream_start(struct xrt_fs *xfs, + struct xrt_frame_sink *xs, + uint32_t descriptor_index) { struct v4l2_fs *vid = v4l2_fs(xfs); @@ -583,6 +585,7 @@ v4l2_fs_stream_start(struct xrt_fs *xfs, uint32_t descriptor_index) } vid->selected = descriptor_index; + vid->sink = xs; vid->is_running = true; if (pthread_create(&vid->stream_thread, NULL, v4l2_fs_stream_run, xfs)) { @@ -667,9 +670,7 @@ v4l2_fs_node_destroy(struct xrt_frame_node *node) } struct xrt_fs * -v4l2_fs_create(struct xrt_frame_context *xfctx, - const char *path, - struct xrt_frame_sink *sink) +v4l2_fs_create(struct xrt_frame_context *xfctx, const char *path) { struct v4l2_fs *vid = U_TYPED_CALLOC(struct v4l2_fs); vid->base.enumerate_modes = v4l2_fs_enumerate_modes; @@ -681,7 +682,6 @@ v4l2_fs_create(struct xrt_frame_context *xfctx, vid->node.destroy = v4l2_fs_node_destroy; vid->print_spew = debug_get_bool_option_v4l2_spew(); vid->print_debug = debug_get_bool_option_v4l2_debug(); - vid->sink = sink; vid->fd = -1; int fd = open(path, O_RDWR, 0); diff --git a/src/xrt/drivers/v4l2/v4l2_interface.h b/src/xrt/drivers/v4l2/v4l2_interface.h index 5503ab747..e39da96c4 100644 --- a/src/xrt/drivers/v4l2/v4l2_interface.h +++ b/src/xrt/drivers/v4l2/v4l2_interface.h @@ -63,9 +63,7 @@ struct v4l2_source_descriptor * @ingroup drv_v4l2 */ struct xrt_fs * -v4l2_fs_create(struct xrt_frame_context *xfctx, - const char *path, - struct xrt_frame_sink *sink); +v4l2_fs_create(struct xrt_frame_context *xfctx, const char *path); #ifdef __cplusplus diff --git a/src/xrt/include/xrt/xrt_frameserver.h b/src/xrt/include/xrt/xrt_frameserver.h index dcd3d42e2..d48944a9f 100644 --- a/src/xrt/include/xrt/xrt_frameserver.h +++ b/src/xrt/include/xrt/xrt_frameserver.h @@ -72,7 +72,9 @@ struct xrt_fs /*! * Start the capture stream. */ - bool (*stream_start)(struct xrt_fs *xfs, uint32_t descriptor_index); + bool (*stream_start)(struct xrt_fs *xfs, + struct xrt_frame_sink *xs, + uint32_t descriptor_index); /*! * Stop the capture stream. @@ -123,9 +125,11 @@ xrt_fs_configure_capture(struct xrt_fs *xfs, * @ingroup xrt_iface */ static inline XRT_MAYBE_UNUSED bool -xrt_fs_stream_start(struct xrt_fs *xfs, uint32_t descriptor_index) +xrt_fs_stream_start(struct xrt_fs *xfs, + struct xrt_frame_sink *xs, + uint32_t descriptor_index) { - return xfs->stream_start(xfs, descriptor_index); + return xfs->stream_start(xfs, xs, descriptor_index); } /*!