[0.11] gstreamer: adapter: automatically unmap on clearing

Mark Nauwelaerts mnauw at kemper.freedesktop.org
Sat Jan 14 11:53:15 PST 2012

Module: gstreamer
Branch: 0.11
Commit: 12757e604a894533b8fcd80a128eee528a613851
URL:    http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=12757e604a894533b8fcd80a128eee528a613851

Author: Vincent Penquerc'h <vincent.penquerch at collabora.co.uk>
Date:   Tue Nov 15 17:42:56 2011 +0000

adapter: automatically unmap on clearing

When _clear gets called between _map and _unmap, buffers
will be unreffed. If the adapter was mapped, memory leaks
may occur.
While calling _clear between _map and _unmap does not seem
like such a great idea, this is possible in the audio
encoder base class, as _clear may be called in _finish_frame.
Since the audio encoder relies on flushing to keep track of
timestamps, delaying flushing till after handle_frame seems
So, we unmap on clear, as the next unmap will do nothing.
This makes _clear safe to call between _map and _unmap,
while avoiding leaking the mapped buffer.



 libs/gst/base/gstadapter.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/libs/gst/base/gstadapter.c b/libs/gst/base/gstadapter.c
index 3604019..2f14541 100644
--- a/libs/gst/base/gstadapter.c
+++ b/libs/gst/base/gstadapter.c
@@ -216,6 +216,10 @@ gst_adapter_clear (GstAdapter * adapter)
   g_return_if_fail (GST_IS_ADAPTER (adapter));
+  if (adapter->priv->cdata) {
+    gst_adapter_unmap (adapter);
+  }
   g_slist_foreach (adapter->buflist, (GFunc) gst_mini_object_unref, NULL);
   g_slist_free (adapter->buflist);
   adapter->buflist = NULL;

More information about the gstreamer-commits mailing list