PipeWire capture: Clean latest_available_frame on capture stop
Once we stop capturing, we clear the queue with frames, but we still
keep pointer to the latest available frame. This latest available frame
should be invalidated, otherwise it will be now pointing to non-existent
frame. This is not a problem when we completely stop capturing, but if
we are just restarting it to pick a different source, we can crash on it
if we are asked to provide a frame, but we didn't get any yet from the
new source.
Bug: chromium:400656070
Change-Id: I780392999ebba917aa72dde8a2c9b77bfc21cd0f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/379920
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Jan Grulich <grulja@gmail.com>
Cr-Commit-Position: refs/heads/main@{#44084}
diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
index 9aa50e1..1f028d8 100644
--- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
+++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
@@ -587,6 +587,10 @@
webrtc::MutexLock lock(&queue_lock_);
queue_.Reset();
}
+ {
+ webrtc::MutexLock latest_frame_lock(&latest_frame_lock_);
+ latest_available_frame_ = nullptr;
+ }
}
if (pw_core_) {