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

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

Issue 11086009: Prevent AudioLowLatencyInputMac from changing frame sizes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Typo fix. Created 8 years, 2 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 | media/audio/mac/audio_low_latency_output_mac.cc » ('j') | 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 dc9bd8ab48ee7d87aa52a690b407fa3da2cc2ec1..276f3e7196bb4b459fc0f0e5a383cce04ee16ae7 100644
--- a/media/audio/mac/audio_low_latency_input_mac.cc
+++ b/media/audio/mac/audio_low_latency_input_mac.cc
@@ -195,6 +195,11 @@ bool AUAudioInputStream::Open() {
}
// Set the desired number of frames in the IO buffer (output scope).
+ // WARNING: Setting this value changes the frame size for all audio units in
+ // the current process. It's imperative that the input and output frame sizes
+ // be the same as audio_util::GetAudioHardwareBufferSize().
+ // TODO(henrika): Due to http://crrev.com/159666 this is currently not true
+ // and should be fixed, a CHECK() should be added at that time.
result = AudioUnitSetProperty(audio_unit_,
kAudioDevicePropertyBufferFrameSize,
kAudioUnitScope_Output,
@@ -460,6 +465,18 @@ OSStatus AUAudioInputStream::Provide(UInt32 number_of_frames,
if (!audio_data)
return kAudioUnitErr_InvalidElement;
+ // Unfortunately AUAudioInputStream and AUAudioOutputStream share the frame
+ // size set by kAudioDevicePropertyBufferFrameSize above on a per process
+ // basis. What this means is that the |number_of_frames| value may be larger
+ // or smaller than the value set during Configure(). In this case either
+ // audio input or audio output will be broken, so just do nothing.
+ // TODO(henrika): This should never happen so long as we're always using the
+ // hardware sample rate and the input/output streams configure the same frame
+ // size. This is currently not true. See http://crbug.com/154352. Once
+ // fixed, a CHECK() should be added and this wall of text removed.
+ if (number_of_frames != static_cast<UInt32>(number_of_frames_))
+ return noErr;
+
// Deliver data packet, delay estimation and volume level to the user.
sink_->OnData(this,
audio_data,
« no previous file with comments | « no previous file | media/audio/mac/audio_low_latency_output_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698