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

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

Issue 236123002: Allow pass through buffer sizes on OSX. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. Rebase. Created 6 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.cc ('k') | media/audio/mac/audio_manager_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 5623bce162231fdb3016e2615bb7497c8d174cf4..6b31839fe2c167bd9dbd584f65efcd696311024d 100644
--- a/media/audio/mac/audio_low_latency_input_mac.cc
+++ b/media/audio/mac/audio_low_latency_input_mac.cc
@@ -64,9 +64,6 @@ AUAudioInputStream::AUAudioInputStream(
// Set number of sample frames per callback used by the internal audio layer.
// An internal FIFO is then utilized to adapt the internal size to the size
// requested by the client.
- // Note that we use the same native buffer size as for the output side here
- // since the AUHAL implementation requires that both capture and render side
- // use the same buffer size. See http://crbug.com/154352 for more details.
number_of_frames_ = output_params.frames_per_buffer();
DVLOG(1) << "Size of data buffer in frames : " << number_of_frames_;
@@ -233,23 +230,38 @@ 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 the frames_per_buffer() returned by
- // GetInputStreamParameters().
- // 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_,
+ // WARNING: Setting this value changes the frame size for all input and output
no longer working on chromium 2014/04/17 10:25:46 ditto?
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_,
kAudioDevicePropertyBufferFrameSize,
kAudioUnitScope_Output,
1,
- &number_of_frames_, // size is set in the ctor
- sizeof(number_of_frames_));
- if (result) {
+ &buffer_size,
+ &property_size);
+ if (result != noErr) {
HandleError(result);
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_->input_stream_count() == 1 || number_of_frames_ < buffer_size) {
+ buffer_size = number_of_frames_;
+ result = AudioUnitSetProperty(audio_unit_,
+ kAudioDevicePropertyBufferFrameSize,
+ kAudioUnitScope_Output,
+ 1,
+ &buffer_size,
+ sizeof(buffer_size));
+ if (result != noErr) {
+ HandleError(result);
+ return false;
+ }
+ }
+
// Finally, initialize the audio unit and ensure that it is ready to render.
// Allocates memory according to the maximum number of audio frames
// it can produce in response to a single render call.
« no previous file with comments | « media/audio/mac/audio_auhal_mac.cc ('k') | media/audio/mac/audio_manager_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698