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

Unified Diff: media/audio/audio_util.cc

Issue 12316131: Moved AudioUtil static functions to AudioManager interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: made the GetPreferredOutputStreamParameters protected Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/audio_util.h ('k') | media/audio/cras/audio_manager_cras.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_util.cc
diff --git a/media/audio/audio_util.cc b/media/audio/audio_util.cc
index 0c8b96c4596799ea63426129ff04f494df220c17..f88478f8f0d3191c01bfc04593424bf8db1c58d8 100644
--- a/media/audio/audio_util.cc
+++ b/media/audio/audio_util.cc
@@ -108,124 +108,6 @@ bool AdjustVolume(void* buf,
return false;
}
-int GetAudioHardwareSampleRate() {
-#if defined(OS_MACOSX)
- // Hardware sample-rate on the Mac can be configured, so we must query.
- return AUAudioOutputStream::HardwareSampleRate();
-#elif defined(OS_WIN)
- if (!CoreAudioUtil::IsSupported()) {
- // Fall back to Windows Wave implementation on Windows XP or lower
- // and use 48kHz as default input sample rate.
- return 48000;
- }
-
- // TODO(crogers): tune this rate for best possible WebAudio performance.
- // WebRTC works well at 48kHz and a buffer size of 480 samples will be used
- // for this case. Note that exclusive mode is experimental.
- const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
- if (cmd_line->HasSwitch(switches::kEnableExclusiveAudio)) {
- // This sample rate will be combined with a buffer size of 256 samples
- // (see GetAudioHardwareBufferSize()), which corresponds to an output
- // delay of ~5.33ms.
- return 48000;
- }
-
- // Hardware sample-rate on Windows can be configured, so we must query.
- // TODO(henrika): improve possibility to specify an audio endpoint.
- // Use the default device (same as for Wave) for now to be compatible.
- return WASAPIAudioOutputStream::HardwareSampleRate();
-#elif defined(OS_ANDROID)
- // TODO(leozwang): return native sampling rate on Android.
- return 16000;
-#else
- return 48000;
-#endif
-}
-
-int GetAudioInputHardwareSampleRate(const std::string& device_id) {
- // TODO(henrika): add support for device selection on all platforms.
- // Only exists on Windows today.
-#if defined(OS_MACOSX)
- return AUAudioInputStream::HardwareSampleRate();
-#elif defined(OS_WIN)
- if (!CoreAudioUtil::IsSupported()) {
- return 48000;
- }
- return WASAPIAudioInputStream::HardwareSampleRate(device_id);
-#elif defined(OS_ANDROID)
- return 16000;
-#else
- // Hardware for Linux is nearly always 48KHz.
- // TODO(crogers) : return correct value in rare non-48KHz cases.
- return 48000;
-#endif
-}
-
-size_t GetAudioHardwareBufferSize() {
- int user_buffer_size = GetUserBufferSize();
- if (user_buffer_size)
- return user_buffer_size;
-
- // The sizes here were determined by experimentation and are roughly
- // the lowest value (for low latency) that still allowed glitch-free
- // audio under high loads.
- //
- // For Mac OS X and Windows the chromium audio backend uses a low-latency
- // Core Audio API, so a low buffer size is possible. For Linux, further
- // tuning may be needed.
-#if defined(OS_MACOSX)
- return 128;
-#elif defined(OS_WIN)
- // TODO(henrika): resolve conflict with GetUserBufferSize().
- // If the user tries to set a buffer size using GetUserBufferSize() it will
- // most likely fail since only the native/perfect buffer size is allowed.
-
- // Buffer size to use when a proper size can't be determined from the system.
- static const int kFallbackBufferSize = 2048;
-
- if (!CoreAudioUtil::IsSupported()) {
- // Fall back to Windows Wave implementation on Windows XP or lower
- // and assume 48kHz as default sample rate.
- return kFallbackBufferSize;
- }
-
- // TODO(crogers): tune this size to best possible WebAudio performance.
- // WebRTC always uses 10ms for Windows and does not call this method.
- // Note that exclusive mode is experimental.
- const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
- if (cmd_line->HasSwitch(switches::kEnableExclusiveAudio)) {
- return 256;
- }
-
- AudioParameters params;
- HRESULT hr = CoreAudioUtil::GetPreferredAudioParameters(eRender, eConsole,
- &params);
- return FAILED(hr) ? kFallbackBufferSize : params.frames_per_buffer();
-#elif defined(OS_LINUX)
- return 512;
-#else
- return 2048;
-#endif
-}
-
-ChannelLayout GetAudioInputHardwareChannelLayout(const std::string& device_id) {
- // TODO(henrika): add support for device selection on all platforms.
- // Only exists on Windows today.
-#if defined(OS_MACOSX)
- return CHANNEL_LAYOUT_MONO;
-#elif defined(OS_WIN)
- if (!CoreAudioUtil::IsSupported()) {
- // Fall back to Windows Wave implementation on Windows XP or lower and
- // use stereo by default.
- return CHANNEL_LAYOUT_STEREO;
- }
- return WASAPIAudioInputStream::HardwareChannelCount(device_id) == 1 ?
- CHANNEL_LAYOUT_MONO : CHANNEL_LAYOUT_STEREO;
-#else
- return CHANNEL_LAYOUT_STEREO;
-#endif
-}
-
// Computes a buffer size based on the given |sample_rate|. Must be used in
// conjunction with AUDIO_PCM_LINEAR.
size_t GetHighLatencyOutputBufferSize(int sample_rate) {
« no previous file with comments | « media/audio/audio_util.h ('k') | media/audio/cras/audio_manager_cras.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698