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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/870>
This commit is contained in:
Nicolas Dufresne 2021-02-09 14:44:02 -05:00
parent c386aa43cc
commit 1b21c1b15b
3 changed files with 9 additions and 4 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -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",