Added QAbstractVideoBuffer::release virtual method
authorDmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
Wed, 6 Jun 2012 04:35:42 +0000 (14:35 +1000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 7 Jun 2012 06:28:08 +0000 (08:28 +0200)
It's useful when the buffer pool stores QAbstractVideoBuffer
instances instead of underlying system buffers and
allows to avoid reallocation of QAbstractVideoBuffer instances.

The default implementation deletes the buffer,
so this change is source compatible.

Change-Id: I7dadd7dac529748b5eb33e5aa7c2d0578b8b1634
Reviewed-by: Lev Zelenskiy <lev.zelenskiy@nokia.com>
Reviewed-by: Jonas Rabbe <jonas.rabbe@gmail.com>
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
src/multimedia/video/qabstractvideobuffer.cpp
src/multimedia/video/qabstractvideobuffer.h
src/multimedia/video/qvideoframe.cpp

index 0d0ff597e2f33d8e7474dcef9c423fa5cc6baa0f..127cd5ea04c10e6260b64395260f3b4c05ffd82c 100644 (file)
@@ -148,6 +148,19 @@ QAbstractVideoBuffer::~QAbstractVideoBuffer()
     delete d_ptr;
 }
 
+/*!
+    Releases the video buffer.
+
+    QVideoFrame calls QAbstractVideoBuffer::release when the buffer is not used
+    any more and can be destroyed or returned to the buffer pool.
+
+    The default implementation deletes the buffer instance.
+*/
+void QAbstractVideoBuffer::release()
+{
+    delete this;
+}
+
 /*!
     Returns the type of a video buffer's handle.
 
index 0e92d32858634d1d7efb47fa9bc3fe1ed248d6a1..6bd7f8a58327f1e78e520778be3be191991f0703 100644 (file)
@@ -82,6 +82,7 @@ public:
 
     QAbstractVideoBuffer(HandleType type);
     virtual ~QAbstractVideoBuffer();
+    virtual void release();
 
     HandleType handleType() const;
 
index c17a88835665b8ecb6bf8a9cce06be6b3d8caf30..4b13098064993ff51e6add8c3d44d0ed1af4fbc9 100644 (file)
@@ -102,7 +102,8 @@ public:
 
     ~QVideoFramePrivate()
     {
-        delete buffer;
+        if (buffer)
+            buffer->release();
     }
 
     QSize size;