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

Side by Side Diff: media/filters/video_renderer_base.cc

Issue 8294027: Merge r104540 into 874 (m15). (Closed) Base URL: svn://svn.chromium.org/chrome/branches/874/src/
Patch Set: '' Created 9 years, 2 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 | « media/filters/ffmpeg_video_decoder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/threading/platform_thread.h" 7 #include "base/threading/platform_thread.h"
8 #include "media/base/buffers.h" 8 #include "media/base/buffers.h"
9 #include "media/base/callback.h" 9 #include "media/base/callback.h"
10 #include "media/base/filter_host.h" 10 #include "media/base/filter_host.h"
(...skipping 21 matching lines...) Expand all
32 state_(kUninitialized), 32 state_(kUninitialized),
33 thread_(base::kNullThreadHandle), 33 thread_(base::kNullThreadHandle),
34 pending_reads_(0), 34 pending_reads_(0),
35 pending_paint_(false), 35 pending_paint_(false),
36 pending_paint_with_last_available_(false), 36 pending_paint_with_last_available_(false),
37 playback_rate_(0) { 37 playback_rate_(0) {
38 } 38 }
39 39
40 VideoRendererBase::~VideoRendererBase() { 40 VideoRendererBase::~VideoRendererBase() {
41 base::AutoLock auto_lock(lock_); 41 base::AutoLock auto_lock(lock_);
42 DCHECK(state_ == kUninitialized || state_ == kStopped); 42 DCHECK(state_ == kUninitialized || state_ == kStopped) << state_;
43 } 43 }
44 44
45 void VideoRendererBase::Play(FilterCallback* callback) { 45 void VideoRendererBase::Play(FilterCallback* callback) {
46 base::AutoLock auto_lock(lock_); 46 base::AutoLock auto_lock(lock_);
47 DCHECK_EQ(kPrerolled, state_); 47 DCHECK_EQ(kPrerolled, state_);
48 scoped_ptr<FilterCallback> c(callback); 48 scoped_ptr<FilterCallback> c(callback);
49 state_ = kPlaying; 49 state_ = kPlaying;
50 callback->Run(); 50 callback->Run();
51 } 51 }
52 52
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 // Signal the subclass we're stopping. 91 // Signal the subclass we're stopping.
92 OnStop(callback); 92 OnStop(callback);
93 } 93 }
94 94
95 void VideoRendererBase::SetPlaybackRate(float playback_rate) { 95 void VideoRendererBase::SetPlaybackRate(float playback_rate) {
96 base::AutoLock auto_lock(lock_); 96 base::AutoLock auto_lock(lock_);
97 playback_rate_ = playback_rate; 97 playback_rate_ = playback_rate;
98 } 98 }
99 99
100 void VideoRendererBase::Seek(base::TimeDelta time, const FilterStatusCB& cb) { 100 void VideoRendererBase::Seek(base::TimeDelta time, const FilterStatusCB& cb) {
101 bool run_callback = false; 101 bool run_callback = false;
102 102
103 { 103 {
104 base::AutoLock auto_lock(lock_); 104 base::AutoLock auto_lock(lock_);
105 // There is a race condition between filters to receive SeekTask(). 105 // There is a race condition between filters to receive SeekTask().
106 // It turns out we could receive buffer from decoder before seek() 106 // It turns out we could receive buffer from decoder before seek()
107 // is called on us. so we do the following: 107 // is called on us. so we do the following:
108 // kFlushed => ( Receive first buffer or Seek() ) => kSeeking and 108 // kFlushed => ( Receive first buffer or Seek() ) => kSeeking and
109 // kSeeking => ( Receive enough buffers) => kPrerolled. ) 109 // kSeeking => ( Receive enough buffers) => kPrerolled. )
110 DCHECK(state_ == kPrerolled || state_ == kFlushed || state_ == kSeeking); 110 DCHECK(state_ == kPrerolled || state_ == kFlushed || state_ == kSeeking);
111 DCHECK(!cb.is_null()); 111 DCHECK(!cb.is_null());
112 DCHECK(seek_cb_.is_null()); 112 DCHECK(seek_cb_.is_null());
113 113
114 if (state_ == kPrerolled) { 114 if (state_ == kPrerolled) {
115 // Already get enough buffers from decoder. 115 // Already get enough buffers from decoder.
116 run_callback = true; 116 run_callback = true;
117
118 } else { 117 } else {
119 // Otherwise we are either kFlushed or kSeeking, but without enough 118 // Otherwise we are either kFlushed or kSeeking, but without enough
120 // buffers we should save the callback function and call it later. 119 // buffers we should save the callback function and call it later.
121 state_ = kSeeking; 120 state_ = kSeeking;
122 seek_cb_ = cb; 121 seek_cb_ = cb;
123 } 122 }
124 123
125 seek_timestamp_ = time; 124 seek_timestamp_ = time;
126 ScheduleRead_Locked(); 125 ScheduleRead_Locked();
127 } 126 }
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 void VideoRendererBase::DoStopOrErrorFlush_Locked() { 591 void VideoRendererBase::DoStopOrErrorFlush_Locked() {
593 DCHECK(!pending_paint_); 592 DCHECK(!pending_paint_);
594 DCHECK(!pending_paint_with_last_available_); 593 DCHECK(!pending_paint_with_last_available_);
595 lock_.AssertAcquired(); 594 lock_.AssertAcquired();
596 FlushBuffers_Locked(); 595 FlushBuffers_Locked();
597 last_available_frame_ = NULL; 596 last_available_frame_ = NULL;
598 DCHECK_EQ(pending_reads_, 0); 597 DCHECK_EQ(pending_reads_, 0);
599 } 598 }
600 599
601 } // namespace media 600 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_video_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698