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

Side by Side Diff: media/renderers/video_renderer_impl.h

Issue 1247973002: Fix race condition when accessing time_progressing_. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Created 5 years, 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ 5 #ifndef MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_
6 #define MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ 6 #define MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_
7 7
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 // Returns true if there is no more room for additional buffered frames. 141 // Returns true if there is no more room for additional buffered frames.
142 bool HaveReachedBufferingCap(); 142 bool HaveReachedBufferingCap();
143 143
144 // Starts or stops |sink_| respectively. Do not call while |lock_| is held. 144 // Starts or stops |sink_| respectively. Do not call while |lock_| is held.
145 void StartSink(); 145 void StartSink();
146 void StopSink(); 146 void StopSink();
147 147
148 // Fires |ended_cb_| if there are no remaining usable frames and 148 // Fires |ended_cb_| if there are no remaining usable frames and
149 // |received_end_of_stream_| is true. Sets |rendered_end_of_stream_| if it 149 // |received_end_of_stream_| is true. Sets |rendered_end_of_stream_| if it
150 // does so. Returns algorithm_->EffectiveFramesQueued(). 150 // does so.
151 size_t MaybeFireEndedCallback(); 151 //
152 // When called from the media thread, |time_progressing| should reflect the
153 // value of |time_progressing_|. When called from Render() on the sink
154 // callback thread, the inverse of |render_first_frame_and_stop_| should be
155 // used as a proxy for |time_progressing_|.
156 //
157 // Returns algorithm_->EffectiveFramesQueued().
158 size_t MaybeFireEndedCallback_Locked(bool time_progressing);
152 159
153 // Helper method for converting a single media timestamp to wall clock time. 160 // Helper method for converting a single media timestamp to wall clock time.
154 base::TimeTicks ConvertMediaTimestamp(base::TimeDelta media_timestamp); 161 base::TimeTicks ConvertMediaTimestamp(base::TimeDelta media_timestamp);
155 162
156 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 163 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
157 164
158 // Enables the use of VideoRendererAlgorithm and VideoRendererSink for frame 165 // Enables the use of VideoRendererAlgorithm and VideoRendererSink for frame
159 // rendering instead of using a thread in a sleep-loop. Set via the command 166 // rendering instead of using a thread in a sleep-loop. Set via the command
160 // line flag kEnableNewVideoRenderer or via test methods. 167 // line flag kEnableNewVideoRenderer or via test methods.
161 bool use_new_video_renderering_path_; 168 bool use_new_video_renderering_path_;
162 169
163 // Sink which calls into VideoRendererImpl via Render() for video frames. Do 170 // Sink which calls into VideoRendererImpl via Render() for video frames. Do
164 // not call any methods on the sink while |lock_| is held or the two threads 171 // not call any methods on the sink while |lock_| is held or the two threads
165 // might deadlock. Do not call Start() or Stop() on the sink directly, use 172 // might deadlock. Do not call Start() or Stop() on the sink directly, use
166 // StartSink() and StopSink() to ensure background rendering is started. 173 // StartSink() and StopSink() to ensure background rendering is started. Only
174 // access these values on |task_runner_|.
167 VideoRendererSink* const sink_; 175 VideoRendererSink* const sink_;
168 bool sink_started_; 176 bool sink_started_;
169 177
170 // Used for accessing data members. 178 // Used for accessing data members.
171 base::Lock lock_; 179 base::Lock lock_;
172 180
173 // Provides video frames to VideoRendererImpl. 181 // Provides video frames to VideoRendererImpl.
174 scoped_ptr<VideoFrameStream> video_frame_stream_; 182 scoped_ptr<VideoFrameStream> video_frame_stream_;
175 183
176 // Pool of GpuMemoryBuffers and resources used to create hardware frames. 184 // Pool of GpuMemoryBuffers and resources used to create hardware frames.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 272
265 // Algorithm for selecting which frame to render; manages frames and all 273 // Algorithm for selecting which frame to render; manages frames and all
266 // timing related information. 274 // timing related information.
267 scoped_ptr<VideoRendererAlgorithm> algorithm_; 275 scoped_ptr<VideoRendererAlgorithm> algorithm_;
268 276
269 // Indicates that Render() was called with |background_rendering| set to true, 277 // Indicates that Render() was called with |background_rendering| set to true,
270 // so we've entered a background rendering mode where dropped frames are not 278 // so we've entered a background rendering mode where dropped frames are not
271 // counted. Must be accessed under |lock_| once |sink_| is started. 279 // counted. Must be accessed under |lock_| once |sink_| is started.
272 bool was_background_rendering_; 280 bool was_background_rendering_;
273 281
274 // Indicates whether or not media time is currently progressing or not. 282 // Indicates whether or not media time is currently progressing or not. Must
283 // only be accessed from |task_runner_|.
275 bool time_progressing_; 284 bool time_progressing_;
276 285
277 // Indicates that Render() should only render the first frame and then request 286 // Indicates that Render() should only render the first frame and then request
278 // that the sink be stopped. |posted_maybe_stop_after_first_paint_| is used 287 // that the sink be stopped. |posted_maybe_stop_after_first_paint_| is used
279 // to avoid repeated task posts. 288 // to avoid repeated task posts.
280 bool render_first_frame_and_stop_; 289 bool render_first_frame_and_stop_;
281 bool posted_maybe_stop_after_first_paint_; 290 bool posted_maybe_stop_after_first_paint_;
282 291
283 // NOTE: Weak pointers must be invalidated before all other member variables. 292 // NOTE: Weak pointers must be invalidated before all other member variables.
284 base::WeakPtrFactory<VideoRendererImpl> weak_factory_; 293 base::WeakPtrFactory<VideoRendererImpl> weak_factory_;
285 294
286 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); 295 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl);
287 }; 296 };
288 297
289 } // namespace media 298 } // namespace media
290 299
291 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ 300 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | media/renderers/video_renderer_impl.cc » ('j') | media/renderers/video_renderer_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698