Commit 71e4caf1 authored by Max Morin's avatar Max Morin Committed by Commit Bot

Fix another three missing calls to ARS::Stop().

It shouldn't be possible to have an infinite number of these bugs, so
I'll just keep fixing them and hope the Clusterfuzz reports come to an
end :).

Bug: 825679
Change-Id: I899c87b7849cdf7cefc50976b247bce4307b89d2
Reviewed-on: https://chromium-review.googlesource.com/979801Reviewed-by: default avatarOlga Sharonova <olka@chromium.org>
Commit-Queue: Max Morin <maxmorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545753}
parent 5a867e71
......@@ -4,6 +4,8 @@
#include "content/renderer/media/stream/track_audio_renderer.h"
#include <utility>
#include "base/location.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
......@@ -264,6 +266,7 @@ void TrackAudioRenderer::SwitchOutputDevice(
media::OutputDeviceStatus new_sink_status =
new_sink->GetOutputDeviceInfo().device_status();
if (new_sink_status != media::OUTPUT_DEVICE_STATUS_OK) {
new_sink->Stop();
callback.Run(new_sink_status);
return;
}
......
......@@ -7,6 +7,7 @@
#include <stdint.h>
#include <memory>
#include <string>
#include <vector>
......
......@@ -207,6 +207,7 @@ bool WebRtcAudioRenderer::Initialize(WebRtcAudioRendererSource* source) {
if (sink_->GetOutputDeviceInfo().device_status() !=
media::OUTPUT_DEVICE_STATUS_OK) {
sink_->Stop();
return false;
}
......@@ -391,6 +392,7 @@ void WebRtcAudioRenderer::SwitchOutputDevice(
media::OutputDeviceStatus status =
new_sink->GetOutputDeviceInfo().device_status();
if (status != media::OUTPUT_DEVICE_STATUS_OK) {
new_sink->Stop();
callback.Run(status);
return;
}
......
......@@ -105,24 +105,25 @@ class WebRtcAudioRendererTest : public testing::Test,
int session_id,
const std::string& device_id,
const url::Origin& security_origin) {
scoped_refptr<media::MockAudioRendererSink> fake_sink(
new media::MockAudioRendererSink(
device_id, device_id == kInvalidOutputDeviceId
? media::OUTPUT_DEVICE_STATUS_ERROR_INTERNAL
: media::OUTPUT_DEVICE_STATUS_OK,
media::AudioParameters(
media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
media::CHANNEL_LAYOUT_STEREO, kHardwareSampleRate, 16,
kHardwareBufferSize)));
mock_sink_ = new media::MockAudioRendererSink(
device_id,
device_id == kInvalidOutputDeviceId
? media::OUTPUT_DEVICE_STATUS_ERROR_INTERNAL
: media::OUTPUT_DEVICE_STATUS_OK,
media::AudioParameters(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
media::CHANNEL_LAYOUT_STEREO,
kHardwareSampleRate, 16, kHardwareBufferSize));
if (device_id != kInvalidOutputDeviceId) {
mock_sink_ = fake_sink;
EXPECT_CALL(*mock_sink_.get(), Start());
EXPECT_CALL(*mock_sink_.get(), Play());
} else {
EXPECT_CALL(*mock_sink_.get(), Stop());
}
MockCreateAudioRendererSink(source_type, render_frame_id, session_id,
device_id, security_origin);
return fake_sink;
return mock_sink_;
}
void TearDown() override {
......@@ -260,6 +261,7 @@ TEST_F(WebRtcAudioRendererTest, SwitchOutputDeviceInvalidDevice) {
SetupRenderer(kDefaultOutputDeviceId);
EXPECT_EQ(kDefaultOutputDeviceId,
mock_sink_->GetOutputDeviceInfo().device_id());
auto original_sink = mock_sink_;
renderer_proxy_->Start();
EXPECT_CALL(*this,
......@@ -274,11 +276,27 @@ TEST_F(WebRtcAudioRendererTest, SwitchOutputDeviceInvalidDevice) {
base::Unretained(this), &loop));
loop.Run();
EXPECT_EQ(kDefaultOutputDeviceId,
mock_sink_->GetOutputDeviceInfo().device_id());
original_sink->GetOutputDeviceInfo().device_id());
EXPECT_CALL(*mock_sink_.get(), Stop());
EXPECT_CALL(*original_sink.get(), Stop());
EXPECT_CALL(*source_.get(), RemoveAudioRenderer(renderer_.get()));
renderer_proxy_->Stop();
}
TEST_F(WebRtcAudioRendererTest, InitializeWithInvalidDevice) {
renderer_ = new WebRtcAudioRenderer(message_loop_->task_runner(), stream_, 1,
1, kInvalidOutputDeviceId, url::Origin());
EXPECT_CALL(*this,
MockCreateAudioRendererSink(AudioDeviceFactory::kSourceWebRtc, _,
_, kInvalidOutputDeviceId, _));
EXPECT_FALSE(renderer_->Initialize(source_.get()));
renderer_proxy_ = renderer_->CreateSharedAudioRendererProxy(stream_);
EXPECT_EQ(kInvalidOutputDeviceId,
mock_sink_->GetOutputDeviceInfo().device_id());
}
} // namespace content
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