Chromium Code Reviews| Index: media/audio/audio_util.cc |
| diff --git a/media/audio/audio_util.cc b/media/audio/audio_util.cc |
| index 4035d28a589fa4737cee6b1b5561fcca3a02f443..e177d525cf12e36b465efa7cd03b0bfb4ebc67d0 100644 |
| --- a/media/audio/audio_util.cc |
| +++ b/media/audio/audio_util.cc |
| @@ -20,20 +20,20 @@ |
| #include "base/logging.h" |
| #include "base/shared_memory.h" |
| #include "base/time.h" |
| -#if defined(OS_WIN) |
| -#include "base/sys_info.h" |
| -#include "base/win/windows_version.h" |
| -#include "media/audio/audio_manager_base.h" |
| -#endif |
| #include "media/audio/audio_parameters.h" |
| #include "media/audio/audio_util.h" |
| + |
| #if defined(OS_MACOSX) |
| #include "media/audio/mac/audio_low_latency_input_mac.h" |
| #include "media/audio/mac/audio_low_latency_output_mac.h" |
| -#endif |
| -#if defined(OS_WIN) |
| +#elif defined(OS_WIN) |
| +#include "base/command_line.h" |
| +#include "base/sys_info.h" |
| +#include "base/win/windows_version.h" |
| #include "media/audio/win/audio_low_latency_input_win.h" |
| #include "media/audio/win/audio_low_latency_output_win.h" |
| +#include "media/base/media_switches.h" |
| +#include "media/audio/audio_manager_base.h" |
|
no longer working on chromium
2012/07/25 12:32:57
in alphabet order
henrika (OOO until Aug 14)
2012/07/25 15:26:30
Done.
|
| #endif |
| using base::subtle::Atomic32; |
| @@ -351,16 +351,28 @@ int GetAudioHardwareSampleRate() { |
| 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(); |
|
no longer working on chromium
2012/07/25 12:32:57
Curiously, isn't it nicer to do it inside Hardware
henrika (OOO until Aug 14)
2012/07/25 15:26:30
Not sure if that is better. In any case, these par
tommi (sloooow) - chröme
2012/07/26 09:13:04
since exclusive mode applies only to WASAPIAudioOu
tommi (sloooow) - chröme
2012/07/26 13:41:49
I took another look at this and now understand why
|
| + if (cmd_line->HasSwitch(switches::kEnableExclusiveMode)) { |
| + // 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 audio endpoint. |
| - // Use the default device (same as for Wave) for now to be compatible. |
| + // TODO(henrika): improve possibility to specify an audio endpoint. |
| + // Use the default device (same as for Wave) for now to be compatible |
| + // or possibly remove the ERole argument completely until it is in use. |
| return WASAPIAudioOutputStream::HardwareSampleRate(eConsole); |
| #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; |
| + // Hardware for Linux is nearly always 48KHz. |
| + // TODO(crogers) : return correct value in rare non-48KHz cases. |
| + return 48000; |
| #endif |
| } |
| @@ -397,6 +409,15 @@ size_t GetAudioHardwareBufferSize() { |
| // and assume 48kHz as default sample rate. |
| return 2048; |
| } |
| + |
| + // 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::kEnableExclusiveMode)) { |
| + return 256; |
|
no longer working on chromium
2012/07/25 12:32:57
same question but on WASAPIAudioOutputStream::Hard
henrika (OOO until Aug 14)
2012/07/25 15:26:30
See above.
tommi (sloooow) - chröme
2012/07/26 09:13:04
+1 for Shijing's suggestion.
|
| + } |
| + |
| // This call must be done on a COM thread configured as MTA. |
| // TODO(tommi): http://code.google.com/p/chromium/issues/detail?id=103835. |
| int mixing_sample_rate = |