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 d71673fd12ae517dd61f0fdedabda64d2e7e4077..8bb62e809ecb08be16817bb5389d1b44d657a506 100644 |
| --- a/media/audio/mac/audio_auhal_mac.cc |
| +++ b/media/audio/mac/audio_auhal_mac.cc |
| @@ -44,6 +44,7 @@ AUHALStream::AUHALStream(AudioManagerMac* manager, |
| params_(params), |
| output_channels_(params_.channels()), |
| number_of_frames_(params_.frames_per_buffer()), |
| + actual_io_buffer_frame_size_(0), |
| number_of_frames_requested_(0), |
| source_(NULL), |
| device_(device), |
| @@ -115,6 +116,12 @@ bool AUHALStream::Open() { |
| if (configured) |
| hardware_latency_frames_ = GetHardwareLatency(); |
| +#if !defined(NDEBUG) |
| + // Print a list of all existing output streams and there current buffer size |
| + // state (required and actual). Does nothing in Release builds. |
| + manager_->PrintOutputBufferSizes(); |
| +#endif |
| + |
| return configured; |
| } |
| @@ -175,6 +182,7 @@ void AUHALStream::Stop() { |
| if (stopped_) |
| return; |
| DVLOG(1) << "Stop"; |
| + DVLOG(2) << "number_of_frames: " << number_of_frames_; |
| OSStatus result = AudioOutputUnitStop(audio_unit_); |
| OSSTATUS_DLOG_IF(ERROR, result != noErr, result) |
| << "AudioOutputUnitStop() failed."; |
| @@ -217,13 +225,16 @@ OSStatus AUHALStream::Render( |
| // any further changes will be ignored. It would be nice to have all |
| // changes reflected in UMA stats. |
| number_of_frames_requested_ = number_of_frames; |
| + actual_io_buffer_frame_size_ = number_of_frames; |
|
Henrik Grunell
2016/04/27 08:59:28
Is the intention that only the first time the requ
henrika (OOO until Aug 14)
2016/04/27 12:12:30
Good point. I can move it up one scope instead. Th
|
| DVLOG(1) << "Audio frame size changed from " << number_of_frames_ |
| - << " to " << number_of_frames |
| - << "; adding FIFO to compensate."; |
| + << " to " << number_of_frames << " adding FIFO to compensate."; |
| audio_fifo_.reset(new AudioPullFifo( |
| output_channels_, |
| number_of_frames_, |
| base::Bind(&AUHALStream::ProvideInput, base::Unretained(this)))); |
| +#if !defined(NDEBUG) |
| + manager_->PrintOutputBufferSizes(); |
| +#endif |
| } |
| } |
| @@ -512,6 +523,26 @@ bool AUHALStream::ConfigureAUHAL() { |
| return false; |
| } |
| + // Get the actual number of frames in the IO buffers after the audio manager |
| + // has tried to set the requested size. We could use |io_buffer_frame_size| |
| + // here instead of doing these extra steps but I prefer to play it safe and |
| + // to ensure that the change done by the audio manager is really active. |
| + // TODO(henrika): it might be possible to remove this part. |
| + UInt32 actual_io_buffer_frame_size; |
| + UInt32 property_size = sizeof(actual_io_buffer_frame_size); |
| + result = AudioUnitGetProperty( |
| + audio_unit_, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global, |
| + 0, &actual_io_buffer_frame_size, &property_size); |
| + LOG_IF(WARNING, result != noErr) |
| + << "Failed to get the actual I/O buffer size"; |
| + if (result == noErr) { |
| + actual_io_buffer_frame_size_ = actual_io_buffer_frame_size; |
| + DVLOG(1) << "actual_io_buffer_frame_size: " << actual_io_buffer_frame_size_; |
| + } |
| + LOG_IF(WARNING, actual_io_buffer_frame_size_ != number_of_frames_) |
| + << "Failed to set the requested buffer frame size exactly"; |
| + DCHECK_EQ(io_buffer_frame_size, actual_io_buffer_frame_size); |
| + |
| // Setup callback. |
| AURenderCallbackStruct callback; |
| callback.inputProc = InputProc; |