Commit e69459df authored by David Bienvenu's avatar David Bienvenu Committed by Commit Bot

Replace base::Closure with Once/RepeatingClosure in media/gpu/*

Bug: 1007807
Change-Id: I979b461f6d1ef5b6a9f01a9b272683d01112cc96
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2533732
Commit-Queue: David Bienvenu <davidbienvenu@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827419}
parent 34bf7349
......@@ -163,9 +163,8 @@ TEST_P(VideoDecoderPipelineTest, Initialize) {
SetCreateDecoderFunctions(GetParam().create_decoder_functions);
base::RunLoop run_loop;
base::Closure quit_closure = run_loop.QuitClosure();
EXPECT_CALL(*this, OnInit(MatchesStatusCode(GetParam().status_code)))
.WillOnce(RunClosure(quit_closure));
.WillOnce(RunClosure(run_loop.QuitClosure()));
InitializeDecoder();
run_loop.Run();
......
......@@ -213,9 +213,9 @@ class VaapiVideoDecodeAcceleratorTest : public TestWithParam<TestParams>,
// Reset epilogue, needed to get |vda_| worker thread out of its Wait().
void ResetSequence() {
base::RunLoop run_loop;
base::Closure quit_closure = run_loop.QuitClosure();
EXPECT_CALL(*mock_decoder_, Reset());
EXPECT_CALL(*this, NotifyResetDone()).WillOnce(RunClosure(quit_closure));
EXPECT_CALL(*this, NotifyResetDone())
.WillOnce(RunClosure(run_loop.QuitClosure()));
vda_.Reset();
run_loop.Run();
}
......@@ -231,8 +231,6 @@ class VaapiVideoDecodeAcceleratorTest : public TestWithParam<TestParams>,
bool expect_dismiss_picture_buffers = false,
size_t num_picture_buffers_to_dismiss = 0) {
::testing::InSequence s;
base::RunLoop run_loop;
base::Closure quit_closure = run_loop.QuitClosure();
EXPECT_CALL(*mock_decoder_,
SetStream(_, IsExpectedDecoderBuffer(kInputSize, nullptr)))
.WillOnce(Return());
......@@ -262,10 +260,12 @@ class VaapiVideoDecodeAcceleratorTest : public TestWithParam<TestParams>,
? num_pictures - kNumReferenceFrames
: num_pictures;
base::RunLoop run_loop;
EXPECT_CALL(*this,
ProvidePictureBuffers(expected_num_picture_buffers_requested, _,
1, picture_size, _))
.WillOnce(RunClosure(quit_closure));
.WillOnce(RunClosure(run_loop.QuitClosure()));
auto region = base::UnsafeSharedMemoryRegion::TakeHandleForSerialization(
in_shm_.Duplicate());
......@@ -286,9 +286,6 @@ class VaapiVideoDecodeAcceleratorTest : public TestWithParam<TestParams>,
ASSERT_TRUE(vda_.curr_input_buffer_)
<< "QueueInputBuffer() should have been called";
base::RunLoop run_loop;
base::Closure quit_closure = run_loop.QuitClosure();
// |decode_using_client_picture_buffers| determines the concrete method for
// creation of context, surfaces and VaapiPictures.
if (GetParam().decode_using_client_picture_buffers) {
......@@ -326,10 +323,12 @@ class VaapiVideoDecodeAcceleratorTest : public TestWithParam<TestParams>,
}
::testing::InSequence s;
base::RunLoop run_loop;
EXPECT_CALL(*mock_decoder_, Decode())
.WillOnce(Return(AcceleratedVideoDecoder::kRanOutOfStreamData));
EXPECT_CALL(*this, NotifyEndOfBitstreamBuffer(bitstream_id))
.WillOnce(RunClosure(quit_closure));
.WillOnce(RunClosure(run_loop.QuitClosure()));
const auto tex_target = mock_vaapi_picture_factory_->GetGLTextureTarget();
int irrelevant_id = 2;
......@@ -352,14 +351,13 @@ class VaapiVideoDecodeAcceleratorTest : public TestWithParam<TestParams>,
// because the Decode() is (almost) immediate.
void DecodeOneFrameFast(int32_t bitstream_id) {
base::RunLoop run_loop;
base::Closure quit_closure = run_loop.QuitClosure();
EXPECT_CALL(*mock_decoder_,
SetStream(_, IsExpectedDecoderBuffer(kInputSize, nullptr)))
.WillOnce(Return());
EXPECT_CALL(*mock_decoder_, Decode())
.WillOnce(Return(AcceleratedVideoDecoder::kRanOutOfStreamData));
EXPECT_CALL(*this, NotifyEndOfBitstreamBuffer(bitstream_id))
.WillOnce(RunClosure(quit_closure));
.WillOnce(RunClosure(run_loop.QuitClosure()));
auto region = base::UnsafeSharedMemoryRegion::TakeHandleForSerialization(
in_shm_.Duplicate());
......@@ -442,14 +440,13 @@ TEST_P(VaapiVideoDecodeAcceleratorTest, QueueInputBufferAndDecodeError) {
BitstreamBuffer bitstream_buffer(kBitstreamId, std::move(region), kInputSize);
base::RunLoop run_loop;
base::Closure quit_closure = run_loop.QuitClosure();
EXPECT_CALL(*mock_decoder_,
SetStream(_, IsExpectedDecoderBuffer(kInputSize, nullptr)))
.WillOnce(Return());
EXPECT_CALL(*mock_decoder_, Decode())
.WillOnce(Return(AcceleratedVideoDecoder::kDecodeError));
EXPECT_CALL(*this, NotifyError(VaapiVideoDecodeAccelerator::PLATFORM_FAILURE))
.WillOnce(RunClosure(quit_closure));
.WillOnce(RunClosure(run_loop.QuitClosure()));
QueueInputBuffer(std::move(bitstream_buffer));
run_loop.Run();
......
......@@ -182,7 +182,6 @@ class VaapiVideoEncodeAcceleratorTest
void InitializeSequenceForVP9(const VideoEncodeAccelerator::Config& config) {
base::RunLoop run_loop;
base::Closure quit_closure = run_loop.QuitClosure();
::testing::InSequence s;
constexpr auto kBitrateControl =
AcceleratedVideoEncoder::BitrateControl::kConstantQuantizationParameter;
......@@ -208,14 +207,12 @@ class VaapiVideoEncodeAcceleratorTest
}));
EXPECT_CALL(client_, NotifyEncoderInfoChange(MatchesEncoderInfo(
config.spatial_layers[0].num_of_temporal_layers)))
.WillOnce([&quit_closure]() { quit_closure.Run(); });
.WillOnce(RunClosure(run_loop.QuitClosure()));
ASSERT_TRUE(InitializeVideoEncodeAccelerator(config));
run_loop.Run();
}
void EncodeSequenceForVP9(bool use_temporal_layer_encoding) {
base::RunLoop run_loop;
base::Closure quit_closure = run_loop.QuitClosure();
::testing::InSequence s;
constexpr VABufferID kCodedBufferId = 123;
......@@ -284,11 +281,13 @@ class VaapiVideoEncodeAcceleratorTest
}));
constexpr int32_t kBitstreamId = 12;
base::RunLoop run_loop;
EXPECT_CALL(client_, BitstreamBufferReady(kBitstreamId,
MatchesBitstreamBufferMetadata(
kEncodedChunkSize, false,
use_temporal_layer_encoding)))
.WillOnce(RunClosure(quit_closure));
.WillOnce(RunClosure(run_loop.QuitClosure()));
auto region = base::UnsafeSharedMemoryRegion::Create(output_buffer_size_);
ASSERT_TRUE(region.IsValid());
......
......@@ -1078,8 +1078,8 @@ class VideoFrameQualityValidator
VideoFrameQualityValidator(const VideoCodecProfile profile,
const VideoPixelFormat pixel_format,
bool verify_quality,
const base::Closure& flush_complete_cb,
const base::Closure& decode_error_cb);
const base::RepeatingClosure& flush_complete_cb,
const base::RepeatingClosure& decode_error_cb);
void Initialize(const gfx::Size& coded_size, const gfx::Rect& visible_size);
// Save original YUV frame to compare it with the decoded frame later.
void AddOriginalFrame(scoped_refptr<VideoFrame> frame);
......@@ -1111,8 +1111,8 @@ class VideoFrameQualityValidator
const bool verify_quality_;
std::unique_ptr<FFmpegVideoDecoder> decoder_;
// Callback of Flush(). Called after all frames are decoded.
const base::Closure flush_complete_cb_;
const base::Closure decode_error_cb_;
base::RepeatingClosure flush_complete_cb_;
base::RepeatingClosure decode_error_cb_;
State decoder_state_;
base::queue<scoped_refptr<VideoFrame>> original_frames_;
base::queue<scoped_refptr<DecoderBuffer>> decode_buffers_;
......@@ -1124,8 +1124,8 @@ VideoFrameQualityValidator::VideoFrameQualityValidator(
const VideoCodecProfile profile,
const VideoPixelFormat pixel_format,
const bool verify_quality,
const base::Closure& flush_complete_cb,
const base::Closure& decode_error_cb)
const base::RepeatingClosure& flush_complete_cb,
const base::RepeatingClosure& decode_error_cb)
: profile_(profile),
pixel_format_(pixel_format),
verify_quality_(verify_quality),
......
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