52 lines
2.0 KiB
Diff
52 lines
2.0 KiB
Diff
From b7653310766909158a4781fe9def5fb8e9414d1a Mon Sep 17 00:00:00 2001
|
|
From: Jan Grulich <grulja@gmail.com>
|
|
Date: Mon, 06 May 2024 11:20:27 +0200
|
|
Subject: [PATCH] Video capture PipeWire: drop corrupted PipeWire buffers
|
|
|
|
Use SPA_CHUNK_FLAG_CORRUPTED and SPA_META_HEADER_FLAG_CORRUPTED flags to
|
|
determine corrupted buffers or corrupted buffer data. We used to only
|
|
rely on compositors setting chunk->size, but this doesn't make sense for
|
|
dmabufs where they have to make up arbitrary values. It also looks this
|
|
is not reliable and can cause glitches as we end up processing corrupted buffers.
|
|
|
|
Bug: webrtc:338232699
|
|
Change-Id: Ida0c6a5e7a37e19598c6d5884726200f81b94962
|
|
---
|
|
|
|
diff --git a/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
|
|
index 6998d65..f7feddd 100644
|
|
--- a/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
|
|
+++ b/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
|
|
@@ -323,6 +323,15 @@
|
|
return;
|
|
}
|
|
|
|
+ struct spa_meta_header* header =
|
|
+ static_cast<spa_meta_header*>(spa_buffer_find_meta_data(
|
|
+ buffer->buffer, SPA_META_Header, sizeof(*header)));
|
|
+ if (header && (header->flags & SPA_META_HEADER_FLAG_CORRUPTED)) {
|
|
+ RTC_LOG(LS_WARNING) << "Dropping corrupted buffer";
|
|
+ pw_stream_queue_buffer(that->pw_stream_, buffer);
|
|
+ return;
|
|
+ }
|
|
+
|
|
that->ProcessBuffer(buffer);
|
|
|
|
pw_stream_queue_buffer(that->pw_stream_, buffer);
|
|
@@ -709,7 +718,14 @@
|
|
}
|
|
}
|
|
|
|
- if (spa_buffer->datas[0].chunk->size == 0) {
|
|
+ if (spa_buffer->datas[0].chunk->flags & SPA_CHUNK_FLAG_CORRUPTED) {
|
|
+ RTC_LOG(LS_WARNING) << "Dropping buffer with corrupted data";
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ if (spa_buffer->datas[0].type == SPA_DATA_MemFd &&
|
|
+ spa_buffer->datas[0].chunk->size == 0) {
|
|
+ RTC_LOG(LS_WARNING) << "Dropping buffer with empty data";
|
|
return;
|
|
}
|
|
|