[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [phonon-gstreamer/1.0-porting-for-merge] gstreamer: Fix various memory leaks
From:       Dan_Vrátil <dvratil () redhat ! com>
Date:       2014-08-12 14:39:07
Message-ID: E1XHDEB-00073J-C4 () scm ! kde ! org
[Download RAW message or body]

Git commit cfd4eb6c892970e7084a72b5bdaf961c48c04526 by Dan Vrátil.
Committed on 12/08/2014 at 10:05.
Pushed by dvratil into branch '1.0-porting-for-merge'.

Fix various memory leaks

The code is not unref'ing some structures we got from gstreamer. This is probably
leftover from gst-0.10 times, when the ownership situation might have been different.

I still suspect various leaks over the place, but that needs deeper investigation.

M  +1    -0    gstreamer/audiodataoutput.cpp
M  +1    -0    gstreamer/backend.cpp
M  +1    -0    gstreamer/mediaobject.cpp
M  +4    -2    gstreamer/pipeline.cpp
M  +6    -4    gstreamer/videowidget.cpp

http://commits.kde.org/phonon-gstreamer/cfd4eb6c892970e7084a72b5bdaf961c48c04526

diff --git a/gstreamer/audiodataoutput.cpp b/gstreamer/audiodataoutput.cpp
index 11ad7b8..e7e9c14 100644
--- a/gstreamer/audiodataoutput.cpp
+++ b/gstreamer/audiodataoutput.cpp
@@ -124,6 +124,7 @@ void AudioDataOutput::processBuffer(GstElement*, GstBuffer* buffer, GstPad* pad,
     GstCaps *caps = gst_pad_get_current_caps(GST_PAD(pad));
     GstStructure *structure = gst_caps_get_structure(caps, 0);
     gst_structure_get_int(structure, "channels", &that->m_channels);
+    gst_caps_unref(caps);
 
     // Let's get the buffers
     gint16 *gstBufferData;
diff --git a/gstreamer/backend.cpp b/gstreamer/backend.cpp
index e6f2e01..7888af1 100644
--- a/gstreamer/backend.cpp
+++ b/gstreamer/backend.cpp
@@ -290,6 +290,7 @@ QStringList Backend::availableMimeTypes() const
                                 availableMimeTypes.append(mime);
                             }
                         }
+                        gst_caps_unref(caps);
                     }
                 }
             }
diff --git a/gstreamer/mediaobject.cpp b/gstreamer/mediaobject.cpp
index e08338b..fad729d 100644
--- a/gstreamer/mediaobject.cpp
+++ b/gstreamer/mediaobject.cpp
@@ -767,6 +767,7 @@ void MediaObject::_iface_jumpToMenu(MediaController::NavigationMenu menu)
     if (target) {
         gst_navigation_send_command(GST_NAVIGATION(target), command);
     }
+    gst_object_unref(target);
 }
 
 void MediaObject::handleTrackCountChange(int tracks)
diff --git a/gstreamer/pipeline.cpp b/gstreamer/pipeline.cpp
index 4b760a1..a770dd3 100644
--- a/gstreamer/pipeline.cpp
+++ b/gstreamer/pipeline.cpp
@@ -580,8 +580,8 @@ gboolean Pipeline::cb_tag(GstBus *bus, GstMessage *msg, gpointer data)
     gst_message_parse_tag(msg, &tag_list);
     if (tag_list) {
         TagMap newTags;
-        gst_tag_list_foreach (tag_list, &foreach_tag_function, &newTags);
-        gst_tag_list_free(tag_list);
+        gst_tag_list_foreach(tag_list, &foreach_tag_function, &newTags);
+        gst_tag_list_unref(tag_list);
 
         // Determine if we should no fake the album/artist tags.
         // This is a little confusing as we want to fake it on initial
@@ -748,6 +748,8 @@ void Pipeline::updateNavigation()
                 }
             }
         }
+        gst_query_unref(query);
+        gst_object_unref(target);
     }
 
     if (ret != m_menus) {
diff --git a/gstreamer/videowidget.cpp b/gstreamer/videowidget.cpp
index 3172614..725e00d 100644
--- a/gstreamer/videowidget.cpp
+++ b/gstreamer/videowidget.cpp
@@ -334,17 +334,18 @@ QImage VideoWidget::snapshot() const
                                                 "format = (string)", G_TYPE_STRING, GST_VIDEO_NE(RGB),
                                                 NULL);
 
-        GstBuffer *snapbuffer;
         GstSample *sample = gst_video_convert_sample(videobuffer, snapcaps, GST_SECOND, NULL);
-        snapbuffer = gst_sample_get_buffer(sample);
-        GstMapInfo info;
-        gst_buffer_map(snapbuffer, &info, GST_MAP_READ);
+        GstBuffer *snapbuffer = gst_sample_get_buffer(sample);
         gst_sample_unref(videobuffer);
         gst_caps_unref(snapcaps);
 
         if (snapbuffer) {
             gint width, height;
             gboolean ret;
+
+            GstMapInfo info;
+            gst_buffer_map(snapbuffer, &info, GST_MAP_READ);
+
             GstStructure *s = gst_caps_get_structure(gst_sample_get_caps(sample), 0);
             ret  = gst_structure_get_int(s, "width", &width);
             ret &= gst_structure_get_int(s, "height", &height);
@@ -362,6 +363,7 @@ QImage VideoWidget::snapshot() const
                 return snapimage;
             }
 
+            gst_buffer_unmap(snapbuffer, &info);
             gst_buffer_unref(snapbuffer);
         }
     }

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic