Commit 1ac9bd6c authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Commit Bot

media/gpu/v4l2: add sequence checker to V4L2Device

The V4L2Device class has grown a bit chaotically, and proper sequence
checking is not currently being enforced, although other classes of the
same unit (V4L2Queue notably) do sequence checking.

Add a sequence checker for the queue-related methods, which must always
be called from the client's sequence. The use of this checker will be
expanded to new use-cases and hopefully to older ones as well as we
confirm they are safe.

Bug: 1003223
Test: vdatests passing on Kevin.
Change-Id: I60aa8eb52e48a13fa99c42990af2f621982c44e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1799651
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: default avatarChih-Yu Huang <akahuang@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#696044}
parent 03c3ab5d
...@@ -1005,11 +1005,15 @@ class V4L2QueueFactory { ...@@ -1005,11 +1005,15 @@ class V4L2QueueFactory {
} }
}; };
V4L2Device::V4L2Device() {} V4L2Device::V4L2Device() {
DETACH_FROM_SEQUENCE(client_sequence_checker_);
}
V4L2Device::~V4L2Device() {} V4L2Device::~V4L2Device() {}
scoped_refptr<V4L2Queue> V4L2Device::GetQueue(enum v4l2_buf_type type) { scoped_refptr<V4L2Queue> V4L2Device::GetQueue(enum v4l2_buf_type type) {
DCHECK_CALLED_ON_VALID_SEQUENCE(client_sequence_checker_);
switch (type) { switch (type) {
// Supported queue types. // Supported queue types.
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
...@@ -1034,6 +1038,8 @@ scoped_refptr<V4L2Queue> V4L2Device::GetQueue(enum v4l2_buf_type type) { ...@@ -1034,6 +1038,8 @@ scoped_refptr<V4L2Queue> V4L2Device::GetQueue(enum v4l2_buf_type type) {
} }
void V4L2Device::OnQueueDestroyed(v4l2_buf_type buf_type) { void V4L2Device::OnQueueDestroyed(v4l2_buf_type buf_type) {
DCHECK_CALLED_ON_VALID_SEQUENCE(client_sequence_checker_);
auto it = queues_.find(buf_type); auto it = queues_.find(buf_type);
DCHECK(it != queues_.end()); DCHECK(it != queues_.end());
queues_.erase(it); queues_.erase(it);
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "base/files/scoped_file.h" #include "base/files/scoped_file.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/sequence_checker.h"
#include "media/base/video_decoder_config.h" #include "media/base/video_decoder_config.h"
#include "media/base/video_frame.h" #include "media/base/video_frame.h"
#include "media/base/video_frame_layout.h" #include "media/base/video_frame_layout.h"
...@@ -548,6 +549,8 @@ class MEDIA_GPU_EXPORT V4L2Device ...@@ -548,6 +549,8 @@ class MEDIA_GPU_EXPORT V4L2Device
// Callback that is called upon a queue's destruction, to cleanup its pointer // Callback that is called upon a queue's destruction, to cleanup its pointer
// in queues_. // in queues_.
void OnQueueDestroyed(v4l2_buf_type buf_type); void OnQueueDestroyed(v4l2_buf_type buf_type);
SEQUENCE_CHECKER(client_sequence_checker_);
}; };
} // namespace media } // namespace media
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment