waylandsink : fix bug about buffer ref count (TSAM-5929) 92/78792/1 accepted/tizen/common/20160707.171755 accepted/tizen/ivi/20160707.043601 accepted/tizen/mobile/20160707.043713 accepted/tizen/tv/20160707.043526 accepted/tizen/wearable/20160707.043623 submit/tizen/20160707.031448
authorHyunil <hyunil46.park@samsung.com>
Thu, 7 Jul 2016 01:55:53 +0000 (10:55 +0900)
committerHyunil <hyunil46.park@samsung.com>
Thu, 7 Jul 2016 01:55:53 +0000 (10:55 +0900)
Change-Id: Idc225b5d93795e5476dca50607e1685cfe6e1303
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
ext/wayland/gstwaylandsink.c
ext/wayland/wlbuffer.c

index d8b5d59..757d4fc 100755 (executable)
@@ -394,21 +394,29 @@ gst_wayland_sink_update_last_buffer_geometry (GstWaylandSink * sink)
   FUNCTION;
   g_return_if_fail (sink != NULL);
   g_return_if_fail (sink->last_buffer != NULL);
-
-  GST_DEBUG ("gstbuffer ref count is %d",
-      GST_OBJECT_REFCOUNT_VALUE (sink->last_buffer));
   wlbuffer = gst_buffer_get_wl_buffer (sink->last_buffer);
   g_return_if_fail (wlbuffer != NULL);
   wlbuffer->used_by_compositor = FALSE;
-  /*need to render last buffer, reuse current GstWlBuffer */
-  render_last_buffer (sink);
-  /* ref count is incresed in gst_wl_buffer_attach() of render_last_buffer(),
-     to call gst_wl_buffer_finalize(), we need to decrease buffer ref count.
-     wayland can not release buffer if we attach same buffer,
-     if we use no visible, we need to attach null buffer and wayland can release buffer,
-     so we don't need to below if() code. */
-  if (!sink->visible)
+
+  GST_LOG ("gstbuffer(%p) ref count(%d)", sink->last_buffer,
+      GST_OBJECT_REFCOUNT_VALUE (sink->last_buffer));
+
+  if (sink->visible) {
+    /*need to render last buffer, reuse current GstWlBuffer */
+    render_last_buffer (sink);
+    /* ref count is incresed in gst_wl_buffer_attach() of render_last_buffer(),
+       to call gst_wl_buffer_finalize(), we need to decrease buffer ref count.
+       wayland can not release buffer if we attach same buffer,
+       if we use no visible, we need to attach null buffer and wayland can release buffer,
+       so we don't need to below if() code. */
     gst_buffer_unref (wlbuffer->gstbuffer);
+  } else {
+    GST_LOG ("skip rendering");
+  }
+
+  GST_LOG ("gstbuffer(%p) ref count(%d)", sink->last_buffer,
+      GST_OBJECT_REFCOUNT_VALUE (sink->last_buffer));
+
 }
 
 #ifdef USE_WL_FLUSH_BUFFER
@@ -1366,7 +1374,7 @@ render_last_buffer (GstWaylandSink * sink)
 
   if (G_UNLIKELY (sink->video_info_changed)) {
 #ifdef GST_WLSINK_ENHANCEMENT
-      gst_wl_window_set_video_info_change (sink->window, TRUE);
+    gst_wl_window_set_video_info_change (sink->window, TRUE);
 #endif
     info = &sink->video_info;
     sink->video_info_changed = FALSE;
@@ -1385,7 +1393,8 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer)
 
   g_mutex_lock (&sink->render_lock);
 
