| 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 <dlfcn.h> | 5 #include <dlfcn.h> |
| 6 #include <errno.h> | 6 #include <errno.h> |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <linux/videodev2.h> | 8 #include <linux/videodev2.h> |
| 9 #include <poll.h> | 9 #include <poll.h> |
| 10 #include <sys/eventfd.h> | 10 #include <sys/eventfd.h> |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 gsc_fd_(-1), | 234 gsc_fd_(-1), |
| 235 gsc_input_streamon_(false), | 235 gsc_input_streamon_(false), |
| 236 gsc_input_buffer_queued_count_(0), | 236 gsc_input_buffer_queued_count_(0), |
| 237 gsc_output_streamon_(false), | 237 gsc_output_streamon_(false), |
| 238 gsc_output_buffer_queued_count_(0), | 238 gsc_output_buffer_queued_count_(0), |
| 239 device_poll_thread_("ExynosDevicePollThread"), | 239 device_poll_thread_("ExynosDevicePollThread"), |
| 240 device_poll_interrupt_fd_(-1), | 240 device_poll_interrupt_fd_(-1), |
| 241 make_context_current_(make_context_current), | 241 make_context_current_(make_context_current), |
| 242 egl_display_(egl_display), | 242 egl_display_(egl_display), |
| 243 egl_context_(egl_context), | 243 egl_context_(egl_context), |
| 244 video_profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN) { | 244 video_profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN) {} |
| 245 } | |
| 246 | 245 |
| 247 ExynosVideoDecodeAccelerator::~ExynosVideoDecodeAccelerator() { | 246 ExynosVideoDecodeAccelerator::~ExynosVideoDecodeAccelerator() { |
| 248 DCHECK(!decoder_thread_.IsRunning()); | 247 DCHECK(!decoder_thread_.IsRunning()); |
| 249 DCHECK(!device_poll_thread_.IsRunning()); | 248 DCHECK(!device_poll_thread_.IsRunning()); |
| 250 | 249 |
| 251 if (device_poll_interrupt_fd_ != -1) { | 250 if (device_poll_interrupt_fd_ != -1) { |
| 252 HANDLE_EINTR(close(device_poll_interrupt_fd_)); | 251 HANDLE_EINTR(close(device_poll_interrupt_fd_)); |
| 253 device_poll_interrupt_fd_ = -1; | 252 device_poll_interrupt_fd_ = -1; |
| 254 } | 253 } |
| 255 if (gsc_fd_ != -1) { | 254 if (gsc_fd_ != -1) { |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); | 432 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
| 434 | 433 |
| 435 if (buffers.size() != gsc_output_buffer_map_.size()) { | 434 if (buffers.size() != gsc_output_buffer_map_.size()) { |
| 436 DLOG(ERROR) << "AssignPictureBuffers(): Failed to provide requested picture" | 435 DLOG(ERROR) << "AssignPictureBuffers(): Failed to provide requested picture" |
| 437 " buffers. (Got " << buffers.size() << ", requested " << | 436 " buffers. (Got " << buffers.size() << ", requested " << |
| 438 gsc_output_buffer_map_.size() << ")"; | 437 gsc_output_buffer_map_.size() << ")"; |
| 439 NOTIFY_ERROR(INVALID_ARGUMENT); | 438 NOTIFY_ERROR(INVALID_ARGUMENT); |
| 440 return; | 439 return; |
| 441 } | 440 } |
| 442 | 441 |
| 443 for (size_t i = 0; i < buffers.size(); ++i) { | |
| 444 if (buffers[i].size() != frame_buffer_size_) { | |
| 445 DLOG(ERROR) << "AssignPictureBuffers(): invalid buffer size"; | |
| 446 NOTIFY_ERROR(INVALID_ARGUMENT); | |
| 447 return; | |
| 448 } | |
| 449 } | |
| 450 | |
| 451 if (!make_context_current_.Run()) { | 442 if (!make_context_current_.Run()) { |
| 452 DLOG(ERROR) << "AssignPictureBuffers(): could not make context current"; | 443 DLOG(ERROR) << "AssignPictureBuffers(): could not make context current"; |
| 453 NOTIFY_ERROR(PLATFORM_FAILURE); | 444 NOTIFY_ERROR(PLATFORM_FAILURE); |
| 454 return; | 445 return; |
| 455 } | 446 } |
| 456 | 447 |
| 457 scoped_ptr<PictureBufferArrayRef> pic_buffers_ref( | 448 scoped_ptr<PictureBufferArrayRef> pic_buffers_ref( |
| 458 new PictureBufferArrayRef(egl_display_, buffers.size())); | 449 new PictureBufferArrayRef(egl_display_, buffers.size())); |
| 459 | 450 |
| 460 const static EGLint kImageAttrs[] = { | 451 const static EGLint kImageAttrs[] = { |
| 461 EGL_IMAGE_PRESERVED_KHR, 0, | 452 EGL_IMAGE_PRESERVED_KHR, 0, |
| 462 EGL_NONE, | 453 EGL_NONE, |
| 463 }; | 454 }; |
| 464 Display* x_display = base::MessagePumpForUI::GetDefaultXDisplay(); | 455 Display* x_display = base::MessagePumpForUI::GetDefaultXDisplay(); |
| 465 gfx::ScopedTextureBinder bind_restore(GL_TEXTURE_2D, 0); | 456 gfx::ScopedTextureBinder bind_restore(GL_TEXTURE_2D, 0); |
| 466 for (size_t i = 0; i < pic_buffers_ref->picture_buffers.size(); ++i) { | 457 for (size_t i = 0; i < pic_buffers_ref->picture_buffers.size(); ++i) { |
| 458 DCHECK(buffers[i].size() == frame_buffer_size_); |
| 467 PictureBufferArrayRef::PictureBufferRef& buffer = | 459 PictureBufferArrayRef::PictureBufferRef& buffer = |
| 468 pic_buffers_ref->picture_buffers[i]; | 460 pic_buffers_ref->picture_buffers[i]; |
| 469 // Create the X pixmap and then create an EGLImageKHR from it, so we can | 461 // Create the X pixmap and then create an EGLImageKHR from it, so we can |
| 470 // get dma_buf backing. | 462 // get dma_buf backing. |
| 471 Pixmap pixmap = XCreatePixmap(x_display, RootWindow(x_display, 0), | 463 Pixmap pixmap = XCreatePixmap(x_display, |
| 472 buffers[i].size().width(), buffers[i].size().height(), 32); | 464 RootWindow(x_display, 0), |
| 465 frame_buffer_size_.width(), |
| 466 frame_buffer_size_.height(), |
| 467 32); |
| 473 if (!pixmap) { | 468 if (!pixmap) { |
| 474 DLOG(ERROR) << "AssignPictureBuffers(): could not create X pixmap"; | 469 DLOG(ERROR) << "AssignPictureBuffers(): could not create X pixmap"; |
| 475 NOTIFY_ERROR(PLATFORM_FAILURE); | 470 NOTIFY_ERROR(PLATFORM_FAILURE); |
| 476 return; | 471 return; |
| 477 } | 472 } |
| 478 glBindTexture(GL_TEXTURE_2D, buffers[i].texture_id()); | 473 glBindTexture(GL_TEXTURE_2D, buffers[i].texture_id()); |
| 479 EGLImageKHR egl_image = eglCreateImageKHR( | 474 EGLImageKHR egl_image = eglCreateImageKHR( |
| 480 egl_display_, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, | 475 egl_display_, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, |
| 481 (EGLClientBuffer)pixmap, kImageAttrs); | 476 (EGLClientBuffer)pixmap, kImageAttrs); |
| 482 // We can free the X pixmap immediately -- according to the | 477 // We can free the X pixmap immediately -- according to the |
| (...skipping 1966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2449 DestroyGscOutputBuffers(); | 2444 DestroyGscOutputBuffers(); |
| 2450 DestroyMfcOutputBuffers(); | 2445 DestroyMfcOutputBuffers(); |
| 2451 | 2446 |
| 2452 // Finish resolution change on decoder thread. | 2447 // Finish resolution change on decoder thread. |
| 2453 decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( | 2448 decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| 2454 &ExynosVideoDecodeAccelerator::FinishResolutionChange, | 2449 &ExynosVideoDecodeAccelerator::FinishResolutionChange, |
| 2455 base::Unretained(this))); | 2450 base::Unretained(this))); |
| 2456 } | 2451 } |
| 2457 | 2452 |
| 2458 } // namespace content | 2453 } // namespace content |
| OLD | NEW |