1. Fix issue hen an instance is destroyed and recreated
authorSejun Park <sejun79.park@samsung.com>
Thu, 16 Aug 2018 11:48:34 +0000 (20:48 +0900)
committerSejun Park <sejun79.park@samsung.com>
Mon, 20 Aug 2018 07:48:38 +0000 (16:48 +0900)
2. Remove warning messages

Change-Id: I9ba89a9db42547fe1a91020bde5000c3854d5e93

gst-libs/gst/allocators/gsttizenbufferpool.c
gst-libs/gst/allocators/gsttizenbufferpool.h
gst-libs/gst/allocators/gsttizenmemory.c
gst-libs/gst/allocators/gsttizenmemory.h

index 76db280..d643425 100644 (file)
@@ -23,6 +23,7 @@
 #endif
 
 #include "gsttizenbufferpool.h"
+#include <tbm_surface_internal.h>
 
 GST_DEBUG_CATEGORY_STATIC (gst_tizen_vidbufpool_debug);
 #define GST_CAT_DEFAULT gst_tizen_vidbufpool_debug
@@ -133,10 +134,10 @@ unknown_format:
 }
 
 static void
-_destroy_tbm_surface (struct UserPtrData *data)
+_destroy_tbm_surface (tbm_surface_h surface)
 {
-  GST_DEBUG ("destroy surface %p", data);
-  tbm_surface_internal_destroy ((tbm_surface_h)data);
+  GST_DEBUG ("destroy surface %p", surface);
+  tbm_surface_internal_destroy (surface);
 }
 
 /* This function handles GstBuffer creation */
@@ -148,7 +149,7 @@ gst_tizen_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
   GstVideoInfo *info;
   GstBuffer *buf;
   GstMemory *tizen_mem;
-  gint offsets[4] = {0, };
+  gsize offsets[4] = {0, };
 
   GST_DEBUG_OBJECT (pool, "gst_tizen_buffer_pool_alloc");
   info = &_tpool->info;
@@ -246,7 +247,7 @@ gst_tizen_buffer_pool_acquire_buffer (GstBufferPool * bpool, GstBuffer ** buffer
   return GST_FLOW_OK;
 }
 
-void
+static void
 gst_tizen_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer)
 {
   GstTizenBufferPool *_tpool = GST_TIZEN_BUFFER_POOL_CAST (bpool);
@@ -304,10 +305,15 @@ gst_tizen_buffer_pool_finalize (GObject * object)
   G_OBJECT_CLASS (gst_tizen_buffer_pool_parent_class)->finalize (object);
 }
 
-GstBufferPool *
-gst_tizen_buffer_pool_new ()
+static void
+gst_tizen_buffer_pool_init (GstTizenBufferPool * pool)
 {
-  return GST_BUFFER_POOL_CAST (g_object_new (GST_TYPE_TIZEN_BUFFER_POOL, NULL));
+  g_mutex_init (&pool->lock);
+  pool->priv = gst_tizen_buffer_pool_get_instance_private (pool);
+  pool->buffers = g_ptr_array_new ();
+  pool->allocator = gst_tizen_allocator_new ();
+  g_atomic_int_set(&pool->outstandings, 0);
+  GST_LOG_OBJECT (pool, "Tizen buffer pool init %p", pool);
 }
 
 static void
@@ -329,14 +335,8 @@ gst_tizen_buffer_pool_class_init (GstTizenBufferPoolClass * klass)
   gstbufferpool_class->release_buffer = gst_tizen_buffer_pool_release_buffer;
 }
 
-static void
-gst_tizen_buffer_pool_init (GstTizenBufferPool * pool)
+GstBufferPool *
+gst_tizen_buffer_pool_new (void)
 {
-  g_mutex_init (&pool->lock);
-  pool->priv = gst_tizen_buffer_pool_get_instance_private (pool);
-  pool->buffers = g_ptr_array_new ();
-  pool->allocator = gst_tizen_allocator_new ();
-  g_atomic_int_set(&pool->outstandings, 0);
-  GST_LOG_OBJECT (pool, "Tizen buffer pool init %p", pool);
+  return GST_BUFFER_POOL_CAST (g_object_new (GST_TYPE_TIZEN_BUFFER_POOL, NULL));
 }
-
index 709a7df..8fa5631 100644 (file)
@@ -74,7 +74,7 @@ struct _GstTizenBufferPoolClass
 };
 
 GType gst_tizen_buffer_pool_get_type (void);
-GstBufferPool *gst_tizen_buffer_pool_new ();
+GstBufferPool *gst_tizen_buffer_pool_new (void);
 
 
 G_END_DECLS
index fa6fefd..85ebe5b 100644 (file)
 #include "config.h"
 #endif
 
+#include "gstdmabuf.h"
 #include "gsttizenmemory.h"
 #include <tbm_surface_internal.h>
 
 #define GST_TIZEN_ALLOCATOR_NAME "TizenVideoMemory"
 
-
-static GstAllocator *_tizen_allocator;
-
 GST_DEBUG_CATEGORY_STATIC (gst_tizenmemory_debug);
 #define GST_CAT_DEFAULT gst_tizenmemory_debug
 
