Cleaned up INFO system some more, added API to select categories, modified the printo...
authorErik Walthinsen <omega@temple-baptist.org>
Mon, 1 Jan 2001 00:17:21 +0000 (00:17 +0000)
committerErik Walthinsen <omega@temple-baptist.org>
Mon, 1 Jan 2001 00:17:21 +0000 (00:17 +0000)
Original commit message from CVS:
Cleaned up INFO system some more, added API to select categories, modified
the printout function to print cleanly for GST_INIT info (the default min)
and spew function:line debug_string [element] for everything else.
Eventually could make even that configurable easily enough, just check
against another bitmap instead of checking for == GST_INIT.

gst/elements/gstelements.c
gst/gstcpu.c
gst/gstinfo.c
gst/gstinfo.h
plugins/elements/gstelements.c

index 9cf4092..15091a0 100644 (file)
@@ -96,7 +96,7 @@ GstPlugin *plugin_init (GModule *module)
     i++;
   }
 
-  INFO (0,"gstelements: loaded %d standard elements", i);
+//  INFO (GST_INFO_PLUGIN_LOAD,"gstelements: loaded %d standard elements", i);
 
   return plugin;
 }
index 52758a3..9ccba53 100644 (file)
@@ -37,29 +37,39 @@ void gst_cpuid_i386(int,long *,long *,long *,long *);
 #define gst_cpuid(o,a,b,c,d) (void)(a);(void)(b);(void)(c);
 #endif
 
+static gchar *stringcat (gchar *a,gchar *b) {
+  gchar *c;
+  if (a) {
+    c = g_strconcat(a,b);
+    g_free(a);
+  } else
+    c = g_strdup(b);
+  return c;
+}
+
 void 
 _gst_cpu_initialize (void) 
 {
+  gchar *featurelist = NULL;
+
   long eax=0, ebx=0, ecx=0, edx=0;
 
   gst_cpuid(1, &eax, &ebx, &ecx, &edx);
 
-  g_print("CPU features : ");
-
   if (edx & (1<<23)) {
     _gst_cpu_flags |= GST_CPU_FLAG_MMX;
-    g_print("MMX ");
+    featurelist = stringcat(featurelist,"MMX ");
   }
   if (edx & (1<<25)) {
     _gst_cpu_flags |= GST_CPU_FLAG_SSE;
-    g_print("SSE ");
+    featurelist = stringcat(featurelist,"SSE ");
   }
 
   if (!_gst_cpu_flags) {
-    g_print("NONE");
+    featurelist = stringcat(featurelist,"NONE");
   }
-  g_print("\n");
 
+  INFO(GST_INFO_GST_INIT, "CPU features: %s",featurelist);
 }
 
 GstCPUFlags 
index 9c9d2c0..8a4ec63 100644 (file)
@@ -34,7 +34,7 @@ GHashTable *__gst_function_pointers = NULL;
 /***** INFO system *****/
 GstInfoHandler _gst_info_handler = gst_default_info_handler;
 //guint32 _gst_info_categories = 0xffffffff;
