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

Side by Side 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: Created 8 years, 2 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 unified diff | Download patch
« no previous file with comments | « media/audio/mac/audio_manager_mac.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <CoreAudio/AudioHardware.h> 5 #include <CoreAudio/AudioHardware.h>
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/mac/mac_logging.h" 10 #include "base/mac/mac_logging.h"
11 #include "base/mac/scoped_cftyperef.h" 11 #include "base/mac/scoped_cftyperef.h"
12 #include "base/sys_string_conversions.h" 12 #include "base/sys_string_conversions.h"
13 #include "media/audio/audio_util.h"
13 #include "media/audio/mac/audio_input_mac.h" 14 #include "media/audio/mac/audio_input_mac.h"
14 #include "media/audio/mac/audio_low_latency_input_mac.h" 15 #include "media/audio/mac/audio_low_latency_input_mac.h"
15 #include "media/audio/mac/audio_low_latency_output_mac.h" 16 #include "media/audio/mac/audio_low_latency_output_mac.h"
16 #include "media/audio/mac/audio_manager_mac.h" 17 #include "media/audio/mac/audio_manager_mac.h"
17 #include "media/audio/mac/audio_output_mac.h" 18 #include "media/audio/mac/audio_output_mac.h"
18 #include "media/audio/mac/audio_synchronized_mac.h" 19 #include "media/audio/mac/audio_synchronized_mac.h"
19 #include "media/audio/mac/audio_unified_mac.h" 20 #include "media/audio/mac/audio_unified_mac.h"
20 #include "media/base/limits.h" 21 #include "media/base/limits.h"
21 #include "media/base/media_switches.h" 22 #include "media/base/media_switches.h"
22 23
23 namespace media { 24 namespace media {
24 25
25 // Maximum number of output streams that can be open simultaneously. 26 // Maximum number of output streams that can be open simultaneously.
26 static const int kMaxOutputStreams = 50; 27 static const int kMaxOutputStreams = 50;
27 28
29 // Maximum buffer size CoreAudio can support.
30 static const int kMaxBufferSize = 2047;
DaleCurtis 2012/10/01 17:37:36 Add some comment about low latency specifically. M
no longer working on chromium 2012/10/02 08:06:22 Done.
31
28 static bool HasAudioHardware(AudioObjectPropertySelector selector) { 32 static bool HasAudioHardware(AudioObjectPropertySelector selector) {
29 AudioDeviceID output_device_id = kAudioObjectUnknown; 33 AudioDeviceID output_device_id = kAudioObjectUnknown;
30 const AudioObjectPropertyAddress property_address = { 34 const AudioObjectPropertyAddress property_address = {
31 selector, 35 selector,
32 kAudioObjectPropertyScopeGlobal, // mScope 36 kAudioObjectPropertyScopeGlobal, // mScope
33 kAudioObjectPropertyElementMaster // mElement 37 kAudioObjectPropertyElementMaster // mElement
34 }; 38 };
35 UInt32 output_device_id_size = static_cast<UInt32>(sizeof(output_device_id)); 39 UInt32 output_device_id_size = static_cast<UInt32>(sizeof(output_device_id));
36 OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject, 40 OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject,
37 &property_address, 41 &property_address,
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 if (audio_device_id != kAudioObjectUnknown) 330 if (audio_device_id != kAudioObjectUnknown)
327 stream = new AUAudioInputStream(this, params, audio_device_id); 331 stream = new AUAudioInputStream(this, params, audio_device_id);
328 332
329 return stream; 333 return stream;
330 } 334 }
331 335
332 AudioManager* CreateAudioManager() { 336 AudioManager* CreateAudioManager() {
333 return new AudioManagerMac(); 337 return new AudioManagerMac();
334 } 338 }
335 339
340 AudioParameters AudioManagerMac::GetPreferredLowLatencyOutputStreamParameters(
341 const AudioParameters& params) {
342 // Applications should use their own preferred buffer size when no resampler
343 // is needed, and Apple CoreAudio can accept any buffer size up to 2047.
344 int native_sample_rate = GetAudioHardwareSampleRate();
345 int buffer_size = GetAudioHardwareBufferSize();
346 if (native_sample_rate == params.sample_rate() &&
347 params.frames_per_buffer() <= kMaxBufferSize) {
348 buffer_size = params.frames_per_buffer();
349 }
350
351 return AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
352 params.channel_layout(),
353 native_sample_rate,
354 16,
355 buffer_size);
356 }
357
336 } // namespace media 358 } // namespace media
OLDNEW
« 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