OLD | NEW |
---|---|
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 Loading... | |
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, don't bother, as OMX_FillThisBuffer will fail anyway. | |
364 // If we're in the middle of closing, this will put the Accelerator in | |
365 // ERRORING mode, which has the side effect of not going through the | |
366 // OMX_FreeBuffers path and leaks memory. | |
367 if (current_state_change_ == RESETTING) | |
Ami GONE FROM CHROMIUM
2012/08/11 04:29:00
|| DESTROYING || ERRORING
marcheu
2012/08/13 19:23:04
Done.
| |
368 return; | |
369 | |
362 RETURN_ON_FAILURE(CanFillBuffer(), "Can't fill buffer", ILLEGAL_STATE,); | 370 RETURN_ON_FAILURE(CanFillBuffer(), "Can't fill buffer", ILLEGAL_STATE,); |
363 | 371 |
364 OutputPictureById::iterator it = pictures_.find(picture_buffer_id); | 372 OutputPictureById::iterator it = pictures_.find(picture_buffer_id); |
365 RETURN_ON_FAILURE(it != pictures_.end(), | 373 RETURN_ON_FAILURE(it != pictures_.end(), |
366 "Missing picture buffer id: " << picture_buffer_id, | 374 "Missing picture buffer id: " << picture_buffer_id, |
367 INVALID_ARGUMENT,); | 375 INVALID_ARGUMENT,); |
368 OutputPicture& output_picture = it->second; | 376 OutputPicture& output_picture = it->second; |
369 | 377 |
370 ++output_buffers_at_component_; | 378 ++output_buffers_at_component_; |
371 OMX_ERRORTYPE result = | 379 OMX_ERRORTYPE result = |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 // Note that during the Executing -> Idle transition, the OMX spec guarantees | 585 // Note that during the Executing -> Idle transition, the OMX spec guarantees |
578 // buffers have been returned to the client, so we don't need to do an | 586 // buffers have been returned to the client, so we don't need to do an |
579 // explicit FlushIOPorts(). | 587 // explicit FlushIOPorts(). |
580 | 588 |
581 BeginTransitionToState(OMX_StateLoaded); | 589 BeginTransitionToState(OMX_StateLoaded); |
582 | 590 |
583 // TODO(fischman): evaluate what these conditionals are doing. What happens | 591 // TODO(fischman): evaluate what these conditionals are doing. What happens |
584 // if they're false?? | 592 // if they're false?? |
585 if (!input_buffers_at_component_) | 593 if (!input_buffers_at_component_) |
586 FreeInputBuffers(); | 594 FreeInputBuffers(); |
587 if (!output_buffers_at_component_) | 595 if (!output_buffers_at_component_) |
Ami GONE FROM CHROMIUM
2012/08/11 04:29:00
Does you change obviate the need for this? (allow
marcheu
2012/08/13 19:23:04
It might be that this is the case.
With the OMX i
| |
588 FreeOutputBuffers(); | 596 FreeOutputBuffers(); |
589 } | 597 } |
590 | 598 |
591 void OmxVideoDecodeAccelerator::OnReachedLoadedInDestroying() { | 599 void OmxVideoDecodeAccelerator::OnReachedLoadedInDestroying() { |
592 DCHECK_EQ(client_state_, OMX_StateIdle); | 600 DCHECK_EQ(client_state_, OMX_StateIdle); |
593 client_state_ = OMX_StateLoaded; | 601 client_state_ = OMX_StateLoaded; |
594 current_state_change_ = NO_TRANSITION; | 602 current_state_change_ = NO_TRANSITION; |
595 ShutdownComponent(); | 603 ShutdownComponent(); |
596 } | 604 } |
597 | 605 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
793 RETURN_ON_OMX_FAILURE(result, "OMX_FreeBuffer failed", PLATFORM_FAILURE,); | 801 RETURN_ON_OMX_FAILURE(result, "OMX_FreeBuffer failed", PLATFORM_FAILURE,); |
794 return; | 802 return; |
795 } | 803 } |
796 DCHECK(!fake_output_buffers_.size()); | 804 DCHECK(!fake_output_buffers_.size()); |
797 | 805 |
798 // When the EOS picture is delivered back to us, notify the client and reuse | 806 // When the EOS picture is delivered back to us, notify the client and reuse |
799 // the underlying picturebuffer. | 807 // the underlying picturebuffer. |
800 if (buffer->nFlags & OMX_BUFFERFLAG_EOS) { | 808 if (buffer->nFlags & OMX_BUFFERFLAG_EOS) { |
801 buffer->nFlags &= ~OMX_BUFFERFLAG_EOS; | 809 buffer->nFlags &= ~OMX_BUFFERFLAG_EOS; |
802 OnReachedEOSInFlushing(); | 810 OnReachedEOSInFlushing(); |
803 if (current_state_change_ != DESTROYING) | 811 if (current_state_change_ != DESTROYING) |
Ami GONE FROM CHROMIUM
2012/08/11 04:29:00
Make this unconditional.
marcheu
2012/08/13 19:23:04
Done.
| |
804 ReusePictureBuffer(picture_buffer_id); | 812 ReusePictureBuffer(picture_buffer_id); |
805 return; | 813 return; |
806 } | 814 } |
807 | 815 |
808 // During the transition from Executing to Idle, and during port-flushing, all | 816 // 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. | 817 // pictures are sent back through here. Avoid giving them to the client. |
810 if (current_state_change_ != NO_TRANSITION && | 818 if (current_state_change_ != NO_TRANSITION && |
811 current_state_change_ != FLUSHING) { | 819 current_state_change_ != FLUSHING) { |
812 if (current_state_change_ == RESETTING) | 820 if (current_state_change_ == RESETTING) |
813 queued_picture_buffer_ids_.push_back(picture_buffer_id); | 821 queued_picture_buffer_ids_.push_back(picture_buffer_id); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1077 | 1085 |
1078 bool OmxVideoDecodeAccelerator::SendCommandToPort( | 1086 bool OmxVideoDecodeAccelerator::SendCommandToPort( |
1079 OMX_COMMANDTYPE cmd, int port_index) { | 1087 OMX_COMMANDTYPE cmd, int port_index) { |
1080 DCHECK_EQ(message_loop_, MessageLoop::current()); | 1088 DCHECK_EQ(message_loop_, MessageLoop::current()); |
1081 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, | 1089 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, |
1082 cmd, port_index, 0); | 1090 cmd, port_index, 0); |
1083 RETURN_ON_OMX_FAILURE(result, "SendCommand() failed" << cmd, | 1091 RETURN_ON_OMX_FAILURE(result, "SendCommand() failed" << cmd, |
1084 PLATFORM_FAILURE, false); | 1092 PLATFORM_FAILURE, false); |
1085 return true; | 1093 return true; |
1086 } | 1094 } |
OLD | NEW |