cache return values of _gst_debug_nameof_funcptr

Original commit message from CVS:
kill some memleaks, add ::signal-handoffs property to fakesrc/sink (default FALSE), cache return values of _gst_debug_nameof_funcptr
This commit is contained in:
Andy Wingo 2003-08-07 12:45:31 +00:00
parent 093f00d2df
commit 5c2d6b2f43
16 changed files with 159 additions and 22 deletions

View file

@ -339,8 +339,76 @@ TODO: how to distinguish MJPEG-A/B (Quicktime) and lossless JPEG?
TODO: divx4/divx5/xvid/3ivx/mpeg-4 - how to make them overlap? (all
ISO MPEG-4 compatible)
Audio codecs
------------
3c) Audio Codecs
----------------
for convenience, the two-byte hexcodes (as are being used for identification
in AVI files) are also given
Preface - (optional) properties for all audio formats:
'rate' = X (int) <- sampling rate
'channels' = X (int) <- number of audio channels
1 - Raw Audio (integer format)
mimetype: audio/x-raw-int
properties: 'width' = X (INT) <- memory bits per sample
'depth' = X (INT) <- used bits per sample
'signed' = X (BOOLEAN)
'endianness' = 1234/4321 (INT)
2 - Raw Audio (floating point format)
mimetype: audio/x-raw-float
properties: 'depth' = X (INT) <- 32=float, 64=double
'endianness' = 1234/4321 (INT) <- use G_BIG/LITTLE_ENDIAN!
'buffer-frames' = (INT)
With regards to the signal: 0.0 represents no signal, +/- 1.0 is 0 dB.
3 - Alaw Raw Audio
mimetype: audio/x-alaw
4 - Mulaw Raw Audio
mimetype: audio/x-mulaw
5 - MPEG-1 layer 1/2/3 audio
mimetype: audio/mpeg
properties: 'mpegversion' = 1 (INT)
'layer' = 1/2/3 (INT)
6 - Ogg/Vorbis
mimetype: audio/x-vorbis
7 - Windows Media Audio 1 and 2 (WMA)
mimetype: audio/x-wma
properties: 'wmaversion' = 1/2 (INT)
8 - AC3
mimetype: audio/x-ac3
9 - FLAC (Free Lossless Audio Codec)
mimetype: audio/x-flac
10 - MACE 3/6 (Quicktime audio)
mimetype: audio/x-mace
properties: 'maceversion' = 3/6 (INT)
11 - MPEG-4 AAC
mimetype: audio/mpeg
properties: 'mpegversion' = 4 (INT)
12 - (IMA) ADPCM (Quicktime/WAV/Microsoft/4XM)
mimetype: audio/x-adpcm
properties: 'layout' = "quicktime"/"wav"/"microsoft"/"4xm" (STRING)
Note: the difference between each of these is the number of
samples packaed together per channel. For WAV, for
example, each sample is 4 bit, and 8 samples are packed
together per channel in the bytestream. For the others,
refer to technical documentation.
We probably want to distinguish these differently, but
I don't know how, yet.
13 - RealAudio (Real)
mimetype: audio/x-pn-realaudio
properties: 'bitrate' = 14400/28800 (INT)
For convenience, the two-byte hexcodes (as used for identification in AVI files)
are also given.

View file

@ -55,6 +55,7 @@ enum {
ARG_SILENT,
ARG_DUMP,
ARG_SYNC,
ARG_SIGNAL_HANDOFFS,
ARG_LAST_MESSAGE,
};
@ -150,6 +151,9 @@ gst_fakesink_class_init (GstFakeSinkClass *klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC,
g_param_spec_boolean ("sync", "Sync", "Sync on the clock",
FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS,
g_param_spec_boolean ("signal-handoffs", "Signal handoffs", "Send a signal before unreffing the buffer",
FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events",
FALSE, G_PARAM_READWRITE));
@ -185,6 +189,7 @@ gst_fakesink_init (GstFakeSink *fakesink)
fakesink->sync = FALSE;
fakesink->last_message = NULL;
fakesink->state_error = FAKESINK_STATE_ERROR_NONE;
fakesink->signal_handoffs = FALSE;
GST_FLAG_SET (fakesink, GST_ELEMENT_EVENT_AWARE);
}
@ -246,6 +251,9 @@ gst_fakesink_set_property (GObject *object, guint prop_id, const GValue *value,
case ARG_SYNC:
sink->sync = g_value_get_boolean (value);
break;
case ARG_SIGNAL_HANDOFFS:
sink->signal_handoffs = g_value_get_boolean (value);
break;
default:
break;
}
@ -277,6 +285,9 @@ gst_fakesink_get_property (GObject *object, guint prop_id, GValue *value, GParam
case ARG_SYNC:
g_value_set_boolean (value, sink->sync);
break;
case ARG_SIGNAL_HANDOFFS:
g_value_set_boolean (value, sink->signal_handoffs);
break;
case ARG_LAST_MESSAGE:
g_value_set_string (value, sink->last_message);
break;
@ -295,7 +306,7 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (buf != NULL);
fakesink = GST_FAKESINK (gst_pad_get_parent (pad));
fakesink = GST_FAKESINK (GST_OBJECT_PARENT (pad));
if (GST_IS_EVENT (buf)) {
GstEvent *event = GST_EVENT (buf);
@ -345,6 +356,7 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
g_object_notify (G_OBJECT (fakesink), "last_message");
}
if (fakesink->signal_handoffs)
g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0, buf, pad);
if (fakesink->dump) {
@ -383,6 +395,8 @@ gst_fakesink_change_state (GstElement *element)
case GST_STATE_READY_TO_NULL:
if (fakesink->state_error == FAKESINK_STATE_ERROR_READY_NULL)
goto error;
g_free (fakesink->last_message);
fakesink->last_message = NULL;
break;
}

