summaryrefslogtreecommitdiff
path: root/src/plugins/directshow/camera
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2017-08-16 11:33:25 +0200
committerAndy Shaw <andy.shaw@qt.io>2017-08-16 11:58:54 +0000
commit343e281f0e7cc7fd9e1558e4d92f5019fa565181 (patch)
tree9262c3bcd119bd582e89f879d33b49acb43787f5 /src/plugins/directshow/camera
parent116cd7bdbd1e148aef05c27602780d65be335205 (diff)
downloadqtmultimedia-343e281f0e7cc7fd9e1558e4d92f5019fa565181.tar.gz
DirectShow: Copy the frame data when we get it before emitting
Since the slot connected to the frameAvailable signal may be in another thread there is a bigger risk of it being invalid by the time the slot is invoked. Therefore we copy the data and emit with the copy to ensure that we don't lose the data. Task-number: QTBUG-61817 Change-Id: I2888661d8a7f97105a85f87b08cc9ec25f8ce8c7 Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Diffstat (limited to 'src/plugins/directshow/camera')
-rw-r--r--src/plugins/directshow/camera/dscamerasession.cpp4
-rw-r--r--src/plugins/directshow/camera/dscamerasession.h2
2 files changed, 2 insertions, 4 deletions
diff --git a/src/plugins/directshow/camera/dscamerasession.cpp b/src/plugins/directshow/camera/dscamerasession.cpp
index 3f1187baa..55ab868ce 100644
--- a/src/plugins/directshow/camera/dscamerasession.cpp
+++ b/src/plugins/directshow/camera/dscamerasession.cpp
@@ -529,12 +529,10 @@ int DSCameraSession::captureImage(const QString &fileName)
return m_imageIdCounter;
}
-void DSCameraSession::onFrameAvailable(double time, quint8 *buffer, long len)
+void DSCameraSession::onFrameAvailable(double time, const QByteArray &data)
{
// !!! Not called on the main thread
Q_UNUSED(time);
- // Deep copy, the data might be modified or freed after the callback returns
- QByteArray data(reinterpret_cast<const char *>(buffer), len);
m_presentMutex.lock();
diff --git a/src/plugins/directshow/camera/dscamerasession.h b/src/plugins/directshow/camera/dscamerasession.h
index 6b6cb49b2..90407f49e 100644
--- a/src/plugins/directshow/camera/dscamerasession.h
+++ b/src/plugins/directshow/camera/dscamerasession.h
@@ -156,7 +156,7 @@ private:
void setStatus(QCamera::Status status);
- void onFrameAvailable(double time, quint8 *buffer, long len);
+ void onFrameAvailable(double time, const QByteArray &data);
void saveCapturedImage(int id, const QImage &image, const QString &path);
bool createFilterGraph();