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

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

Issue 10837199: OMX: Make context current before using EGLImage functions. (Closed) Base URL: https://git.chromium.org/git/chromium/src@git-svn
Patch Set: 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
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 RETURN_ON_FAILURE( \ 84 RETURN_ON_FAILURE( \
85 ((omx_result) == OMX_ErrorNone), \ 85 ((omx_result) == OMX_ErrorNone), \
86 log << ", OMX result: 0x" << std::hex << omx_result, \ 86 log << ", OMX result: 0x" << std::hex << omx_result, \
87 error, ret_val) 87 error, ret_val)
88 88
89 // static 89 // static
90 bool OmxVideoDecodeAccelerator::pre_sandbox_init_done_ = false; 90 bool OmxVideoDecodeAccelerator::pre_sandbox_init_done_ = false;
91 91
92 OmxVideoDecodeAccelerator::OmxVideoDecodeAccelerator( 92 OmxVideoDecodeAccelerator::OmxVideoDecodeAccelerator(
93 EGLDisplay egl_display, EGLContext egl_context, 93 EGLDisplay egl_display, EGLContext egl_context,
94 media::VideoDecodeAccelerator::Client* client) 94 media::VideoDecodeAccelerator::Client* client,
95 const base::Callback<bool(void)>& make_context_current)
95 : message_loop_(MessageLoop::current()), 96 : message_loop_(MessageLoop::current()),
96 component_handle_(NULL), 97 component_handle_(NULL),
97 weak_this_(base::AsWeakPtr(this)), 98 weak_this_(base::AsWeakPtr(this)),
98 init_begun_(false), 99 init_begun_(false),
99 client_state_(OMX_StateMax), 100 client_state_(OMX_StateMax),
100 current_state_change_(NO_TRANSITION), 101 current_state_change_(NO_TRANSITION),
101 input_buffer_count_(0), 102 input_buffer_count_(0),
102 input_buffer_size_(0), 103 input_buffer_size_(0),
103 input_port_(0), 104 input_port_(0),
104 input_buffers_at_component_(0), 105 input_buffers_at_component_(0),
105 output_port_(0), 106 output_port_(0),
106 output_buffers_at_component_(0), 107 output_buffers_at_component_(0),
107 egl_display_(egl_display), 108 egl_display_(egl_display),
108 egl_context_(egl_context), 109 egl_context_(egl_context),
110 make_context_current_(make_context_current),
109 client_(client), 111 client_(client),
110 codec_(UNKNOWN), 112 codec_(UNKNOWN),
111 h264_profile_(OMX_VIDEO_AVCProfileMax), 113 h264_profile_(OMX_VIDEO_AVCProfileMax),
112 component_name_is_nvidia_h264ext_(false) { 114 component_name_is_nvidia_h264ext_(false) {
113 static bool omx_functions_initialized = PostSandboxInitialization(); 115 static bool omx_functions_initialized = PostSandboxInitialization();
114 RETURN_ON_FAILURE(omx_functions_initialized, 116 RETURN_ON_FAILURE(omx_functions_initialized,
115 "Failed to load openmax library", PLATFORM_FAILURE,); 117 "Failed to load openmax library", PLATFORM_FAILURE,);
116 RETURN_ON_OMX_FAILURE(omx_init(), "Failed to init OpenMAX core", 118 RETURN_ON_OMX_FAILURE(omx_init(), "Failed to init OpenMAX core",
117 PLATFORM_FAILURE,); 119 PLATFORM_FAILURE,);
118 } 120 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 329
328 void OmxVideoDecodeAccelerator::AssignPictureBuffers( 330 void OmxVideoDecodeAccelerator::AssignPictureBuffers(
329 const std::vector<media::PictureBuffer>& buffers) { 331 const std::vector<media::PictureBuffer>& buffers) {
330 DCHECK_EQ(message_loop_, MessageLoop::current()); 332 DCHECK_EQ(message_loop_, MessageLoop::current());
331 RETURN_ON_FAILURE(CanFillBuffer(), "Can't fill buffer", ILLEGAL_STATE,); 333 RETURN_ON_FAILURE(CanFillBuffer(), "Can't fill buffer", ILLEGAL_STATE,);
332 334
333 DCHECK_EQ(output_buffers_at_component_, 0); 335 DCHECK_EQ(output_buffers_at_component_, 0);
334 DCHECK_EQ(fake_output_buffers_.size(), 0U); 336 DCHECK_EQ(fake_output_buffers_.size(), 0U);
335 DCHECK_EQ(pictures_.size(), 0U); 337 DCHECK_EQ(pictures_.size(), 0U);
336 338
339 if (!make_context_current_.Run())
340 return;
341
337 for (size_t i = 0; i < buffers.size(); ++i) { 342 for (size_t i = 0; i < buffers.size(); ++i) {
338 EGLImageKHR egl_image = 343 EGLImageKHR egl_image =
339 texture_to_egl_image_translator_->TranslateToEglImage( 344 texture_to_egl_image_translator_->TranslateToEglImage(
340 egl_display_, egl_context_, 345 egl_display_, egl_context_,
341 buffers[i].texture_id(), 346 buffers[i].texture_id(),
342 last_requested_picture_buffer_dimensions_); 347 last_requested_picture_buffer_dimensions_);
343 CHECK(pictures_.insert(std::make_pair( 348 CHECK(pictures_.insert(std::make_pair(
344 buffers[i].id(), OutputPicture(buffers[i], NULL, egl_image))).second); 349 buffers[i].id(), OutputPicture(buffers[i], NULL, egl_image))).second);
345 } 350 }
346 351
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 free_input_buffers_.pop(); 705 free_input_buffers_.pop();
701 result = OMX_FreeBuffer(component_handle_, input_port_, omx_buffer); 706 result = OMX_FreeBuffer(component_handle_, input_port_, omx_buffer);
702 RETURN_ON_OMX_FAILURE(result, "OMX_FreeBuffer", PLATFORM_FAILURE,); 707 RETURN_ON_OMX_FAILURE(result, "OMX_FreeBuffer", PLATFORM_FAILURE,);
703 } 708 }
704 } 709 }
705 710
706 void OmxVideoDecodeAccelerator::FreeOutputBuffers() { 711 void OmxVideoDecodeAccelerator::FreeOutputBuffers() {
707 DCHECK_EQ(message_loop_, MessageLoop::current()); 712 DCHECK_EQ(message_loop_, MessageLoop::current());
708 // Calls to OMX to free buffers. 713 // Calls to OMX to free buffers.
709 OMX_ERRORTYPE result; 714 OMX_ERRORTYPE result;
715
716 if (!make_context_current_.Run())
717 return;
718
710 for (OutputPictureById::iterator it = pictures_.begin(); 719 for (OutputPictureById::iterator it = pictures_.begin();
711 it != pictures_.end(); ++it) { 720 it != pictures_.end(); ++it) {
712 OMX_BUFFERHEADERTYPE* omx_buffer = it->second.omx_buffer_header; 721 OMX_BUFFERHEADERTYPE* omx_buffer = it->second.omx_buffer_header;
713 DCHECK(omx_buffer); 722 DCHECK(omx_buffer);
714 delete reinterpret_cast<media::Picture*>(omx_buffer->pAppPrivate); 723 delete reinterpret_cast<media::Picture*>(omx_buffer->pAppPrivate);
715 result = OMX_FreeBuffer(component_handle_, output_port_, omx_buffer); 724 result = OMX_FreeBuffer(component_handle_, output_port_, omx_buffer);
716 RETURN_ON_OMX_FAILURE(result, "OMX_FreeBuffer", PLATFORM_FAILURE,); 725 RETURN_ON_OMX_FAILURE(result, "OMX_FreeBuffer", PLATFORM_FAILURE,);
717 texture_to_egl_image_translator_->DestroyEglImage(egl_display_, 726 texture_to_egl_image_translator_->DestroyEglImage(egl_display_,
718 it->second.egl_image); 727 it->second.egl_image);
719 if (client_) 728 if (client_)
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 1086
1078 bool OmxVideoDecodeAccelerator::SendCommandToPort( 1087 bool OmxVideoDecodeAccelerator::SendCommandToPort(
1079 OMX_COMMANDTYPE cmd, int port_index) { 1088 OMX_COMMANDTYPE cmd, int port_index) {
1080 DCHECK_EQ(message_loop_, MessageLoop::current()); 1089 DCHECK_EQ(message_loop_, MessageLoop::current());
1081 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, 1090 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_,
1082 cmd, port_index, 0); 1091 cmd, port_index, 0);
1083 RETURN_ON_OMX_FAILURE(result, "SendCommand() failed" << cmd, 1092 RETURN_ON_OMX_FAILURE(result, "SendCommand() failed" << cmd,
1084 PLATFORM_FAILURE, false); 1093 PLATFORM_FAILURE, false);
1085 return true; 1094 return true;
1086 } 1095 }
OLDNEW
« no previous file with comments | « content/common/gpu/media/omx_video_decode_accelerator.h ('k') | content/common/gpu/media/video_decode_accelerator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698