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

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

Issue 6628020: Cleaning up src/media to be consistent with static versus anonymous namespaces. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: fix namespaces Created 9 years, 9 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/sys_info.h" 7 #include "base/sys_info.h"
8 #include "media/audio/fake_audio_input_stream.h" 8 #include "media/audio/fake_audio_input_stream.h"
9 #include "media/audio/fake_audio_output_stream.h" 9 #include "media/audio/fake_audio_output_stream.h"
10 #include "media/audio/mac/audio_input_mac.h" 10 #include "media/audio/mac/audio_input_mac.h"
11 #include "media/audio/mac/audio_low_latency_output_mac.h" 11 #include "media/audio/mac/audio_low_latency_output_mac.h"
12 #include "media/audio/mac/audio_manager_mac.h" 12 #include "media/audio/mac/audio_manager_mac.h"
13 #include "media/audio/mac/audio_output_mac.h" 13 #include "media/audio/mac/audio_output_mac.h"
14 #include "media/base/limits.h" 14 #include "media/base/limits.h"
15 15
16 namespace { 16 static const int kMaxInputChannels = 2;
17
18 const int kMaxInputChannels = 2;
19 17
20 // Maximum number of output streams that can be open simultaneously. 18 // Maximum number of output streams that can be open simultaneously.
21 const size_t kMaxOutputStreams = 50; 19 static const size_t kMaxOutputStreams = 50;
22 20
23 // By experiment the maximum number of audio streams allowed in Leopard 21 // By experiment the maximum number of audio streams allowed in Leopard
24 // is 18. But we put a slightly smaller number just to be safe. 22 // is 18. But we put a slightly smaller number just to be safe.
25 const size_t kMaxOutputStreamsLeopard = 15; 23 static const size_t kMaxOutputStreamsLeopard = 15;
26 24
27 // Initialized to ether |kMaxOutputStreams| or |kMaxOutputStreamsLeopard|. 25 // Initialized to ether |kMaxOutputStreams| or |kMaxOutputStreamsLeopard|.
28 size_t g_max_output_streams = 0; 26 static size_t g_max_output_streams = 0;
29 27
30 // Returns the number of audio streams allowed. This is a practical limit to 28 // Returns the number of audio streams allowed. This is a practical limit to
31 // prevent failure caused by too many audio streams opened. 29 // prevent failure caused by too many audio streams opened.
32 size_t GetMaxAudioOutputStreamsAllowed() { 30 static size_t GetMaxAudioOutputStreamsAllowed() {
33 if (g_max_output_streams == 0) { 31 if (g_max_output_streams == 0) {
34 // We are hitting a bug in Leopard where too many audio streams will cause 32 // We are hitting a bug in Leopard where too many audio streams will cause
35 // a deadlock in the AudioQueue API when starting the stream. Unfortunately 33 // a deadlock in the AudioQueue API when starting the stream. Unfortunately
36 // there's no way to detect it within the AudioQueue API, so we put a 34 // there's no way to detect it within the AudioQueue API, so we put a
37 // special hard limit only for Leopard. 35 // special hard limit only for Leopard.
38 // See bug: http://crbug.com/30242 36 // See bug: http://crbug.com/30242
39 int32 major, minor, bugfix; 37 int32 major, minor, bugfix;
40 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix); 38 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
41 if (major < 10 || (major == 10 && minor <= 5)) { 39 if (major < 10 || (major == 10 && minor <= 5)) {
42 g_max_output_streams = kMaxOutputStreamsLeopard; 40 g_max_output_streams = kMaxOutputStreamsLeopard;
43 } else { 41 } else {
44 // In OS other than OSX Leopard, the number of audio streams 42 // In OS other than OSX Leopard, the number of audio streams
45 // allowed is a lot more. 43 // allowed is a lot more.
46 g_max_output_streams = kMaxOutputStreams; 44 g_max_output_streams = kMaxOutputStreams;
47 } 45 }
48 } 46 }
49 47
50 return g_max_output_streams; 48 return g_max_output_streams;
51 } 49 }
52 50
53 bool HasAudioHardware(AudioObjectPropertySelector selector) { 51 static bool HasAudioHardware(AudioObjectPropertySelector selector) {
54 AudioDeviceID output_device_id = kAudioObjectUnknown; 52 AudioDeviceID output_device_id = kAudioObjectUnknown;
55 const AudioObjectPropertyAddress property_address = { 53 const AudioObjectPropertyAddress property_address = {
56 selector, 54 selector,
57 kAudioObjectPropertyScopeGlobal, // mScope 55 kAudioObjectPropertyScopeGlobal, // mScope
58 kAudioObjectPropertyElementMaster // mElement 56 kAudioObjectPropertyElementMaster // mElement
59 }; 57 };
60 size_t output_device_id_size = sizeof(output_device_id); 58 size_t output_device_id_size = sizeof(output_device_id);
61 OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject, 59 OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject,
62 &property_address, 60 &property_address,
63 0, // inQualifierDataSize 61 0, // inQualifierDataSize
64 NULL, // inQualifierData 62 NULL, // inQualifierData
65 &output_device_id_size, 63 &output_device_id_size,
66 &output_device_id); 64 &output_device_id);
67 return err == kAudioHardwareNoError && 65 return err == kAudioHardwareNoError &&
68 output_device_id != kAudioObjectUnknown; 66 output_device_id != kAudioObjectUnknown;
69 } 67 }
70 } // namespace
71 68
72 AudioManagerMac::AudioManagerMac() 69 AudioManagerMac::AudioManagerMac()
73 : num_output_streams_(0) { 70 : num_output_streams_(0) {
74 } 71 }
75 72
76 AudioManagerMac::~AudioManagerMac() { 73 AudioManagerMac::~AudioManagerMac() {
77 } 74 }
78 75
79 bool AudioManagerMac::HasAudioOutputDevices() { 76 bool AudioManagerMac::HasAudioOutputDevices() {
80 return HasAudioHardware(kAudioHardwarePropertyDefaultOutputDevice); 77 return HasAudioHardware(kAudioHardwarePropertyDefaultOutputDevice);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 136
140 // Called by the stream when it has been released by calling Close(). 137 // Called by the stream when it has been released by calling Close().
141 void AudioManagerMac::ReleaseInputStream(PCMQueueInAudioInputStream* stream) { 138 void AudioManagerMac::ReleaseInputStream(PCMQueueInAudioInputStream* stream) {
142 delete stream; 139 delete stream;
143 } 140 }
144 141
145 // static 142 // static
146 AudioManager* AudioManager::CreateAudioManager() { 143 AudioManager* AudioManager::CreateAudioManager() {
147 return new AudioManagerMac(); 144 return new AudioManagerMac();
148 } 145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698