| OLD | NEW |
| 1 // Copyright (c) 2011 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/mac/mac_util.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 static const int kMaxInputChannels = 2; | 16 static const int kMaxInputChannels = 2; |
| 17 | 17 |
| 18 // Maximum number of output streams that can be open simultaneously. | 18 // Maximum number of output streams that can be open simultaneously. |
| 19 static const size_t kMaxOutputStreams = 50; | 19 static const size_t kMaxOutputStreams = 50; |
| 20 | 20 |
| 21 // By experiment the maximum number of audio streams allowed in Leopard | 21 // By experiment the maximum number of audio streams allowed in Leopard |
| 22 // 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. |
| 23 static const size_t kMaxOutputStreamsLeopard = 15; | 23 static const size_t kMaxOutputStreamsLeopard = 15; |
| 24 | 24 |
| 25 // Initialized to ether |kMaxOutputStreams| or |kMaxOutputStreamsLeopard|. | 25 // Initialized to ether |kMaxOutputStreams| or |kMaxOutputStreamsLeopard|. |
| 26 static size_t g_max_output_streams = 0; | 26 static size_t g_max_output_streams = 0; |
| 27 | 27 |
| 28 // 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 |
| 29 // prevent failure caused by too many audio streams opened. | 29 // prevent failure caused by too many audio streams opened. |
| 30 static size_t GetMaxAudioOutputStreamsAllowed() { | 30 static size_t GetMaxAudioOutputStreamsAllowed() { |
| 31 if (g_max_output_streams == 0) { | 31 if (g_max_output_streams == 0) { |
| 32 // 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 |
| 33 // a deadlock in the AudioQueue API when starting the stream. Unfortunately | 33 // a deadlock in the AudioQueue API when starting the stream. Unfortunately |
| 34 // 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 |
| 35 // special hard limit only for Leopard. | 35 // special hard limit only for Leopard. |
| 36 // See bug: http://crbug.com/30242 | 36 // See bug: http://crbug.com/30242 |
| 37 int32 major, minor, bugfix; | 37 if (base::mac::IsOSLeopardOrEarlier()) { |
| 38 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix); | |
| 39 if (major < 10 || (major == 10 && minor <= 5)) { | |
| 40 g_max_output_streams = kMaxOutputStreamsLeopard; | 38 g_max_output_streams = kMaxOutputStreamsLeopard; |
| 41 } else { | 39 } else { |
| 42 // In OS other than OSX Leopard, the number of audio streams | 40 // In OS other than OSX Leopard, the number of audio streams |
| 43 // allowed is a lot more. | 41 // allowed is a lot more. |
| 44 g_max_output_streams = kMaxOutputStreams; | 42 g_max_output_streams = kMaxOutputStreams; |
| 45 } | 43 } |
| 46 } | 44 } |
| 47 | 45 |
| 48 return g_max_output_streams; | 46 return g_max_output_streams; |
| 49 } | 47 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 148 |
| 151 // Called by the stream when it has been released by calling Close(). | 149 // Called by the stream when it has been released by calling Close(). |
| 152 void AudioManagerMac::ReleaseInputStream(PCMQueueInAudioInputStream* stream) { | 150 void AudioManagerMac::ReleaseInputStream(PCMQueueInAudioInputStream* stream) { |
| 153 delete stream; | 151 delete stream; |
| 154 } | 152 } |
| 155 | 153 |
| 156 // static | 154 // static |
| 157 AudioManager* AudioManager::CreateAudioManager() { | 155 AudioManager* AudioManager::CreateAudioManager() { |
| 158 return new AudioManagerMac(); | 156 return new AudioManagerMac(); |
| 159 } | 157 } |
| OLD | NEW |