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

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

Issue 10837158: mac: Delete more 10.5-only code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 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
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/mac/mac_logging.h" 9 #include "base/mac/mac_logging.h"
10 #include "base/mac/mac_util.h"
11 #include "base/mac/scoped_cftyperef.h" 10 #include "base/mac/scoped_cftyperef.h"
12 #include "base/sys_string_conversions.h" 11 #include "base/sys_string_conversions.h"
13 #include "media/audio/mac/audio_input_mac.h" 12 #include "media/audio/mac/audio_input_mac.h"
14 #include "media/audio/mac/audio_low_latency_input_mac.h" 13 #include "media/audio/mac/audio_low_latency_input_mac.h"
15 #include "media/audio/mac/audio_low_latency_output_mac.h" 14 #include "media/audio/mac/audio_low_latency_output_mac.h"
16 #include "media/audio/mac/audio_manager_mac.h" 15 #include "media/audio/mac/audio_manager_mac.h"
17 #include "media/audio/mac/audio_output_mac.h" 16 #include "media/audio/mac/audio_output_mac.h"
18 #include "media/base/limits.h" 17 #include "media/base/limits.h"
19 18
20 namespace media { 19 namespace media {
21 20
22 // Maximum number of output streams that can be open simultaneously. 21 // Maximum number of output streams that can be open simultaneously.
23 static const int kMaxOutputStreams = 50; 22 static const int kMaxOutputStreams = 50;
24 23
25 // By experiment the maximum number of audio streams allowed in Leopard
26 // is 18. But we put a slightly smaller number just to be safe.
27 static const int kMaxOutputStreamsLeopard = 15;
28
29 static bool HasAudioHardware(AudioObjectPropertySelector selector) { 24 static bool HasAudioHardware(AudioObjectPropertySelector selector) {
30 AudioDeviceID output_device_id = kAudioObjectUnknown; 25 AudioDeviceID output_device_id = kAudioObjectUnknown;
31 const AudioObjectPropertyAddress property_address = { 26 const AudioObjectPropertyAddress property_address = {
32 selector, 27 selector,
33 kAudioObjectPropertyScopeGlobal, // mScope 28 kAudioObjectPropertyScopeGlobal, // mScope
34 kAudioObjectPropertyElementMaster // mElement 29 kAudioObjectPropertyElementMaster // mElement
35 }; 30 };
36 size_t output_device_id_size = sizeof(output_device_id); 31 size_t output_device_id_size = sizeof(output_device_id);
37 OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject, 32 OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject,
38 &property_address, 33 &property_address,
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 200
206 if (result) { 201 if (result) {
207 OSSTATUS_DLOG(WARNING, result) << "Unable to query device " << device_id 202 OSSTATUS_DLOG(WARNING, result) << "Unable to query device " << device_id
208 << " for AudioDeviceID"; 203 << " for AudioDeviceID";
209 } 204 }
210 205
211 return audio_device_id; 206 return audio_device_id;
212 } 207 }
213 208
214 AudioManagerMac::AudioManagerMac() { 209 AudioManagerMac::AudioManagerMac() {
215 // We are hitting a bug in Leopard where too many audio streams will cause 210 SetMaxOutputStreamsAllowed(kMaxOutputStreams);
216 // a deadlock in the AudioQueue API when starting the stream. Unfortunately
217 // there's no way to detect it within the AudioQueue API, so we put a
218 // special hard limit only for Leopard.
219 // See bug: http://crbug.com/30242
220 // In OS other than OSX Leopard, the number of audio streams
221 // allowed is a lot more.
222 int max_output_stream = base::mac::IsOSLeopardOrEarlier() ?
223 kMaxOutputStreamsLeopard : kMaxOutputStreams;
224 SetMaxOutputStreamsAllowed(max_output_stream);
225 } 211 }
226 212
227 AudioManagerMac::~AudioManagerMac() { 213 AudioManagerMac::~AudioManagerMac() {
228 Shutdown(); 214 Shutdown();
229 } 215 }
230 216
231 bool AudioManagerMac::HasAudioOutputDevices() { 217 bool AudioManagerMac::HasAudioOutputDevices() {
232 return HasAudioHardware(kAudioHardwarePropertyDefaultOutputDevice); 218 return HasAudioHardware(kAudioHardwarePropertyDefaultOutputDevice);
233 } 219 }
234 220
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 stream = new AUAudioInputStream(this, params, audio_device_id); 270 stream = new AUAudioInputStream(this, params, audio_device_id);
285 271
286 return stream; 272 return stream;
287 } 273 }
288 274
289 AudioManager* CreateAudioManager() { 275 AudioManager* CreateAudioManager() {
290 return new AudioManagerMac(); 276 return new AudioManagerMac();
291 } 277 }
292 278
293 } // namespace media 279 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698