1From 35d33587722cf44478632827bfb7049c003c4fef 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 26/33] 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 fe7e0e3..934464c 100644 17--- a/ext/wayland/gstwaylandsink.c 18+++ b/ext/wayland/gstwaylandsink.c 19@@ -917,7 +917,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@@ -991,7 +990,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 = sink->video_info; 32 vmeta = gst_buffer_get_video_meta (buffer); 33 if (vmeta) { 34 gint i; 35@@ -1032,9 +1030,6 @@ gst_wayland_sink_show_frame (GstVideoSink * vsink, GstBuffer * buffer) 36 GstVideoFrame src, dst; 37 GstVideoInfo src_info = sink->video_info; 38 39- /* rollback video info changes */ 40- sink->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@@ -1060,8 +1055,13 @@ gst_wayland_sink_show_frame (GstVideoSink * vsink, GstBuffer * buffer) 46 if (!gst_buffer_pool_set_config (sink->pool, config) || 47 !gst_buffer_pool_set_active (sink->pool, TRUE)) 48 goto activate_failed; 49+ 50+ sink->pool_vinfo = sink->video_info; 51 } 52 53+ /* rollback video info changes */ 54+ sink->video_info = sink->pool_vinfo; 55+ 56 ret = gst_buffer_pool_acquire_buffer (sink->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 1f70f76..4f517f8 100644 61--- a/ext/wayland/gstwaylandsink.h 62+++ b/ext/wayland/gstwaylandsink.h 63@@ -61,6 +61,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