From bbca6cc8c8125f53b74f7b9a5b7a559595f9cf89 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 25 Jul 2023 15:15:58 +0200 Subject: [PATCH] videoflip: fix concurrent access when modifying the tag list We were checking if the tag list is writable, but it may actually be shared through the same event (tee upstream or multiple consumers). Fix a bug where multiple branches have a videoflip element checking the taglist. The first one was changing the orientation back to rotate-0 which was resetting the other instances. Part-of: --- .../gst/videofilter/gstvideoflip.c | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/subprojects/gst-plugins-good/gst/videofilter/gstvideoflip.c b/subprojects/gst-plugins-good/gst/videofilter/gstvideoflip.c index bd7cbeb640..718ab45b86 100644 --- a/subprojects/gst-plugins-good/gst/videofilter/gstvideoflip.c +++ b/subprojects/gst-plugins-good/gst/videofilter/gstvideoflip.c @@ -1790,19 +1790,15 @@ gst_video_flip_sink_event (GstBaseTransform * trans, GstEvent * event) gst_video_flip_set_method (vf, method, TRUE); if (vf->method == GST_VIDEO_ORIENTATION_AUTO) { - /* update the orientation tag as we rotate the video accordingly */ - if (gst_tag_list_is_writable (taglist)) { - gst_tag_list_add (taglist, GST_TAG_MERGE_REPLACE, - "image-orientation", "rotate-0", NULL); - } else { - taglist = gst_tag_list_copy (taglist); - - gst_tag_list_add (taglist, GST_TAG_MERGE_REPLACE, - "image-orientation", "rotate-0", NULL); - - gst_event_unref (event); - event = gst_event_new_tag (taglist); - } + /* Update the orientation tag as we rotate the video accordingly. + * The event (and so the tag list) can be shared so always copy both. */ + taglist = gst_tag_list_copy (taglist); + + gst_tag_list_add (taglist, GST_TAG_MERGE_REPLACE, + "image-orientation", "rotate-0", NULL); + + gst_event_unref (event); + event = gst_event_new_tag (taglist); } } break; -- 2.34.1