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

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

Issue 2812783002: Always post mailbox release in GpuVideoDecoder; avoids deadlock. (Closed)
Patch Set: Created 3 years, 8 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) 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 "media/filters/gpu_video_decoder.h" 5 #include "media/filters/gpu_video_decoder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <array> 8 #include <array>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1); 177 "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1);
178 178
179 if (!success) { 179 if (!success) {
180 media_log->RecordRapporWithSecurityOrigin( 180 media_log->RecordRapporWithSecurityOrigin(
181 "Media.OriginUrl.GpuVideoDecoderInitFailure"); 181 "Media.OriginUrl.GpuVideoDecoderInitFailure");
182 } 182 }
183 183
184 cb.Run(success); 184 cb.Run(success);
185 } 185 }
186 186
187 // static
188 void ReleaseMailboxTrampoline(
189 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
190 const VideoFrame::ReleaseMailboxCB& release_mailbox_cb,
191 const gpu::SyncToken& release_sync_token) {
192 if (task_runner->BelongsToCurrentThread()) {
193 release_mailbox_cb.Run(release_sync_token);
194 return;
195 }
196
197 task_runner->PostTask(FROM_HERE,
198 base::Bind(release_mailbox_cb, release_sync_token));
199 }
200
201 std::string GpuVideoDecoder::GetDisplayName() const { 187 std::string GpuVideoDecoder::GetDisplayName() const {
202 return kDecoderName; 188 return kDecoderName;
203 } 189 }
204 190
205 void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, 191 void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config,
206 bool /* low_delay */, 192 bool /* low_delay */,
207 CdmContext* cdm_context, 193 CdmContext* cdm_context,
208 const InitCB& init_cb, 194 const InitCB& init_cb,
209 const OutputCB& output_cb) { 195 const OutputCB& output_cb) {
210 DVLOG(3) << "Initialize()"; 196 DVLOG(3) << "Initialize()";
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 DCHECK(decoder_texture_target_); 652 DCHECK(decoder_texture_target_);
667 653
668 gpu::MailboxHolder mailbox_holders[VideoFrame::kMaxPlanes]; 654 gpu::MailboxHolder mailbox_holders[VideoFrame::kMaxPlanes];
669 for (size_t i = 0; i < pb.client_texture_ids().size(); ++i) { 655 for (size_t i = 0; i < pb.client_texture_ids().size(); ++i) {
670 mailbox_holders[i] = gpu::MailboxHolder(pb.texture_mailbox(i), sync_token_, 656 mailbox_holders[i] = gpu::MailboxHolder(pb.texture_mailbox(i), sync_token_,
671 decoder_texture_target_); 657 decoder_texture_target_);
672 } 658 }
673 659
674 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTextures( 660 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTextures(
675 pixel_format_, mailbox_holders, 661 pixel_format_, mailbox_holders,
676 base::Bind( 662 // Always post ReleaseMailbox to avoid deadlock with the compositor when
677 &ReleaseMailboxTrampoline, factories_->GetTaskRunner(), 663 // releasing video frames on the media thread; http://crbug.com/710209.
678 base::Bind(&GpuVideoDecoder::ReleaseMailbox, 664 BindToCurrentLoop(base::Bind(
679 weak_factory_.GetWeakPtr(), factories_, 665 &GpuVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(),
680 picture.picture_buffer_id(), pb.client_texture_ids())), 666 factories_, picture.picture_buffer_id(), pb.client_texture_ids())),
681 pb.size(), visible_rect, natural_size, timestamp)); 667 pb.size(), visible_rect, natural_size, timestamp));
682 if (!frame) { 668 if (!frame) {
683 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id(); 669 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id();
684 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); 670 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE);
685 return; 671 return;
686 } 672 }
687 frame->set_color_space(picture.color_space()); 673 frame->set_color_space(picture.color_space());
688 if (picture.allow_overlay()) 674 if (picture.allow_overlay())
689 frame->metadata()->SetBoolean(VideoFrameMetadata::ALLOW_OVERLAY, true); 675 frame->metadata()->SetBoolean(VideoFrameMetadata::ALLOW_OVERLAY, true);
690 if (picture.surface_texture()) 676 if (picture.surface_texture())
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 } 893 }
908 return false; 894 return false;
909 } 895 }
910 896
911 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() 897 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent()
912 const { 898 const {
913 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); 899 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread());
914 } 900 }
915 901
916 } // namespace media 902 } // namespace media
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