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 |