@@ -223,7 +221,6 @@ gst_tizen_allocator_class_init (GstTizenAllocatorClass * klass)
   allocator_class->free = gst_tizen_mem_free;
 
   object_class->finalize = gst_tizen_allocator_finalize;
-
 }
 
 static void
@@ -253,29 +250,24 @@ gst_tizen_allocator_init (GstTizenAllocator * allocator)
 GstAllocator *
 gst_tizen_allocator_new (void)
 {
-  static volatile gsize _init = 0;
-
-  if (g_once_init_enter (&_init)) {
-
-    _tizen_allocator = g_object_new (GST_TYPE_TIZEN_ALLOCATOR, NULL);
-        gst_allocator_register (GST_TIZEN_ALLOCATOR_NAME,
-    gst_object_ref (_tizen_allocator));
-    g_once_init_leave (&_init, 1);
-  }
-  return _tizen_allocator;
+  return g_object_new (GST_TYPE_TIZEN_ALLOCATOR, NULL);
 }
 
 GstMemory *
 gst_tizen_allocator_alloc (GstAllocator * allocator, GstVideoInfo * vinfo)
 {
-  return (GstMemory *)_tizen_video_mem_new (_tizen_allocator, NULL, vinfo, NULL, NULL, NULL);
+  g_return_val_if_fail (GST_IS_TIZEN_ALLOCATOR (allocator), NULL);
+
+  return (GstMemory *)_tizen_video_mem_new (allocator, NULL, vinfo, NULL, NULL, NULL);
 }
 
 GstMemory *
 gst_tizen_allocator_alloc_surface (GstAllocator * allocator, GstVideoInfo * vinfo,
     tbm_surface_h surface, gpointer user_data, GDestroyNotify notify)
 {
-  return (GstMemory *)_tizen_video_mem_new (_tizen_allocator, NULL, vinfo, surface, user_data, notify);
+  g_return_val_if_fail (GST_IS_TIZEN_ALLOCATOR (allocator), NULL);
+
+  return (GstMemory *)_tizen_video_mem_new (allocator, NULL, vinfo, surface, user_data, notify);
 }
 
 gboolean
@@ -291,8 +283,8 @@ gst_tizen_memory_get_num_bos (GstMemory *mem)
 {
   GstTizenMemory *tmem;
 
-  g_return_val_if_fail (mem != NULL, NULL);
-  g_return_val_if_fail (GST_IS_TIZEN_ALLOCATOR (mem->allocator), NULL);
+  g_return_val_if_fail (mem != NULL, -1);
+  g_return_val_if_fail (GST_IS_TIZEN_ALLOCATOR (mem->allocator), -1);
 
   tmem = (GstTizenMemory *)mem;
 
@@ -395,14 +387,12 @@ gst_tizen_video_memory_map (GstVideoMeta * meta, guint plane, GstMapInfo * info,
     gpointer * data, gint * stride, GstMapFlags flags)
 {
   gint err;
-  gint bo_idx;
   tbm_surface_info_s surface_info;
   GstBuffer *buffer = meta->buffer;
   GstTizenMemory *vmem =
       (GstTizenMemory *) gst_buffer_get_memory (buffer, 0);
 
-  g_return_val_if_fail (((GstMemory *) vmem)->allocator == _tizen_allocator,
-      FALSE);
+  g_return_val_if_fail (GST_IS_TIZEN_ALLOCATOR (((GstMemory *) vmem)->allocator), FALSE);
 
   err = tbm_surface_map (vmem->surface, TBM_SURF_OPTION_WRITE|TBM_SURF_OPTION_READ, &surface_info);
   if (err == TBM_SURFACE_ERROR_NONE) {
@@ -426,8 +416,7 @@ gst_tizen_video_memory_unmap (GstVideoMeta * meta, guint plane, GstMapInfo * inf
   GstTizenMemory *vmem =
       (GstTizenMemory *) gst_buffer_get_memory (buffer, 0);
 
-  g_return_val_if_fail (((GstMemory *) vmem)->allocator == _tizen_allocator,
-      FALSE);
+  g_return_val_if_fail (GST_IS_TIZEN_ALLOCATOR (((GstMemory *) vmem)->allocator), FALSE);
 
   tbm_surface_unmap (vmem->surface);
   GST_DEBUG ("_video_memory_unmap -> plane : %d", plane);
index c844fad..5f68b31 100644 (file)
@@ -103,6 +103,7 @@ void *          gst_tizen_memory_get_bos   (GstMemory *mem, gint index);
 void *          gst_tizen_memory_get_surface (GstMemory *mem);
 
 GstMemory *     gst_tizen_allocator_dmabuf_export (GstAllocator * allocator, GstMemory *tmem, int bo_idx);
+GstTizenMemory *gst_tizen_allocator_dambuf_import (GstAllocator * allocator, gint * fds, gint planes, gsize offsets[4], GstVideoInfo * vinfo);
 
 gboolean        gst_tizen_video_memory_map (GstVideoMeta * meta, guint plane, GstMapInfo * info,
                     gpointer * data, gint * stride, GstMapFlags flags);