]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gstreamer0-10.git/blobdiff - plugins/indexers/gstfileindex.c
gststructure: early out when we know a value cannot be a subset
[glsdk/gstreamer0-10.git] / plugins / indexers / gstfileindex.c
index 5c59c2be1121ee5fdc929fec0ccc9fdb0c116db2..c8c8fb1f5d5eaa80650b07dd0b078ad2ee8ed713 100644 (file)
 #include <fcntl.h>
 #include <string.h>
 
+#ifdef GST_DISABLE_DEPRECATED
+#include <libxml/parser.h>
+#endif
+
+#include "gstindexers.h"
+
 #define GST_TYPE_FILE_INDEX             \
   (gst_file_index_get_type ())
 #define GST_FILE_INDEX(obj)             \
@@ -118,8 +124,6 @@ enum
   ARG_LOCATION,
 };
 
-static void gst_file_index_class_init (GstFileIndexClass * klass);
-static void gst_file_index_init (GstFileIndex * index);
 static void gst_file_index_dispose (GObject * object);
 
 static void
@@ -142,33 +146,9 @@ static GstIndexEntry *gst_file_index_get_assoc_entry (GstIndex * index, gint id,
 
 #define CLASS(file_index)  GST_FILE_INDEX_CLASS (G_OBJECT_GET_CLASS (file_index))
 
-static GstIndex *parent_class = NULL;
+GType gst_file_index_get_type (void);
 
-GType
-gst_file_index_get_type (void)
-{
-  static GType file_index_type = 0;
-
-  if (!file_index_type) {
-    static const GTypeInfo file_index_info = {
-      sizeof (GstFileIndexClass),
-      NULL,
-      NULL,
-      (GClassInitFunc) gst_file_index_class_init,
-      NULL,
-      NULL,
-      sizeof (GstFileIndex),
-      1,
-      (GInstanceInitFunc) gst_file_index_init,
-      NULL
-    };
-
-    file_index_type =
-        g_type_register_static (GST_TYPE_INDEX, "GstFileIndex",
-        &file_index_info, 0);
-  }
-  return file_index_type;
-}
+G_DEFINE_TYPE (GstFileIndex, gst_file_index, GST_TYPE_INDEX);
 
 static void
 gst_file_index_class_init (GstFileIndexClass * klass)
@@ -179,8 +159,6 @@ gst_file_index_class_init (GstFileIndexClass * klass)
   gobject_class = (GObjectClass *) klass;
   gstindex_class = (GstIndexClass *) klass;
 
-  parent_class = g_type_class_peek_parent (klass);
-
   gobject_class->dispose = gst_file_index_dispose;
   gobject_class->set_property = gst_file_index_set_property;
   gobject_class->get_property = gst_file_index_get_property;
@@ -192,7 +170,8 @@ gst_file_index_class_init (GstFileIndexClass * klass)
 
   g_object_class_install_property (gobject_class, ARG_LOCATION,
       g_param_spec_string ("location", "File Location",
-          "Location of the index file", NULL, G_PARAM_READWRITE));
+          "Location of the index file", NULL,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 }
 
 static void
@@ -215,7 +194,7 @@ _file_index_id_free (GstFileIndexId * index_id, gboolean is_mmapped)
       munmap (index_id->array->data, ARRAY_TOTAL_SIZE (index_id));
     g_array_free (index_id->array, !is_mmapped);
   }
-  g_free (index_id);
+  g_slice_free (GstFileIndexId, index_id);
 }
 
 static gboolean
@@ -252,7 +231,7 @@ gst_file_index_dispose (GObject * object)
 
   gst_index_entry_free (index->ret_entry);      /* hack */
 
-  G_OBJECT_CLASS (parent_class)->dispose (object);
+  G_OBJECT_CLASS (gst_file_index_parent_class)->dispose (object);
 }
 
 struct fi_find_writer_context
@@ -261,7 +240,7 @@ struct fi_find_writer_context
   GstFileIndexId *ii;
 };
 
-void
+static void
 _fi_find_writer (gpointer key, gpointer val, gpointer data)
 {
   struct fi_find_writer_context *cx = data;
@@ -399,7 +378,7 @@ gst_file_index_load (GstFileIndex * index)
           continue;
         }
 
