| Index: media/audio/audio_output_device.cc
|
| diff --git a/media/audio/audio_output_device.cc b/media/audio/audio_output_device.cc
|
| index cf4ebffe7254f481cca349301b6ab59e6b881992..837c240ee9c8438b9677036b36fa753d4fa12a34 100644
|
| --- a/media/audio/audio_output_device.cc
|
| +++ b/media/audio/audio_output_device.cc
|
| @@ -73,6 +73,7 @@ void AudioOutputDevice::InitializeIO(const AudioParameters& params,
|
| AudioOutputDevice::~AudioOutputDevice() {
|
| // The current design requires that the user calls Stop() before deleting
|
| // this class.
|
| + LOG(ERROR) << "AudioOutputDevice::~@" << this;
|
| DCHECK(audio_thread_.IsStopped());
|
|
|
| if (ipc_)
|
| @@ -186,8 +187,13 @@ void AudioOutputDevice::SetVolumeOnIOThread(double volume) {
|
| void AudioOutputDevice::OnStateChanged(AudioOutputIPCDelegate::State state) {
|
| DCHECK(message_loop()->BelongsToCurrentThread());
|
|
|
| - // Do nothing if the stream has been closed.
|
| - if (state_ < CREATING_STREAM)
|
| + // Do nothing if the stream has been closed. Don't dereference the callback
|
| + // object if the audio thread is stopped or stopping. That could mean that
|
| + // the callback object has been deleted.
|
| + // 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 (state_ < CREATING_STREAM || audio_thread_.IsStopped())
|
| return;
|
|
|
| if (state == AudioOutputIPCDelegate::kError) {
|
| @@ -198,8 +204,11 @@ void AudioOutputDevice::OnStateChanged(AudioOutputIPCDelegate::State 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();
|
| + // if (!audio_thread_.IsStopped())
|
| + // callback_->OnRenderError();
|
| + } else if (state == AudioOutputIPCDelegate::kDeviceChange) {
|
| + LOG(ERROR) << "AudioOutputDevice::kDeviceChange@" << this;
|
| + callback_->OnDeviceChange();
|
| }
|
| }
|
|
|
|
|