plugins/screencast: Corrupt header to indicate that buffer has no data
SPA_META_HEADER_FLAG_CORRUPTED indicates that the buffer contains absolutely no any data. SPA_CHUNK_FLAG_CORRUPTED indicates that the buffer has no frame contents but it can contain other data, for example cursor metadata.
This commit is contained in:
parent
a4be9859b7
commit
0c49ae5360
2 changed files with 13 additions and 4 deletions
|
@ -546,7 +546,7 @@ void ScreenCastStream::recordFrame(const QRegion &_damagedRegion)
|
|||
uint8_t *data = static_cast<uint8_t *>(spa_data->data);
|
||||
if (!data) {
|
||||
qCWarning(KWIN_SCREENCAST) << objectName() << "Failed to record frame: invalid buffer data";
|
||||
spa_data->chunk->flags = SPA_CHUNK_FLAG_CORRUPTED;
|
||||
corruptHeader(spa_buffer);
|
||||
pw_stream_queue_buffer(m_pwStream, buffer);
|
||||
return;
|
||||
}
|
||||
|
@ -557,7 +557,7 @@ void ScreenCastStream::recordFrame(const QRegion &_damagedRegion)
|
|||
|
||||
if ((stride * size.height()) > spa_data->maxsize) {
|
||||
qCDebug(KWIN_SCREENCAST) << objectName() << "Failed to record frame: frame is too big";
|
||||
spa_data->chunk->flags = SPA_CHUNK_FLAG_CORRUPTED;
|
||||
corruptHeader(spa_buffer);
|
||||
pw_stream_queue_buffer(m_pwStream, buffer);
|
||||
return;
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ void ScreenCastStream::recordFrame(const QRegion &_damagedRegion)
|
|||
auto dmabuf = m_dmabufDataForPwBuffer.constFind(buffer);
|
||||
if (dmabuf == m_dmabufDataForPwBuffer.constEnd()) {
|
||||
qCDebug(KWIN_SCREENCAST) << objectName() << "Failed to record frame: no dmabuf data";
|
||||
spa_data->chunk->flags = SPA_CHUNK_FLAG_CORRUPTED;
|
||||
corruptHeader(spa_buffer);
|
||||
pw_stream_queue_buffer(m_pwStream, buffer);
|
||||
return;
|
||||
}
|
||||
|
@ -630,7 +630,7 @@ void ScreenCastStream::recordFrame(const QRegion &_damagedRegion)
|
|||
}
|
||||
} else {
|
||||
qCWarning(KWIN_SCREENCAST, "%s Failed to record frame: invalid buffer type: %d", objectName().toUtf8().constData(), spa_data[0].type);
|
||||
spa_data->chunk->flags = SPA_CHUNK_FLAG_CORRUPTED;
|
||||
corruptHeader(spa_buffer);
|
||||
pw_stream_queue_buffer(m_pwStream, buffer);
|
||||
return;
|
||||
}
|
||||
|
@ -656,6 +656,14 @@ void ScreenCastStream::addHeader(spa_buffer *spaBuffer)
|
|||
}
|
||||
}
|
||||
|
||||
void ScreenCastStream::corruptHeader(spa_buffer *spaBuffer)
|
||||
{
|
||||
spa_meta_header *spaHeader = (spa_meta_header *)spa_buffer_find_meta_data(spaBuffer, SPA_META_Header, sizeof(spaHeader));
|
||||
if (spaHeader) {
|
||||
spaHeader->flags = SPA_META_HEADER_FLAG_CORRUPTED;
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenCastStream::addDamage(spa_buffer *spaBuffer, const QRegion &damagedRegion)
|
||||
{
|
||||
if (spa_meta *vdMeta = spa_buffer_find_meta(spaBuffer, SPA_META_VideoDamage)) {
|
||||
|
|
|
@ -91,6 +91,7 @@ private:
|
|||
void coreFailed(const QString &errorMessage);
|
||||
void sendCursorData(Cursor *cursor, spa_meta_cursor *spa_cursor);
|
||||
void addHeader(spa_buffer *spaBuffer);
|
||||
void corruptHeader(spa_buffer *spaBuffer);
|
||||
void addDamage(spa_buffer *spaBuffer, const QRegion &damagedRegion);
|
||||
void newStreamParams();
|
||||
void enqueue(pw_buffer *buffer);
|
||||
|
|
Loading…
Reference in a new issue