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

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

Issue 9295020: Fix ChunkDemuxer seek deadlock (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copyright year. Created 8 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/filter_host.h" 9 #include "media/base/filter_host.h"
10 #include "media/base/limits.h" 10 #include "media/base/limits.h"
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 // frame when this is true. 329 // frame when this is true.
330 frame_available_.Signal(); 330 frame_available_.Signal();
331 if (state_ == kFlushing) { 331 if (state_ == kFlushing) {
332 AttemptFlush_Locked(); 332 AttemptFlush_Locked();
333 } else if (state_ == kError || state_ == kStopped) { 333 } else if (state_ == kError || state_ == kStopped) {
334 DoStopOrError_Locked(); 334 DoStopOrError_Locked();
335 } 335 }
336 } 336 }
337 337
338 void VideoRendererBase::FrameReady(scoped_refptr<VideoFrame> frame) { 338 void VideoRendererBase::FrameReady(scoped_refptr<VideoFrame> frame) {
339 DCHECK(frame);
340
341 base::AutoLock auto_lock(lock_); 339 base::AutoLock auto_lock(lock_);
342 DCHECK_NE(state_, kUninitialized); 340 DCHECK_NE(state_, kUninitialized);
343 DCHECK_NE(state_, kStopped); 341 DCHECK_NE(state_, kStopped);
344 DCHECK_NE(state_, kError); 342 DCHECK_NE(state_, kError);
345 DCHECK_NE(state_, kFlushed); 343 DCHECK_NE(state_, kFlushed);
346 CHECK(pending_read_); 344 CHECK(pending_read_);
347 345
348 pending_read_ = false; 346 pending_read_ = false;
349 347
350 if (state_ == kFlushing) { 348 if (state_ == kFlushing) {
351 AttemptFlush_Locked(); 349 AttemptFlush_Locked();
352 return; 350 return;
353 } 351 }
354 352
353 if (!frame) {
354 if (state_ != kSeeking)
355 return;
356
357 // Abort seek early for a NULL frame because we won't get more frames.
358 // A new seek will be requested after this one completes so there is no
359 // point trying to collect more frames.
360 state_ = kPrerolled;
361 ResetAndRunCB(&seek_cb_, PIPELINE_OK);
362 return;
363 }
364
355 // Discard frames until we reach our desired seek timestamp. 365 // Discard frames until we reach our desired seek timestamp.
356 if (state_ == kSeeking && !frame->IsEndOfStream() && 366 if (state_ == kSeeking && !frame->IsEndOfStream() &&
357 (frame->GetTimestamp() + frame->GetDuration()) <= seek_timestamp_) { 367 (frame->GetTimestamp() + frame->GetDuration()) <= seek_timestamp_) {
358 AttemptRead_Locked(); 368 AttemptRead_Locked();
359 return; 369 return;
360 } 370 }
361 371
362 // Adjust the incoming frame if its rendering stop time is past the duration 372 // Adjust the incoming frame if its rendering stop time is past the duration
363 // of the video itself. This is typically the last frame of the video and 373 // of the video itself. This is typically the last frame of the video and
364 // occurs if the container specifies a duration that isn't a multiple of the 374 // occurs if the container specifies a duration that isn't a multiple of the
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 480
471 int VideoRendererBase::NumFrames_Locked() const { 481 int VideoRendererBase::NumFrames_Locked() const {
472 lock_.AssertAcquired(); 482 lock_.AssertAcquired();
473 int outstanding_frames = 483 int outstanding_frames =
474 (current_frame_ ? 1 : 0) + (last_available_frame_ ? 1 : 0) + 484 (current_frame_ ? 1 : 0) + (last_available_frame_ ? 1 : 0) +
475 (current_frame_ && (current_frame_ == last_available_frame_) ? -1 : 0); 485 (current_frame_ && (current_frame_ == last_available_frame_) ? -1 : 0);
476 return ready_frames_.size() + outstanding_frames; 486 return ready_frames_.size() + outstanding_frames;
477 } 487 }
478 488
479 } // namespace media 489 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/pipeline_integration_test.cc ('k') | media/filters/video_renderer_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698