+2004-03-21 Tim-Philipp Müller <t.i.m@zen.co.uk>
+
+ reviewed by Benjamin Otte <otte@gnome.org>
+
+ * gst/autoplug/gstspider.c: (gst_spider_dispose):
+ * gst/elements/gstaggregator.c: (gst_aggregator_finalize),
+ (gst_aggregator_class_init), (gst_aggregator_init):
+ * gst/elements/gstfilesrc.c: (gst_filesrc_init),
+ (gst_filesrc_dispose), (gst_filesrc_set_location):
+ * gst/elements/gstidentity.c: (gst_identity_finalize),
+ (gst_identity_class_init), (gst_identity_chain):
+ * gst/elements/gstmultifilesrc.c: (gst_multifilesrc_open_file):
+ * gst/elements/gststatistics.c: (gst_statistics_finalize),
+ (gst_statistics_class_init):
+ * gst/elements/gsttee.c: (gst_tee_finalize), (gst_tee_class_init),
+ (gst_tee_get_property):
+ clean up used memory in this elements correctly on teardown (closes
+ #137279)
+
2004-03-20 Colin Walters <walters@redhat.com>
* gst/registries/gstxmlregistry.c:
spider = GST_SPIDER (object);
g_list_free (spider->factories);
+ spider->factories = NULL;
((GObjectClass *) parent_class)->dispose (object);
}
GstPadTemplate * temp, const gchar * unused);
static void gst_aggregator_update_functions (GstAggregator * aggregator);
+static void gst_aggregator_finalize (GObject * object);
static void gst_aggregator_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_aggregator_get_property (GObject * object, guint prop_id,
gst_static_pad_template_get (&aggregator_src_template));
gst_element_class_set_details (gstelement_class, &gst_aggregator_details);
}
+
+static void
+gst_aggregator_finalize (GObject * object)
+{
+ GstAggregator *aggregator;
+
+ aggregator = GST_AGGREGATOR (object);
+
+ g_list_free (aggregator->sinkpads);
+ g_free (aggregator->last_message);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
static void
gst_aggregator_class_init (GstAggregatorClass * klass)
{
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
-
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS,
g_param_spec_int ("num_pads", "Num pads", "The number of source pads",
0, G_MAXINT, 0, G_PARAM_READABLE));
g_param_spec_string ("last_message", "Last message",
"The current state of the element", NULL, G_PARAM_READABLE));
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_aggregator_finalize);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_aggregator_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_aggregator_get_property);
aggregator->sinkpads = NULL;
aggregator->silent = FALSE;
aggregator->sched = AGGREGATOR_LOOP;
+ aggregator->last_message = NULL;
gst_aggregator_update_functions (aggregator);
}
src->filename = NULL;
src->fd = 0;
src->filelen = 0;
+ src->uri = NULL;
src->curoffset = 0;
src->block_size = DEFAULT_BLOCKSIZE;
src = GST_FILESRC (object);
- G_OBJECT_CLASS (parent_class)->dispose (object);
+ g_free (src->filename);
+ g_free (src->uri);
+
+ /* dispose may be called multiple times */
+ src->filename = NULL;
+ src->uri = NULL;
- if (src->filename)
- g_free (src->filename);
- if (src->uri)
- g_free (src->uri);
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
static gboolean
if (GST_STATE (src) != GST_STATE_READY && GST_STATE (src) != GST_STATE_NULL)
return FALSE;
- if (src->filename)
- g_free (src->filename);
- if (src->uri)
- g_free (src->uri);
+ g_free (src->filename);
+ g_free (src->uri);
+
/* clear the filename if we get a NULL (is that possible?) */
if (location == NULL) {
src->filename = NULL;
GST_BOILERPLATE_FULL (GstIdentity, gst_identity, GstElement, GST_TYPE_ELEMENT,
_do_init);
+static void gst_identity_finalize (GObject * object);
static void gst_identity_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_identity_get_property (GObject * object, guint prop_id,
gst_element_class_set_details (gstelement_class, &gst_identity_details);
}
+
+static void
+gst_identity_finalize (GObject * object)
+{
+ GstIdentity *identity;
+
+ identity = GST_IDENTITY (object);
+
+ g_free (identity->last_message);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
static void
gst_identity_class_init (GstIdentityClass * klass)
{
G_STRUCT_OFFSET (GstIdentityClass, handoff), NULL, NULL,
gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, GST_TYPE_BUFFER);
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_identity_finalize);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_identity_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_identity_get_property);
}
if (identity->drop_probability > 0.0) {
if ((gfloat) (1.0 * rand () / (RAND_MAX)) < identity->drop_probability) {
- if (identity->last_message != NULL) {
- g_free (identity->last_message);
- }
+ g_free (identity->last_message);
identity->last_message =
g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, %"
G_GINT64_FORMAT ")", GST_DEBUG_PAD_NAME (identity->sinkpad),
return FALSE;
}
- /* open the file */
+ /* open the file. FIXME: do we need to use O_LARGEFILE here? */
src->fd = open ((const char *) src->currentfilename, O_RDONLY);
if (src->fd < 0) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
/* find the file length */
src->size = lseek (src->fd, 0, SEEK_END);
lseek (src->fd, 0, SEEK_SET);
- /* map the file into memory */
+ /* map the file into memory.
+ * FIXME: don't map the whole file at once, there might
+ * be restrictions set. Get max size via getrlimit
+ * or re-try with smaller size if mmap fails with ENOMEM? */
src->map = mmap (NULL, src->size, PROT_READ, MAP_SHARED, src->fd, 0);
- madvise (src->map, src->size, 2);
+ madvise (src->map, src->size, MADV_SEQUENTIAL);
/* collapse state if that failed */
if (src->map == NULL) {
close (src->fd);
GST_BOILERPLATE_FULL (GstStatistics, gst_statistics, GstElement,
GST_TYPE_ELEMENT, _do_init);
+static void gst_statistics_finalize (GObject * object);
static void gst_statistics_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_statistics_get_property (GObject * object, guint prop_id,
gst_element_class_set_details (gstelement_class, &gst_statistics_details);
}
+
+static void
+gst_statistics_finalize (GObject * object)
+{
+ GstStatistics *statistics;
+
+ statistics = GST_STATISTICS (object);
+
+ if (statistics->timer)
+ g_timer_destroy (statistics->timer);
+
+ if (statistics->last_timer)
+ g_timer_destroy (statistics->last_timer);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
static void
gst_statistics_class_init (GstStatisticsClass * klass)
{
G_STRUCT_OFFSET (GstStatisticsClass, update), NULL, NULL,
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_statistics_finalize);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_statistics_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_statistics_get_property);
}
static GstPad *gst_tee_request_new_pad (GstElement * element,
GstPadTemplate * temp, const gchar * unused);
+static void gst_tee_finalize (GObject * object);
static void gst_tee_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_tee_get_property (GObject * object, guint prop_id,
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&tee_src_template));
}
+
+static void
+gst_tee_finalize (GObject * object)
+{
+ GstTee *tee;
+
+ tee = GST_TEE (object);
+
+ g_free (tee->last_message);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
static void
gst_tee_class_init (GstTeeClass * klass)
{
NULL, G_PARAM_READABLE));
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_tee_finalize);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_tee_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_tee_get_property);
g_value_set_boolean (value, tee->silent);
break;
case ARG_LAST_MESSAGE:
- g_value_set_string ((GValue *) value, tee->last_message);
+ g_value_set_string (value, tee->last_message);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
GstPadTemplate * temp, const gchar * unused);
static void gst_aggregator_update_functions (GstAggregator * aggregator);
+static void gst_aggregator_finalize (GObject * object);
static void gst_aggregator_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_aggregator_get_property (GObject * object, guint prop_id,
gst_static_pad_template_get (&aggregator_src_template));
gst_element_class_set_details (gstelement_class, &gst_aggregator_details);
}
+
+static void
+gst_aggregator_finalize (GObject * object)
+{
+ GstAggregator *aggregator;
+
+ aggregator = GST_AGGREGATOR (object);
+
+ g_list_free (aggregator->sinkpads);
+ g_free (aggregator->last_message);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
static void
gst_aggregator_class_init (GstAggregatorClass * klass)
{
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
-
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS,
g_param_spec_int ("num_pads", "Num pads", "The number of source pads",
0, G_MAXINT, 0, G_PARAM_READABLE));
g_param_spec_string ("last_message", "Last message",
"The current state of the element", NULL, G_PARAM_READABLE));
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_aggregator_finalize);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_aggregator_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_aggregator_get_property);
aggregator->sinkpads = NULL;
aggregator->silent = FALSE;
aggregator->sched = AGGREGATOR_LOOP;
+ aggregator->last_message = NULL;
gst_aggregator_update_functions (aggregator);
}
src->filename = NULL;
src->fd = 0;
src->filelen = 0;
+ src->uri = NULL;
src->curoffset = 0;
src->block_size = DEFAULT_BLOCKSIZE;
src = GST_FILESRC (object);
- G_OBJECT_CLASS (parent_class)->dispose (object);
+ g_free (src->filename);
+ g_free (src->uri);
+
+ /* dispose may be called multiple times */
+ src->filename = NULL;
+ src->uri = NULL;
- if (src->filename)
- g_free (src->filename);
- if (src->uri)
- g_free (src->uri);
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
static gboolean
if (GST_STATE (src) != GST_STATE_READY && GST_STATE (src) != GST_STATE_NULL)
return FALSE;
- if (src->filename)
- g_free (src->filename);
- if (src->uri)
- g_free (src->uri);
+ g_free (src->filename);
+ g_free (src->uri);
+
/* clear the filename if we get a NULL (is that possible?) */
if (location == NULL) {
src->filename = NULL;
GST_BOILERPLATE_FULL (GstIdentity, gst_identity, GstElement, GST_TYPE_ELEMENT,
_do_init);
+static void gst_identity_finalize (GObject * object);
static void gst_identity_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_identity_get_property (GObject * object, guint prop_id,
gst_element_class_set_details (gstelement_class, &gst_identity_details);
}
+
+static void
+gst_identity_finalize (GObject * object)
+{
+ GstIdentity *identity;
+
+ identity = GST_IDENTITY (object);
+
+ g_free (identity->last_message);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
static void
gst_identity_class_init (GstIdentityClass * klass)
{
G_STRUCT_OFFSET (GstIdentityClass, handoff), NULL, NULL,
gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, GST_TYPE_BUFFER);
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_identity_finalize);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_identity_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_identity_get_property);
}
if (identity->drop_probability > 0.0) {
if ((gfloat) (1.0 * rand () / (RAND_MAX)) < identity->drop_probability) {
- if (identity->last_message != NULL) {
- g_free (identity->last_message);
- }
+ g_free (identity->last_message);
identity->last_message =
g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, %"
G_GINT64_FORMAT ")", GST_DEBUG_PAD_NAME (identity->sinkpad),
return FALSE;
}
- /* open the file */
+ /* open the file. FIXME: do we need to use O_LARGEFILE here? */
src->fd = open ((const char *) src->currentfilename, O_RDONLY);
if (src->fd < 0) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
/* find the file length */
src->size = lseek (src->fd, 0, SEEK_END);
lseek (src->fd, 0, SEEK_SET);
- /* map the file into memory */
+ /* map the file into memory.
+ * FIXME: don't map the whole file at once, there might
+ * be restrictions set. Get max size via getrlimit
+ * or re-try with smaller size if mmap fails with ENOMEM? */
src->map = mmap (NULL, src->size, PROT_READ, MAP_SHARED, src->fd, 0);
- madvise (src->map, src->size, 2);
+ madvise (src->map, src->size, MADV_SEQUENTIAL);
/* collapse state if that failed */
if (src->map == NULL) {
close (src->fd);
GST_BOILERPLATE_FULL (GstStatistics, gst_statistics, GstElement,
GST_TYPE_ELEMENT, _do_init);
+static void gst_statistics_finalize (GObject * object);
static void gst_statistics_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_statistics_get_property (GObject * object, guint prop_id,
gst_element_class_set_details (gstelement_class, &gst_statistics_details);
}
+
+static void
+gst_statistics_finalize (GObject * object)
+{
+ GstStatistics *statistics;
+
+ statistics = GST_STATISTICS (object);
+
+ if (statistics->timer)
+ g_timer_destroy (statistics->timer);
+
+ if (statistics->last_timer)
+ g_timer_destroy (statistics->last_timer);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
static void
gst_statistics_class_init (GstStatisticsClass * klass)
{
G_STRUCT_OFFSET (GstStatisticsClass, update), NULL, NULL,
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_statistics_finalize);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_statistics_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_statistics_get_property);
}
static GstPad *gst_tee_request_new_pad (GstElement * element,
GstPadTemplate * temp, const gchar * unused);
+static void gst_tee_finalize (GObject * object);
static void gst_tee_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_tee_get_property (GObject * object, guint prop_id,
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&tee_src_template));
}
+
+static void
+gst_tee_finalize (GObject * object)
+{
+ GstTee *tee;
+
+ tee = GST_TEE (object);
+
+ g_free (tee->last_message);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
static void
gst_tee_class_init (GstTeeClass * klass)
{
NULL, G_PARAM_READABLE));
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_tee_finalize);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_tee_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_tee_get_property);
g_value_set_boolean (value, tee->silent);
break;
case ARG_LAST_MESSAGE:
- g_value_set_string ((GValue *) value, tee->last_message);
+ g_value_set_string (value, tee->last_message);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);