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

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

Issue 11014015: implement AudioManagerMac::GetPreferredLowLatencyOutputStreamParameters( (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: address Dale's comment Created 8 years, 3 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_manager_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « media/audio/mac/audio_manager_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698