-  GST_LOG_OBJECT (sink, "render buffer %p", buffer);
+  GST_LOG_OBJECT (sink, "render gstbuffer %p, ref_count(%d)", buffer,
+      GST_OBJECT_REFCOUNT_VALUE (buffer));
 
   if (G_UNLIKELY (!sink->window)) {
     /* ask for window handle. Unlock render_lock while doing that because
@@ -1553,8 +1562,11 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer)
     }
     gst_buffer_replace (&sink->last_buffer, buffer);
 
-    if (sink->visible)
+    if (sink->visible) {
       render_last_buffer (sink);
+    } else {
+      GST_LOG ("skip rendering");
+    }
 
     goto done;
 
index 6907430..a57a1d8 100644 (file)
@@ -91,7 +91,7 @@ gst_wl_buffer_dispose (GObject * gobject)
 {
   GstWlBuffer *self = GST_WL_BUFFER (gobject);
   FUNCTION;
-  GST_INFO ("%p", self);
+  GST_INFO ("GstWlBuffer:%p", self);
   GST_TRACE_OBJECT (self, "dispose");
 
   /* if the display is shutting down and we are trying to dipose
@@ -114,13 +114,15 @@ gst_wl_buffer_finalize (GObject * gobject)
 
   GST_TRACE_OBJECT (self, "finalize");
 #ifdef GST_WLSINK_ENHANCEMENT
-  if (self->tsurface)
+  if (self->tsurface) {
+    GST_INFO ("self->tsurface:%p", self->tsurface);
     tbm_surface_destroy (self->tsurface);
+  }
 #endif
-  GST_INFO ("%p", self->wlbuffer);
-  if (self->wlbuffer)
+  if (self->wlbuffer) {
+    GST_INFO ("self->wl_buffer:%p", self->wlbuffer);
     wl_buffer_destroy (self->wlbuffer);
-
+  }
 #ifdef USE_WL_FLUSH_BUFFER
   if (self->display) {
     if (self->is_flush_request) {
@@ -160,8 +162,11 @@ buffer_release (void *data, struct wl_buffer *wl_buffer)
 {
   GstWlBuffer *self = data;
   FUNCTION;
-  GST_LOG_OBJECT (self, "wl_buffer(%p)::release (GstBuffer: %p)", wl_buffer,
-      self->gstbuffer);
+  g_return_if_fail (self != NULL);
+
+  GST_LOG_OBJECT (self,
+      "get event : wl_buffer(%p)::release (GstBuffer: %p):: tsurface(%p)",
+      wl_buffer, self->gstbuffer, self->tsurface);
 
   self->used_by_compositor = FALSE;
 
@@ -169,7 +174,13 @@ buffer_release (void *data, struct wl_buffer *wl_buffer)
   /* unref should be last, because it may end up destroying the GstWlBuffer */
   if (!self->is_flush_request) {
     /*in case of is_flush_request, gstbuffer ref-count has already decreased. */
+    GST_LOG_OBJECT (self, "gstbuffer(%p), ref_count(%d)", self->gstbuffer,
+        GST_OBJECT_REFCOUNT_VALUE (self->gstbuffer));
     gst_buffer_unref (self->gstbuffer);
+    if (self->gstbuffer) {
+      GST_ERROR_OBJECT (self, "gstbuffer(%p), ref_count(%d)", self->gstbuffer,
+          GST_OBJECT_REFCOUNT_VALUE (self->gstbuffer));
+    }
   } else {
     /*we blocked below code at gstbuffer_disposed() */
     /* unref(GstWlBuffer), now gst_wl_buffer_dispose() will be called by below code */
@@ -189,7 +200,7 @@ gstbuffer_disposed (GstWlBuffer * self)
 {
   FUNCTION;
   g_assert (!self->used_by_compositor);
-  GST_INFO ("%p", self->gstbuffer);
+  GST_INFO ("GstBuffer: %p", self->gstbuffer);
   self->gstbuffer = NULL;
 
   GST_TRACE_OBJECT (self, "owning GstBuffer was finalized");
@@ -301,6 +312,7 @@ gst_wl_buffer_attach (GstWlBuffer * self, struct wl_surface *surface)
   if (!self->is_flush_request)
 #endif
     gst_buffer_ref (self->gstbuffer);
-
+  GST_LOG_OBJECT (self, "gstbuffer(%p), ref_count(%d)", self->gstbuffer,
+      GST_OBJECT_REFCOUNT_VALUE (self->gstbuffer));
   self->used_by_compositor = TRUE;
 }