Chromium Code Reviews| Index: media/audio/mac/audio_low_latency_output_mac.cc |
| diff --git a/media/audio/mac/audio_low_latency_output_mac.cc b/media/audio/mac/audio_low_latency_output_mac.cc |
| index 0327db0b444d0af8ba610354e236897842bb452b..9d1c673e5936f40f7cf83e2b02791ef7790ce6ff 100644 |
| --- a/media/audio/mac/audio_low_latency_output_mac.cc |
| +++ b/media/audio/mac/audio_low_latency_output_mac.cc |
| @@ -154,6 +154,11 @@ bool AUAudioOutputStream::Configure() { |
| return false; |
| // Set the buffer frame size. |
| + // 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. |
| UInt32 buffer_size = number_of_frames_; |
| result = AudioUnitSetProperty( |
| output_unit_, |
| @@ -234,18 +239,21 @@ OSStatus AUAudioOutputStream::Render(UInt32 number_of_frames, |
| uint32 hardware_pending_bytes = static_cast<uint32> |
| ((playout_latency_frames + 0.5) * format_.mBytesPerFrame); |
| - // If we specify a buffer size which is too low, the OS will ask for more data |
| - // to fulfill the hardware request, so resize the AudioBus as appropriate. |
| - // This change requires AudioOutputResampler to prevent buffer size mismatches |
| - // downstream, so glitch if it's not enabled. |
| - if (!kDisableAudioOutputResampler && |
| - static_cast<UInt32>(audio_bus_->frames()) != number_of_frames) { |
| - audio_bus_ = AudioBus::Create(audio_bus_->channels(), number_of_frames); |
| - } |
| - |
| + // Unfortunately AUAudioInputStream and AUAudioOutputStream share the frame |
|
Chris Rogers
2012/10/08 21:08:26
nit: "frame frame"
DaleCurtis
2012/10/08 21:17:34
Done.
|
| + // 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(). The downstream |
| + // audio pipeline does not support dynamic frame size changes, as such we must |
| + // clip |frames_filled| as necessary, this will result in bad audio, but the |
| + // alternative is a browser crash. |
| + // 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 the clipping + wall of text removed. |
|
Chris Rogers
2012/10/08 21:08:26
Don't we still want to check for (audio_bus_->fram
DaleCurtis
2012/10/08 21:17:34
Things are already broken so it doesn't really mat
|
| int frames_filled = std::min(source_->OnMoreData( |
| audio_bus_.get(), AudioBuffersState(0, hardware_pending_bytes)), |
| static_cast<int>(number_of_frames)); |
| + |
| // Note: If this ever changes to output raw float the data must be clipped and |
| // sanitized since it may come from an untrusted source such as NaCl. |
| audio_bus_->ToInterleaved( |