base: make GstQueueArray private to coreelements for now
authorTim-Philipp Müller <tim@centricular.net>
Sat, 14 Jul 2012 18:24:57 +0000 (19:24 +0100)
committerTim-Philipp Müller <tim@centricular.net>
Sat, 14 Jul 2012 18:36:02 +0000 (19:36 +0100)
Keep it private until we have a reason to make it public.

libs/gst/base/Makefile.am
libs/gst/base/gstqueuearray.c [deleted file]
libs/gst/base/gstqueuearray.h [deleted file]
plugins/elements/Makefile.am
plugins/elements/gstdataqueue.h
plugins/elements/gstqueue.h
plugins/elements/gstqueuearray.c [new file with mode: 0644]
plugins/elements/gstqueuearray.h [new file with mode: 0644]
tests/check/libs/queuearray.c
win32/common/libgstbase.def

index 3dbbb92387f648d2b45cc15b390079f4686e8515..069f96bddfe89b31d1f847f581df0f0fad548041 100644 (file)
@@ -13,8 +13,7 @@ libgstbase_@GST_API_VERSION@_la_SOURCES = \
        gstbytewriter.c         \
        gstcollectpads.c        \
        gstpushsrc.c            \
-       gsttypefindhelper.c     \
-       gstqueuearray.c
+       gsttypefindhelper.c
 
 libgstbase_@GST_API_VERSION@_la_CFLAGS = $(GST_OBJ_CFLAGS)
 libgstbase_@GST_API_VERSION@_la_LIBADD = $(GST_OBJ_LIBS)
@@ -34,8 +33,7 @@ libgstbase_@GST_API_VERSION@include_HEADERS = \
        gstbytewriter.h         \
        gstcollectpads.h        \
        gstpushsrc.h            \
-       gsttypefindhelper.h     \
-       gstqueuearray.h
+       gsttypefindhelper.h
 
 noinst_HEADERS = \
        gstbytereader-docs.h \
