mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
Fix memory leaks. More to come.
Original commit message from CVS: * ext/alsaspdif/alsaspdifsink.c: * ext/timidity/gsttimidity.c: * ext/timidity/gstwildmidi.c: * gst/mpegvideoparse/mpegvideoparse.c: Fix memory leaks. More to come. * tests/check/Makefile.am: * tests/check/generic/states.c: Improved state change unit test.
This commit is contained in:
parent
7067d01d2a
commit
ac256b5d15
7 changed files with 161 additions and 37 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2007-09-20 Stefan Kost <ensonic@users.sf.net>
|
||||||
|
|
||||||
|
* ext/alsaspdif/alsaspdifsink.c:
|
||||||
|
* ext/timidity/gsttimidity.c:
|
||||||
|
* ext/timidity/gstwildmidi.c:
|
||||||
|
* gst/mpegvideoparse/mpegvideoparse.c:
|
||||||
|
Fix memory leaks. More to come.
|
||||||
|
|
||||||
|
* tests/check/Makefile.am:
|
||||||
|
* tests/check/generic/states.c:
|
||||||
|
Improved state change unit test.
|
||||||
|
|
||||||
2007-09-20 Wim Taymans <wim.taymans@gmail.com>
|
2007-09-20 Wim Taymans <wim.taymans@gmail.com>
|
||||||
|
|
||||||
* gst/rtpmanager/gstrtpbin.c: (on_ssrc_active), (create_session),
|
* gst/rtpmanager/gstrtpbin.c: (on_ssrc_active), (create_session),
|
||||||
|
|
|
@ -589,6 +589,7 @@ alsaspdifsink_find_pcm_device (AlsaSPDIFSink * sink)
|
||||||
beach:
|
beach:
|
||||||
if (pcm)
|
if (pcm)
|
||||||
snd_pcm_close (pcm);
|
snd_pcm_close (pcm);
|
||||||
|
snd_ctl_elem_list_clear (clist);
|
||||||
snd_ctl_close (ctl);
|
snd_ctl_close (ctl);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -818,17 +818,19 @@ static gboolean
|
||||||
plugin_init (GstPlugin * plugin)
|
plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
static gchar *exts[] = { "mid", "midi", NULL };
|
static gchar *exts[] = { "mid", "midi", NULL };
|
||||||
/* exchange the strings 'plugin' and 'Template plugin' with your
|
GstCaps *caps;
|
||||||
* plugin name and description */
|
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_timidity_debug, "timidity",
|
GST_DEBUG_CATEGORY_INIT (gst_timidity_debug, "timidity",
|
||||||
0, "Timidity plugin");
|
0, "Timidity plugin");
|
||||||
|
|
||||||
|
caps = gst_caps_new_simple ("audio/midi", NULL);
|
||||||
if (!gst_type_find_register (plugin, "audio/midi", GST_RANK_PRIMARY,
|
if (!gst_type_find_register (plugin, "audio/midi", GST_RANK_PRIMARY,
|
||||||
gst_timidity_typefind, exts,
|
gst_timidity_typefind, exts, caps, NULL, NULL)) {
|
||||||
gst_caps_new_simple ("audio/midi", NULL), NULL, NULL)) {
|
|
||||||
GST_WARNING ("can't register typefind");
|
GST_WARNING ("can't register typefind");
|
||||||
|
gst_caps_unref (caps);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
|
||||||
return gst_element_register (plugin, "timidity",
|
return gst_element_register (plugin, "timidity",
|
||||||
GST_RANK_PRIMARY, GST_TYPE_TIMIDITY);
|
GST_RANK_PRIMARY, GST_TYPE_TIMIDITY);
|
||||||
|
|
|
@ -912,17 +912,19 @@ static gboolean
|
||||||
plugin_init (GstPlugin * plugin)
|
plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
static gchar *exts[] = { "mid", "midi", NULL };
|
static gchar *exts[] = { "mid", "midi", NULL };
|
||||||
/* exchange the strings 'plugin' and 'Template plugin' with your
|
GstCaps *caps;
|
||||||
* plugin name and description */
|
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_wildmidi_debug, "wildmidi",
|
GST_DEBUG_CATEGORY_INIT (gst_wildmidi_debug, "wildmidi",
|
||||||
0, "Wildmidi plugin");
|
0, "Wildmidi plugin");
|
||||||
|
|
||||||
|
caps = gst_caps_new_simple ("audio/midi", NULL);
|
||||||
if (!gst_type_find_register (plugin, "audio/midi", GST_RANK_SECONDARY,
|
if (!gst_type_find_register (plugin, "audio/midi", GST_RANK_SECONDARY,
|
||||||
gst_wildmidi_typefind, exts,
|
gst_wildmidi_typefind, exts, caps, NULL, NULL)) {
|
||||||
gst_caps_new_simple ("audio/midi", NULL), NULL, NULL)) {
|
|
||||||
GST_WARNING ("can't register typefind");
|
GST_WARNING ("can't register typefind");
|
||||||
|
gst_caps_unref (caps);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
|
||||||
return gst_element_register (plugin, "wildmidi",
|
return gst_element_register (plugin, "wildmidi",
|
||||||
GST_RANK_SECONDARY, GST_TYPE_WILDMIDI);
|
GST_RANK_SECONDARY, GST_TYPE_WILDMIDI);
|
||||||
|
|
|
@ -89,7 +89,7 @@ enum
|
||||||
static void gst_mpegvideoparse_class_init (MpegVideoParseClass * klass);
|
static void gst_mpegvideoparse_class_init (MpegVideoParseClass * klass);
|
||||||
static void gst_mpegvideoparse_base_init (MpegVideoParseClass * klass);
|
static void gst_mpegvideoparse_base_init (MpegVideoParseClass * klass);
|
||||||
static void gst_mpegvideoparse_init (MpegVideoParse * mpegvideoparse);
|
static void gst_mpegvideoparse_init (MpegVideoParse * mpegvideoparse);
|
||||||
static void gst_mpegvideoparse_dispose (MpegVideoParse * mpegvideoparse);
|
static void gst_mpegvideoparse_dispose (GObject * object);
|
||||||
|
|
||||||
static GstFlowReturn gst_mpegvideoparse_chain (GstPad * pad, GstBuffer * buf);
|
static GstFlowReturn gst_mpegvideoparse_chain (GstPad * pad, GstBuffer * buf);
|
||||||
static gboolean mpv_parse_sink_event (GstPad * pad, GstEvent * event);
|
static gboolean mpv_parse_sink_event (GstPad * pad, GstEvent * event);
|
||||||
|
@ -185,10 +185,14 @@ gst_mpegvideoparse_init (MpegVideoParse * mpegvideoparse)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_mpegvideoparse_dispose (MpegVideoParse * mpegvideoparse)
|
gst_mpegvideoparse_dispose (GObject * object)
|
||||||
{
|
{
|
||||||
|
MpegVideoParse *mpegvideoparse = GST_MPEGVIDEOPARSE (object);
|
||||||
|
|
||||||
mpeg_packetiser_free (&mpegvideoparse->packer);
|
mpeg_packetiser_free (&mpegvideoparse->packer);
|
||||||
gst_buffer_replace (&mpegvideoparse->seq_hdr_buf, NULL);
|
gst_buffer_replace (&mpegvideoparse->seq_hdr_buf, NULL);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
include $(top_srcdir)/common/check.mak
|
include $(top_srcdir)/common/check.mak
|
||||||
|
|
||||||
CHECK_REGISTRY = $(top_builddir)/tests/check/test-registry.xml
|
CHECK_REGISTRY = $(top_builddir)/tests/check/test-registry.reg
|
||||||
|
|
||||||
GST_TOOLS_DIR = $(top_builddir)/tools
|
GST_TOOLS_DIR = $(top_builddir)/tools
|
||||||
|
|
||||||
|
@ -12,7 +12,8 @@ REGISTRY_ENVIRONMENT = \
|
||||||
TESTS_ENVIRONMENT = \
|
TESTS_ENVIRONMENT = \
|
||||||
$(REGISTRY_ENVIRONMENT) \
|
$(REGISTRY_ENVIRONMENT) \
|
||||||
GST_PLUGIN_SYSTEM_PATH= \
|
GST_PLUGIN_SYSTEM_PATH= \
|
||||||
GST_PLUGIN_PATH=$(top_builddir)/gst:$(top_builddir)/sys:$(top_builddir)/ext:$(GSTPB_PLUGINS_DIR):$(GST_PLUGINS_DIR)
|
GST_PLUGIN_PATH=$(top_builddir)/gst:$(top_builddir)/sys:$(top_builddir)/ext:$(GSTPB_PLUGINS_DIR):$(GST_PLUGINS_DIR) \
|
||||||
|
STATE_IGNORE_ELEMENTS="glimagesink"
|
||||||
|
|
||||||
plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@
|
plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@
|
||||||
install-pluginLTLIBRARIES:
|
install-pluginLTLIBRARIES:
|
||||||
|
|
||||||
# the core dumps of some machines have PIDs appended
|
# the core dumps of some machines have PIDs appended
|
||||||
CLEANFILES = core.* test-registry.xml
|
CLEANFILES = core.* test-registry.*
|
||||||
|
|
||||||
SUPPRESSIONS = $(top_srcdir)/common/gst.supp $(srcdir)/gst-plugins-bad.supp
|
SUPPRESSIONS = $(top_srcdir)/common/gst.supp $(srcdir)/gst-plugins-bad.supp
|
||||||
|
|
||||||
|
|
|
@ -28,15 +28,17 @@
|
||||||
|
|
||||||
#include <gst/check/gstcheck.h>
|
#include <gst/check/gstcheck.h>
|
||||||
|
|
||||||
GST_START_TEST (test_state_changes)
|
static GList *elements = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup ()
|
||||||
{
|
{
|
||||||
GstElement *element;
|
|
||||||
GList *features, *f;
|
GList *features, *f;
|
||||||
GList *plugins, *p;
|
GList *plugins, *p;
|
||||||
gchar **ignorelist = NULL;
|
gchar **ignorelist = NULL;
|
||||||
const gchar *STATE_IGNORE_ELEMENTS = NULL;
|
const gchar *STATE_IGNORE_ELEMENTS = NULL;
|
||||||
|
|
||||||
GST_DEBUG ("testing elements from source %s", PACKAGE);
|
GST_DEBUG ("getting elements for package %s", PACKAGE);
|
||||||
STATE_IGNORE_ELEMENTS = g_getenv ("STATE_IGNORE_ELEMENTS");
|
STATE_IGNORE_ELEMENTS = g_getenv ("STATE_IGNORE_ELEMENTS");
|
||||||
if (STATE_IGNORE_ELEMENTS) {
|
if (STATE_IGNORE_ELEMENTS) {
|
||||||
GST_DEBUG ("Will ignore element factories: '%s'", STATE_IGNORE_ELEMENTS);
|
GST_DEBUG ("Will ignore element factories: '%s'", STATE_IGNORE_ELEMENTS);
|
||||||
|
@ -76,26 +78,8 @@ GST_START_TEST (test_state_changes)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG ("testing element %s", name);
|
GST_DEBUG ("adding element %s", name);
|
||||||
element = gst_element_factory_make (name, name);
|
elements = g_list_prepend (elements, (gpointer) g_strdup (name));
|
||||||
fail_if (element == NULL, "Could not make element from factory %s", name);
|
|
||||||
|
|
||||||
if (GST_IS_PIPELINE (element)) {
|
|
||||||
GST_DEBUG ("element %s is a pipeline", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_element_set_state (element, GST_STATE_READY);
|
|
||||||
gst_element_set_state (element, GST_STATE_PAUSED);
|
|
||||||
gst_element_set_state (element, GST_STATE_PLAYING);
|
|
||||||
gst_element_set_state (element, GST_STATE_PAUSED);
|
|
||||||
gst_element_set_state (element, GST_STATE_READY);
|
|
||||||
gst_element_set_state (element, GST_STATE_NULL);
|
|
||||||
gst_element_set_state (element, GST_STATE_PAUSED);
|
|
||||||
gst_element_set_state (element, GST_STATE_READY);
|
|
||||||
gst_element_set_state (element, GST_STATE_PLAYING);
|
|
||||||
gst_element_set_state (element, GST_STATE_PAUSED);
|
|
||||||
gst_element_set_state (element, GST_STATE_NULL);
|
|
||||||
gst_object_unref (GST_OBJECT (element));
|
|
||||||
}
|
}
|
||||||
gst_plugin_feature_list_free (features);
|
gst_plugin_feature_list_free (features);
|
||||||
}
|
}
|
||||||
|
@ -103,8 +87,123 @@ GST_START_TEST (test_state_changes)
|
||||||
g_strfreev (ignorelist);
|
g_strfreev (ignorelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
teardown ()
|
||||||
|
{
|
||||||
|
GList *e;
|
||||||
|
|
||||||
|
for (e = elements; e; e = e->next) {
|
||||||
|
g_free (e->data);
|
||||||
|
}
|
||||||
|
g_list_free (elements);
|
||||||
|
elements = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GST_START_TEST (test_state_changes_up_and_down_seq)
|
||||||
|
{
|
||||||
|
GstElement *element;
|
||||||
|
GList *e;
|
||||||
|
|
||||||
|
for (e = elements; e; e = e->next) {
|
||||||
|
const gchar *name = e->data;
|
||||||
|
|
||||||
|
GST_DEBUG ("testing element %s", name);
|
||||||
|
element = gst_element_factory_make (name, name);
|
||||||
|
fail_if (element == NULL, "Could not make element from factory %s", name);
|
||||||
|
|
||||||
|
if (GST_IS_PIPELINE (element)) {
|
||||||
|
GST_DEBUG ("element %s is a pipeline", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_element_set_state (element, GST_STATE_READY);
|
||||||
|
gst_element_set_state (element, GST_STATE_PAUSED);
|
||||||
|
gst_element_set_state (element, GST_STATE_PLAYING);
|
||||||
|
gst_element_set_state (element, GST_STATE_PAUSED);
|
||||||
|
gst_element_set_state (element, GST_STATE_READY);
|
||||||
|
gst_element_set_state (element, GST_STATE_NULL);
|
||||||
|
gst_element_set_state (element, GST_STATE_PAUSED);
|
||||||
|
gst_element_set_state (element, GST_STATE_READY);
|
||||||
|
gst_element_set_state (element, GST_STATE_PLAYING);
|
||||||
|
gst_element_set_state (element, GST_STATE_PAUSED);
|
||||||
|
gst_element_set_state (element, GST_STATE_NULL);
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
|
GST_START_TEST (test_state_changes_up_seq)
|
||||||
|
{
|
||||||
|
GstElement *element;
|
||||||
|
GList *e;
|
||||||
|
|
||||||
|
for (e = elements; e; e = e->next) {
|
||||||
|
const gchar *name = e->data;
|
||||||
|
|
||||||
|
GST_DEBUG ("testing element %s", name);
|
||||||
|
element = gst_element_factory_make (name, name);
|
||||||
|
fail_if (element == NULL, "Could not make element from factory %s", name);
|
||||||
|
|
||||||
|
if (GST_IS_PIPELINE (element)) {
|
||||||
|
GST_DEBUG ("element %s is a pipeline", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_element_set_state (element, GST_STATE_READY);
|
||||||
|
|
||||||
|
gst_element_set_state (element, GST_STATE_PAUSED);
|
||||||
|
gst_element_set_state (element, GST_STATE_READY);
|
||||||
|
|
||||||
|
gst_element_set_state (element, GST_STATE_PAUSED);
|
||||||
|
gst_element_set_state (element, GST_STATE_PLAYING);
|
||||||
|
gst_element_set_state (element, GST_STATE_PAUSED);
|
||||||
|
gst_element_set_state (element, GST_STATE_READY);
|
||||||
|
|
||||||
|
gst_element_set_state (element, GST_STATE_NULL);
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
GST_START_TEST (test_state_changes_down_seq)
|
||||||
|
{
|
||||||
|
GstElement *element;
|
||||||
|
GList *e;
|
||||||
|
|
||||||
|
for (e = elements; e; e = e->next) {
|
||||||
|
const gchar *name = e->data;
|
||||||
|
|
||||||
|
GST_DEBUG ("testing element %s", name);
|
||||||
|
element = gst_element_factory_make (name, name);
|
||||||
|
fail_if (element == NULL, "Could not make element from factory %s", name);
|
||||||
|
|
||||||
|
if (GST_IS_PIPELINE (element)) {
|
||||||
|
GST_DEBUG ("element %s is a pipeline", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_element_set_state (element, GST_STATE_READY);
|
||||||
|
gst_element_set_state (element, GST_STATE_PAUSED);
|
||||||
|
gst_element_set_state (element, GST_STATE_PLAYING);
|
||||||
|
|
||||||
|
gst_element_set_state (element, GST_STATE_PAUSED);
|
||||||
|
gst_element_set_state (element, GST_STATE_PLAYING);
|
||||||
|
|
||||||
|
gst_element_set_state (element, GST_STATE_PAUSED);
|
||||||
|
gst_element_set_state (element, GST_STATE_READY);
|
||||||
|
gst_element_set_state (element, GST_STATE_PAUSED);
|
||||||
|
gst_element_set_state (element, GST_STATE_PLAYING);
|
||||||
|
|
||||||
|
gst_element_set_state (element, GST_STATE_PAUSED);
|
||||||
|
gst_element_set_state (element, GST_STATE_READY);
|
||||||
|
gst_element_set_state (element, GST_STATE_NULL);
|
||||||
|
gst_object_unref (GST_OBJECT (element));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
|
||||||
Suite *
|
Suite *
|
||||||
states_suite (void)
|
states_suite (void)
|
||||||
{
|
{
|
||||||
|
@ -112,7 +211,10 @@ states_suite (void)
|
||||||
TCase *tc_chain = tcase_create ("general");
|
TCase *tc_chain = tcase_create ("general");
|
||||||
|
|
||||||
suite_add_tcase (s, tc_chain);
|
suite_add_tcase (s, tc_chain);
|
||||||
tcase_add_test (tc_chain, test_state_changes);
|
tcase_add_checked_fixture (tc_chain, setup, teardown);
|
||||||
|
tcase_add_test (tc_chain, test_state_changes_up_and_down_seq);
|
||||||
|
tcase_add_test (tc_chain, test_state_changes_up_seq);
|
||||||
|
tcase_add_test (tc_chain, test_state_changes_down_seq);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue