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

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

Issue 1687143002: Remove calls to MediaCodec#stop from AVDA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "content/common/gpu/media/android_video_decode_accelerator.h" 5 #include "content/common/gpu/media/android_video_decode_accelerator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/android/build_info.h" 9 #include "base/android/build_info.h"
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 // We might increment error_sequence_token here to cancel any delayed errors, 757 // We might increment error_sequence_token here to cancel any delayed errors,
758 // but right now it's unclear that it's safe to do so. If we are in an error 758 // but right now it's unclear that it's safe to do so. If we are in an error
759 // state because of a codec error, then it would be okay. Otherwise, it's 759 // state because of a codec error, then it would be okay. Otherwise, it's
760 // less obvious that we are exiting the error state. Since deferred errors 760 // less obvious that we are exiting the error state. Since deferred errors
761 // are only intended for fullscreen transitions right now, we take the more 761 // are only intended for fullscreen transitions right now, we take the more
762 // conservative approach and let the errors post. 762 // conservative approach and let the errors post.
763 // TODO(liberato): revisit this once we sort out the error state a bit more. 763 // TODO(liberato): revisit this once we sort out the error state a bit more.
764 764
765 // When codec is not in error state we can quickly reset (internally calls 765 // When codec is not in error state we can quickly reset (internally calls
766 // flush()) for JB-MR2 and beyond. Prior to JB-MR2, flush() had several bugs 766 // flush()) for JB-MR2 and beyond. Prior to JB-MR2, flush() had several bugs
767 // (b/8125974, b/8347958) so we must stop() and reconfigure MediaCodec. The 767 // (b/8125974, b/8347958) so we must delete the MediaCodec and create a new
768 // full reconfigure is much slower and may cause visible freezing if done 768 // one. The full reconfigure is much slower and may cause visible freezing if
769 // mid-stream. 769 // done mid-stream.
770 if (state_ == NO_ERROR && 770 if (state_ == NO_ERROR &&
771 base::android::BuildInfo::GetInstance()->sdk_int() >= 18) { 771 base::android::BuildInfo::GetInstance()->sdk_int() >= 18) {
772 DVLOG(3) << __FUNCTION__ << " Doing fast MediaCodec reset (flush)."; 772 DVLOG(3) << __FUNCTION__ << " Doing fast MediaCodec reset (flush).";
773 media_codec_->Reset(); 773 media_codec_->Reset();
774 // Since we just flushed all the output buffers, make sure that nothing is 774 // Since we just flushed all the output buffers, make sure that nothing is
775 // using them. 775 // using them.
776 strategy_->CodecChanged(media_codec_.get(), output_picture_buffers_); 776 strategy_->CodecChanged(media_codec_.get(), output_picture_buffers_);
777 } else { 777 } else {
778 DVLOG(3) << __FUNCTION__ 778 DVLOG(3) << __FUNCTION__
779 << " Doing slow MediaCodec reset (stop/re-configure)."; 779 << " Deleting the MediaCodec and creating a new one.";
780 io_timer_.Stop(); 780 io_timer_.Stop();
781 media_codec_->Stop(); 781 media_codec_.reset();
782 // Changing the codec will also notify the strategy to forget about any 782 // Changing the codec will also notify the strategy to forget about any
783 // output buffers it has currently. 783 // output buffers it has currently.
784 state_ = NO_ERROR; 784 state_ = NO_ERROR;
785 if (!ConfigureMediaCodec()) 785 if (!ConfigureMediaCodec())
786 POST_ERROR(PLATFORM_FAILURE, "Failed to create MediaCodec."); 786 POST_ERROR(PLATFORM_FAILURE, "Failed to create MediaCodec.");
787 } 787 }
788 } 788 }
789 789
790 void AndroidVideoDecodeAccelerator::DismissPictureBuffers() { 790 void AndroidVideoDecodeAccelerator::DismissPictureBuffers() {
791 DCHECK(thread_checker_.CalledOnValidThread()); 791 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 841
842 // If we have an OnFrameAvailable handler, tell it that we're going away. 842 // If we have an OnFrameAvailable handler, tell it that we're going away.
843 if (on_frame_available_handler_) { 843 if (on_frame_available_handler_) {
844 on_frame_available_handler_->ClearOwner(); 844 on_frame_available_handler_->ClearOwner();
845 on_frame_available_handler_ = nullptr; 845 on_frame_available_handler_ = nullptr;
846 } 846 }
847 847
848 weak_this_factory_.InvalidateWeakPtrs(); 848 weak_this_factory_.InvalidateWeakPtrs();
849 if (media_codec_) { 849 if (media_codec_) {
850 io_timer_.Stop(); 850 io_timer_.Stop();
851 media_codec_->Stop(); 851 media_codec_.reset();
852 } 852 }
853 delete this; 853 delete this;
854 } 854 }
855 855
856 bool AndroidVideoDecodeAccelerator::CanDecodeOnIOThread() { 856 bool AndroidVideoDecodeAccelerator::CanDecodeOnIOThread() {
857 return false; 857 return false;
858 } 858 }
859 859
860 const gfx::Size& AndroidVideoDecodeAccelerator::GetSize() const { 860 const gfx::Size& AndroidVideoDecodeAccelerator::GetSize() const {
861 return size_; 861 return size_;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 1015
1016 if (UseDeferredRenderingStrategy()) { 1016 if (UseDeferredRenderingStrategy()) {
1017 capabilities.flags = media::VideoDecodeAccelerator::Capabilities:: 1017 capabilities.flags = media::VideoDecodeAccelerator::Capabilities::
1018 NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE; 1018 NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE;
1019 } 1019 }
1020 1020
1021 return capabilities; 1021 return capabilities;
1022 } 1022 }
1023 1023
1024 } // namespace content 1024 } // 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