diff options
author | kylep@chromium.org <kylep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-11 17:11:42 +0000 |
---|---|---|
committer | kylep@chromium.org <kylep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-11 17:11:42 +0000 |
commit | 378f0b723c021e87c1f021c7a7c8c272f272065c (patch) | |
tree | 7ba8fdc1fdc17442ac50ae2734d121892693eef2 /webkit/glue/webmediaplayer_impl.cc | |
parent | 3d40d3e4f87c891c285fed5bbe5091c71d8e8be5 (diff) | |
download | chromium_src-378f0b723c021e87c1f021c7a7c8c272f272065c.zip chromium_src-378f0b723c021e87c1f021c7a7c8c272f272065c.tar.gz chromium_src-378f0b723c021e87c1f021c7a7c8c272f272065c.tar.bz2 |
Disallow setting the rate to values that would cause busy loops (< 1/16x) or rendering issues (> 16x)
BUG=18362
TEST=none
Review URL: http://codereview.chromium.org/164032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23037 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webmediaplayer_impl.cc')
-rw-r--r-- | webkit/glue/webmediaplayer_impl.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/webkit/glue/webmediaplayer_impl.cc b/webkit/glue/webmediaplayer_impl.cc index 0d96865..04f5dc8 100644 --- a/webkit/glue/webmediaplayer_impl.cc +++ b/webkit/glue/webmediaplayer_impl.cc @@ -27,6 +27,25 @@ namespace { // queue but gives up a pretty good latency on repaint. const int kMaxOutstandingRepaints = 50; +// Limits the range of playback rate. +// +// TODO(kylep): Revisit these. +// +// Vista has substantially lower performance than XP or Windows7. If you speed +// up a video too much, it can't keep up, and rendering stops updating except on +// the time bar. For really high speeds, audio becomes a bottleneck and we just +// use up the data we have, which may not achieve the speed requested, but will +// not crash the tab. +// +// A very slow speed, ie 0.00000001x, causes the machine to lock up. (It seems +// like a busy loop). It gets unresponsive, although its not completely dead. +// +// Also our timers are not very accurate (especially for ogg), which becomes +// evident at low speeds and on Vista. Since other speeds are risky and outside +// the norms, we think 1/16x to 16x is a safe and useful range for now. +const float kMinRate = 0.0625f; +const float kMaxRate = 16.0f; + } // namespace namespace webkit_glue { @@ -248,6 +267,19 @@ void WebMediaPlayerImpl::setEndTime(float seconds) { void WebMediaPlayerImpl::setRate(float rate) { DCHECK(MessageLoop::current() == main_loop_); + // TODO(kylep): Remove when support for negatives is added. Also, modify the + // following checks so rewind uses reasonable values also. + if (rate < 0.0f) + return; + + // Limit rates to reasonable values by clamping. + if (rate != 0.0f) { + if (rate < kMinRate) + rate = kMinRate; + else if (rate > kMaxRate) + rate = kMaxRate; + } + playback_rate_ = rate; if (!paused_) { pipeline_->SetPlaybackRate(rate); |