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

Unified Diff: media/audio/mac/audio_low_latency_input_mac.cc

Issue 1668373003: Improved error handling in AUAudioInputStream::Open() for Mac OSX (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed audio input unit test. Now inline with how output side works as well Created 4 years, 10 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
Index: media/audio/mac/audio_low_latency_input_mac.cc
diff --git a/media/audio/mac/audio_low_latency_input_mac.cc b/media/audio/mac/audio_low_latency_input_mac.cc
index afd17c90a9ae84e50553e2762853b9e36816ee36..588c1cf21cdd68ad47df1eb1e585f5711385402a 100644
--- a/media/audio/mac/audio_low_latency_input_mac.cc
+++ b/media/audio/mac/audio_low_latency_input_mac.cc
@@ -114,13 +114,13 @@ AUAudioInputStream::~AUAudioInputStream() {
bool AUAudioInputStream::Open() {
DCHECK(thread_checker_.CalledOnValidThread());
DVLOG(1) << "Open";
- // Verify that we are not already opened.
- if (audio_unit_)
- return false;
+ DCHECK(!audio_unit_);
- // Verify that we have a valid device.
+ // Verify that we have a valid device. Send appropriate error code to
+ // HandleError() to ensure that the error type is added to UMA stats.
if (input_device_id_ == kAudioObjectUnknown) {
NOTREACHED() << "Device ID is unknown";
+ HandleError(kAudioUnitErr_InvalidElement);
return false;
}
@@ -136,6 +136,7 @@ bool AUAudioInputStream::Open() {
UMA_HISTOGRAM_SPARSE_SLOWLY("Media.InputInvalidSampleRateMac", sample_rate);
NOTREACHED() << "Requested sample-rate: " << format_.mSampleRate
<< " must match the hardware sample-rate: " << sample_rate;
+ HandleError(kAudioUnitErr_InvalidParameter);
return false;
}
@@ -154,8 +155,13 @@ bool AUAudioInputStream::Open() {
0
};
+ // Find a component that meets the description in |desc|.
AudioComponent comp = AudioComponentFindNext(nullptr, &desc);
DCHECK(comp);
+ if (!comp) {
+ HandleError(kAudioUnitErr_NoConnection);
+ return false;
+ }
// Get access to the service provided by the specified Audio Unit.
OSStatus result = AudioComponentInstanceNew(comp, &audio_unit_);

Powered by Google App Engine
This is Rietveld 408576698