Commit 331f7ff4 authored by Armando Miraglia's avatar Armando Miraglia Committed by Commit Bot

Remove checks for params.IsValid in favour of DCHECK() checks.

According to the TODOs left in the code and the state of crbug/803102,
it is now safe to remove the params.IsValid() from some if-statements.
This is so, when the paramters are passed through Mojo, which will
already perform the checks.

To guarantee that all is working correctly, the check is transfromed
into a DCHECK.

BUG=803102

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I069a902141d8003f2bb9656f691b5bbbdb69c259
Reviewed-on: https://chromium-review.googlesource.com/1181134Reviewed-by: default avatarMax Morin <maxmorin@chromium.org>
Commit-Queue: Armando Miraglia <armax@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584703}
parent 8442f319
......@@ -208,10 +208,9 @@ scoped_refptr<AudioInputController> AudioInputController::Create(
DCHECK(audio_manager);
DCHECK(sync_writer);
DCHECK(event_handler);
DCHECK(params.IsValid());
// TODO(https://crbug.com/803102): remove check after switching to input
// stream factory.
if (!params.IsValid() || (params.channels() > kMaxInputChannels))
if (params.channels() > kMaxInputChannels)
return nullptr;
if (factory_) {
......
......@@ -196,17 +196,6 @@ TEST_P(AudioInputControllerTest, CreateRecordAndClose) {
CloseAudioController();
}
// Test that AudioInputController rejects insanely large packet sizes.
TEST_P(AudioInputControllerTest, SamplesPerPacketTooLarge) {
// Create an audio device with a very large packet size.
params_.set_frames_per_buffer(kSamplesPerPacket * 1000);
// OnCreated() shall not be called in this test.
EXPECT_CALL(event_handler_, OnCreated(_)).Times(Exactly(0));
CreateAudioController();
ASSERT_FALSE(controller_.get());
}
TEST_P(AudioInputControllerTest, CloseTwice) {
EXPECT_CALL(event_handler_, OnCreated(_));
CreateAudioController();
......
......@@ -180,17 +180,13 @@ AudioOutputStream* AudioManagerBase::MakeAudioOutputStream(
const std::string& device_id,
const LogCallback& log_callback) {
CHECK(GetTaskRunner()->BelongsToCurrentThread());
DCHECK(params.IsValid());
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kFailAudioStreamCreation)) {
return nullptr;
}
if (!params.IsValid()) {
DLOG(ERROR) << "Audio parameters are invalid";
return nullptr;
}
// Limit the number of audio streams opened. This is to prevent using
// excessive resources for a large number of audio streams. More
// importantly it prevents instability on certain systems.
......
......@@ -209,10 +209,9 @@ std::unique_ptr<InputController> InputController::Create(
DCHECK(audio_manager->GetTaskRunner()->BelongsToCurrentThread());
DCHECK(sync_writer);
DCHECK(event_handler);
DCHECK(params.IsValid());
// TODO(https://crbug.com/803102): remove check after switching to input
// stream factory.
if (!params.IsValid() || (params.channels() > kMaxInputChannels))
if (params.channels() > kMaxInputChannels)
return nullptr;
// Create the InputController object and ensure that it runs on
......
......@@ -179,17 +179,6 @@ TEST_F(InputControllerTest, CreateRecordAndClose) {
task_environment_.RunUntilIdle();
}
// Test that InputController rejects insanely large packet sizes.
TEST_F(InputControllerTest, SamplesPerPacketTooLarge) {
// Create an audio device with a very large packet size.
params_.set_frames_per_buffer(1000000);
// OnCreated() shall not be called in this test.
EXPECT_CALL(event_handler_, OnCreated(_)).Times(Exactly(0));
CreateAudioController();
ASSERT_FALSE(controller_.get());
}
TEST_F(InputControllerTest, CloseTwice) {
EXPECT_CALL(event_handler_, OnCreated(_));
CreateAudioController();
......
......@@ -59,6 +59,7 @@ InputStream::InputStream(CreatedCallback created_callback,
DCHECK(client_.is_bound());
DCHECK(created_callback_);
DCHECK(delete_callback_);
DCHECK(params.IsValid());
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0("audio", "audio::InputStream", this);
TRACE_EVENT_NESTABLE_ASYNC_BEGIN2("audio", "InputStream", this, "device id",
device_id, "params",
......@@ -78,7 +79,7 @@ InputStream::InputStream(CreatedCallback created_callback,
// Only MONO, STEREO and STEREO_AND_KEYBOARD_MIC channel layouts are expected,
// see AudioManagerBase::MakeAudioInputStream().
if (!params.IsValid() || (params.channels() > kMaxInputChannels)) {
if (params.channels() > kMaxInputChannels) {
OnStreamError(true);
return;
}
......
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