diff --git a/libs/gst/base/gstqueuearray.c b/libs/gst/base/gstqueuearray.c
deleted file mode 100644 (file)
index 9e2ed54..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/* GStreamer
- * Copyright (C) 2009 Edward Hervey <bilboed@bilboed.com>
- *
- * gstqueuearray.c:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <string.h>
-#include <gst/gst.h>
-#include "gstqueuearray.h"
-
-GstQueueArray *
-gst_queue_array_new (guint initial_size)
-{
-  GstQueueArray *array = g_malloc (sizeof (GstQueueArray));
-
-  array->size = initial_size;
-  array->array = g_new0 (gpointer, initial_size);
-  array->head = 0;
-  array->tail = 0;
-  array->length = 0;
-
-  return array;
-}
-
-gpointer
-gst_queue_array_pop_head (GstQueueArray * array)
-{
-  gpointer ret;
-
-  /* empty array */
-  if (G_UNLIKELY (array->length == 0))
-    return NULL;
-  ret = array->array[array->head];
-  array->head++;
-  array->head %= array->size;
-  array->length--;
-  return ret;
-}
-
-void
-gst_queue_array_push_tail (GstQueueArray * array, gpointer data)
-{
-  /* Check if we need to make room */
-  if (G_UNLIKELY (array->length == array->size)) {
-    /* newsize is 50% bigger */
-    guint newsize = (3 * array->size) / 2;
-
-    /* copy over data */
-    if (array->tail != 0) {
-      gpointer *array2 = g_new0 (gpointer, newsize);
-      guint t1 = array->head;
-      guint t2 = array->size - array->head;
-
-      /* [0-----TAIL][HEAD------SIZE]
-       *
-       * We want to end up with
-       * [HEAD------------------TAIL][----FREEDATA------NEWSIZE]
-       *
-       * 1) move [HEAD-----SIZE] part to beginning of new array
-       * 2) move [0-------TAIL] part new array, after previous part
-       */
-
-      memcpy (array2, &array->array[array->head], t2 * sizeof (gpointer));
-      memcpy (&array2[t2], array->array, t1 * sizeof (gpointer));
-
-      g_free (array->array);
-      array->array = array2;
-      array->head = 0;
-    } else {
-      /* Fast path, we just need to grow the array */
-      array->array = g_renew (gpointer, array->array, newsize);
-    }
-    array->tail = array->size;
-    array->size = newsize;
-  }
-
-  array->array[array->tail] = data;
-  array->tail++;
-  array->tail %= array->size;
-  array->length++;
-}
-
-gboolean
-gst_queue_array_is_empty (GstQueueArray * array)
-{
-  return (array->length == 0);
-}
-
-void
-gst_queue_array_free (GstQueueArray * array)
-{
-  g_free (array->array);
-  g_free (array);
-}
-
-void
-gst_queue_array_drop_element (GstQueueArray * array, guint idx)
-{
-  if (idx == array->head) {
-    /* just move the head */
-    array->head++;
-    array->head %= array->size;
-    return;
-  }
-  if (idx == array->tail - 1) {
-    /* just move the tail */
-    array->tail = (array->tail - 1 + array->size) % array->size;
-    return;
-  }
-  /* drop the element #idx... and readjust the array */
-  if (array->head < array->tail) {
-    /* Make sure it's within the boundaries */
-    g_assert (array->head < idx && idx <= array->tail);
-    /* ends not wrapped */
-    /* move head-idx to head+1 */
-    memcpy (&array->array[array->head + 1],
-        &array->array[array->head], (idx - array->head) * sizeof (gpointer));
-    array->tail--;
-  } else {
-    /* ends are wrapped */
-    if (idx < array->tail) {
-      /* move idx-tail backwards one */
-      memcpy (&array->array[idx - 1],
-          &array->array[idx], (array->tail - idx) * sizeof (gpointer));
-      array->tail--;
-    } else if (idx >= array->head) {
-      /* move head-idx forwards one */
-      memcpy (&array->array[array->head],
-          &array->array[array->head + 1],
-          (idx - array->head) * sizeof (gpointer));
-      array->head++;
-    } else
-      g_assert_not_reached ();
-  }
-}
-
-guint
-gst_queue_array_find (GstQueueArray * array, GCompareFunc func, gpointer data)
-{
-  guint i;
-
-  /* Scan from head to tail */
-  for (i = array->head; i < array->length; i = (i + 1) % array->size)
-    if (func (array->array[i], data) == 0)
-      return i;
-  return -1;
-}
diff --git a/libs/gst/base/gstqueuearray.h b/libs/gst/base/gstqueuearray.h
deleted file mode 100644 (file)
index 0c79540..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/* GStreamer
- * Copyright (C) 2009-2010 Edward Hervey <bilboed@bilboed.com>
- *
- * gstqueuearray.h:
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <glib.h>
-
-#ifndef __GST_QUEUE_ARRAY_H__
-#define __GST_QUEUE_ARRAY_H__
-
-typedef struct _GstQueueArray GstQueueArray;
-
-struct _GstQueueArray
-{
-  gpointer *array;
-  guint size;
-  guint head;
-  guint tail;
-  guint length;
-};
-
-GstQueueArray *gst_queue_array_new (guint initial_size);
-gpointer gst_queue_array_pop_head (GstQueueArray * array);
-void gst_queue_array_push_tail (GstQueueArray * array, gpointer data);
-gboolean gst_queue_array_is_empty (GstQueueArray * array);
-void gst_queue_array_free (GstQueueArray * array);
-
-void gst_queue_array_drop_element (GstQueueArray * array, guint idx);
-guint gst_queue_array_find (GstQueueArray * array, GCompareFunc func,
-    gpointer data);
-
-#endif
index d451a1f30d509f5e1fcb8f8d5fa429bb4cfae58d..5e0230c6bb73b279fb7ada0c19f8e0dc6b7dfbc3 100644 (file)
@@ -17,6 +17,7 @@ libgstcoreelements_la_SOURCES =       \
        gstoutputselector.c     \
        gstdataqueue.c          \
        gstmultiqueue.c         \
+       gstqueuearray.c \
        gstqueue.c              \
        gstqueue2.c             \
        gsttee.c                \
@@ -44,6 +45,7 @@ noinst_HEADERS =              \
        gstoutputselector.h     \
        gstdataqueue.h          \
        gstmultiqueue.h         \
+       gstqueuearray.h \
        gstqueue.h              \
        gstqueue2.h             \
        gsttee.h                \
index cc00a49ff2a6d640d451954f1e8f04c5cc94962a..2921a32939d001512bd17d94aa974509bdc5d16e 100644 (file)
@@ -24,7 +24,7 @@
 #define __GST_DATA_QUEUE_H__
 
 #include <gst/gst.h>
-#include <gst/base/gstqueuearray.h>
+#include "gstqueuearray.h"
 
 G_BEGIN_DECLS
 #define GST_TYPE_DATA_QUEUE \
index 552a1287b858bd3f9a62becf60b44a7c6cf351e7..e959f42ccaf0eb5b67b01cffebd08a74fc9b2238 100644 (file)
@@ -25,7 +25,7 @@
 #define __GST_QUEUE_H__
 
 #include <gst/gst.h>
-#include <gst/base/gstqueuearray.h>
+#include "gstqueuearray.h"
 
 G_BEGIN_DECLS
 
diff --git a/plugins/elements/gstqueuearray.c b/plugins/elements/gstqueuearray.c
new file mode 100644 (file)
index 0000000..9e2ed54
--- /dev/null
@@ -0,0 +1,162 @@
+/* GStreamer
+ * Copyright (C) 2009 Edward Hervey <bilboed@bilboed.com>
+ *
+ * gstqueuearray.c:
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <string.h>
+#include <gst/gst.h>
+#include "gstqueuearray.h"
+
+GstQueueArray *
+gst_queue_array_new (guint initial_size)
+{
+  GstQueueArray *array = g_malloc (sizeof (GstQueueArray));
+
+  array->size = initial_size;
+  array->array = g_new0 (gpointer, initial_size);
+  array->head = 0;
+  array->tail = 0;
+  array->length = 0;
+
+  return array;
+}
+
+gpointer
+gst_queue_array_pop_head (GstQueueArray * array)
+{
+  gpointer ret;
+
+  /* empty array */
+  if (G_UNLIKELY (array->length == 0))
+    return NULL;
+  ret = array->array[array->head];
+  array->head++;
+  array->head %= array->size;
+  array->length--;
+  return ret;
+}
+
+void
+gst_queue_array_push_tail (GstQueueArray * array, gpointer data)
+{
+  /* Check if we need to make room */
+  if (G_UNLIKELY (array->length == array->size)) {
+    /* newsize is 50% bigger */
+    guint newsize = (3 * array->size) / 2;
+
+    /* copy over data */
+    if (array->tail != 0) {
+      gpointer *array2 = g_new0 (gpointer, newsize);
+      guint t1 = array->head;
+      guint t2 = array->size - array->head;
+
+      /* [0-----TAIL][HEAD------SIZE]
+       *
+       * We want to end up with
+       * [HEAD------------------TAIL][----FREEDATA------NEWSIZE]
+       *
+       * 1) move [HEAD-----SIZE] part to beginning of new array
+       * 2) move [0-------TAIL] part new array, after previous part
+       */
+
+      memcpy (array2, &array->array[array->head], t2 * sizeof (gpointer));
+      memcpy (&array2[t2], array->array, t1 * sizeof (gpointer));
+
+      g_free (array->array);
+      array->array = array2;
+      array->head = 0;
+    } else {
+      /* Fast path, we just need to grow the array */
+      array->array = g_renew (gpointer, array->array, newsize);
+    }
+    array->tail = array->size;
+    array->size = newsize;
+  }
+
+  array->array[array->tail] = data;
+  array->tail++;
+  array->tail %= array->size;
+  array->length++;
+}
+
+gboolean
+gst_queue_array_is_empty (GstQueueArray * array)
+{
+  return (array->length == 0);
+}
+
+void
+gst_queue_array_free (GstQueueArray * array)
+{
+  g_free (array->array);
+  g_free (array);
+}
+
+void
+gst_queue_array_drop_element (GstQueueArray * array, guint idx)
+{
+  if (idx == array->head) {
+    /* just move the head */
+    array->head++;
+    array->head %= array->size;
+    return;
+  }
+  if (idx == array->tail - 1) {
+    /* just move the tail */
+    array->tail = (array->tail - 1 + array->size) % array->size;
+    return;
+  }
+  /* drop the element #idx... and readjust the array */
+  if (array->head < array->tail) {
+    /* Make sure it's within the boundaries */
+    g_assert (array->head < idx && idx <= array->tail);
+    /* ends not wrapped */
+    /* move head-idx to head+1 */
+    memcpy (&array->array[array->head + 1],
+        &array->array[array->head], (idx - array->head) * sizeof (gpointer));
+    array->tail--;
+  } else {
+    /* ends are wrapped */
+    if (idx < array->tail) {
+      /* move idx-tail backwards one */
+      memcpy (&array->array[idx - 1],
+          &array->array[idx], (array->tail - idx) * sizeof (gpointer));
+      array->tail--;
+    } else if (idx >= array->head) {
+      /* move head-idx forwards one */
+      memcpy (&array->array[array->head],
+          &array->array[array->head + 1],
+          (idx - array->head) * sizeof (gpointer));
+      array->head++;
+    } else
+      g_assert_not_reached ();
+  }
+}
+
+guint
+gst_queue_array_find (GstQueueArray * array, GCompareFunc func, gpointer data)
+{
+  guint i;
+
+  /* Scan from head to tail */
+  for (i = array->head; i < array->length; i = (i + 1) % array->size)
+    if (func (array->array[i], data) == 0)
+      return i;
+  return -1;
+}
diff --git a/plugins/elements/gstqueuearray.h b/plugins/elements/gstqueuearray.h
new file mode 100644 (file)
index 0000000..0c79540
--- /dev/null
@@ -0,0 +1,48 @@
+/* GStreamer
+ * Copyright (C) 2009-2010 Edward Hervey <bilboed@bilboed.com>
+ *
+ * gstqueuearray.h:
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <glib.h>
+
+#ifndef __GST_QUEUE_ARRAY_H__
+#define __GST_QUEUE_ARRAY_H__
+
+typedef struct _GstQueueArray GstQueueArray;
+
+struct _GstQueueArray
+{
+  gpointer *array;
+  guint size;
+  guint head;
+  guint tail;
+  guint length;
+};
+
+GstQueueArray *gst_queue_array_new (guint initial_size);
+gpointer gst_queue_array_pop_head (GstQueueArray * array);
+void gst_queue_array_push_tail (GstQueueArray * array, gpointer data);
+gboolean gst_queue_array_is_empty (GstQueueArray * array);
+void gst_queue_array_free (GstQueueArray * array);
+
+void gst_queue_array_drop_element (GstQueueArray * array, guint idx);
+guint gst_queue_array_find (GstQueueArray * array, GCompareFunc func,
+    gpointer data);
+
+#endif
index 3f21f3c7c3c921916ff4878cd39fef11a2f7ef27..ca5024bced8eefb03be52b2b6b5e9e6675d340fe 100644 (file)
@@ -26,7 +26,8 @@
 
 #include <gst/gst.h>
 #include <gst/check/gstcheck.h>
-#include <gst/base/gstqueuearray.h>
+#include "../../../plugins/elements/gstqueuearray.h"
+#include "../../../plugins/elements/gstqueuearray.c"
 
 /* Simplest test
  * Initial size : 10
index e6735884b2a9620a3509511e8906079a99a213d6..83191040381b8ff6d3741003f7928b977823fba0 100644 (file)
@@ -237,13 +237,6 @@ EXPORTS
        gst_collect_pads_stop
        gst_collect_pads_take_buffer
        gst_push_src_get_type
-       gst_queue_array_drop_element
-       gst_queue_array_find
-       gst_queue_array_free
-       gst_queue_array_is_empty
-       gst_queue_array_new
-       gst_queue_array_pop_head
-       gst_queue_array_push_tail
        gst_type_find_helper
        gst_type_find_helper_for_buffer
        gst_type_find_helper_for_data