Fix v4l2 data race

The v4l2_sink implementation directly read the internal video_buffer
field "pending_frame_consumed", which is protected by the internal
video_buffer mutex. But this mutex was not locked, so reads were racy.

Lock using the v4l2_sink mutex in addition, and use a separate field to
avoid depending on the video_buffer internal data.
This commit is contained in:
Romain Vimont
2021-06-26 15:53:05 +02:00
parent 33fbdc86c7
commit 5caeab5f6d
2 changed files with 11 additions and 3 deletions

View File

@@ -22,6 +22,7 @@ struct sc_v4l2_sink {
sc_thread thread;
sc_mutex mutex;
sc_cond cond;
bool has_frame;
bool stopped;
bool header_written;