Chromium Code Reviews| Index: media/audio/audio_input_device.cc |
| diff --git a/media/audio/audio_input_device.cc b/media/audio/audio_input_device.cc |
| index fc6b39285ad363aeb2e7591eacfcd77b8d97bfbb..71518d79951b35a678dc654afb3c70072b289399 100644 |
| --- a/media/audio/audio_input_device.cc |
| +++ b/media/audio/audio_input_device.cc |
| @@ -94,7 +94,7 @@ void AudioInputDevice::Stop() { |
| { |
| base::AutoLock auto_lock(audio_thread_lock_); |
| - audio_thread_.Stop(base::MessageLoop::current()); |
| + audio_thread_.reset(); |
| stopping_hack_ = true; |
| } |
| @@ -143,11 +143,12 @@ void AudioInputDevice::OnStreamCreated( |
| if (stopping_hack_) |
| return; |
| - DCHECK(audio_thread_.IsStopped()); |
| + DCHECK(!audio_callback_); |
| + DCHECK(!audio_thread_); |
| audio_callback_.reset(new AudioInputDevice::AudioThreadCallback( |
| audio_parameters_, handle, length, total_segments, callback_)); |
| - audio_thread_.Start( |
| - audio_callback_.get(), socket_handle, "AudioInputDevice", true); |
| + audio_thread_.reset(new AudioDeviceThread(audio_callback_.get(), |
| + socket_handle, "AudioInputDevice")); |
| state_ = RECORDING; |
| ipc_->RecordStream(); |
| @@ -182,9 +183,13 @@ void AudioInputDevice::OnStateChanged( |
| // 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_->OnCaptureError( |
| - "AudioInputDevice::OnStateChanged - audio thread still running"); |
| + { |
| + base::AutoLock auto_lock_(audio_thread_lock_); |
|
tommi (sloooow) - chröme
2016/06/16 22:19:22
auto_lock
|
| + if (audio_thread_) { |
| + callback_->OnCaptureError( |
| + "AudioInputDevice::OnStateChanged - audio thread still running"); |
| + } |
| + } |
| break; |
| default: |
| NOTREACHED(); |
| @@ -198,11 +203,7 @@ void AudioInputDevice::OnIPCClosed() { |
| ipc_.reset(); |
| } |
| -AudioInputDevice::~AudioInputDevice() { |
| - // TODO(henrika): The current design requires that the user calls |
| - // Stop before deleting this class. |
| - DCHECK(audio_thread_.IsStopped()); |
| -} |
| +AudioInputDevice::~AudioInputDevice() {} |
| void AudioInputDevice::StartUpOnIOThread() { |
| DCHECK(task_runner()->BelongsToCurrentThread()); |
| @@ -241,7 +242,7 @@ void AudioInputDevice::ShutDownOnIOThread() { |
| // and can't not 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; |
| } |