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

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

Issue 7017006: Fix the EOS hang. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 7 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
« 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/gpu/omx_video_decode_accelerator.h" 5 #include "content/gpu/omx_video_decode_accelerator.h"
6 6
7 #include "content/common/gpu/gpu_channel.h" 7 #include "content/common/gpu/gpu_channel.h"
8 #include "content/common/gpu_messages.h" 8 #include "content/common/gpu_messages.h"
9 #include "content/gpu/gles2_texture_to_egl_image_translator.h" 9 #include "content/gpu/gles2_texture_to_egl_image_translator.h"
10 #include "media/base/bitstream_buffer.h" 10 #include "media/base/bitstream_buffer.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 std::vector<PictureBuffer*> picture_buffers) { 287 std::vector<PictureBuffer*> picture_buffers) {
288 // NOTE: this is only partially-implemented as it only inspects the first 288 // NOTE: this is only partially-implemented as it only inspects the first
289 // picture buffer passed in each AssignPictureBuffer call, and never unsets 289 // picture buffer passed in each AssignPictureBuffer call, and never unsets
290 // uses_egl_image_ once set. 290 // uses_egl_image_ once set.
291 if (PictureBuffer::PICTUREBUFFER_MEMORYTYPE_GL_TEXTURE == 291 if (PictureBuffer::PICTUREBUFFER_MEMORYTYPE_GL_TEXTURE ==
292 picture_buffers[0]->GetMemoryType()) { 292 picture_buffers[0]->GetMemoryType()) {
293 uses_egl_image_ = true; 293 uses_egl_image_ = true;
294 } 294 }
295 295
296 assigned_picture_buffers_.insert( 296 assigned_picture_buffers_.insert(
297 assigned_picture_buffers_.begin(), 297 assigned_picture_buffers_.end(),
298 picture_buffers.begin(), 298 picture_buffers.begin(),
299 picture_buffers.end()); 299 picture_buffers.end());
300 300
301 if (assigned_picture_buffers_.size() < kNumPictureBuffers) 301 if (assigned_picture_buffers_.size() < kNumPictureBuffers)
302 return; // get all the buffers first. 302 return; // get all the buffers first.
303 303
304 // Obtain the information about the output port. 304 // Obtain the information about the output port.
305 OMX_PARAM_PORTDEFINITIONTYPE port_format; 305 OMX_PARAM_PORTDEFINITIONTYPE port_format;
306 InitParam(*this, &port_format); 306 InitParam(*this, &port_format);
307 port_format.nPortIndex = output_port_; 307 port_format.nPortIndex = output_port_;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 OMX_GetState(component_handle_, &il_state); 389 OMX_GetState(component_handle_, &il_state);
390 DCHECK_EQ(il_state, OMX_StateExecuting); 390 DCHECK_EQ(il_state, OMX_StateExecuting);
391 if (il_state != OMX_StateExecuting) { 391 if (il_state != OMX_StateExecuting) {
392 callback.Run(); 392 callback.Run();
393 return false; 393 return false;
394 } 394 }
395 on_buffer_flag_event_func_ = &OmxVideoDecodeAccelerator::FlushBegin; 395 on_buffer_flag_event_func_ = &OmxVideoDecodeAccelerator::FlushBegin;
396 flush_done_callback_ = callback; 396 flush_done_callback_ = callback;
397 397
398 OMX_BUFFERHEADERTYPE* omx_buffer = free_input_buffers_.front(); 398 OMX_BUFFERHEADERTYPE* omx_buffer = free_input_buffers_.front();
399 free_input_buffers_.pop();
399 omx_buffer->nFilledLen = 0; 400 omx_buffer->nFilledLen = 0;
400 omx_buffer->nAllocLen = omx_buffer->nFilledLen; 401 omx_buffer->nAllocLen = omx_buffer->nFilledLen;
401 omx_buffer->nFlags |= OMX_BUFFERFLAG_EOS; 402 omx_buffer->nFlags |= OMX_BUFFERFLAG_EOS;
402 omx_buffer->nTimeStamp = 0; 403 omx_buffer->nTimeStamp = 0;
403 // Give this buffer to OMX. 404 // Give this buffer to OMX.
404 OMX_ERRORTYPE result = OMX_ErrorNone; 405 OMX_ERRORTYPE result = OMX_ErrorNone;
405 result = OMX_EmptyThisBuffer(component_handle_, omx_buffer); 406 result = OMX_EmptyThisBuffer(component_handle_, omx_buffer);
406 if (result != OMX_ErrorNone) { 407 if (result != OMX_ErrorNone) {
407 LOG(ERROR) << "OMX_EmptyThisBuffer() failed with result " << result; 408 LOG(ERROR) << "OMX_EmptyThisBuffer() failed with result " << result;
408 StopOnError(); 409 StopOnError();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 DCHECK_EQ(state, OMX_StateExecuting); 523 DCHECK_EQ(state, OMX_StateExecuting);
523 524
524 VLOG(1) << "Deinit from Executing"; 525 VLOG(1) << "Deinit from Executing";
525 on_state_event_func_ = 526 on_state_event_func_ =
526 &OmxVideoDecodeAccelerator::OnStateChangeExecutingToIdle; 527 &OmxVideoDecodeAccelerator::OnStateChangeExecutingToIdle;
527 TransitionToState(OMX_StateIdle); 528 TransitionToState(OMX_StateIdle);
528 for (int i = 0; i < output_buffer_count_; ++i) { 529 for (int i = 0; i < output_buffer_count_; ++i) {
529 OutputPicture output_picture = output_pictures_[i]; 530 OutputPicture output_picture = output_pictures_[i];
530 client_->DismissPictureBuffer(output_picture.first); 531 client_->DismissPictureBuffer(output_picture.first);
531 } 532 }
532 output_pictures_.clear();
533 } 533 }
534 534
535 void OmxVideoDecodeAccelerator::OnStateChangeExecutingToIdle( 535 void OmxVideoDecodeAccelerator::OnStateChangeExecutingToIdle(
536 OMX_STATETYPE state) { 536 OMX_STATETYPE state) {
537 DCHECK_EQ(state, OMX_StateIdle); 537 DCHECK_EQ(state, OMX_StateIdle);
538 538
539 VLOG(1) << "Deinit from Idle"; 539 VLOG(1) << "Deinit from Idle";
540 on_state_event_func_ = 540 on_state_event_func_ =
541 &OmxVideoDecodeAccelerator::OnStateChangeIdleToLoaded; 541 &OmxVideoDecodeAccelerator::OnStateChangeIdleToLoaded;
542 TransitionToState(OMX_StateLoaded); 542 TransitionToState(OMX_StateLoaded);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 buffer->pAppPrivate = picture; 662 buffer->pAppPrivate = picture;
663 } 663 }
664 } 664 }
665 return true; 665 return true;
666 } 666 }
667 667
668 void OmxVideoDecodeAccelerator::FreeInputBuffers() { 668 void OmxVideoDecodeAccelerator::FreeInputBuffers() {
669 // Calls to OMX to free buffers. 669 // Calls to OMX to free buffers.
670 OMX_ERRORTYPE result; 670 OMX_ERRORTYPE result;
671 OMX_BUFFERHEADERTYPE* omx_buffer; 671 OMX_BUFFERHEADERTYPE* omx_buffer;
672 for (int i = 0; i < input_buffer_count_; ++i) { 672 while (!free_input_buffers_.empty()) {
673 omx_buffer = free_input_buffers_.front(); 673 omx_buffer = free_input_buffers_.front();
674 free_input_buffers_.pop(); 674 free_input_buffers_.pop();
675 result = OMX_FreeBuffer(component_handle_, input_port_, omx_buffer); 675 result = OMX_FreeBuffer(component_handle_, input_port_, omx_buffer);
676 if (result != OMX_ErrorNone) { 676 if (result != OMX_ErrorNone) {
677 LOG(ERROR) << "SendCommand(OMX_CommandPortDisable) failed"; 677 LOG(ERROR) << "SendCommand(OMX_CommandPortDisable) failed";
678 StopOnError(); 678 StopOnError();
679 return; 679 return;
680 } 680 }
681 } 681 }
682 } 682 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 return (client_state_ != OMX_StateInvalid && 848 return (client_state_ != OMX_StateInvalid &&
849 client_state_ != OMX_StatePause && 849 client_state_ != OMX_StatePause &&
850 client_state_ != OMX_StateLoaded); 850 client_state_ != OMX_StateLoaded);
851 } 851 }
852 852
853 bool OmxVideoDecodeAccelerator::CanFillBuffer() { 853 bool OmxVideoDecodeAccelerator::CanFillBuffer() {
854 // Make sure component is in the executing state and end-of-stream 854 // Make sure component is in the executing state and end-of-stream
855 // has not been reached. 855 // has not been reached.
856 OMX_ERRORTYPE result; 856 OMX_ERRORTYPE result;
857 OMX_STATETYPE il_state; 857 OMX_STATETYPE il_state;
858 if (client_state_ == OMX_StateLoaded)
859 return false;
858 result = OMX_GetState(component_handle_, &il_state); 860 result = OMX_GetState(component_handle_, &il_state);
859 if (result != OMX_ErrorNone) { 861 if (result != OMX_ErrorNone) {
860 LOG(ERROR) << "SendCommand(OMX_CommandPortDisable) failed"; 862 LOG(ERROR) << "SendCommand(OMX_CommandPortDisable) failed";
861 StopOnError(); 863 StopOnError();
862 return false; 864 return false;
863 } 865 }
864 return (il_state == OMX_StateExecuting); 866 return (il_state == OMX_StateExecuting);
865 } 867 }
866 868
867 // Send command to disable/enable port. 869 // Send command to disable/enable port.
868 void OmxVideoDecodeAccelerator::ChangePort( 870 void OmxVideoDecodeAccelerator::ChangePort(
869 OMX_COMMANDTYPE cmd, int port_index) { 871 OMX_COMMANDTYPE cmd, int port_index) {
870 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, 872 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_,
871 cmd, port_index, 0); 873 cmd, port_index, 0);
872 if (result != OMX_ErrorNone) { 874 if (result != OMX_ErrorNone) {
873 LOG(ERROR) << "SendCommand(OMX_CommandPortDisable) failed"; 875 LOG(ERROR) << "SendCommand(OMX_CommandPortDisable) failed";
874 StopOnError(); 876 StopOnError();
875 return; 877 return;
876 } 878 }
877 } 879 }
878 880
879 DISABLE_RUNNABLE_METHOD_REFCOUNT(OmxVideoDecodeAccelerator); 881 DISABLE_RUNNABLE_METHOD_REFCOUNT(OmxVideoDecodeAccelerator);
880 882
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