View file

@ -61,6 +61,7 @@ struct _GstFakeSink {
gboolean silent;
gboolean dump;
gboolean sync;
gboolean signal_handoffs;
GstClock *clock;
GstFakeSinkStateError state_error;

View file

@ -69,6 +69,7 @@ enum {
ARG_PATTERN,
ARG_NUM_BUFFERS,
ARG_EOS,
ARG_SIGNAL_HANDOFFS,
ARG_SILENT,
ARG_DUMP,
ARG_PARENTSIZE,
@ -250,6 +251,9 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events",
FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS,
g_param_spec_boolean ("signal-handoffs", "Signal handoffs", "Send a signal before pushing the buffer",
FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
g_param_spec_boolean ("dump", "Dump", "Dump produced bytes to stdout",
FALSE, G_PARAM_READWRITE));
@ -286,6 +290,7 @@ gst_fakesrc_init (GstFakeSrc *fakesrc)
fakesrc->rt_num_buffers = -1;
fakesrc->buffer_count = 0;
fakesrc->silent = FALSE;
fakesrc->signal_handoffs = FALSE;
fakesrc->dump = FALSE;
fakesrc->pattern_byte = 0x00;
fakesrc->need_flush = FALSE;
@ -514,6 +519,9 @@ gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, G
case ARG_SILENT:
src->silent = g_value_get_boolean (value);
break;
case ARG_SIGNAL_HANDOFFS:
src->signal_handoffs = g_value_get_boolean (value);
break;
case ARG_DUMP:
src->dump = g_value_get_boolean (value);
break;
@ -572,6 +580,9 @@ gst_fakesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS
case ARG_SILENT:
g_value_set_boolean (value, src->silent);
break;
case ARG_SIGNAL_HANDOFFS:
g_value_set_boolean (value, src->signal_handoffs);
break;
case ARG_DUMP:
g_value_set_boolean (value, src->dump);
break;
@ -731,7 +742,7 @@ gst_fakesrc_get(GstPad *pad)
g_return_val_if_fail (pad != NULL, NULL);
src = GST_FAKESRC (gst_pad_get_parent (pad));
src = GST_FAKESRC (GST_OBJECT_PARENT (pad));
g_return_val_if_fail (GST_IS_FAKESRC (src), NULL);
@ -777,10 +788,12 @@ gst_fakesrc_get(GstPad *pad)
g_object_notify (G_OBJECT (src), "last_message");
}
if (src->signal_handoffs) {
GST_LOG_OBJECT (src, "pre handoff emit");
g_signal_emit (G_OBJECT (src), gst_fakesrc_signals[SIGNAL_HANDOFF], 0,
buf, pad);
GST_LOG_OBJECT (src, "post handoff emit");
}
return buf;
}

View file

@ -102,6 +102,7 @@ struct _GstFakeSrc {
gint rt_num_buffers; /* we are going to change this at runtime */
guint64 buffer_count;
gboolean silent;
gboolean signal_handoffs;
gboolean dump;
gboolean need_flush;
GstBufferPool *pool;

View file

@ -209,8 +209,9 @@ get_type_for_mime (const gchar *mime)
definition.typefindfunc = NULL;
factory = gst_type_factory_new (&definition);
typeid = gst_type_register (factory);
g_free (definition.mime);
}
return typeid;
}

View file

@ -873,10 +873,10 @@ gst_debug_get_all_categories (void)
/*** FUNCTION POINTERS ********************************************************/
GHashTable *__gst_function_pointers = NULL;
gchar *_gst_debug_nameof_funcptr (void *ptr) G_GNUC_NO_INSTRUMENT;
const gchar *_gst_debug_nameof_funcptr (void *ptr) G_GNUC_NO_INSTRUMENT;
/* This function MUST NOT return NULL */
gchar *
const gchar *
_gst_debug_nameof_funcptr (void *ptr)
{
gchar *ptrname;
@ -885,15 +885,21 @@ _gst_debug_nameof_funcptr (void *ptr)
#endif
if (__gst_function_pointers && (ptrname = g_hash_table_lookup(__gst_function_pointers,ptr))) {
return g_strdup(ptrname);
} else
return ptrname;
}
/* we need to create an entry in the hash table for this one so we don't leak
* the name */
#ifdef HAVE_DLADDR
if (dladdr(ptr,&dlinfo) && dlinfo.dli_sname) {
return g_strdup(dlinfo.dli_sname);
gchar *name = g_strdup (dlinfo.dli_sname);
_gst_debug_register_funcptr (ptr, name);
return name;
} else
#endif
{
return g_strdup_printf("%p",ptr);
gchar *name = g_strdup_printf ("%p", ptr);
_gst_debug_register_funcptr (ptr, name);
return name;
}
}

View file

@ -379,7 +379,7 @@ extern gboolean __gst_debug_enabled;
/********** function pointer stuff **********/
void* _gst_debug_register_funcptr (void * ptr,
gchar * ptrname);
gchar* _gst_debug_nameof_funcptr (void * ptr);
const gchar* _gst_debug_nameof_funcptr (void * ptr);
#define GST_DEBUG_FUNCPTR(ptr) (_gst_debug_register_funcptr((void *)(ptr), #ptr) , ptr)
#define GST_DEBUG_FUNCPTR_NAME(ptr) _gst_debug_nameof_funcptr((void *)ptr)

View file

@ -55,6 +55,7 @@ enum {
ARG_SILENT,
ARG_DUMP,
ARG_SYNC,
ARG_SIGNAL_HANDOFFS,
ARG_LAST_MESSAGE,
};
@ -150,6 +151,9 @@ gst_fakesink_class_init (GstFakeSinkClass *klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC,
g_param_spec_boolean ("sync", "Sync", "Sync on the clock",
FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS,
g_param_spec_boolean ("signal-handoffs", "Signal handoffs", "Send a signal before unreffing the buffer",
FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events",
FALSE, G_PARAM_READWRITE));
@ -185,6 +189,7 @@ gst_fakesink_init (GstFakeSink *fakesink)
fakesink->sync = FALSE;
fakesink->last_message = NULL;
fakesink->state_error = FAKESINK_STATE_ERROR_NONE;
fakesink->signal_handoffs = FALSE;
GST_FLAG_SET (fakesink, GST_ELEMENT_EVENT_AWARE);
}
@ -246,6 +251,9 @@ gst_fakesink_set_property (GObject *object, guint prop_id, const GValue *value,
case ARG_SYNC:
sink->sync = g_value_get_boolean (value);
break;
case ARG_SIGNAL_HANDOFFS:
sink->signal_handoffs = g_value_get_boolean (value);
break;
default:
break;
}
@ -277,6 +285,9 @@ gst_fakesink_get_property (GObject *object, guint prop_id, GValue *value, GParam
case ARG_SYNC:
g_value_set_boolean (value, sink->sync);
break;
case ARG_SIGNAL_HANDOFFS:
g_value_set_boolean (value, sink->signal_handoffs);
break;
case ARG_LAST_MESSAGE:
g_value_set_string (value, sink->last_message);
break;
@ -295,7 +306,7 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (buf != NULL);
fakesink = GST_FAKESINK (gst_pad_get_parent (pad));
fakesink = GST_FAKESINK (GST_OBJECT_PARENT (pad));
if (GST_IS_EVENT (buf)) {
GstEvent *event = GST_EVENT (buf);
@ -345,6 +356,7 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf)
g_object_notify (G_OBJECT (fakesink), "last_message");
}
if (fakesink->signal_handoffs)
g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0, buf, pad);
if (fakesink->dump) {
@ -383,6 +395,8 @@ gst_fakesink_change_state (GstElement *element)
case GST_STATE_READY_TO_NULL:
if (fakesink->state_error == FAKESINK_STATE_ERROR_READY_NULL)
goto error;
g_free (fakesink->last_message);
fakesink->last_message = NULL;
break;
}

