gst/typefind/gsttypefindfunctions.c: Fix leaks in typefind registration

Original commit message from CVS:

* gst/typefind/gsttypefindfunctions.c: (utf8_type_find):
Fix leaks in typefind registration
Clean up the gratuitous commenting and whitespacing a little
This commit is contained in:
Thomas Vander Stichele 2005-10-08 15:36:50 +00:00
parent d920233a73
commit 0a9dd40f25
2 changed files with 69 additions and 54 deletions

View file

@ -1,3 +1,9 @@
2005-10-08 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/typefind/gsttypefindfunctions.c: (utf8_type_find):
Fix leaks in typefind registration
Clean up the gratuitous commenting and whitespacing a little
2005-10-08 Wim Taymans <wim@fluendo.com> 2005-10-08 Wim Taymans <wim@fluendo.com>
* gst-libs/gst/audio/gstaudiosink.c: (gst_audioringbuffer_stop): * gst-libs/gst/audio/gstaudiosink.c: (gst_audioringbuffer_stop):

View file

@ -37,7 +37,7 @@
GST_DEBUG_CATEGORY_STATIC (type_find_debug); GST_DEBUG_CATEGORY_STATIC (type_find_debug);
#define GST_CAT_DEFAULT type_find_debug #define GST_CAT_DEFAULT type_find_debug
/*** text/plain ****************************************************************/ /*** text/plain ***/
static GstStaticCaps utf8_caps = GST_STATIC_CAPS ("text/plain"); static GstStaticCaps utf8_caps = GST_STATIC_CAPS ("text/plain");
@ -50,7 +50,8 @@ utf8_type_find (GstTypeFind * tf, gpointer unused)
/* randomly decided values */ /* randomly decided values */
guint size = 1024; /* starting size */ guint size = 1024; /* starting size */
guint probability = 95; /* starting probability */ guint probability = 95; /* starting probability */
guint step = 10; /* how much we reduce probability in each iteration */ guint step = 10; /* how much we reduce probability in each
* iteration */
while (probability > step) { while (probability > step) {
data = gst_type_find_peek (tf, 0, size); data = gst_type_find_peek (tf, 0, size);
@ -68,7 +69,7 @@ utf8_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** text/uri-list ************************************************************/ /*** text/uri-list ***/
static GstStaticCaps uri_caps = GST_STATIC_CAPS ("text/uri-list"); static GstStaticCaps uri_caps = GST_STATIC_CAPS ("text/uri-list");
@ -132,7 +133,7 @@ uri_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** video/x-fli **************************************************************/ /*** video/x-fli ***/
static GstStaticCaps flx_caps = GST_STATIC_CAPS ("video/x-fli"); static GstStaticCaps flx_caps = GST_STATIC_CAPS ("video/x-fli");
@ -163,7 +164,7 @@ flx_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** application/x-id3 **************************************************************/ /*** application/x-id3 ***/
static GstStaticCaps id3_caps = GST_STATIC_CAPS ("application/x-id3"); static GstStaticCaps id3_caps = GST_STATIC_CAPS ("application/x-id3");
@ -190,7 +191,7 @@ id3_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** application/x-ape **************************************************************/ /*** application/x-ape ***/
static GstStaticCaps apetag_caps = GST_STATIC_CAPS ("application/x-apetag"); static GstStaticCaps apetag_caps = GST_STATIC_CAPS ("application/x-apetag");
@ -215,7 +216,7 @@ apetag_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** audio/x-ttafile *********************************************************/ /*** audio/x-ttafile ***/
static GstStaticCaps tta_caps = GST_STATIC_CAPS ("audio/x-ttafile"); static GstStaticCaps tta_caps = GST_STATIC_CAPS ("audio/x-ttafile");
@ -233,7 +234,7 @@ tta_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** audio/mpeg version 2, 4 *************************************************/ /*** audio/mpeg version 2, 4 ***/
static GstStaticCaps aac_caps = GST_STATIC_CAPS ("audio/mpeg, " static GstStaticCaps aac_caps = GST_STATIC_CAPS ("audio/mpeg, "
"mpegversion = (int) { 2, 4 }, framed = (bool) false"); "mpegversion = (int) { 2, 4 }, framed = (bool) false");
@ -261,7 +262,7 @@ aac_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** audio/mpeg version 1 ****************************************************/ /*** audio/mpeg version 1 ***/
/* /*
* The chance that random data is identified as a valid mp3 header is 63 / 2^18 * The chance that random data is identified as a valid mp3 header is 63 / 2^18
@ -509,7 +510,7 @@ mp3_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** audio/x-ac3 **************************************************************/ /*** audio/x-ac3 ***/
static GstStaticCaps ac3_caps = GST_STATIC_CAPS ("audio/x-ac3"); static GstStaticCaps ac3_caps = GST_STATIC_CAPS ("audio/x-ac3");
#define AC3_CAPS (gst_static_caps_get(&ac3_caps)) #define AC3_CAPS (gst_static_caps_get(&ac3_caps))
@ -528,7 +529,7 @@ ac3_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** video/mpeg systemstream **************************************************/ /*** video/mpeg systemstream ***/
static GstStaticCaps mpeg_sys_caps = GST_STATIC_CAPS ("video/mpeg, " static GstStaticCaps mpeg_sys_caps = GST_STATIC_CAPS ("video/mpeg, "
"systemstream = (boolean) true, mpegversion = (int) [ 1, 2 ]"); "systemstream = (boolean) true, mpegversion = (int) [ 1, 2 ]");
@ -584,7 +585,7 @@ mpeg2_sys_type_find (GstTypeFind * tf, gpointer unused)
}; };
/* ATTANTION: ugly return value: /* ATTENTION: ugly return value:
* 0 - invalid data * 0 - invalid data
* 1 - not enough data * 1 - not enough data
* anything else - size until next package * anything else - size until next package
@ -723,7 +724,7 @@ mpeg1_sys_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** video/mpeg video stream **************************************************/ /*** video/mpeg video stream ***/
static GstStaticCaps mpeg_video_caps = GST_STATIC_CAPS ("video/mpeg, " static GstStaticCaps mpeg_video_caps = GST_STATIC_CAPS ("video/mpeg, "
"systemstream = (boolean) false"); "systemstream = (boolean) false");
@ -833,7 +834,7 @@ mpeg_video_stream_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** video/quicktime***********************************************************/ /*** video/quicktime***/
static GstStaticCaps qt_caps = GST_STATIC_CAPS ("video/quicktime"); static GstStaticCaps qt_caps = GST_STATIC_CAPS ("video/quicktime");
@ -886,7 +887,7 @@ qt_type_find (GstTypeFind * tf, gpointer unused)
} }
}; };
/*** audio/x-aiff *********************************************/ /*** audio/x-aiff ***/
static GstStaticCaps aiff_caps = GST_STATIC_CAPS ("audio/x-aiff"); static GstStaticCaps aiff_caps = GST_STATIC_CAPS ("audio/x-aiff");
@ -903,7 +904,7 @@ aiff_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** audio/x-aiff *********************************************/ /*** audio/x-aiff ***/
static GstStaticCaps svx_caps = GST_STATIC_CAPS ("audio/x-svx"); static GstStaticCaps svx_caps = GST_STATIC_CAPS ("audio/x-svx");
@ -920,7 +921,7 @@ svx_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** audio/x-shorten ****************************************/ /*** audio/x-shorten ***/
static GstStaticCaps shn_caps = GST_STATIC_CAPS ("audio/x-shorten"); static GstStaticCaps shn_caps = GST_STATIC_CAPS ("audio/x-shorten");
@ -939,7 +940,7 @@ shn_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** application/x-ape *********************************************/ /*** application/x-ape ***/
static GstStaticCaps ape_caps = GST_STATIC_CAPS ("application/x-ape"); static GstStaticCaps ape_caps = GST_STATIC_CAPS ("application/x-ape");
@ -954,7 +955,7 @@ ape_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** audio/x-m4a *********************************************/ /*** audio/x-m4a ***/
static GstStaticCaps m4a_caps = GST_STATIC_CAPS ("audio/x-m4a"); static GstStaticCaps m4a_caps = GST_STATIC_CAPS ("audio/x-m4a");
@ -969,7 +970,7 @@ m4a_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** application/x-3gp *********************************************/ /*** application/x-3gp ***/
/* /*
* The Q is there because variables can't start with a number. * The Q is there because variables can't start with a number.
@ -988,7 +989,7 @@ q3gp_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** audio/x-mod *********************************************/ /*** audio/x-mod ***/
static GstStaticCaps mod_caps = GST_STATIC_CAPS ("audio/x-mod"); static GstStaticCaps mod_caps = GST_STATIC_CAPS ("audio/x-mod");
@ -1107,7 +1108,7 @@ mod_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** application/x-shockwave-flash ********************************************/ /*** application/x-shockwave-flash ***/
static GstStaticCaps swf_caps = static GstStaticCaps swf_caps =
GST_STATIC_CAPS ("application/x-shockwave-flash"); GST_STATIC_CAPS ("application/x-shockwave-flash");
@ -1123,7 +1124,7 @@ swf_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** image/jpeg ***************************************************************/ /*** image/jpeg ***/
static GstStaticCaps jpeg_caps = GST_STATIC_CAPS ("image/jpeg"); static GstStaticCaps jpeg_caps = GST_STATIC_CAPS ("image/jpeg");
@ -1145,7 +1146,7 @@ jpeg_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** image/bmp *********************/ /*** image/bmp ***/
static GstStaticCaps bmp_caps = GST_STATIC_CAPS ("image/bmp"); static GstStaticCaps bmp_caps = GST_STATIC_CAPS ("image/bmp");
@ -1165,7 +1166,7 @@ bmp_type_find (GstTypeFind * tf, gpointer unused)
} }
} }
/*** image/tiff ********************/ /*** image/tiff ***/
static GstStaticCaps tiff_caps = GST_STATIC_CAPS ("image/tiff, " static GstStaticCaps tiff_caps = GST_STATIC_CAPS ("image/tiff, "
"endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }"); "endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }");
#define TIFF_CAPS (gst_static_caps_get(&tiff_caps)) #define TIFF_CAPS (gst_static_caps_get(&tiff_caps))
@ -1246,7 +1247,7 @@ ircam_type_find (GstTypeFind * tf, gpointer ununsed)
} }
/*** video/x-matroska ********************/ /*** video/x-matroska ***/
static GstStaticCaps matroska_caps = GST_STATIC_CAPS ("video/x-matroska"); static GstStaticCaps matroska_caps = GST_STATIC_CAPS ("video/x-matroska");
#define MATROSKA_CAPS (gst_static_caps_get(&matroska_caps)) #define MATROSKA_CAPS (gst_static_caps_get(&matroska_caps))
@ -1294,7 +1295,7 @@ matroska_type_find (GstTypeFind * tf, gpointer ununsed)
} }
} }
/*** video/x-dv ***************************************************************/ /*** video/x-dv ***/
static GstStaticCaps dv_caps = GST_STATIC_CAPS ("video/x-dv, " static GstStaticCaps dv_caps = GST_STATIC_CAPS ("video/x-dv, "
"systemstream = (boolean) true"); "systemstream = (boolean) true");
@ -1326,7 +1327,7 @@ dv_type_find (GstTypeFind * tf, gpointer private)
} }
/*** application/ogg and application/x-annodex *****************************/ /*** application/ogg and application/x-annodex ***/
static GstStaticCaps ogg_caps = GST_STATIC_CAPS ("application/ogg"); static GstStaticCaps ogg_caps = GST_STATIC_CAPS ("application/ogg");
static GstStaticCaps annodex_caps = GST_STATIC_CAPS ("application/x-annodex"); static GstStaticCaps annodex_caps = GST_STATIC_CAPS ("application/x-annodex");
static GstStaticCaps ogganx_caps = static GstStaticCaps ogganx_caps =
@ -1354,7 +1355,7 @@ ogganx_type_find (GstTypeFind * tf, gpointer private)
} }
} }
/*** audio/x-vorbis ***********************************************************/ /*** audio/x-vorbis ***/
static GstStaticCaps vorbis_caps = GST_STATIC_CAPS ("audio/x-vorbis"); static GstStaticCaps vorbis_caps = GST_STATIC_CAPS ("audio/x-vorbis");
#define VORBIS_CAPS (gst_static_caps_get(&vorbis_caps)) #define VORBIS_CAPS (gst_static_caps_get(&vorbis_caps))
@ -1398,7 +1399,7 @@ vorbis_type_find (GstTypeFind * tf, gpointer private)
} }
} }
/*** video/x-theora ***********************************************************/ /*** video/x-theora ***/
static GstStaticCaps theora_caps = GST_STATIC_CAPS ("video/x-theora"); static GstStaticCaps theora_caps = GST_STATIC_CAPS ("video/x-theora");
@ -1419,7 +1420,7 @@ theora_type_find (GstTypeFind * tf, gpointer private)
} }
} }
/*** application/x-ogm-video or audio*****************************************/ /*** application/x-ogm-video or audio***/
static GstStaticCaps ogmvideo_caps = static GstStaticCaps ogmvideo_caps =
GST_STATIC_CAPS ("application/x-ogm-video"); GST_STATIC_CAPS ("application/x-ogm-video");
@ -1466,7 +1467,7 @@ ogmtext_type_find (GstTypeFind * tf, gpointer private)
} }
} }
/*** audio/x-speex ***********************************************************/ /*** audio/x-speex ***/
static GstStaticCaps speex_caps = GST_STATIC_CAPS ("audio/x-speex"); static GstStaticCaps speex_caps = GST_STATIC_CAPS ("audio/x-speex");
@ -1502,7 +1503,7 @@ speex_type_find (GstTypeFind * tf, gpointer private)
} }
} }
/*** application/x-ogg-skeleton ***********************************************************/ /*** application/x-ogg-skeleton ***/
static GstStaticCaps ogg_skeleton_caps = static GstStaticCaps ogg_skeleton_caps =
GST_STATIC_CAPS ("application/x-ogg-skeleton"); GST_STATIC_CAPS ("application/x-ogg-skeleton");
#define OGG_SKELETON_CAPS (gst_static_caps_get(&ogg_skeleton_caps)) #define OGG_SKELETON_CAPS (gst_static_caps_get(&ogg_skeleton_caps))
@ -1563,6 +1564,7 @@ typedef struct
GstCaps *caps; GstCaps *caps;
} }
GstTypeFindData; GstTypeFindData;
static void static void
start_with_type_find (GstTypeFind * tf, gpointer private) start_with_type_find (GstTypeFind * tf, gpointer private)
{ {
@ -1585,11 +1587,14 @@ G_BEGIN_DECLS{ \
sw_data->size = _size; \ sw_data->size = _size; \
sw_data->probability = _probability; \ sw_data->probability = _probability; \
sw_data->caps = gst_caps_new_simple (name, NULL); \ sw_data->caps = gst_caps_new_simple (name, NULL); \
TYPE_FIND_REGISTER (plugin, name, rank, start_with_type_find, \ if (!gst_type_find_register (plugin, name, rank, start_with_type_find,\
ext, sw_data->caps, sw_data); \ ext, sw_data->caps, sw_data)) { \
gst_caps_unref (sw_data->caps); \
g_free (sw_data); \
} \
}G_END_DECLS }G_END_DECLS
/*** same for riff types ******************************************************/ /*** same for riff types ***/
static void static void
riff_type_find (GstTypeFind * tf, gpointer private) riff_type_find (GstTypeFind * tf, gpointer private)
@ -1611,13 +1616,17 @@ G_BEGIN_DECLS{ \
sw_data->size = 4; \ sw_data->size = 4; \
sw_data->probability = GST_TYPE_FIND_MAXIMUM; \ sw_data->probability = GST_TYPE_FIND_MAXIMUM; \
sw_data->caps = gst_caps_new_simple (name, NULL); \ sw_data->caps = gst_caps_new_simple (name, NULL); \
TYPE_FIND_REGISTER (plugin, name, rank, riff_type_find, \ if (!gst_type_find_register (plugin, name, rank, riff_type_find, \
ext, sw_data->caps, sw_data); \ ext, sw_data->caps, sw_data)) { \
gst_caps_unref (sw_data->caps); \
g_free (sw_data); \
} \
}G_END_DECLS }G_END_DECLS
/*** plugin initialization ****************************************************/ /*** plugin initialization ***/
#define TYPE_FIND_REGISTER(plugin,name,rank,func,ext,caps,priv) G_BEGIN_DECLS{\ #define TYPE_FIND_REGISTER(plugin,name,rank,func,ext,caps,priv) \
G_BEGIN_DECLS{\
if (!gst_type_find_register (plugin, name, rank, func, ext, caps, priv))\ if (!gst_type_find_register (plugin, name, rank, func, ext, caps, priv))\
return FALSE; \ return FALSE; \
}G_END_DECLS }G_END_DECLS