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

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: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c81c93da2d6bf016c07e56446e41b7cb4dab4440 100644
--- a/media/audio/mac/audio_low_latency_input_mac.cc
+++ b/media/audio/mac/audio_low_latency_input_mac.cc
@@ -114,13 +114,20 @@ AUAudioInputStream::~AUAudioInputStream() {
bool AUAudioInputStream::Open() {
DCHECK(thread_checker_.CalledOnValidThread());
DVLOG(1) << "Open";
- // Verify that we are not already opened.
- if (audio_unit_)
+
+ // Verify that we are not already opened. Send appropriate error code to
+ // HandleError() to ensure that the error type is added to UMA stats where
+ // the frequency of error codes can be analyzed.
+ if (audio_unit_) {
+ HandleError(kAudioUnitErr_Initialized);
tommi (sloooow) - chröme 2016/02/05 12:29:30 I'm not sure this is a good idea. HandleError()
henrika (OOO until Aug 14) 2016/02/05 12:50:51 Done.
return false;
+ }
- // 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 +143,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);
henrika (OOO until Aug 14) 2016/02/05 12:16:28 Adding one extra here since we can then see the re
tommi (sloooow) - chröme 2016/02/05 12:29:30 Acknowledged.
return false;
}
@@ -154,8 +162,13 @@ bool AUAudioInputStream::Open() {
0
};
+ // Find a component that meets the description in |desc|.
AudioComponent comp = AudioComponentFindNext(nullptr, &desc);
DCHECK(comp);
+ if (!comp) {
+ HandleError(kAudioComponentErr_InstanceInvalidated);
+ return false;
+ }
// Get access to the service provided by the specified Audio Unit.
OSStatus result = AudioComponentInstanceNew(comp, &audio_unit_);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698