~phablet-team/media-hub/fix-1510219

« back to all changes in this revision

Viewing changes to src/core/media/gstreamer/playbin.cpp

  • Committer: CI Train Bot
  • Author(s): Simon Fels
  • Date: 2015-09-23 14:23:07 UTC
  • mfrom: (154.1.2 fix-leaking-fds)
  • Revision ID: ci-train-bot@canonical.com-20150923142307-3uluu4vflxhtw1um
Correctly cleanup gstreamer elements to prevent us from leaking memory/file descriptors. Fixes: #1496894

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
      bus{gst_element_get_bus(pipeline)},
95
95
      file_type(MEDIA_FILE_TYPE_NONE),
96
96
      video_sink(nullptr),
 
97
      audio_sink(nullptr),
97
98
      on_new_message_connection_async(
98
99
          bus.on_new_message_async.connect(
99
100
              std::bind(
142
143
 
143
144
    if (pipeline)
144
145
        gst_object_unref(pipeline);
 
146
 
 
147
    if (video_sink)
 
148
        gst_object_unref(video_sink);
 
149
 
 
150
    if (audio_sink)
 
151
        gst_object_unref(audio_sink);
145
152
}
146
153
 
147
154
void gstreamer::Playbin::reset()
283
290
 
284
291
    if (::getenv("CORE_UBUNTU_MEDIA_SERVICE_AUDIO_SINK_NAME") != nullptr)
285
292
    {
286
 
        auto audio_sink = gst_element_factory_make (
 
293
        audio_sink = gst_element_factory_make (
287
294
                    ::getenv("CORE_UBUNTU_MEDIA_SERVICE_AUDIO_SINK_NAME"),
288
295
                    "audio-sink");
289
296
 
294
301
                    "audio-sink",
295
302
                    audio_sink,
296
303
                    NULL);
 
304
 
 
305
        gst_object_unref(audio_sink);
297
306
    }
298
307
 
299
308
    if (::getenv("CORE_UBUNTU_MEDIA_SERVICE_VIDEO_SINK_NAME") != nullptr)
309
318
                "video-sink",
310
319
                video_sink,
311
320
                NULL);
 
321
 
 
322
        gst_object_unref(video_sink);
312
323
    }
313
324
}
314
325