Fixed a problem than adds duplicate listener to wl_buffer. 53/263153/3
authorJoonbum Ko <joonbum.ko@samsung.com>
Fri, 27 Aug 2021 01:31:11 +0000 (10:31 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Fri, 27 Aug 2021 01:48:33 +0000 (10:48 +0900)
Change-Id: I0ab36d23602b9b3099b2057ea0701cf9a4540234
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/tpl_wl_egl_thread.c

index 12f6e3a..aae8adb 100755 (executable)
@@ -244,6 +244,8 @@ struct pst_feedback {
 };
 #endif
 
+static const struct wl_buffer_listener wl_buffer_release_listener;
+
 static int
 _get_tbm_surface_bo_name(tbm_surface_h tbm_surface);
 static void
@@ -2785,6 +2787,12 @@ _thread_surface_queue_acquire(tpl_wl_egl_surface_t *wl_egl_surface)
                                TPL_INFO("[WL_BUFFER_CREATE]",
                                                  "wl_egl_buffer(%p) wl_buffer(%p) tbm_surface(%p)",
                                                  wl_egl_buffer, wl_egl_buffer->wl_buffer, tbm_surface);
+                               if (!wl_egl_display->use_explicit_sync ||
+                                       !wl_egl_surface->surface_sync) {
+                                               wl_buffer_add_listener((struct wl_buffer *)wl_egl_buffer->wl_buffer,
+                                                                                          &wl_buffer_release_listener,
+                                                                                          wl_egl_buffer);
+                               }
                        }
                }
 
@@ -3173,6 +3181,17 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface,
                        (struct wl_proxy *)wayland_tbm_client_create_buffer(
                                                wl_egl_display->wl_tbm_client,
                                                wl_egl_buffer->tbm_surface);
+               TPL_INFO("[WL_BUFFER_CREATE]",
+                                "wl_egl_buffer(%p) wl_buffer(%p) tbm_surface(%p)",
+                                wl_egl_buffer, wl_egl_buffer->wl_buffer,
+                                wl_egl_buffer->tbm_surface);
+
+               if (!wl_egl_display->use_explicit_sync ||
+                       !wl_egl_surface->surface_sync) {
+                       wl_buffer_add_listener((struct wl_buffer *)wl_egl_buffer->wl_buffer,
+                                                                  &wl_buffer_release_listener,
+                                                                  wl_egl_buffer);
+               }
        }
        TPL_CHECK_ON_FALSE_ASSERT_FAIL(wl_egl_buffer->wl_buffer != NULL,
                                                                   "[FATAL] Failed to create wl_buffer");
@@ -3290,12 +3309,8 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface,
                                wl_egl_buffer->buffer_release, &zwp_release_listner, wl_egl_buffer);
                        TPL_DEBUG("add explicit_sync_release_listener.");
                }
-       } else
-#endif
-       {
-               wl_buffer_add_listener((void *)wl_egl_buffer->wl_buffer,
-                                                          &wl_buffer_release_listener, wl_egl_buffer);
        }
+#endif
 
        wl_surface_commit(wl_surface);