gst player: clear the buffer pool when the video sink is stopped
authorDmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
Fri, 20 Apr 2012 01:32:59 +0000 (11:32 +1000)
committerQt by Nokia <qt-info@nokia.com>
Fri, 20 Apr 2012 06:47:32 +0000 (08:47 +0200)
Buffers were kept allocated until the player is destroyed or
next media played.

Change-Id: I8a0c85da3a82ac6883075a1d0674143783c7f010
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
src/gsttools/qvideosurfacegstsink.cpp
src/multimedia/gsttools_headers/qvideosurfacegstsink_p.h

index 6347582..7f61a68 100644 (file)
@@ -176,6 +176,13 @@ bool QVideoSurfaceGstDelegate::isActive()
     return !m_surface.isNull() && m_surface->isActive();
 }
 
+void QVideoSurfaceGstDelegate::clearPoolBuffers()
+{
+    QMutexLocker locker(&m_poolMutex);
+    if (m_pool)
+        m_pool->clear();
+}
+
 GstFlowReturn QVideoSurfaceGstDelegate::render(GstBuffer *buffer)
 {
     if (!m_surface) {
@@ -840,7 +847,8 @@ gboolean QVideoSurfaceGstSink::start(GstBaseSink *base)
 
 gboolean QVideoSurfaceGstSink::stop(GstBaseSink *base)
 {
-    Q_UNUSED(base);
+    VO_SINK(base);
+    sink->delegate->clearPoolBuffers();
 
     return TRUE;
 }
index 6ee6907..c87db3a 100644 (file)
@@ -94,6 +94,7 @@ public:
 
     QGstBufferPoolInterface *pool() { return m_pool; }
     QMutex *poolMutex() { return &m_poolMutex; }
+    void clearPoolBuffers();
 
     GstFlowReturn render(GstBuffer *buffer);