Index: media/audio/mac/audio_manager_mac.cc |
diff --git a/media/audio/mac/audio_manager_mac.cc b/media/audio/mac/audio_manager_mac.cc |
index edf59930d155f57bda6be85a2a139c4fa3314ad6..a4cadbaa39f6eaa0a5d0dfcd7d4ff5aa85858695 100644 |
--- a/media/audio/mac/audio_manager_mac.cc |
+++ b/media/audio/mac/audio_manager_mac.cc |
@@ -10,6 +10,7 @@ |
#include "base/mac/mac_logging.h" |
#include "base/mac/scoped_cftyperef.h" |
#include "base/sys_string_conversions.h" |
+#include "media/audio/audio_util.h" |
#include "media/audio/mac/audio_input_mac.h" |
#include "media/audio/mac/audio_low_latency_input_mac.h" |
#include "media/audio/mac/audio_low_latency_output_mac.h" |
@@ -25,6 +26,9 @@ namespace media { |
// Maximum number of output streams that can be open simultaneously. |
static const int kMaxOutputStreams = 50; |
+// Maximum buffer size that CoreAudio can support, used by low latency path. |
+static const int kMaxLowLatencyBufferSize = 2047; |
+ |
static bool HasAudioHardware(AudioObjectPropertySelector selector) { |
AudioDeviceID output_device_id = kAudioObjectUnknown; |
const AudioObjectPropertyAddress property_address = { |
@@ -333,4 +337,22 @@ AudioManager* CreateAudioManager() { |
return new AudioManagerMac(); |
} |
+AudioParameters AudioManagerMac::GetPreferredLowLatencyOutputStreamParameters( |
+ const AudioParameters& params) { |
+ // Applications should use their own preferred buffer size when no resampler |
+ // is needed, and Apple CoreAudio can accept any buffer size up to 2047. |
+ int native_sample_rate = GetAudioHardwareSampleRate(); |
+ int buffer_size = GetAudioHardwareBufferSize(); |
+ if (native_sample_rate == params.sample_rate() && |
+ params.frames_per_buffer() <= kMaxLowLatencyBufferSize) { |
+ buffer_size = params.frames_per_buffer(); |
+ } |
+ |
+ return AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, |
+ params.channel_layout(), |
+ native_sample_rate, |
+ 16, |
+ buffer_size); |
+} |
+ |
} // namespace media |