| Index: webkit/glue/webmediaplayer_impl.cc
|
| ===================================================================
|
| --- webkit/glue/webmediaplayer_impl.cc (revision 22918)
|
| +++ webkit/glue/webmediaplayer_impl.cc (working copy)
|
| @@ -27,6 +27,25 @@
|
| // 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::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);
|
|
|