Commit d1b3f322 authored by Chih-Yu Huang's avatar Chih-Yu Huang Committed by Commit Bot

media/gpu/v4l2: Polish V4L2DecodeSurface class.

This CL adds sequence check at each method, and check the release
callback is null when setting it.

Bug: 1020668
Test: run vda_tests on kevin

Change-Id: Ia2760e1a787b0ca65a652b58a4f7ecfc66b61e8a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1974720
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726299}
parent 1f93b4b5
...@@ -79,6 +79,7 @@ void V4L2DecodeSurface::SetDecodeDoneCallback(base::OnceClosure done_cb) { ...@@ -79,6 +79,7 @@ void V4L2DecodeSurface::SetDecodeDoneCallback(base::OnceClosure done_cb) {
void V4L2DecodeSurface::SetReleaseCallback(base::OnceClosure release_cb) { void V4L2DecodeSurface::SetReleaseCallback(base::OnceClosure release_cb) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!release_cb_);
release_cb_ = std::move(release_cb); release_cb_ = std::move(release_cb);
} }
...@@ -130,6 +131,7 @@ bool V4L2ConfigStoreDecodeSurface::Submit() { ...@@ -130,6 +131,7 @@ bool V4L2ConfigStoreDecodeSurface::Submit() {
void V4L2RequestDecodeSurface::PrepareSetCtrls( void V4L2RequestDecodeSurface::PrepareSetCtrls(
struct v4l2_ext_controls* ctrls) const { struct v4l2_ext_controls* ctrls) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_NE(ctrls, nullptr); DCHECK_NE(ctrls, nullptr);
DCHECK(request_ref_.IsValid()); DCHECK(request_ref_.IsValid());
...@@ -139,6 +141,7 @@ void V4L2RequestDecodeSurface::PrepareSetCtrls( ...@@ -139,6 +141,7 @@ void V4L2RequestDecodeSurface::PrepareSetCtrls(
void V4L2RequestDecodeSurface::PrepareQueueBuffer( void V4L2RequestDecodeSurface::PrepareQueueBuffer(
struct v4l2_buffer* buffer) const { struct v4l2_buffer* buffer) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_NE(buffer, nullptr); DCHECK_NE(buffer, nullptr);
DCHECK(request_ref_.IsValid()); DCHECK(request_ref_.IsValid());
...@@ -153,12 +156,15 @@ void V4L2RequestDecodeSurface::PrepareQueueBuffer( ...@@ -153,12 +156,15 @@ void V4L2RequestDecodeSurface::PrepareQueueBuffer(
} }
uint64_t V4L2RequestDecodeSurface::GetReferenceID() const { uint64_t V4L2RequestDecodeSurface::GetReferenceID() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Convert the input buffer ID to what the internal representation of // Convert the input buffer ID to what the internal representation of
// the timestamp we submitted will be (tv_usec * 1000). // the timestamp we submitted will be (tv_usec * 1000).
return output_record() * 1000; return output_record() * 1000;
} }
bool V4L2RequestDecodeSurface::Submit() { bool V4L2RequestDecodeSurface::Submit() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(request_ref_.IsValid()); DCHECK(request_ref_.IsValid());
return std::move(request_ref_).Submit().IsValid(); return std::move(request_ref_).Submit().IsValid();
......
...@@ -22,7 +22,8 @@ namespace media { ...@@ -22,7 +22,8 @@ namespace media {
// A V4L2-specific decode surface generated by V4L2DecodeSurfaceHandler. // A V4L2-specific decode surface generated by V4L2DecodeSurfaceHandler.
// It is used to store common picture metadata (e.g. visible_rect) and // It is used to store common picture metadata (e.g. visible_rect) and
// platform-specific metadata (e.g. {input,output}_record). // platform-specific metadata (e.g. {input,output}_record). All the methods
// should be called on the same sequence.
class V4L2DecodeSurface : public base::RefCounted<V4L2DecodeSurface> { class V4L2DecodeSurface : public base::RefCounted<V4L2DecodeSurface> {
public: public:
// V4L2DecodeSurfaceHandler maintains a list of InputRecords, which records // V4L2DecodeSurfaceHandler maintains a list of InputRecords, which records
...@@ -48,6 +49,8 @@ class V4L2DecodeSurface : public base::RefCounted<V4L2DecodeSurface> { ...@@ -48,6 +49,8 @@ class V4L2DecodeSurface : public base::RefCounted<V4L2DecodeSurface> {
// decoding into this surface is finished. The callback is reset afterwards, // decoding into this surface is finished. The callback is reset afterwards,
// so it needs to be set again before each decode operation. // so it needs to be set again before each decode operation.
void SetDecodeDoneCallback(base::OnceClosure done_cb); void SetDecodeDoneCallback(base::OnceClosure done_cb);
// Set the callback that will be called when the surface is released. This
// method must be called one time at most.
void SetReleaseCallback(base::OnceClosure release_cb); void SetReleaseCallback(base::OnceClosure release_cb);
// Update the passed v4l2_ext_controls structure to add the request or // Update the passed v4l2_ext_controls structure to add the request or
......
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