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

Side by Side Diff: media/audio/mac/audio_manager_mac.cc

Issue 11028092: Revert 159666 - Use clients' preferred buffer size when the sample rates match and it is a number s… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
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 | Annotate | Revision Log
« 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"
14 #include "media/audio/mac/audio_input_mac.h" 13 #include "media/audio/mac/audio_input_mac.h"
15 #include "media/audio/mac/audio_low_latency_input_mac.h" 14 #include "media/audio/mac/audio_low_latency_input_mac.h"
16 #include "media/audio/mac/audio_low_latency_output_mac.h" 15 #include "media/audio/mac/audio_low_latency_output_mac.h"
17 #include "media/audio/mac/audio_manager_mac.h" 16 #include "media/audio/mac/audio_manager_mac.h"
18 #include "media/audio/mac/audio_output_mac.h" 17 #include "media/audio/mac/audio_output_mac.h"
19 #include "media/audio/mac/audio_synchronized_mac.h" 18 #include "media/audio/mac/audio_synchronized_mac.h"
20 #include "media/audio/mac/audio_unified_mac.h" 19 #include "media/audio/mac/audio_unified_mac.h"
21 #include "media/base/limits.h" 20 #include "media/base/limits.h"
22 #include "media/base/media_switches.h" 21 #include "media/base/media_switches.h"
23 22
24 namespace media { 23 namespace media {
25 24
26 // Maximum number of output streams that can be open simultaneously. 25 // Maximum number of output streams that can be open simultaneously.
27 static const int kMaxOutputStreams = 50; 26 static const int kMaxOutputStreams = 50;
28 27
29 // Maximum buffer size that CoreAudio can support, used by low latency path.
30 static const int kMaxLowLatencyBufferSize = 2047;
31
32 static bool HasAudioHardware(AudioObjectPropertySelector selector) { 28 static bool HasAudioHardware(AudioObjectPropertySelector selector) {
33 AudioDeviceID output_device_id = kAudioObjectUnknown; 29 AudioDeviceID output_device_id = kAudioObjectUnknown;
34 const AudioObjectPropertyAddress property_address = { 30 const AudioObjectPropertyAddress property_address = {
35 selector, 31 selector,
36 kAudioObjectPropertyScopeGlobal, // mScope 32 kAudioObjectPropertyScopeGlobal, // mScope
37 kAudioObjectPropertyElementMaster // mElement 33 kAudioObjectPropertyElementMaster // mElement
38 }; 34 };
39 UInt32 output_device_id_size = static_cast<UInt32>(sizeof(output_device_id)); 35 UInt32 output_device_id_size = static_cast<UInt32>(sizeof(output_device_id));
40 OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject, 36 OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject,
41 &property_address, 37 &property_address,
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 if (audio_device_id != kAudioObjectUnknown) 326 if (audio_device_id != kAudioObjectUnknown)
331 stream = new AUAudioInputStream(this, params, audio_device_id); 327 stream = new AUAudioInputStream(this, params, audio_device_id);
332 328
333 return stream; 329 return stream;
334 } 330 }
335 331
336 AudioManager* CreateAudioManager() { 332 AudioManager* CreateAudioManager() {
337 return new AudioManagerMac(); 333 return new AudioManagerMac();
338 } 334 }
339 335
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() <= kMaxLowLatencyBufferSize) {
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
358 } // namespace media 336 } // 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