-        id_index = g_new0 (GstFileIndexId, 1);
+        id_index = g_slice_new0 (GstFileIndexId);
         id_index->id_desc = (char *) xmlGetProp (writer, (xmlChar *) "id");
 
         for (wpart = writer->children; wpart; wpart = wpart->next) {
@@ -495,7 +474,7 @@ static void
 _file_index_id_save_xml (gpointer _key, GstFileIndexId * ii, xmlNodePtr writers)
 {
   const gint bufsize = 16;
-  gchar buf[bufsize];
+  gchar buf[16];
   xmlNodePtr writer;
   xmlNodePtr formats;
   gint xx;
@@ -655,7 +634,7 @@ gst_file_index_add_id (GstIndex * index, GstIndexEntry * entry)
   id_index = g_hash_table_lookup (fileindex->id_index, &entry->id);
 
   if (!id_index) {
-    id_index = g_new0 (GstFileIndexId, 1);
+    id_index = g_slice_new0 (GstFileIndexId);
 
     id_index->id = entry->id;
     id_index->id_desc = g_strdup (entry->data.id.description);
@@ -791,7 +770,7 @@ gst_file_index_add_association (GstIndex * index, GstIndexEntry * entry)
   }
 
   /* this is a hack, we should use a private structure instead */
-  sample.format = 0;
+  sample.format = GST_FORMAT_UNDEFINED;
   sample.value = GST_INDEX_ASSOC_VALUE (entry, 0);
 
   exact =
@@ -807,7 +786,7 @@ gst_file_index_add_association (GstIndex * index, GstIndexEntry * entry)
   }
 
   {
-    gchar row_data[ARRAY_ROW_SIZE (id_index)];
+    gchar *row_data = (gchar *) g_malloc (ARRAY_ROW_SIZE (id_index));
     gint fx;
 
     gint32 flags_host = GST_INDEX_ASSOC_FLAGS (entry);
@@ -821,6 +800,8 @@ gst_file_index_add_association (GstIndex * index, GstIndexEntry * entry)
     }
 
     g_array_insert_vals (id_index->array, mx, row_data, 1);
+
+    g_free (row_data);
   }
 }
 
@@ -922,7 +903,7 @@ gst_file_index_get_assoc_entry (GstIndex * index,
   }
 
   /* this is a hack, we should use a private structure instead */
-  sample.format = formatx;
+  sample.format = (GstFormat) formatx;
   sample.value = value;
 
   exact = _fc_bsearch (id_index->array, ARRAY_ROW_SIZE (id_index),
@@ -957,7 +938,7 @@ gst_file_index_get_assoc_entry (GstIndex * index,
 
   /* entry memory management needs improvement FIXME */
   if (!fileindex->ret_entry)
-    fileindex->ret_entry = g_new0 (GstIndexEntry, 1);
+    fileindex->ret_entry = g_slice_new0 (GstIndexEntry);
   entry = fileindex->ret_entry;
   if (entry->data.assoc.assocs) {
     g_free (entry->data.assoc.assocs);
@@ -972,7 +953,7 @@ gst_file_index_get_assoc_entry (GstIndex * index,
   {
     gint32 flags_be = ARRAY_ROW_FLAGS (row_data);
 
-    GST_INDEX_ASSOC_FLAGS (entry) = GINT32_FROM_BE (flags_be);
+    GST_INDEX_ASSOC_FLAGS (entry) = (GstAssocFlags) GINT32_FROM_BE (flags_be);
 
     for (xx = 0; xx < id_index->nformats; xx++) {
       gint64 val_be = ARRAY_ROW_VALUE (row_data, xx);
@@ -997,7 +978,7 @@ gst_file_index_plugin_init (GstPlugin * plugin)
     return FALSE;
   }
 
-  GST_PLUGIN_FEATURE (factory)->plugin_name = g_strdup (plugin->desc.name);
+  GST_PLUGIN_FEATURE (factory)->plugin_name = plugin->desc.name;
   GST_PLUGIN_FEATURE (factory)->loaded = TRUE;
 
   gst_registry_add_feature (gst_registry_get_default (),