waylandsink: failure when using waylandsink after tee when buffers are not copied
When displaying the same buffer on two waylandsink instances via tee, the gst-launch will fail in either one of two ways:
- assertion failure in wlbuffer.c that stops the whole process
wlbuffer.c:152:gstbuffer_disposed: assertion failed: (!self->used_by_compositor)
- a failure that shuts down one window, while the other one continues.
wl_display@1: error 1: invalid arguments for wl_surface@9.attach
This only happens when the GstBuffer content is not copied to wl_shm buffers in waylandsink.
I can reproduce this with input coming from v4l2src (using the vivid module) when io-mode=dmabuf
with the following command (the frame size of 640x480 makes it easier to see both windows on screen at the same time, but otherwise has no
effect):
gst-launch-1.0 v4l2src io-mode=dmabuf ! video/x-raw,width=640,height=480 ! tee name=t ! queue ! waylandsink t. ! queue ! waylandsink
When io-mode=mmap
, buffers are copied in waylandsink, and there is no problem.
It seems that an instance of GstWlBuffer is attached to each GstBuffer with gst_mini_object_set_qdata()
, in wlbuffer.c but since the same GstBuffer goes to both instances of waylandsink they overwrite each other, causing a conflict.
I wonder if its enough to attach one GstWlBuffer per waylandsink (using a different GQuark per waylandsink instance) or if some other method would be better.
I noticed that GstWlDisplay also seems to maintain a set (g_hash) of GstWlBuffer's, which could be converted to a hash table and used to look up the GstWlBuffer with the GstBuffer as the key, instead of the current set/get_qdata(), but maybe that introduces other problems.