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

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

Issue 1903753002: Restores larger output buffer size when output stream requiring smaller size is closed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 years, 8 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 | « media/audio/mac/audio_auhal_mac.h ('k') | media/audio/mac/audio_manager_mac.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..56784deacbf5ddfd21753ef908acba114a0a18a7 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.";
@@ -211,6 +219,9 @@ OSStatus 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.
if (number_of_frames != number_of_frames_) {
+ // Update the actual buffer size given the recent change.
+ base::subtle::Release_Store(&actual_io_buffer_frame_size_,
o1ka 2016/04/27 13:24:40 What is the guarantee that actual size we get in I
henrika (OOO until Aug 14) 2016/04/27 13:36:43 Sorry, don't understand. Race between what?
o1ka 2016/04/27 15:04:31 See my question: what is the guarantee that we upd
Henrik Grunell 2016/04/28 07:51:38 I'm not following either. Olga, do you mean that t
henrika (OOO until Aug 14) 2016/04/28 11:28:44 Redesigned. Stream no longer contains actual buffe
+ number_of_frames);
// Create a FIFO on the fly to handle any discrepancies in callback rates.
if (!audio_fifo_) {
// TODO(grunell): We'll only care about the first buffer size change,
@@ -218,8 +229,7 @@ OSStatus AUHALStream::Render(
// changes reflected in UMA stats.
number_of_frames_requested_ = number_of_frames;
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_,
@@ -512,6 +522,27 @@ 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.
Henrik Grunell 2016/04/28 07:51:38 What is required to do to figure out if this part
henrika (OOO until Aug 14) 2016/04/28 11:28:44 Removed now ;-)
+ 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) {
+ base::subtle::Release_Store(&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;
« no previous file with comments | « media/audio/mac/audio_auhal_mac.h ('k') | media/audio/mac/audio_manager_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698