1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Warn on failed frame maping

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-07-01 22:30:56 +02:00
parent f5793b0db8
commit a9b76253af
2 changed files with 7 additions and 2 deletions

View File

@ -13,9 +13,10 @@ AudioBuffer::~AudioBuffer()
qint64 AudioBuffer::readData(char *data, qint64 len) qint64 AudioBuffer::readData(char *data, qint64 len)
{ {
qint64 total;
bufferMutex.lock(); bufferMutex.lock();
try { try {
const qint64 total = qMin((qint64)buffer.size(), len); total = qMin((qint64)buffer.size(), len);
memcpy(data, buffer.constData(), total); memcpy(data, buffer.constData(), total);
buffer = buffer.mid(total); buffer = buffer.mid(total);
} }

View File

@ -83,7 +83,11 @@ bool Camera::start(const QVideoSurfaceFormat &format)
bool Camera::present(const QVideoFrame &frame) bool Camera::present(const QVideoFrame &frame)
{ {
QVideoFrame frameMap(frame); // Basically a const_cast because shallow copies QVideoFrame frameMap(frame); // Basically a const_cast because shallow copies
frameMap.map(QAbstractVideoBuffer::ReadOnly); if (!frameMap.map(QAbstractVideoBuffer::ReadOnly))
{
qWarning() << "Camera::present: Unable to map frame";
return false;
}
int w = frameMap.width(), h = frameMap.height(); int w = frameMap.width(), h = frameMap.height();
int bpl = frameMap.bytesPerLine(), size = frameMap.mappedBytes(); int bpl = frameMap.bytesPerLine(), size = frameMap.mappedBytes();
QVideoFrame frameCopy(size, QSize(w, h), bpl, frameMap.pixelFormat()); QVideoFrame frameCopy(size, QSize(w, h), bpl, frameMap.pixelFormat());