Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Unified Diff: media/audio/audio_output_device.cc

Issue 2076793002: Cleanup AudioDeviceThread to reduce locking and unused features. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« media/audio/audio_input_device.cc ('K') | « media/audio/audio_output_device.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_output_device.cc
diff --git a/media/audio/audio_output_device.cc b/media/audio/audio_output_device.cc
index 12d102c4ad196911c9ddfb7430e60da7ca99093b..cfe5dcc512bbcff1fc480cdb13bed6a9bdecbfeb 100644
--- a/media/audio/audio_output_device.cc
+++ b/media/audio/audio_output_device.cc
@@ -91,11 +91,7 @@ void AudioOutputDevice::Initialize(const AudioParameters& params,
callback_ = callback;
}
-AudioOutputDevice::~AudioOutputDevice() {
- // The current design requires that the user calls Stop() before deleting
- // this class.
- DCHECK(audio_thread_.IsStopped());
-}
+AudioOutputDevice::~AudioOutputDevice() {}
void AudioOutputDevice::RequestDeviceAuthorization() {
task_runner()->PostTask(
@@ -114,7 +110,7 @@ void AudioOutputDevice::Start() {
void AudioOutputDevice::Stop() {
{
base::AutoLock auto_lock(audio_thread_lock_);
- audio_thread_.Stop(base::MessageLoop::current());
+ audio_thread_.reset();
stopping_hack_ = true;
}
@@ -256,7 +252,7 @@ void AudioOutputDevice::ShutDownOnIOThread() {
// and can't rely on the main thread existing either.
base::AutoLock auto_lock_(audio_thread_lock_);
base::ThreadRestrictions::ScopedAllowIO allow_io;
- audio_thread_.Stop(NULL);
+ audio_thread_.reset();
audio_callback_.reset();
stopping_hack_ = false;
}
@@ -288,8 +284,11 @@ void AudioOutputDevice::OnStateChanged(AudioOutputIPCDelegateState state) {
// TODO(tommi): Add an explicit contract for clearing the callback
// object. Possibly require calling Initialize again or provide
// a callback object via Start() and clear it in Stop().
- if (!audio_thread_.IsStopped())
- callback_->OnRenderError();
+ {
+ base::AutoLock auto_lock_(audio_thread_lock_);
+ if (audio_thread_)
+ callback_->OnRenderError();
+ }
break;
default:
NOTREACHED();
@@ -389,11 +388,13 @@ void AudioOutputDevice::OnStreamCreated(
if (stopping_hack_)
return;
- DCHECK(audio_thread_.IsStopped());
+ DCHECK(!audio_thread_);
+ DCHECK(!audio_callback_);
+
audio_callback_.reset(new AudioOutputDevice::AudioThreadCallback(
audio_parameters_, handle, length, callback_));
- audio_thread_.Start(audio_callback_.get(), socket_handle,
- "AudioOutputDevice", true);
+ audio_thread_.reset(new AudioDeviceThread(
+ audio_callback_.get(), socket_handle, "AudioOutputDevice"));
state_ = PAUSED;
// We handle the case where Play() and/or Pause() may have been called
« media/audio/audio_input_device.cc ('K') | « media/audio/audio_output_device.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698