aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2016-01-12 09:38:54 +0100
committerHans Verkuil <hans.verkuil@cisco.com>2016-01-12 09:38:54 +0100
commit91c6bf546d7e085f55dfc235526d9c79e6af7a43 (patch)
tree866348cf242514159584abb59542e123a15e0231
parent3ef2fb1ec38083da151f4989f3768a5b49ed0824 (diff)
skip in case of read failurefile
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
-rw-r--r--utils/qv4l2/qv4l2.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/utils/qv4l2/qv4l2.cpp b/utils/qv4l2/qv4l2.cpp
index e4ca4fa9..744bb592 100644
--- a/utils/qv4l2/qv4l2.cpp
+++ b/utils/qv4l2/qv4l2.cpp
@@ -981,6 +981,7 @@ void ApplicationWindow::capFrame()
#ifdef HAVE_ALSA
struct timeval tv_alsa;
#endif
+ bool skip = false;
if (m_singleStep)
m_capNotifier->setEnabled(false);
@@ -992,7 +993,8 @@ void ApplicationWindow::capFrame()
if (m_capFromFile.openMode()) {
if (m_capFromFile.pos() + m_capSrcFormat.g_sizeimage(0) > m_capFromFile.size())
m_capFromFile.seek(0);
- m_capFromFile.read((char *)m_frameData, m_capSrcFormat.g_sizeimage(0));
+ if (m_capFromFile.read((char *)m_frameData, m_capSrcFormat.g_sizeimage(0)) < m_capSrcFormat.g_sizeimage(0))
+ skip = true;
}
#ifdef HAVE_ALSA
alsa_thread_timestamp(&tv_alsa);
@@ -1056,12 +1058,14 @@ void ApplicationWindow::capFrame()
if (m_capFromFile.openMode()) {
if (m_capFromFile.pos() + bytesused[0] + bytesused[1] + bytesused[2] > m_capFromFile.size())
m_capFromFile.seek(0);
- m_capFromFile.read((char *)plane[0], bytesused[0]);
+ if (m_capFromFile.read((char *)plane[0], bytesused[0]) < bytesused[0])
+ skip = true;
if (plane[1])
- m_capFromFile.read((char *)plane[1], bytesused[1]);
+ if (m_capFromFile.read((char *)plane[1], bytesused[1]) < bytesused[1])
+ skip = true;
if (plane[2])
- m_capFromFile.read((char *)plane[2], bytesused[2]);
-
+ if (m_capFromFile.read((char *)plane[2], bytesused[2]) < bytesused[2])
+ skip = true;
}
if (showFrames() && m_mustConvert) {
err = v4lconvert_convert(m_convertData, &m_capSrcFormat, &m_capDestFormat,
@@ -1105,7 +1109,7 @@ void ApplicationWindow::capFrame()
if (plane[0] == NULL && showFrames())
status.append(" Error: Unsupported format.");
- if (showFrames())
+ if (!skip && showFrames())
m_capture->setFrame(m_capImage->width(), m_capImage->height(),
m_capDestFormat.g_pixelformat(),
plane[0], plane[1], plane[2]);

Privacy Policy