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

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

Issue 10837212: OMX: Don't try to send buffers when in resetting state. (Closed) Base URL: https://git.chromium.org/git/chromium/src@git-svn
Patch Set: Also handle the case of destroy/error. Created 8 years, 4 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 "content/common/gpu/media/omx_video_decode_accelerator.h" 5 #include "content/common/gpu/media/omx_video_decode_accelerator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 if (!AllocateOutputBuffers()) 352 if (!AllocateOutputBuffers())
353 return; 353 return;
354 if (!SendCommandToPort(OMX_CommandPortEnable, output_port_)) 354 if (!SendCommandToPort(OMX_CommandPortEnable, output_port_))
355 return; 355 return;
356 } 356 }
357 357
358 void OmxVideoDecodeAccelerator::ReusePictureBuffer(int32 picture_buffer_id) { 358 void OmxVideoDecodeAccelerator::ReusePictureBuffer(int32 picture_buffer_id) {
359 TRACE_EVENT1("Video Decoder", "OVDA::ReusePictureBuffer", 359 TRACE_EVENT1("Video Decoder", "OVDA::ReusePictureBuffer",
360 "Picture id", picture_buffer_id); 360 "Picture id", picture_buffer_id);
361 DCHECK_EQ(message_loop_, MessageLoop::current()); 361 DCHECK_EQ(message_loop_, MessageLoop::current());
362
363 // If we are resetting/destroying/erroring, don't bother, as
364 // OMX_FillThisBuffer will fail anyway. In case we're in the middle of
365 // closing, this will put the Accelerator in ERRORING mode, which has the
366 // unwanted side effect of not going through the OMX_FreeBuffers path and
367 // leaks memory.
368 if (current_state_change_ == RESETTING ||
369 current_state_change_ == DESTROYING ||
370 current_state_change_ == ERRORING)
371 return;
372
362 RETURN_ON_FAILURE(CanFillBuffer(), "Can't fill buffer", ILLEGAL_STATE,); 373 RETURN_ON_FAILURE(CanFillBuffer(), "Can't fill buffer", ILLEGAL_STATE,);
363 374
364 OutputPictureById::iterator it = pictures_.find(picture_buffer_id); 375 OutputPictureById::iterator it = pictures_.find(picture_buffer_id);
365 RETURN_ON_FAILURE(it != pictures_.end(), 376 RETURN_ON_FAILURE(it != pictures_.end(),
366 "Missing picture buffer id: " << picture_buffer_id, 377 "Missing picture buffer id: " << picture_buffer_id,
367 INVALID_ARGUMENT,); 378 INVALID_ARGUMENT,);
368 OutputPicture& output_picture = it->second; 379 OutputPicture& output_picture = it->second;
369 380
370 ++output_buffers_at_component_; 381 ++output_buffers_at_component_;
371 OMX_ERRORTYPE result = 382 OMX_ERRORTYPE result =
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 RETURN_ON_OMX_FAILURE(result, "OMX_FreeBuffer failed", PLATFORM_FAILURE,); 804 RETURN_ON_OMX_FAILURE(result, "OMX_FreeBuffer failed", PLATFORM_FAILURE,);
794 return; 805 return;
795 } 806 }
796 DCHECK(!fake_output_buffers_.size()); 807 DCHECK(!fake_output_buffers_.size());
797 808
798 // When the EOS picture is delivered back to us, notify the client and reuse 809 // When the EOS picture is delivered back to us, notify the client and reuse
799 // the underlying picturebuffer. 810 // the underlying picturebuffer.
800 if (buffer->nFlags & OMX_BUFFERFLAG_EOS) { 811 if (buffer->nFlags & OMX_BUFFERFLAG_EOS) {
801 buffer->nFlags &= ~OMX_BUFFERFLAG_EOS; 812 buffer->nFlags &= ~OMX_BUFFERFLAG_EOS;
802 OnReachedEOSInFlushing(); 813 OnReachedEOSInFlushing();
803 if (current_state_change_ != DESTROYING) 814 ReusePictureBuffer(picture_buffer_id);
804 ReusePictureBuffer(picture_buffer_id);
805 return; 815 return;
806 } 816 }
807 817
808 // During the transition from Executing to Idle, and during port-flushing, all 818 // During the transition from Executing to Idle, and during port-flushing, all
809 // pictures are sent back through here. Avoid giving them to the client. 819 // pictures are sent back through here. Avoid giving them to the client.
810 if (current_state_change_ != NO_TRANSITION && 820 if (current_state_change_ != NO_TRANSITION &&
811 current_state_change_ != FLUSHING) { 821 current_state_change_ != FLUSHING) {
812 if (current_state_change_ == RESETTING) 822 if (current_state_change_ == RESETTING)
813 queued_picture_buffer_ids_.push_back(picture_buffer_id); 823 queued_picture_buffer_ids_.push_back(picture_buffer_id);
814 return; 824 return;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 1087
1078 bool OmxVideoDecodeAccelerator::SendCommandToPort( 1088 bool OmxVideoDecodeAccelerator::SendCommandToPort(
1079 OMX_COMMANDTYPE cmd, int port_index) { 1089 OMX_COMMANDTYPE cmd, int port_index) {
1080 DCHECK_EQ(message_loop_, MessageLoop::current()); 1090 DCHECK_EQ(message_loop_, MessageLoop::current());
1081 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, 1091 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_,
1082 cmd, port_index, 0); 1092 cmd, port_index, 0);
1083 RETURN_ON_OMX_FAILURE(result, "SendCommand() failed" << cmd, 1093 RETURN_ON_OMX_FAILURE(result, "SendCommand() failed" << cmd,
1084 PLATFORM_FAILURE, false); 1094 PLATFORM_FAILURE, false);
1085 return true; 1095 return true;
1086 } 1096 }
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