dnl Check for a way to display the function name in debug output
AG_GST_CHECK_FUNCTION
-dnl test for register_printf_specifier or register_printf_function
-AC_CHECK_FUNCS([register_printf_specifier register_printf_function],
- [HAVE_PRINTF_EXTENSION=yes])
-
-if test "$HAVE_PRINTF_EXTENSION" = yes; then
- GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE="#define GST_PTR_FORMAT \"P\""
- GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE="#define GST_SEGMENT_FORMAT \"Q\""
- GST_USING_PRINTF_EXTENSION_DEFINE="#define GST_USING_PRINTF_EXTENSION"
- AC_DEFINE(HAVE_PRINTF_EXTENSION, 1,
- [Defined if we have printf specifier extensions available])
-else
- GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE="#define GST_PTR_FORMAT \"p\""
- GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE="#define GST_SEGMENT_FORMAT \"p\""
- GST_USING_PRINTF_EXTENSION_DEFINE="#undef GST_USING_PRINTF_EXTENSION"
-fi
-AC_SUBST(GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE)
-AC_SUBST(GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE)
-AC_SUBST(GST_USING_PRINTF_EXTENSION_DEFINE)
-
dnl test if we have dladdr(); we use it for debugging; see gst/gstinfo.c
save_cflags="$CFLAGS"
CFLAGS="$CFLAGS -D_GNU_SOURCE"
GST_PADDING
GST_PADDING_LARGE
GST_PADDING_INIT
-GST_USING_PRINTF_EXTENSION
</SECTION>
<SECTION>
/* Configures the use of external plugins */
@GST_DISABLE_PLUGIN_DEFINE@
-/* printf extension format */
-/**
- * GST_PTR_FORMAT:
- *
- * printf format type used to debug GStreamer types.
- * This can only be used on types whose size is >= sizeof(gpointer).
- */
-@GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE@
-/**
- * GST_SEGMENT_FORMAT:
- *
- * printf format type used to debug GStreamer segments.
- * This can only be used on pointers to GstSegment structures.
- */
-@GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE@
-
-/* whether or not GST_PTR_FORMAT or GST_SEGMENT_FORMAT are using
- * the printf extension mechanism. This is for internal use in our
- * header files so we know whether we can use G_GNUC_PRINTF or not */
-@GST_USING_PRINTF_EXTENSION_DEFINE@
-
-/* GST_DISABLE_PRINTF_EXTENSION:
- *
- * Define this to debug your debug log messages and make gcc spew warnings
- * if printf format string and arguments don't match up (this is usually
- * not the case when libc and gcc are used because printf format warnings
- * have to be disabled when the printf extension mechanism is in use).
- *
- * Note that using this option disables 'pretty logging' of GStreamer objects
- * like caps, tags, structures, events, pads etc., so that only their address
- * will be printed in the log.
- *
- * This define only disables use of the special registered printf format
- * extensions in the code compiled with it defined. It does not stop
- * GStreamer from registering these extensions in the first place if it
- * was compiled against a libc that supports this.
- *
- * (not official API)
- */
-/* If GLib is not using the system printf, we can't use the registered
- * extensions because the GLib-internal printf won't know how to parse them */
-#if defined(GST_DISABLE_PRINTF_EXTENSION) || !defined(GLIB_USING_SYSTEM_PRINTF)
- #undef GST_PTR_FORMAT
- #define GST_PTR_FORMAT "p"
- #undef GST_SEGMENT_FORMAT
- #define GST_SEGMENT_FORMAT "p"
- #undef GST_USING_PRINTF_EXTENSION
-#endif
-
/* whether or not the CPU supports unaligned access */
@GST_HAVE_UNALIGNED_ACCESS_DEFINE@
#include "gst-i18n-lib.h"
#include "glib-compat-private.h"
+#include "printf/printf.h"
+
/* Element signals and args */
enum
{
{
va_list args;
gchar *buffer;
+ int len;
if (format == NULL)
return NULL;
return NULL;
va_start (args, format);
- buffer = g_strdup_vprintf (format, args);
+
+ len = __gst_vasprintf (&buffer, format, args);
+
va_end (args);
+
+ if (len < 0)
+ buffer = NULL;
+
return buffer;
}
/* error handling */
/* gcc versions < 3.3 warn about NULL being passed as format to printf */
-#if (defined(GST_USING_PRINTF_EXTENSION) || !defined(__GNUC__) || (__GNUC__ < 3) || (__GNUC__ == 3 && __GNUC_MINOR__ < 3))
+#if (!defined(__GNUC__) || (__GNUC__ < 3) || (__GNUC__ == 3 && __GNUC_MINOR__ < 3))
gchar * _gst_element_error_printf (const gchar *format, ...);
#else
gchar * _gst_element_error_printf (const gchar *format, ...) G_GNUC_PRINTF (1, 2);
#ifdef HAVE_DLFCN_H
# include <dlfcn.h>
#endif
-#ifdef HAVE_PRINTF_EXTENSION
-# include <printf.h>
-#endif
#include <stdio.h> /* fprintf */
#include <glib/gstdio.h>
#include <errno.h>
#endif
#include <glib/gprintf.h> /* g_sprintf */
+/* our own printf implementation with custom extensions to %p for caps etc. */
+#include "printf/printf.h"
+
#endif /* !GST_DISABLE_GST_DEBUG */
extern gboolean gst_is_initialized (void);
static void gst_debug_reset_threshold (gpointer category, gpointer unused);
static void gst_debug_reset_all_thresholds (void);
-#ifdef GST_USING_PRINTF_EXTENSION
+#if 0
static int _gst_info_printf_extension_ptr (FILE * stream,
const struct printf_info *info, const void *const *args);
static int _gst_info_printf_extension_segment (FILE * stream,
const struct printf_info *info, const void *const *args);
-#ifdef HAVE_REGISTER_PRINTF_SPECIFIER
-static int _gst_info_printf_extension_arginfo (const struct printf_info *info,
- size_t n, int *argtypes, int *size);
-#else
-static int _gst_info_printf_extension_arginfo (const struct printf_info *info,
- size_t n, int *argtypes);
-#endif
#endif
struct _GstDebugMessage
/* get time we started for debugging messages */
_priv_gst_info_start_time = gst_util_get_timestamp ();
-#ifdef GST_USING_PRINTF_EXTENSION
-#ifdef HAVE_REGISTER_PRINTF_SPECIFIER
+#if 0
register_printf_specifier (GST_PTR_FORMAT[0], _gst_info_printf_extension_ptr,
- _gst_info_printf_extension_arginfo);
+ NULL);
register_printf_specifier (GST_SEGMENT_FORMAT[0],
- _gst_info_printf_extension_segment, _gst_info_printf_extension_arginfo);
-#else
- register_printf_function (GST_PTR_FORMAT[0], _gst_info_printf_extension_ptr,
- _gst_info_printf_extension_arginfo);
- register_printf_function (GST_SEGMENT_FORMAT[0],
- _gst_info_printf_extension_segment, _gst_info_printf_extension_arginfo);
-#endif
+ _gst_info_printf_extension_segment, NULL);
#endif
/* do NOT use a single debug function before this line has been run */
gst_debug_message_get (GstDebugMessage * message)
{
if (message->message == NULL) {
- message->message = g_strdup_vprintf (message->format, message->arguments);
+ int len;
+
+ len = __gst_vasprintf (&message->message, message->format,
+ message->arguments);
+
+ if (len < 0)
+ message->message = NULL;
}
return message->message;
}
return g_strdup_printf ("%p", ptr);
}
-#ifdef GST_USING_PRINTF_EXTENSION
-
+#if 0
static gchar *
gst_debug_print_segment (gpointer ptr)
{
}
}
}
-
-#endif /* GST_USING_PRINTF_EXTENSION */
+#endif
/**
* gst_debug_construct_term_color:
/*** PRINTF EXTENSIONS ********************************************************/
-#ifdef GST_USING_PRINTF_EXTENSION
+#if 0
static int
_gst_info_printf_extension_ptr (FILE * stream, const struct printf_info *info,
const void *const *args)
g_free (buffer);
return len;
}
-
-#ifdef HAVE_REGISTER_PRINTF_SPECIFIER
-static int
-_gst_info_printf_extension_arginfo (const struct printf_info *info, size_t n,
- int *argtypes, int *size)
-#else
-static int
-_gst_info_printf_extension_arginfo (const struct printf_info *info, size_t n,
- int *argtypes)
-#endif
-{
- if (n > 0) {
- argtypes[0] = PA_POINTER;
-#ifdef HAVE_REGISTER_PRINTF_SPECIFIER
- *size = sizeof (gpointer);
#endif
- }
- return 1;
-}
-#endif /* GST_USING_PRINTF_EXTENSION */
static void
gst_info_dump_mem_line (gchar * linebuf, gsize linebuf_size,
#endif
#endif /* ifndef GST_FUNCTION */
+/**
+ * GST_PTR_FORMAT:
+ *
+ * printf format type used to debug GStreamer types.
+ * This can only be used on types whose size is >= sizeof(gpointer).
+ */
+#define GST_PTR_FORMAT "p" /* FIXME: add suffix for differentiation */
+
+/**
+ * GST_SEGMENT_FORMAT:
+ *
+ * printf format type used to debug GStreamer segments.
+ * This can only be used on pointers to GstSegment structures.
+ */
+#define GST_SEGMENT_FORMAT "p" /* FIXME: add suffix for differentiation */
typedef struct _GstDebugMessage GstDebugMessage;
GstDebugMessage * message,
gpointer user_data);
-#ifdef GST_USING_PRINTF_EXTENSION
-
-/* not using G_GNUC_PRINTF, since gcc will choke on GST_PTR_FORMAT being %P */
-void gst_debug_log (GstDebugCategory * category,
- GstDebugLevel level,
- const gchar * file,
- const gchar * function,
- gint line,
- GObject * object,
- const gchar * format,
- ...) G_GNUC_NO_INSTRUMENT;
-
-#else /* GST_USING_PRINTF_EXTENSION */
-
void gst_debug_log (GstDebugCategory * category,
GstDebugLevel level,
const gchar * file,
const gchar * format,
...) G_GNUC_PRINTF (7, 8) G_GNUC_NO_INSTRUMENT;
-#endif /* GST_USING_PRINTF_EXTENSION */
-
void gst_debug_log_valist (GstDebugCategory * category,
GstDebugLevel level,
const gchar * file,