summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sourceforge.net>2008-08-26 12:27:11 +0000
committerStefan Kost <ensonic@users.sourceforge.net>2008-08-26 12:27:11 +0000
commit2ea5c05241edb2ca63967c3056a5ee3347bce576 (patch)
tree92308f8a507e4def3d777d91c11267033fa261eb /sys
parent4e2a12368b67934ae9a8680f9c3c92ac55b53ac1 (diff)
sys/v4l2/: Fix memory leaks. Small code cleanups : No need for empty _init(). No need to memset instance structures. ...
Original commit message from CVS: * sys/v4l2/gstv4l2object.c: * sys/v4l2/gstv4l2src.c: * sys/v4l2/gstv4l2src.h: * sys/v4l2/v4l2_calls.c: * sys/v4l2/v4l2src_calls.c: Fix memory leaks. Small code cleanups : No need for empty _init(). No need to memset instance structures. Some more FIXME's.
Diffstat (limited to 'sys')
-rw-r--r--sys/v4l2/gstv4l2object.c6
-rw-r--r--sys/v4l2/gstv4l2src.c5
-rw-r--r--sys/v4l2/gstv4l2src.h1
-rw-r--r--sys/v4l2/v4l2_calls.c5
-rw-r--r--sys/v4l2/v4l2src_calls.c28
5 files changed, 29 insertions, 16 deletions
diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c
index aff67364..ffc1046d 100644
--- a/sys/v4l2/gstv4l2object.c
+++ b/sys/v4l2/gstv4l2object.c
@@ -290,6 +290,12 @@ gst_v4l2_object_destroy (GstV4l2Object * v4l2object)
if (v4l2object->videodev)
g_free (v4l2object->videodev);
+ if (v4l2object->channel)
+ g_free (v4l2object->channel);
+
+ if (v4l2object->norm)
+ g_free (v4l2object->norm);
+
g_free (v4l2object);
}
diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c
index ce93ee73..7aed289b 100644
--- a/sys/v4l2/gstv4l2src.c
+++ b/sys/v4l2/gstv4l2src.c
@@ -354,6 +354,11 @@ gst_v4l2src_dispose (GObject * object)
gst_v4l2src_clear_format_list (v4l2src);
}
+ if (v4l2src->probed_caps) {
+ gst_caps_unref (v4l2src->probed_caps);
+ }
+
+
G_OBJECT_CLASS (parent_class)->dispose (object);
}
diff --git a/sys/v4l2/gstv4l2src.h b/sys/v4l2/gstv4l2src.h
index ae7aa74e..7c54d944 100644
--- a/sys/v4l2/gstv4l2src.h
+++ b/sys/v4l2/gstv4l2src.h
@@ -70,6 +70,7 @@ struct _GstV4l2Buffer {
struct v4l2_buffer vbuffer;
+ /* FIXME: have GstV4l2Src* instead, as this has GstV4l2BufferPool* */
GstV4l2BufferPool *pool;
};
diff --git a/sys/v4l2/v4l2_calls.c b/sys/v4l2/v4l2_calls.c
index f7cc2bd3..f318fc5b 100644
--- a/sys/v4l2/v4l2_calls.c
+++ b/sys/v4l2/v4l2_calls.c
@@ -313,8 +313,9 @@ gst_v4l2_fill_lists (GstV4l2Object * v4l2object)
channel->label = g_strdup ((const gchar *) control.name);
v4l2channel->id = n;
-#if 0 /* FIXME: it will be need just when handling private controls
- (currently none of base controls are of this type) */
+#if 0
+ /* FIXME: it will be need just when handling private controls
+ *(currently none of base controls are of this type) */
if (control.type == V4L2_CTRL_TYPE_MENU) {
struct v4l2_querymenu menu, *mptr;
diff --git a/sys/v4l2/v4l2src_calls.c b/sys/v4l2/v4l2src_calls.c
index f7e17059..b556cba7 100644
--- a/sys/v4l2/v4l2src_calls.c
+++ b/sys/v4l2/v4l2src_calls.c
@@ -67,6 +67,7 @@ static GstBufferClass *v4l2buffer_parent_class = NULL;
static gboolean
gst_v4l2src_get_nearest_size (GstV4l2Src * v4l2src, guint32 pixelformat,
gint * width, gint * height);
+static void gst_v4l2_buffer_pool_destroy (GstV4l2BufferPool * pool);
static void
gst_v4l2_buffer_finalize (GstV4l2Buffer * buffer)
@@ -113,12 +114,6 @@ gst_v4l2_buffer_finalize (GstV4l2Buffer * buffer)
}
static void
-gst_v4l2_buffer_init (GstV4l2Buffer * xvimage, gpointer g_class)
-{
- /* NOP */
-}
-
-static void
gst_v4l2_buffer_class_init (gpointer g_class, gpointer class_data)
{
GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
@@ -144,7 +139,7 @@ gst_v4l2_buffer_get_type (void)
NULL,
sizeof (GstV4l2Buffer),
0,
- (GInstanceInitFunc) gst_v4l2_buffer_init,
+ NULL,
NULL
};
_gst_v4l2_buffer_type = g_type_register_static (GST_TYPE_BUFFER,
@@ -163,9 +158,8 @@ gst_v4l2_buffer_new (GstV4l2BufferPool * pool, guint index, GstCaps * caps)
GST_LOG ("creating buffer %u, %p in pool %p", index, ret, pool);
- ret->pool = pool;
- gst_mini_object_ref (GST_MINI_OBJECT (pool));
- memset (&ret->vbuffer, 0x00, sizeof (ret->vbuffer));
+ ret->pool =
+ (GstV4l2BufferPool *) gst_mini_object_ref (GST_MINI_OBJECT (pool));
ret->vbuffer.index = index;
ret->vbuffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -237,9 +231,11 @@ gst_v4l2_buffer_pool_finalize (GstV4l2BufferPool * pool)
if (pool->video_fd >= 0)
close (pool->video_fd);
- if (pool->buffers)
+ if (pool->buffers) {
g_free (pool->buffers);
- pool->buffers = NULL;
+ pool->buffers = NULL;
+ }
+
GST_MINI_OBJECT_CLASS (buffer_pool_parent_class)->finalize (GST_MINI_OBJECT
(pool));
}
@@ -326,7 +322,7 @@ buffer_new_failed:
{
gint errnosave = errno;
- gst_mini_object_unref (GST_MINI_OBJECT (pool));
+ gst_v4l2_buffer_pool_destroy (pool);
errno = errnosave;
@@ -379,10 +375,14 @@ gst_v4l2_buffer_pool_destroy (GstV4l2BufferPool * pool)
pool->running = FALSE;
g_mutex_unlock (pool->lock);
+ GST_DEBUG ("destroy pool");
+
/* after this point, no more buffers will be queued or dequeued; no buffer
* from pool->buffers that is NULL will be set to a buffer, and no buffer that
* is not NULL will be pushed out. */
+ /* miniobjects have no dispose, so they can't break ref-cycles, as buffers ref
+ * the pool, we need to unref the buffer to properly finalize te pool */
for (n = 0; n < pool->buffer_count; n++) {
GstBuffer *buf;
@@ -956,7 +956,7 @@ default_frame_sizes:
/******************************************************
* gst_v4l2src_grab_frame ():
* grab a frame for capturing
- * return value: The captured frame number or -1 on error.
+ * return value: GST_FLOW_OK or GST_FLOW_ERROR
******************************************************/
GstFlowReturn
gst_v4l2src_grab_frame (GstV4l2Src * v4l2src, GstBuffer ** buf)