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

Side by Side Diff: webkit/glue/webmediaplayer_impl.cc

Issue 165481: Merge 23037 - Disallow setting the rate to values that would cause busy loops... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Modified: svn:mergeinfo
Merged /trunk/src/webkit/glue/webmediaplayer_impl.cc:r23037
OLDNEW
1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/glue/webmediaplayer_impl.h" 5 #include "webkit/glue/webmediaplayer_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "media/base/media_format.h" 9 #include "media/base/media_format.h"
10 #include "media/filters/ffmpeg_audio_decoder.h" 10 #include "media/filters/ffmpeg_audio_decoder.h"
11 #include "media/filters/ffmpeg_demuxer.h" 11 #include "media/filters/ffmpeg_demuxer.h"
12 #include "media/filters/ffmpeg_video_decoder.h" 12 #include "media/filters/ffmpeg_video_decoder.h"
13 #include "media/filters/null_audio_renderer.h" 13 #include "media/filters/null_audio_renderer.h"
14 #include "webkit/api/public/WebRect.h" 14 #include "webkit/api/public/WebRect.h"
15 #include "webkit/api/public/WebSize.h" 15 #include "webkit/api/public/WebSize.h"
16 #include "webkit/api/public/WebURL.h" 16 #include "webkit/api/public/WebURL.h"
17 #include "webkit/glue/media/video_renderer_impl.h" 17 #include "webkit/glue/media/video_renderer_impl.h"
18 18
19 using WebKit::WebCanvas; 19 using WebKit::WebCanvas;
20 using WebKit::WebRect; 20 using WebKit::WebRect;
21 using WebKit::WebSize; 21 using WebKit::WebSize;
22 22
23 namespace { 23 namespace {
24 24
25 // Limits the maximum outstanding repaints posted on render thread. 25 // Limits the maximum outstanding repaints posted on render thread.
26 // This number of 50 is a guess, it does not take too much memory on the task 26 // This number of 50 is a guess, it does not take too much memory on the task
27 // queue but gives up a pretty good latency on repaint. 27 // queue but gives up a pretty good latency on repaint.
28 const int kMaxOutstandingRepaints = 50; 28 const int kMaxOutstandingRepaints = 50;
29 29
30 // Limits the range of playback rate.
31 //
32 // TODO(kylep): Revisit these.
33 //
34 // Vista has substantially lower performance than XP or Windows7. If you speed
35 // up a video too much, it can't keep up, and rendering stops updating except on
36 // the time bar. For really high speeds, audio becomes a bottleneck and we just
37 // use up the data we have, which may not achieve the speed requested, but will
38 // not crash the tab.
39 //
40 // A very slow speed, ie 0.00000001x, causes the machine to lock up. (It seems
41 // like a busy loop). It gets unresponsive, although its not completely dead.
42 //
43 // Also our timers are not very accurate (especially for ogg), which becomes
44 // evident at low speeds and on Vista. Since other speeds are risky and outside
45 // the norms, we think 1/16x to 16x is a safe and useful range for now.
46 const float kMinRate = 0.0625f;
47 const float kMaxRate = 16.0f;
48
30 } // namespace 49 } // namespace
31 50
32 namespace webkit_glue { 51 namespace webkit_glue {
33 52
34 ///////////////////////////////////////////////////////////////////////////// 53 /////////////////////////////////////////////////////////////////////////////
35 // WebMediaPlayerImpl::Proxy implementation 54 // WebMediaPlayerImpl::Proxy implementation
36 55
37 WebMediaPlayerImpl::Proxy::Proxy(MessageLoop* render_loop, 56 WebMediaPlayerImpl::Proxy::Proxy(MessageLoop* render_loop,
38 WebMediaPlayerImpl* webmediaplayer) 57 WebMediaPlayerImpl* webmediaplayer)
39 : render_loop_(render_loop), 58 : render_loop_(render_loop),
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 void WebMediaPlayerImpl::setEndTime(float seconds) { 277 void WebMediaPlayerImpl::setEndTime(float seconds) {
259 DCHECK(MessageLoop::current() == main_loop_); 278 DCHECK(MessageLoop::current() == main_loop_);
260 279
261 // TODO(hclam): add method call when it has been implemented. 280 // TODO(hclam): add method call when it has been implemented.
262 return; 281 return;
263 } 282 }
264 283
265 void WebMediaPlayerImpl::setRate(float rate) { 284 void WebMediaPlayerImpl::setRate(float rate) {
266 DCHECK(MessageLoop::current() == main_loop_); 285 DCHECK(MessageLoop::current() == main_loop_);
267 286
287 // TODO(kylep): Remove when support for negatives is added. Also, modify the
288 // following checks so rewind uses reasonable values also.
289 if (rate < 0.0f)
290 return;
291
292 // Limit rates to reasonable values by clamping.
293 if (rate != 0.0f) {
294 if (rate < kMinRate)
295 rate = kMinRate;
296 else if (rate > kMaxRate)
297 rate = kMaxRate;
298 }
299
268 playback_rate_ = rate; 300 playback_rate_ = rate;
269 if (!paused_) { 301 if (!paused_) {
270 pipeline_->SetPlaybackRate(rate); 302 pipeline_->SetPlaybackRate(rate);
271 } 303 }
272 } 304 }
273 305
274 void WebMediaPlayerImpl::setVolume(float volume) { 306 void WebMediaPlayerImpl::setVolume(float volume) {
275 DCHECK(MessageLoop::current() == main_loop_); 307 DCHECK(MessageLoop::current() == main_loop_);
276 308
277 pipeline_->SetVolume(volume); 309 pipeline_->SetVolume(volume);
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 } 543 }
512 } 544 }
513 545
514 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { 546 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() {
515 DCHECK(MessageLoop::current() == main_loop_); 547 DCHECK(MessageLoop::current() == main_loop_);
516 DCHECK(client_); 548 DCHECK(client_);
517 return client_; 549 return client_;
518 } 550 }
519 551
520 } // namespace webkit_glue 552 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698