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

Side by Side Diff: content/common/gpu/media/vt_video_decode_accelerator.cc

Issue 900053002: Minor robustness improvements for VTVideoDecodeAccelerator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« 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')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <algorithm> 5 #include <algorithm>
6 6
7 #include <CoreVideo/CoreVideo.h> 7 #include <CoreVideo/CoreVideo.h>
8 #include <OpenGL/CGLIOSurface.h> 8 #include <OpenGL/CGLIOSurface.h>
9 #include <OpenGL/gl.h> 9 #include <OpenGL/gl.h>
10 10
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 } 625 }
626 } 626 }
627 627
628 // This method may be called on any VideoToolbox thread. 628 // This method may be called on any VideoToolbox thread.
629 void VTVideoDecodeAccelerator::Output( 629 void VTVideoDecodeAccelerator::Output(
630 void* source_frame_refcon, 630 void* source_frame_refcon,
631 OSStatus status, 631 OSStatus status,
632 CVImageBufferRef image_buffer) { 632 CVImageBufferRef image_buffer) {
633 if (status) { 633 if (status) {
634 NOTIFY_STATUS("Decoding", status); 634 NOTIFY_STATUS("Decoding", status);
635 } else if (CFGetTypeID(image_buffer) != CVPixelBufferGetTypeID()) { 635 } else if (!image_buffer ||
DaleCurtis 2015/02/04 22:38:52 Needs a comment if this is unexpected.
636 (CFGetTypeID(image_buffer) != CVPixelBufferGetTypeID())) {
636 DLOG(ERROR) << "Decoded frame is not a CVPixelBuffer"; 637 DLOG(ERROR) << "Decoded frame is not a CVPixelBuffer";
637 NotifyError(PLATFORM_FAILURE); 638 NotifyError(PLATFORM_FAILURE);
638 } else { 639 } else {
639 Frame* frame = reinterpret_cast<Frame*>(source_frame_refcon); 640 Frame* frame = reinterpret_cast<Frame*>(source_frame_refcon);
640 frame->image.reset(image_buffer, base::scoped_policy::RETAIN); 641 frame->image.reset(image_buffer, base::scoped_policy::RETAIN);
641 gpu_task_runner_->PostTask(FROM_HERE, base::Bind( 642 gpu_task_runner_->PostTask(FROM_HERE, base::Bind(
642 &VTVideoDecodeAccelerator::DecodeDone, weak_this_, frame)); 643 &VTVideoDecodeAccelerator::DecodeDone, weak_this_, frame));
643 } 644 }
644 } 645 }
645 646
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 } else { 709 } else {
709 client_->DismissPictureBuffer(picture_id); 710 client_->DismissPictureBuffer(picture_id);
710 } 711 }
711 } 712 }
712 713
713 void VTVideoDecodeAccelerator::ProcessWorkQueues() { 714 void VTVideoDecodeAccelerator::ProcessWorkQueues() {
714 DCHECK(gpu_thread_checker_.CalledOnValidThread()); 715 DCHECK(gpu_thread_checker_.CalledOnValidThread());
715 switch (state_) { 716 switch (state_) {
716 case STATE_DECODING: 717 case STATE_DECODING:
717 // TODO(sandersd): Batch where possible. 718 // TODO(sandersd): Batch where possible.
718 while (ProcessReorderQueue() || ProcessTaskQueue()); 719 while (state_ == STATE_DECODING) {
720 if (!ProcessReorderQueue() && !ProcessTaskQueue())
721 break;
722 }
719 return; 723 return;
720 724
721 case STATE_ERROR: 725 case STATE_ERROR:
722 // Do nothing until Destroy() is called. 726 // Do nothing until Destroy() is called.
723 return; 727 return;
724 728
725 case STATE_DESTROYING: 729 case STATE_DESTROYING:
726 // Drop tasks until we are ready to destruct. 730 // Drop tasks until we are ready to destruct.
727 while (!task_queue_.empty()) { 731 while (!task_queue_.empty()) {
728 if (task_queue_.front().type == TASK_DESTROY) { 732 if (task_queue_.front().type == TASK_DESTROY) {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 assigned_bitstream_ids_.clear(); 945 assigned_bitstream_ids_.clear();
942 state_ = STATE_DESTROYING; 946 state_ = STATE_DESTROYING;
943 QueueFlush(TASK_DESTROY); 947 QueueFlush(TASK_DESTROY);
944 } 948 }
945 949
946 bool VTVideoDecodeAccelerator::CanDecodeOnIOThread() { 950 bool VTVideoDecodeAccelerator::CanDecodeOnIOThread() {
947 return false; 951 return false;
948 } 952 }
949 953
950 } // namespace content 954 } // namespace content
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