1From 32ca76a1002b7cd5772ff1e425e42e5e216705b9 Mon Sep 17 00:00:00 2001 2From: Jeffy Chen <jeffy.chen@rock-chips.com> 3Date: Wed, 22 Dec 2021 16:04:46 +0800 4Subject: [PATCH 27/41] waylandsink: Use the correct video info to access 5 allocated buffer 6 7The video info might changed after pool activated. 8 9Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> 10--- 11 ext/wayland/gstwaylandsink.c | 10 +++++----- 12 ext/wayland/gstwaylandsink.h | 1 + 13 2 files changed, 6 insertions(+), 5 deletions(-) 14 15diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c 16index b26b7ee..d75f2e4 100644 17--- a/ext/wayland/gstwaylandsink.c 18+++ b/ext/wayland/gstwaylandsink.c 19@@ -956,7 +956,6 @@ gst_wayland_sink_show_frame (GstVideoSink * vsink, GstBuffer * buffer) 20 GstVideoCropMeta *crop; 21 GstVideoMeta *vmeta; 22 GstVideoFormat format; 23- GstVideoInfo old_vinfo; 24 GstMemory *mem; 25 struct wl_buffer *wbuf = NULL; 26 27@@ -1023,7 +1022,6 @@ gst_wayland_sink_show_frame (GstVideoSink * vsink, GstBuffer * buffer) 28 /* update video info from video meta */ 29 mem = gst_buffer_peek_memory (buffer, 0); 30 31- old_vinfo = self->video_info; 32 vmeta = gst_buffer_get_video_meta (buffer); 33 if (vmeta) { 34 gint i; 35@@ -1065,9 +1063,6 @@ gst_wayland_sink_show_frame (GstVideoSink * vsink, GstBuffer * buffer) 36 GstVideoFrame src, dst; 37 GstVideoInfo src_info = self->video_info; 38 39- /* rollback video info changes */ 40- self->video_info = old_vinfo; 41- 42 /* we don't know how to create a wl_buffer directly from the provided 43 * memory, so we have to copy the data to shm memory that we know how 44 * to handle... */ 45@@ -1094,8 +1089,13 @@ gst_wayland_sink_show_frame (GstVideoSink * vsink, GstBuffer * buffer) 46 if (!gst_buffer_pool_set_config (self->pool, config) || 47 !gst_buffer_pool_set_active (self->pool, TRUE)) 48 goto activate_failed; 49+ 50+ self->pool_vinfo = self->video_info; 51 } 52 53+ /* rollback video info changes */ 54+ self->video_info = self->pool_vinfo; 55+ 56 ret = gst_buffer_pool_acquire_buffer (self->pool, &to_render, NULL); 57 if (ret != GST_FLOW_OK) 58 goto no_buffer; 59diff --git a/ext/wayland/gstwaylandsink.h b/ext/wayland/gstwaylandsink.h 60index 6211fd6..de11859 100644 61--- a/ext/wayland/gstwaylandsink.h 62+++ b/ext/wayland/gstwaylandsink.h 63@@ -56,6 +56,7 @@ struct _GstWaylandSink 64 65 gboolean video_info_changed; 66 GstVideoInfo video_info; 67+ GstVideoInfo pool_vinfo; 68 gboolean fullscreen; 69 GstWlWindowLayer layer; 70 gdouble alpha; 71-- 722.20.1 73 74