From 1b21c1b15b834fbbbd478b914095e6f90d19b211 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Tue, 9 Feb 2021 14:44:02 -0500 Subject: [PATCH] v4l2: Subscribe source_change for the current input When we subscribe for source-change event, we need to specify for which input. Make sure we subscribe for the current input. Part-of: --- sys/v4l2/gstv4l2bufferpool.c | 7 ++++++- sys/v4l2/gstv4l2object.h | 2 +- sys/v4l2/v4l2_calls.c | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c index 8d24819026..164346ef79 100644 --- a/sys/v4l2/gstv4l2bufferpool.c +++ b/sys/v4l2/gstv4l2bufferpool.c @@ -2201,8 +2201,13 @@ gst_v4l2_buffer_pool_flush (GstBufferPool * bpool) void gst_v4l2_buffer_pool_enable_resolution_change (GstV4l2BufferPool * pool) { + guint32 input_id = 0; + g_return_if_fail (!gst_buffer_pool_is_active (GST_BUFFER_POOL (pool))); - if (gst_v4l2_subscribe_event (pool->obj, V4L2_EVENT_SOURCE_CHANGE)) + /* Make sure we subscribe for the current input */ + gst_v4l2_get_input (pool->obj, &input_id); + + if (gst_v4l2_subscribe_event (pool->obj, V4L2_EVENT_SOURCE_CHANGE, input_id)) gst_poll_fd_ctl_pri (pool->poll, &pool->pollfd, TRUE); } diff --git a/sys/v4l2/gstv4l2object.h b/sys/v4l2/gstv4l2object.h index aab2fb2304..ee62ab8eb8 100644 --- a/sys/v4l2/gstv4l2object.h +++ b/sys/v4l2/gstv4l2object.h @@ -343,7 +343,7 @@ gboolean gst_v4l2_set_string_attribute (GstV4l2Object * v4l2object, int attr gboolean gst_v4l2_set_controls (GstV4l2Object * v4l2object, GstStructure * controls); /* events */ -gboolean gst_v4l2_subscribe_event (GstV4l2Object * v4l2object, guint32 event); +gboolean gst_v4l2_subscribe_event (GstV4l2Object * v4l2object, guint32 event, guint32 id); gboolean gst_v4l2_dequeue_event (GstV4l2Object * v4l2object, struct v4l2_event *event); G_END_DECLS diff --git a/sys/v4l2/v4l2_calls.c b/sys/v4l2/v4l2_calls.c index 1ade2d0f6d..dce8e33dcc 100644 --- a/sys/v4l2/v4l2_calls.c +++ b/sys/v4l2/v4l2_calls.c @@ -1237,9 +1237,9 @@ gst_v4l2_event_to_string (guint32 event) } gboolean -gst_v4l2_subscribe_event (GstV4l2Object * v4l2object, guint32 event) +gst_v4l2_subscribe_event (GstV4l2Object * v4l2object, guint32 event, guint32 id) { - struct v4l2_event_subscription sub = {.type = event, }; + struct v4l2_event_subscription sub = {.type = event,.id = id, }; gint ret; GST_DEBUG_OBJECT (v4l2object->dbg_obj, "Subscribing to '%s' event",