diff options
author | enal@chromium.org <enal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-15 18:30:27 +0000 |
---|---|---|
committer | enal@chromium.org <enal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-15 18:30:27 +0000 |
commit | bcb01e9dbad7e7a31b61f6ca87eb7abc1b1ca1a3 (patch) | |
tree | bd4b461aea2c75b3ce4f9597a6d84f7bb3ef5564 /media/audio/audio_util.cc | |
parent | 318bc95a682f2ae4a35d393aa4e43779eea8627f (diff) | |
download | chromium_src-bcb01e9dbad7e7a31b61f6ca87eb7abc1b1ca1a3.zip chromium_src-bcb01e9dbad7e7a31b61f6ca87eb7abc1b1ca1a3.tar.gz chromium_src-bcb01e9dbad7e7a31b61f6ca87eb7abc1b1ca1a3.tar.bz2 |
Do not stop audio physical stream immediately after logical one had stopped.
Wait some time.
We are still stopping/closing the stream, as (1) it is better for battery life,
and (2) some people can hear active device even when it is playing silence.
That increased audio startup latency, especially on Windows, because we are using 3
buffers on Windows. To fix that I changed the code to use 2 buffers on presumable
good Windows boxes -- i.e. running non-Vista and having more than single core.
Changed unit tests as well.
That CL finishes work on browser-side audio mixer. Not sure how important it is,
though -- hopefully it will provide some time while implementing renderer-side mixer.
That CL also fixes bug 131720. Looks that it was caused by timing change, and starting
stream earlier causes less dropped frames. (I still cannot understand why on modern
system we should have even single dropped frame, and why slight timing change
caused us to drop frame, but that is different question...)
BUG=114701
BUG=129190
BUG=131720
BUG=132009
TEST=Should not be noticeable difference in behavior.
TEST=Startup of 2nd stream should become somewhat faster.
TEST=Run tests on Win7 and XP myself.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=141770
Review URL: https://chromiumcodereview.appspot.com/10540034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142430 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/audio_util.cc')
-rw-r--r-- | media/audio/audio_util.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/media/audio/audio_util.cc b/media/audio/audio_util.cc index 23aad0f..4035d28 100644 --- a/media/audio/audio_util.cc +++ b/media/audio/audio_util.cc @@ -21,6 +21,7 @@ #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 @@ -519,6 +520,20 @@ bool IsWASAPISupported() { return base::win::GetVersion() >= base::win::VERSION_VISTA; } +int NumberOfWaveOutBuffers() { + // Simple heuristic: use 3 buffers on single-core system or on Vista, + // 2 otherwise. + // Entire Windows audio stack was rewritten for Windows Vista, and wave out + // API is simulated on top of new API, so there is noticeable performance + // degradation compared to Windows XP. Part of regression was fixed in + // Windows 7. Maybe it is fixed in Vista Serice Pack, but let's be cautious. + if ((base::SysInfo::NumberOfProcessors() < 2) || + (base::win::GetVersion() == base::win::VERSION_VISTA)) { + return 3; + } + return 2; +} + #endif } // namespace media |