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

Unified Diff: media/audio/audio_input_device.cc

Issue 2611063003: Fix issue with audio input streams where an error would not be reported (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « media/audio/BUILD.gn ('k') | media/audio/audio_input_device_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:
« no previous file with comments | « media/audio/BUILD.gn ('k') | media/audio/audio_input_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698