| OLD | NEW |
| 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 // Software adjust volume of samples, allows each audio stream its own | 5 // Software adjust volume of samples, allows each audio stream its own |
| 6 // volume without impacting master volume for chrome and other applications. | 6 // volume without impacting master volume for chrome and other applications. |
| 7 | 7 |
| 8 // Implemented as templates to allow 8, 16 and 32 bit implementations. | 8 // Implemented as templates to allow 8, 16 and 32 bit implementations. |
| 9 // 8 bit is unsigned and biased by 128. | 9 // 8 bit is unsigned and biased by 128. |
| 10 | 10 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 131 } |
| 132 | 132 |
| 133 // Hardware sample-rate on Windows can be configured, so we must query. | 133 // Hardware sample-rate on Windows can be configured, so we must query. |
| 134 // TODO(henrika): improve possibility to specify an audio endpoint. | 134 // TODO(henrika): improve possibility to specify an audio endpoint. |
| 135 // Use the default device (same as for Wave) for now to be compatible. | 135 // Use the default device (same as for Wave) for now to be compatible. |
| 136 return WASAPIAudioOutputStream::HardwareSampleRate(); | 136 return WASAPIAudioOutputStream::HardwareSampleRate(); |
| 137 #elif defined(OS_ANDROID) | 137 #elif defined(OS_ANDROID) |
| 138 // TODO(leozwang): return native sampling rate on Android. | 138 // TODO(leozwang): return native sampling rate on Android. |
| 139 return 16000; | 139 return 16000; |
| 140 #else | 140 #else |
| 141 // Hardware for Linux is nearly always 48KHz. | |
| 142 // TODO(crogers) : return correct value in rare non-48KHz cases. | |
| 143 return 48000; | 141 return 48000; |
| 144 #endif | 142 #endif |
| 145 } | 143 } |
| 146 | 144 |
| 147 int GetAudioInputHardwareSampleRate(const std::string& device_id) { | 145 int GetAudioInputHardwareSampleRate(const std::string& device_id) { |
| 148 // TODO(henrika): add support for device selection on all platforms. | 146 // TODO(henrika): add support for device selection on all platforms. |
| 149 // Only exists on Windows today. | 147 // Only exists on Windows today. |
| 150 #if defined(OS_MACOSX) | 148 #if defined(OS_MACOSX) |
| 151 return AUAudioInputStream::HardwareSampleRate(); | 149 return AUAudioInputStream::HardwareSampleRate(); |
| 152 #elif defined(OS_WIN) | 150 #elif defined(OS_WIN) |
| 153 if (!CoreAudioUtil::IsSupported()) { | 151 if (!CoreAudioUtil::IsSupported()) { |
| 154 return 48000; | 152 return 48000; |
| 155 } | 153 } |
| 156 return WASAPIAudioInputStream::HardwareSampleRate(device_id); | 154 return WASAPIAudioInputStream::HardwareSampleRate(device_id); |
| 157 #elif defined(OS_ANDROID) | 155 #elif defined(OS_ANDROID) |
| 158 return 16000; | 156 return 16000; |
| 159 #else | 157 #else |
| 158 // Hardware for Linux is nearly always 48KHz. |
| 159 // TODO(crogers) : return correct value in rare non-48KHz cases. |
| 160 return 48000; | 160 return 48000; |
| 161 #endif | 161 #endif |
| 162 } | 162 } |
| 163 | 163 |
| 164 size_t GetAudioHardwareBufferSize() { | 164 size_t GetAudioHardwareBufferSize() { |
| 165 int user_buffer_size = GetUserBufferSize(); | 165 int user_buffer_size = GetUserBufferSize(); |
| 166 if (user_buffer_size) | 166 if (user_buffer_size) |
| 167 return user_buffer_size; | 167 return user_buffer_size; |
| 168 | 168 |
| 169 // The sizes here were determined by experimentation and are roughly | 169 // The sizes here were determined by experimentation and are roughly |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 // out performance was degraded compared to XP. | 278 // out performance was degraded compared to XP. |
| 279 // - The regression was fixed in Windows 7 and most configurations will work | 279 // - The regression was fixed in Windows 7 and most configurations will work |
| 280 // with 2, but some (e.g., some Sound Blasters) still need 3. | 280 // with 2, but some (e.g., some Sound Blasters) still need 3. |
| 281 // - Some XP configurations (even multi-processor ones) also need 3. | 281 // - Some XP configurations (even multi-processor ones) also need 3. |
| 282 return (base::win::GetVersion() == base::win::VERSION_VISTA) ? 4 : 3; | 282 return (base::win::GetVersion() == base::win::VERSION_VISTA) ? 4 : 3; |
| 283 } | 283 } |
| 284 | 284 |
| 285 #endif | 285 #endif |
| 286 | 286 |
| 287 } // namespace media | 287 } // namespace media |
| OLD | NEW |