From d940c725e0a128904244ced858dbfc22324152da Mon Sep 17 00:00:00 2001 From: Mohamed Chibani <mohamed.chibani@savoirfairelinux.com> Date: Thu, 14 Apr 2022 10:45:56 -0400 Subject: [PATCH] SMH: fix check on buffer size The SHM buffer size might be slightly larger than the expected size due to 16-byte memory alignment used to create the SHM buffers. Gitlab: #731 Change-Id: Ida174fd16698cdbe6b19ccfd3c0c266adad68fa2 --- src/videoprovider.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/videoprovider.cpp b/src/videoprovider.cpp index 8c8319948..231e95aec 100644 --- a/src/videoprovider.cpp +++ b/src/videoprovider.cpp @@ -229,8 +229,11 @@ VideoProvider::copyUnaligned(QVideoFrame* dst, const video::Frame& src) // The provided source must be valid. assert(src.ptr != nullptr and src.size > 0); - if (dst->width() * dst->height() * BYTES_PER_PIXEL != src.size) { - qCritical() << "Size mismatch. Actual " << src.size << " Expected " + // The source buffer must be greater or equal to the min required + // buffer size. The SHM buffer might be slightly larger than the + // required size due to the 16-byte alignment. + if (dst->width() * dst->height() * BYTES_PER_PIXEL > src.size) { + qCritical() << "The size of frame buffer " << src.size << " is smaller than expected " << dst->width() * dst->height() * BYTES_PER_PIXEL; return; } -- GitLab