Index: media/audio/audio_input_device.cc |
diff --git a/media/audio/audio_input_device.cc b/media/audio/audio_input_device.cc |
index cee639bb68073055d8dab39ff8306086e9c2cfbb..9ebe4805ae010a2b514a95bc819bd47a9754e585 100644 |
--- a/media/audio/audio_input_device.cc |
+++ b/media/audio/audio_input_device.cc |
@@ -178,18 +178,25 @@ void AudioInputDevice::OnStateChanged( |
break; |
case AUDIO_INPUT_IPC_DELEGATE_STATE_ERROR: |
DLOG(WARNING) << "AudioInputDevice::OnStateChanged(ERROR)"; |
- // 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) { |
+ // At this point, we haven't attempted to start the audio thread. |
+ // Accessing the hardware might have failed or we may have reached |
+ // the limit of the number of allowed concurrent streams. |
+ // We must report the error to the |callback_| so that a potential |
+ // audio source object will enter the correct state (e.g. 'ended' for |
+ // a local audio source). |
+ callback_->OnCaptureError( |
+ "Maximum allowed input device limit reached or OS failure."); |
+ } else { |
+ // 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(). |
base::AutoLock auto_lock_(audio_thread_lock_); |
- if (audio_thread_) { |
- callback_->OnCaptureError( |
- "AudioInputDevice::OnStateChanged - audio thread still running"); |
- } |
+ if (audio_thread_) |
+ callback_->OnCaptureError("AUDIO_INPUT_IPC_DELEGATE_STATE_ERROR"); |
} |
break; |
default: |