OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include "media/base/buffers.h" | 5 #include "media/base/buffers.h" |
6 #include "media/base/filter_host.h" | 6 #include "media/base/filter_host.h" |
7 #include "media/base/video_frame_impl.h" | 7 #include "media/base/video_frame_impl.h" |
8 #include "media/filters/video_renderer_base.h" | 8 #include "media/filters/video_renderer_base.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
(...skipping 21 matching lines...) Expand all Loading... |
32 // The number of milliseconds to idle when we do not have anything to do. | 32 // The number of milliseconds to idle when we do not have anything to do. |
33 // Nothing special about the value, other than we're being more OS-friendly | 33 // Nothing special about the value, other than we're being more OS-friendly |
34 // than sleeping for 1 millisecond. | 34 // than sleeping for 1 millisecond. |
35 static const int kIdleMilliseconds = 10; | 35 static const int kIdleMilliseconds = 10; |
36 | 36 |
37 VideoRendererBase::VideoRendererBase() | 37 VideoRendererBase::VideoRendererBase() |
38 : width_(0), | 38 : width_(0), |
39 height_(0), | 39 height_(0), |
40 frame_available_(&lock_), | 40 frame_available_(&lock_), |
41 state_(kUninitialized), | 41 state_(kUninitialized), |
42 thread_(0), | 42 thread_(NULL), |
43 pending_reads_(0), | 43 pending_reads_(0), |
44 playback_rate_(0) { | 44 playback_rate_(0) { |
45 } | 45 } |
46 | 46 |
47 VideoRendererBase::~VideoRendererBase() { | 47 VideoRendererBase::~VideoRendererBase() { |
48 AutoLock auto_lock(lock_); | 48 AutoLock auto_lock(lock_); |
49 DCHECK(state_ == kUninitialized || state_ == kStopped); | 49 DCHECK(state_ == kUninitialized || state_ == kStopped); |
50 } | 50 } |
51 | 51 |
52 // static | 52 // static |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 // Clean up our thread if present. | 99 // Clean up our thread if present. |
100 if (thread_) { | 100 if (thread_) { |
101 // Signal the thread since it's possible to get stopped with the video | 101 // Signal the thread since it's possible to get stopped with the video |
102 // thread waiting for a read to complete. | 102 // thread waiting for a read to complete. |
103 frame_available_.Signal(); | 103 frame_available_.Signal(); |
104 { | 104 { |
105 AutoUnlock auto_unlock(lock_); | 105 AutoUnlock auto_unlock(lock_); |
106 PlatformThread::Join(thread_); | 106 PlatformThread::Join(thread_); |
107 } | 107 } |
108 thread_ = 0; | 108 thread_ = NULL; |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 void VideoRendererBase::SetPlaybackRate(float playback_rate) { | 112 void VideoRendererBase::SetPlaybackRate(float playback_rate) { |
113 AutoLock auto_lock(lock_); | 113 AutoLock auto_lock(lock_); |
114 playback_rate_ = playback_rate; | 114 playback_rate_ = playback_rate; |
115 } | 115 } |
116 | 116 |
117 void VideoRendererBase::Seek(base::TimeDelta time, FilterCallback* callback) { | 117 void VideoRendererBase::Seek(base::TimeDelta time, FilterCallback* callback) { |
118 AutoLock auto_lock(lock_); | 118 AutoLock auto_lock(lock_); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 previous_time_ = now; | 375 previous_time_ = now; |
376 } | 376 } |
377 | 377 |
378 // Scale our sleep based on the playback rate. | 378 // Scale our sleep based on the playback rate. |
379 // TODO(scherkus): floating point badness and degrade gracefully. | 379 // TODO(scherkus): floating point badness and degrade gracefully. |
380 return base::TimeDelta::FromMicroseconds( | 380 return base::TimeDelta::FromMicroseconds( |
381 static_cast<int64>(sleep.InMicroseconds() / playback_rate)); | 381 static_cast<int64>(sleep.InMicroseconds() / playback_rate)); |
382 } | 382 } |
383 | 383 |
384 } // namespace media | 384 } // namespace media |
OLD | NEW |