Commit 63575c0e authored by maxmorin's avatar maxmorin Committed by Commit bot

DCHECK that audio devices are stopped prior to destruction.

This is required (and documented by a comment in the header file), so the DCHECKs are motivated.

BUG=711400
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2828233002
Cr-Commit-Position: refs/heads/master@{#466898}
parent 5aed28a8
...@@ -191,7 +191,17 @@ void AudioInputDevice::OnIPCClosed() { ...@@ -191,7 +191,17 @@ void AudioInputDevice::OnIPCClosed() {
ipc_.reset(); ipc_.reset();
} }
AudioInputDevice::~AudioInputDevice() {} AudioInputDevice::~AudioInputDevice() {
#if DCHECK_IS_ON()
// Make sure we've stopped the stream properly before destructing |this|.
DCHECK(audio_thread_lock_.Try());
DCHECK_LE(state_, IDLE);
DCHECK(!audio_thread_);
DCHECK(!audio_callback_);
DCHECK(!stopping_hack_);
audio_thread_lock_.Release();
#endif // DCHECK_IS_ON()
}
void AudioInputDevice::StartUpOnIOThread() { void AudioInputDevice::StartUpOnIOThread() {
DCHECK(task_runner()->BelongsToCurrentThread()); DCHECK(task_runner()->BelongsToCurrentThread());
......
...@@ -93,6 +93,8 @@ TEST(AudioInputDeviceTest, FailToCreateStream) { ...@@ -93,6 +93,8 @@ TEST(AudioInputDeviceTest, FailToCreateStream) {
EXPECT_CALL(callback, OnCaptureError(_)) EXPECT_CALL(callback, OnCaptureError(_))
.WillOnce(QuitLoop(io_loop.task_runner())); .WillOnce(QuitLoop(io_loop.task_runner()));
base::RunLoop().Run(); base::RunLoop().Run();
device->Stop();
base::RunLoop().RunUntilIdle();
} }
ACTION_P5(ReportOnStreamCreated, device, handle, socket, length, segments) { ACTION_P5(ReportOnStreamCreated, device, handle, socket, length, segments) {
...@@ -139,5 +141,8 @@ TEST(AudioInputDeviceTest, CreateStream) { ...@@ -139,5 +141,8 @@ TEST(AudioInputDeviceTest, CreateStream) {
EXPECT_CALL(callback, OnCaptureStarted()) EXPECT_CALL(callback, OnCaptureStarted())
.WillOnce(QuitLoop(io_loop.task_runner())); .WillOnce(QuitLoop(io_loop.task_runner()));
base::RunLoop().Run(); base::RunLoop().Run();
device->Stop();
base::RunLoop().RunUntilIdle();
} }
} // namespace media. } // namespace media.
...@@ -96,7 +96,17 @@ void AudioOutputDevice::Initialize(const AudioParameters& params, ...@@ -96,7 +96,17 @@ void AudioOutputDevice::Initialize(const AudioParameters& params,
callback_ = callback; callback_ = callback;
} }
AudioOutputDevice::~AudioOutputDevice() {} AudioOutputDevice::~AudioOutputDevice() {
#if DCHECK_IS_ON()
// Make sure we've stopped the stream properly before destructing |this|.
DCHECK(audio_thread_lock_.Try());
DCHECK_LE(state_, IDLE);
DCHECK(!audio_thread_);
DCHECK(!audio_callback_);
DCHECK(!stopping_hack_);
audio_thread_lock_.Release();
#endif // DCHECK_IS_ON()
}
void AudioOutputDevice::RequestDeviceAuthorization() { void AudioOutputDevice::RequestDeviceAuthorization() {
task_runner()->PostTask( task_runner()->PostTask(
......
...@@ -158,6 +158,10 @@ AudioOutputDeviceTest::~AudioOutputDeviceTest() { ...@@ -158,6 +158,10 @@ AudioOutputDeviceTest::~AudioOutputDeviceTest() {
} }
void AudioOutputDeviceTest::CreateDevice(const std::string& device_id) { void AudioOutputDeviceTest::CreateDevice(const std::string& device_id) {
// Make sure the previous device is properly cleaned up.
if (audio_device_)
StopAudioDevice();
audio_output_ipc_ = new MockAudioOutputIPC(); audio_output_ipc_ = new MockAudioOutputIPC();
audio_device_ = new AudioOutputDevice( audio_device_ = new AudioOutputDevice(
base::WrapUnique(audio_output_ipc_), io_loop_.task_runner(), 0, device_id, base::WrapUnique(audio_output_ipc_), io_loop_.task_runner(), 0, device_id,
......
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