Chromium Code Reviews| Index: media/audio/mac/audio_auhal_mac.cc |
| diff --git a/media/audio/mac/audio_auhal_mac.cc b/media/audio/mac/audio_auhal_mac.cc |
| index abbb4bfcbfa43ed531db05463163be2ac4f97cb4..0b9e62a1a9bbdf17249cd46ce0a1a341fa5d8d77 100644 |
| --- a/media/audio/mac/audio_auhal_mac.cc |
| +++ b/media/audio/mac/audio_auhal_mac.cc |
| @@ -217,13 +217,12 @@ OSStatus AUHALStream::Render( |
| TRACE_EVENT0("audio", "AUHALStream::Render"); |
| // If the stream parameters change for any reason, we need to insert a FIFO |
| - // since the OnMoreData() pipeline can't handle frame size changes. Generally |
| - // this is a temporary situation which can occur after a device change has |
| - // occurred but the AudioManager hasn't received the notification yet. |
| + // since the OnMoreData() pipeline can't handle frame size changes. |
| if (number_of_frames != number_of_frames_) { |
| // Create a FIFO on the fly to handle any discrepancies in callback rates. |
| if (!audio_fifo_) { |
| - VLOG(1) << "Audio frame size change detected; adding FIFO to compensate."; |
| + VLOG(1) << "Audio frame size changed from " << number_of_frames_ << " to " |
| + << number_of_frames << "; adding FIFO to compensate."; |
| audio_fifo_.reset(new AudioPullFifo( |
| output_channels_, |
| number_of_frames_, |
| @@ -509,25 +508,41 @@ bool AUHALStream::ConfigureAUHAL() { |
| } |
| // 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 the frames_per_buffer() returned by |
| - // GetDefaultOutputStreamParameters(). |
| - // See http://crbug.com/154352 for details. |
| - UInt32 buffer_size = number_of_frames_; |
| - result = AudioUnitSetProperty( |
| - audio_unit_, |
| - kAudioDevicePropertyBufferFrameSize, |
| - kAudioUnitScope_Output, |
| - 0, |
| - &buffer_size, |
| - sizeof(buffer_size)); |
| + // WARNING: Setting this value changes the frame size for all input and output |
|
no longer working on chromium
2014/04/17 10:25:46
nit, it seems it is not true that this will affect
DaleCurtis
2014/04/17 20:50:29
Done.
|
| + // audio units in the current process. As a result, the AURenderCallback must |
| + // be able to handle arbitrary buffer sizes and FIFO appropriately. |
| + UInt32 buffer_size = 0; |
| + UInt32 property_size = sizeof(buffer_size); |
| + result = AudioUnitGetProperty(audio_unit_, |
|
no longer working on chromium
2014/04/16 14:57:11
curiously, what will the value of buffer_size be w
DaleCurtis
2014/04/16 22:56:02
Whatever the device default is. On my MacBook Pro
|
| + kAudioDevicePropertyBufferFrameSize, |
| + kAudioUnitScope_Output, |
| + 0, |
| + &buffer_size, |
| + &property_size); |
| if (result != noErr) { |
| OSSTATUS_DLOG(ERROR, result) |
| - << "AudioUnitSetProperty(kAudioDevicePropertyBufferFrameSize) failed."; |
| + << "AudioUnitGetProperty(kAudioDevicePropertyBufferFrameSize) failed."; |
| return false; |
| } |
| + // Only set the buffer size if we're the only active stream or the buffer size |
| + // is lower than the current buffer size. |
| + if (manager_->output_stream_count() == 1 || number_of_frames_ < buffer_size) { |
|
no longer working on chromium
2014/04/16 14:57:11
what happen if there are active input streams with
DaleCurtis
2014/04/16 22:56:02
The "0" after kAudioUnitScope_Output controls whet
no longer working on chromium
2014/04/17 10:25:46
Interesting. I might be just misled by that bug.
I
|
| + buffer_size = number_of_frames_; |
| + result = AudioUnitSetProperty(audio_unit_, |
| + kAudioDevicePropertyBufferFrameSize, |
| + kAudioUnitScope_Output, |
| + 0, |
| + &buffer_size, |
| + sizeof(buffer_size)); |
| + if (result != noErr) { |
| + OSSTATUS_DLOG(ERROR, result) << "AudioUnitSetProperty(" |
| + "kAudioDevicePropertyBufferFrameSize) " |
| + "failed."; |
|
no longer working on chromium
2014/04/16 14:57:11
nit, including the number_of_frames_ to the log?
DaleCurtis
2014/04/16 22:56:02
Done.
|
| + return false; |
| + } |
| + } |
| + |
| // Setup callback. |
| AURenderCallbackStruct callback; |
| callback.inputProc = InputProc; |