-guint32 _gst_info_categories = 0x00000000;
+guint32 _gst_info_categories = 0x00000001;
 
 static gchar *_gst_info_category_strings[] = {
   "GST_INIT",
@@ -67,101 +67,52 @@ gst_default_info_handler (gint category, gchar *file, gchar *function,
                            gint line, gchar *debug_string,
                            void *element, gchar *string)
 {
-  if (element) {
-    if (debug_string)
-      fprintf(stderr,"INFO:%s:%d%s: [%s] %s\n",
-              function,line,debug_string,gst_element_get_name(element),string);
-     else
-      fprintf(stderr,"INFO:%s:%d: [%s] %s\n",
-              function,line,gst_element_get_name(element),string);
-  } else {
-    if (debug_string)
-      fprintf(stderr,"INFO:%s:%d%s: %s\n",
-              function,line,debug_string,string);
-    else
-      fprintf(stderr,"INFO:%s:%d: %s\n",
-              function,line,string);
-  }
+  gchar *empty = "";
+  gchar *elementname = empty,*location = empty;
 
-  g_free(string);
-}
+  if (debug_string == NULL) debug_string = "";
+  if (category != GST_INFO_GST_INIT)
+    location = g_strdup_printf("%s:%d%s:",function,line,debug_string);
+  if (element && GST_IS_ELEMENT (element))
+    elementname = g_strdup_printf (" [%s]",gst_element_get_name (element));
 
+  fprintf(stderr,"INFO:%s%s %s\n",location,elementname,string);
 
-/***** ERROR system *****/
-GstErrorHandler _gst_error_handler = gst_default_error_handler;
+  if (location != empty) g_free(location);
+  if (elementname != empty) g_free(elementname);
 
-/*
-gchar *gst_object_get_path_string(GstObject *object) {
-  GSList *parentage = NULL;
-  GSList *parents;
-  void *parent;
-  gchar *prevpath, *path = "";
-  const char *component;
-  gchar *separator = "";
-  gboolean free_component;
+  g_free(string);
+}
 
-  parentage = g_slist_prepend (NULL, object);
+void
+gst_info_set_categories (guint32 categories) {
+  _gst_info_categories = categories;
+}
 
-  // first walk the object hierarchy to build a list of the parents
-  do {
-    if (GST_IS_OBJECT(object)) {
-      if (GST_IS_PAD(object)) {
-        parent = GST_PAD(object)->parent;
-//      } else if (GST_IS_ELEMENT(object)) {
-//        parent = gst_element_get_parent(GST_ELEMENT(object));
-      } else {
-        parent = gst_object_get_parent (object);
-      }
-    } else {
-      parentage = g_slist_prepend (parentage, NULL);
-      parent = NULL;
-    }
+guint32
+gst_info_get_categories () {
+  return _gst_info_categories;
+}
 
-    if (parent != NULL) {
-      parentage = g_slist_prepend (parentage, parent);
-    }
+const gchar *
+gst_info_get_category_name (gint category) {
+  return _gst_info_category_strings[category];
+}
 
-    object = parent;
-  } while (object != NULL);
-
-  // then walk the parent list and print them out
-  parents = parentage;
-  while (parents) {
-    if (GST_IS_OBJECT(parents->data)) {
-      if (GST_IS_PAD(parents->data)) {
-        component = gst_pad_get_name(GST_PAD(parents->data));
-        separator = ".";
-        free_component = FALSE;
-      } else if (GST_IS_ELEMENT(parents->data)) {
-        component = gst_element_get_name(GST_ELEMENT(parents->data));
-        separator = "/";
-        free_component = FALSE;
-      } else {
-//        component = g_strdup_printf("a %s",gtk_type_name(gtk_identifier_get_type(parents->data)));
-        component = g_strdup_printf("unknown%p",parents->data);
-        separator = "/";
-        free_component = TRUE;
-      }
-    } else {
-      component = g_strdup_printf("%p",parents->data);
-      separator = "/";
-      free_component = TRUE;
-    }
+void
+gst_info_enable_category (gint category) {
+  _gst_info_categories |= (1 << category);
+}
 
-    prevpath = path;
-    path = g_strjoin(separator,prevpath,component,NULL);
-    g_free(prevpath);
-    if (free_component)
-      g_free((gchar *)component);
+void
+gst_info_disable_category (gint category) {
+  _gst_info_categories &= ~ (1 << category);
+}
 
-    parents = g_slist_next(parents);
-  }
 
-  g_slist_free(parentage);
 
-  return path;
-}
-*/
+/***** ERROR system *****/
+GstErrorHandler _gst_error_handler = gst_default_error_handler;
 
 void
 gst_default_error_handler (gchar *file, gchar *function,
index ba64329..e672cfb 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
  *                    2000 Wim Taymans <wtay@chello.be>
  *
- * gstdebug.h: Debugging helper macros
+ * gstinfo.h: 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -193,6 +193,12 @@ extern guint32 _gst_info_categories;
 }G_STMT_END
 
 
+void           gst_info_set_categories         (guint32 categories);
+guint32                gst_info_get_categories         ();
+const gchar *  gst_info_get_category_name      (gint category);
+void           gst_info_enable_category        (gint category);
+void           gst_info_disable_category       (gint category);
+
 enum {
   GST_INFO_GST_INIT = 0,       // Library initialization
   GST_INFO_COTHREADS,          // Cothread creation, etc.
index 9cf4092..15091a0 100644 (file)
@@ -96,7 +96,7 @@ GstPlugin *plugin_init (GModule *module)
     i++;
   }
 
-  INFO (0,"gstelements: loaded %d standard elements", i);
+//  INFO (GST_INFO_PLUGIN_LOAD,"gstelements: loaded %d standard elements", i);
 
   return plugin;
 }