Waylandsink : release last wl_buffer 59/44659/2 accepted/tizen/mobile/20150727.093222 accepted/tizen/tv/20150727.093233 accepted/tizen/wearable/20150727.093253 submit/tizen/20150727.070750
authorHyunil Park <hyunil46.park@samsung.com>
Fri, 24 Jul 2015 10:07:12 +0000 (19:07 +0900)
committerHyunil Park <hyunil46.park@samsung.com>
Fri, 24 Jul 2015 10:12:51 +0000 (19:12 +0900)
Change-Id: I0638cf3e6651096a873ad1cdb3fdeadd3199e9d6
Signed-off-by: Hyunil Park <hyunil46.park@samsung.com>
ext/wayland/gstwaylandsink.c
ext/wayland/waylandpool.c
ext/wayland/wldisplay.c
packaging/gst-plugins-bad.spec

index 7afde44..0055c76 100755 (executable)
@@ -395,13 +395,10 @@ gst_wayland_sink_change_state (GstElement * element, GstStateChange transition)
          * unref the pool and therefore the display, which will try to
          * stop the thread from within itself and cause a deadlock.
          */
-#ifdef GST_WLSINK_ENHANCEMENT
-        if (sink->pool && !sink->display->is_native_format)
-#else
-        if (sink->pool)
-#endif
+        if (sink->pool) {
           gst_wayland_compositor_release_all_buffers (GST_WAYLAND_BUFFER_POOL
               (sink->pool));
+        }
         g_clear_object (&sink->display);
         g_clear_object (&sink->pool);
       }
@@ -886,8 +883,6 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer)
       if (ret != GST_FLOW_OK)
         goto no_buffer;
 
-
-
     } else {
       /*in case of normal video format and pool is not our pool */
 
@@ -926,8 +921,10 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer)
   gst_buffer_replace (&sink->last_buffer, to_render);
   render_last_buffer (sink);
 
-  if (buffer != to_render)
+  if (buffer != to_render) {
+    GST_LOG_OBJECT (sink, "Decrease ref count of buffer");
     gst_buffer_unref (to_render);
+ }
   goto done;
 
 no_window_size:
index bf7aaaf..9e2b73a 100755 (executable)
@@ -63,6 +63,11 @@ gst_wl_meta_api_get_type (void)
 static void
 gst_wl_meta_free (GstWlMeta * meta, GstBuffer * buffer)
 {
+#ifdef GST_WLSINK_ENHANCEMENT
+  if (!meta || !meta->pool)
+    return;
+  g_hash_table_remove (meta->pool->buffers_map, meta->wbuffer);
+#endif
   GST_DEBUG ("destroying wl_buffer %p", meta->wbuffer);
   wl_buffer_destroy (meta->wbuffer);
 }
@@ -117,7 +122,6 @@ gst_wayland_buffer_pool_class_init (GstWaylandBufferPoolClass * klass)
 #ifdef GST_WLSINK_ENHANCEMENT
   gobject_class->finalize = gst_wayland_tizen_buffer_pool_finalize;
   gstbufferpool_class->start = gst_wayland_tizen_buffer_pool_start;
-  gstbufferpool_class->stop = gst_wayland_tizen_buffer_pool_stop;
   gstbufferpool_class->alloc_buffer = gst_wayland_tizen_buffer_pool_alloc;
 #else
   gobject_class->finalize = gst_wayland_buffer_pool_finalize;
@@ -174,9 +178,9 @@ buffer_release (void *data, struct wl_buffer *wl_buffer)
     if (meta->used_by_compositor) {
       meta->used_by_compositor = FALSE;
       /* unlock before unref because stop() may be called from here */
-      g_mutex_unlock (&self->buffers_map_mutex);
-         GST_ERROR("gst_buffer_unref");
+      GST_LOG_OBJECT (self, "Decrease ref count of buffer");
       gst_buffer_unref (buffer);
+      g_mutex_unlock (&self->buffers_map_mutex);
       return;
     }
   }
@@ -201,6 +205,7 @@ gst_wayland_compositor_acquire_buffer (GstWaylandBufferPool * self,
   g_return_if_fail (meta->used_by_compositor == FALSE);
 
   meta->used_by_compositor = TRUE;
+  GST_LOG_OBJECT(self, "Increase ref count of buffer");
   gst_buffer_ref (buffer);
 }
 
@@ -213,7 +218,8 @@ unref_used_buffers (gpointer key, gpointer value, gpointer data)
   GstWlMeta *meta = gst_buffer_get_wl_meta (buffer);
   GList **to_unref = data;
 
-  g_return_if_fail (meta != NULL);
+  if (meta == NULL)
+    return;
 
   if (meta->used_by_compositor) {
     meta->used_by_compositor = FALSE;
@@ -230,12 +236,11 @@ gst_wayland_compositor_release_all_buffers (GstWaylandBufferPool * self)
 
   g_mutex_lock (&self->buffers_map_mutex);
   g_hash_table_foreach (self->buffers_map, unref_used_buffers, &to_unref);
-  g_mutex_unlock (&self->buffers_map_mutex);
 
-  /* unref without the lock because stop() may be called from here */
   if (to_unref) {
     g_list_free_full (to_unref, (GDestroyNotify) gst_buffer_unref);
   }
+  g_mutex_unlock (&self->buffers_map_mutex);
 }
 
 static gboolean
@@ -505,6 +510,9 @@ gst_wayland_tizen_buffer_pool_stop (GstBufferPool * pool)
   self->size = 0;
   self->used = 0;
 
+  tizen_buffer_pool_destroy (self->display->tizen_buffer_pool);
+  self->display->tizen_buffer_pool = NULL;
+
   /* all buffers are about to be destroyed;
    * we should no longer do anything with them */
   g_mutex_lock (&self->buffers_map_mutex);
index 1787dd8..5295aed 100755 (executable)
@@ -192,10 +192,6 @@ gst_wl_display_finalize (GObject * gobject)
 #ifdef GST_WLSINK_ENHANCEMENT
   if (self->tizen_policy)
     tizen_policy_destroy (self->tizen_policy);
-  if (self->tizen_buffer_pool) {
-    tizen_buffer_pool_destroy (self->tizen_buffer_pool);
-    self->tizen_buffer_pool = NULL;
-  }
   if (self->device_name)
     free (self->device_name);
   if (self->drm_fd >= 0)
index 141ef54..739afc6 100644 (file)
@@ -4,7 +4,7 @@
 
 Name:           gst-plugins-bad
 Version:        1.4.1
-Release:        5
+Release:        6
 Summary:        GStreamer Streaming-Media Framework Plug-Ins
 License:        GPL-2.0+ and LGPL-2.1+
 Group:          Multimedia/Framework