View file

@ -61,6 +61,7 @@ struct _GstFakeSink {
gboolean silent;
gboolean dump;
gboolean sync;
gboolean signal_handoffs;
GstClock *clock;
GstFakeSinkStateError state_error;

View file

@ -69,6 +69,7 @@ enum {
ARG_PATTERN,
ARG_NUM_BUFFERS,
ARG_EOS,
ARG_SIGNAL_HANDOFFS,
ARG_SILENT,
ARG_DUMP,
ARG_PARENTSIZE,
@ -250,6 +251,9 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events",
FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS,
g_param_spec_boolean ("signal-handoffs", "Signal handoffs", "Send a signal before pushing the buffer",
FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP,
g_param_spec_boolean ("dump", "Dump", "Dump produced bytes to stdout",
FALSE, G_PARAM_READWRITE));
@ -286,6 +290,7 @@ gst_fakesrc_init (GstFakeSrc *fakesrc)
fakesrc->rt_num_buffers = -1;
fakesrc->buffer_count = 0;
fakesrc->silent = FALSE;
fakesrc->signal_handoffs = FALSE;
fakesrc->dump = FALSE;
fakesrc->pattern_byte = 0x00;
fakesrc->need_flush = FALSE;
@ -514,6 +519,9 @@ gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, G
case ARG_SILENT:
src->silent = g_value_get_boolean (value);
break;
case ARG_SIGNAL_HANDOFFS:
src->signal_handoffs = g_value_get_boolean (value);
break;
case ARG_DUMP:
src->dump = g_value_get_boolean (value);
break;
@ -572,6 +580,9 @@ gst_fakesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS
case ARG_SILENT:
g_value_set_boolean (value, src->silent);
break;
case ARG_SIGNAL_HANDOFFS:
g_value_set_boolean (value, src->signal_handoffs);
break;
case ARG_DUMP:
g_value_set_boolean (value, src->dump);
break;
@ -731,7 +742,7 @@ gst_fakesrc_get(GstPad *pad)
g_return_val_if_fail (pad != NULL, NULL);
src = GST_FAKESRC (gst_pad_get_parent (pad));
src = GST_FAKESRC (GST_OBJECT_PARENT (pad));
g_return_val_if_fail (GST_IS_FAKESRC (src), NULL);
@ -777,10 +788,12 @@ gst_fakesrc_get(GstPad *pad)
g_object_notify (G_OBJECT (src), "last_message");
}
if (src->signal_handoffs) {
GST_LOG_OBJECT (src, "pre handoff emit");
g_signal_emit (G_OBJECT (src), gst_fakesrc_signals[SIGNAL_HANDOFF], 0,
buf, pad);
GST_LOG_OBJECT (src, "post handoff emit");
}
return buf;
}

View file

@ -102,6 +102,7 @@ struct _GstFakeSrc {
gint rt_num_buffers; /* we are going to change this at runtime */
guint64 buffer_count;
gboolean silent;
gboolean signal_handoffs;
gboolean dump;
gboolean need_flush;
GstBufferPool *pool;

View file

@ -180,6 +180,7 @@ main (int argc, char *argv[])
sink = gst_element_factory_make ("fakesink", "sink");
g_assert (sink);
g_object_set (sink, "signal-handoff", TRUE, NULL);
g_signal_connect (G_OBJECT (sink), "handoff", G_CALLBACK (handoff), NULL);
bs = gst_element_factory_make ("bstest", "bs");

View file

@ -35,6 +35,7 @@ construct_pipeline (GstElement *pipeline)
gst_bin_add_many (GST_BIN (thread), identity, sink, NULL);
g_object_set (G_OBJECT (src), "num_buffers", 5, NULL);
g_object_set (sink, "signal-handoff", TRUE, NULL);
}
void

View file

@ -180,6 +180,7 @@ main (int argc, char *argv[])
sink = gst_element_factory_make ("fakesink", "sink");
g_assert (sink);
g_object_set (sink, "signal-handoff", TRUE, NULL);
g_signal_connect (G_OBJECT (sink), "handoff", G_CALLBACK (handoff), NULL);
bs = gst_element_factory_make ("bstest", "bs");

View file

@ -35,6 +35,7 @@ construct_pipeline (GstElement *pipeline)
gst_bin_add_many (GST_BIN (thread), identity, sink, NULL);
g_object_set (G_OBJECT (src), "num_buffers", 5, NULL);
g_object_set (sink, "signal-handoff", TRUE, NULL);
}
void