Chromium Code Reviews| Index: content/common/gpu/media/exynos_video_decode_accelerator.cc |
| diff --git a/content/common/gpu/media/exynos_video_decode_accelerator.cc b/content/common/gpu/media/exynos_video_decode_accelerator.cc |
| index cfa34433cd66be9f5f9e51fdbe99507aa9cddea9..e859e3fcb3447a275097b41e215f05ac5bc4854f 100644 |
| --- a/content/common/gpu/media/exynos_video_decode_accelerator.cc |
| +++ b/content/common/gpu/media/exynos_video_decode_accelerator.cc |
| @@ -33,7 +33,7 @@ namespace content { |
| #define IOCTL_OR_ERROR_RETURN(fd, type, arg) \ |
| do { \ |
| - if (HANDLE_EINTR(ioctl(fd, type, arg) != 0)) { \ |
| + if (HANDLE_EINTR(device->dev_ioctl(fd, type, arg) != 0)) { \ |
|
Pawel Osciak
2013/12/24 03:45:24
Please ensure device isn't NULL.
|
| DPLOG(ERROR) << __func__ << "(): ioctl() failed: " << #type; \ |
| NOTIFY_ERROR(PLATFORM_FAILURE); \ |
| return; \ |
| @@ -42,7 +42,7 @@ namespace content { |
| #define IOCTL_OR_ERROR_RETURN_FALSE(fd, type, arg) \ |
| do { \ |
| - if (HANDLE_EINTR(ioctl(fd, type, arg) != 0)) { \ |
| + if (HANDLE_EINTR(device->dev_ioctl(fd, type, arg) != 0)) { \ |
| DPLOG(ERROR) << __func__ << "(): ioctl() failed: " << #type; \ |
| NOTIFY_ERROR(PLATFORM_FAILURE); \ |
| return false; \ |
| @@ -60,7 +60,36 @@ const char kExynosMfcDevice[] = "/dev/mfc-dec"; |
| } // anonymous namespace |
| -struct ExynosVideoDecodeAccelerator::BitstreamBufferRef { |
| +int V4L2VideoDecodeAccelerator :: ExynosV4L2Device :: dev_open (const char *fd, |
|
Pawel Osciak
2013/12/24 03:45:24
Extract to separate file. Also style (spacing, ind
|
| + int flags) { |
| + return HANDLE_EINTR(open(fd,flags)); |
| +} |
| + |
| +int V4L2VideoDecodeAccelerator :: ExynosV4L2Device :: dev_ioctl (int fd, |
| + int flags, void *arg) { |
| + return ioctl(fd, flags, arg); |
|
Pawel Osciak
2013/12/24 03:45:24
HANDLE_EINTR?
|
| +} |
| + |
| +int V4L2VideoDecodeAccelerator :: ExynosV4L2Device :: dev_close (int fd) { |
| + return close(fd); |
| +} |
| + |
| +int V4L2VideoDecodeAccelerator :: ExynosV4L2Device :: dev_poll ( |
| + struct pollfd *fds, nfds_t nfds, int n) { |
| + return poll(fds, nfds, n); |
|
Pawel Osciak
2013/12/24 03:45:24
HANDLE_EINTR?
|
| +} |
| + |
| +void* V4L2VideoDecodeAccelerator :: ExynosV4L2Device :: dev_mmap (void *addr, |
| + unsigned int len, int prot, int flags, int fd, unsigned int offset) { |
| + return mmap(addr, len, prot, flags, fd, offset); |
| +} |
| + |
| +void V4L2VideoDecodeAccelerator :: ExynosV4L2Device :: dev_munmap (void *addr, |
| + unsigned int len) { |
| + munmap(addr,len); |
| +} |
| + |
| +struct V4L2VideoDecodeAccelerator::BitstreamBufferRef { |
| BitstreamBufferRef( |
| base::WeakPtr<Client>& client, |
| scoped_refptr<base::MessageLoopProxy>& client_message_loop_proxy, |
| @@ -76,7 +105,7 @@ struct ExynosVideoDecodeAccelerator::BitstreamBufferRef { |
| const int32 input_id; |
| }; |
| -struct ExynosVideoDecodeAccelerator::PictureBufferArrayRef { |
| +struct V4L2VideoDecodeAccelerator::PictureBufferArrayRef { |
| PictureBufferArrayRef(EGLDisplay egl_display); |
| ~PictureBufferArrayRef(); |
| @@ -91,21 +120,21 @@ struct ExynosVideoDecodeAccelerator::PictureBufferArrayRef { |
| std::vector<PictureBufferRef> picture_buffers; |
| }; |
| -struct ExynosVideoDecodeAccelerator::EGLSyncKHRRef { |
| +struct V4L2VideoDecodeAccelerator::EGLSyncKHRRef { |
| EGLSyncKHRRef(EGLDisplay egl_display, EGLSyncKHR egl_sync); |
| ~EGLSyncKHRRef(); |
| EGLDisplay const egl_display; |
| EGLSyncKHR egl_sync; |
| }; |
| -struct ExynosVideoDecodeAccelerator::PictureRecord { |
| +struct V4L2VideoDecodeAccelerator::PictureRecord { |
| PictureRecord(bool cleared, const media::Picture& picture); |
| ~PictureRecord(); |
| bool cleared; // Whether the texture is cleared and safe to render from. |
| media::Picture picture; // The decoded picture. |
| }; |
| -ExynosVideoDecodeAccelerator::BitstreamBufferRef::BitstreamBufferRef( |
| +V4L2VideoDecodeAccelerator::BitstreamBufferRef::BitstreamBufferRef( |
| base::WeakPtr<Client>& client, |
| scoped_refptr<base::MessageLoopProxy>& client_message_loop_proxy, |
| base::SharedMemory* shm, size_t size, int32 input_id) |
| @@ -117,18 +146,18 @@ ExynosVideoDecodeAccelerator::BitstreamBufferRef::BitstreamBufferRef( |
| input_id(input_id) { |
| } |
| -ExynosVideoDecodeAccelerator::BitstreamBufferRef::~BitstreamBufferRef() { |
| +V4L2VideoDecodeAccelerator::BitstreamBufferRef::~BitstreamBufferRef() { |
| if (input_id >= 0) { |
| client_message_loop_proxy->PostTask(FROM_HERE, base::Bind( |
| &Client::NotifyEndOfBitstreamBuffer, client, input_id)); |
| } |
| } |
| -ExynosVideoDecodeAccelerator::PictureBufferArrayRef::PictureBufferArrayRef( |
| +V4L2VideoDecodeAccelerator::PictureBufferArrayRef::PictureBufferArrayRef( |
| EGLDisplay egl_display) |
| : egl_display(egl_display) {} |
| -ExynosVideoDecodeAccelerator::PictureBufferArrayRef::~PictureBufferArrayRef() { |
| +V4L2VideoDecodeAccelerator::PictureBufferArrayRef::~PictureBufferArrayRef() { |
| for (size_t i = 0; i < picture_buffers.size(); ++i) { |
| EGLImageKHR egl_image = picture_buffers[i].egl_image; |
| if (egl_image != EGL_NO_IMAGE_KHR) |
| @@ -136,18 +165,18 @@ ExynosVideoDecodeAccelerator::PictureBufferArrayRef::~PictureBufferArrayRef() { |
| } |
| } |
| -ExynosVideoDecodeAccelerator::EGLSyncKHRRef::EGLSyncKHRRef( |
| +V4L2VideoDecodeAccelerator::EGLSyncKHRRef::EGLSyncKHRRef( |
| EGLDisplay egl_display, EGLSyncKHR egl_sync) |
| : egl_display(egl_display), |
| egl_sync(egl_sync) { |
| } |
| -ExynosVideoDecodeAccelerator::EGLSyncKHRRef::~EGLSyncKHRRef() { |
| +V4L2VideoDecodeAccelerator::EGLSyncKHRRef::~EGLSyncKHRRef() { |
| if (egl_sync != EGL_NO_SYNC_KHR) |
| eglDestroySyncKHR(egl_display, egl_sync); |
| } |
| -ExynosVideoDecodeAccelerator::MfcInputRecord::MfcInputRecord() |
| +V4L2VideoDecodeAccelerator::MfcInputRecord::MfcInputRecord() |
| : at_device(false), |
| address(NULL), |
| length(0), |
| @@ -155,10 +184,10 @@ ExynosVideoDecodeAccelerator::MfcInputRecord::MfcInputRecord() |
| input_id(-1) { |
| } |
| -ExynosVideoDecodeAccelerator::MfcInputRecord::~MfcInputRecord() { |
| +V4L2VideoDecodeAccelerator::MfcInputRecord::~MfcInputRecord() { |
| } |
| -ExynosVideoDecodeAccelerator::MfcOutputRecord::MfcOutputRecord() |
| +V4L2VideoDecodeAccelerator::MfcOutputRecord::MfcOutputRecord() |
| : at_device(false), |
| at_client(false), |
| egl_image(EGL_NO_IMAGE_KHR), |
| @@ -169,18 +198,17 @@ ExynosVideoDecodeAccelerator::MfcOutputRecord::MfcOutputRecord() |
| fds[i] = -1; |
| } |
| -ExynosVideoDecodeAccelerator::MfcOutputRecord::~MfcOutputRecord() {} |
| +V4L2VideoDecodeAccelerator::MfcOutputRecord::~MfcOutputRecord() {} |
| -ExynosVideoDecodeAccelerator::PictureRecord::PictureRecord( |
| +V4L2VideoDecodeAccelerator::PictureRecord::PictureRecord( |
| bool cleared, |
| const media::Picture& picture) |
| : cleared(cleared), picture(picture) {} |
| -ExynosVideoDecodeAccelerator::PictureRecord::~PictureRecord() {} |
| +V4L2VideoDecodeAccelerator::PictureRecord::~PictureRecord() {} |
| -ExynosVideoDecodeAccelerator::ExynosVideoDecodeAccelerator( |
| +V4L2VideoDecodeAccelerator::V4L2VideoDecodeAccelerator( |
| EGLDisplay egl_display, |
| - EGLContext egl_context, |
| Client* client, |
| const base::WeakPtr<Client>& io_client, |
| const base::Callback<bool(void)>& make_context_current, |
| @@ -191,7 +219,7 @@ ExynosVideoDecodeAccelerator::ExynosVideoDecodeAccelerator( |
| client_ptr_factory_(client), |
| client_(client_ptr_factory_.GetWeakPtr()), |
| io_client_(io_client), |
| - decoder_thread_("ExynosDecoderThread"), |
| + decoder_thread_("V4L2DecoderThread"), |
| decoder_state_(kUninitialized), |
| decoder_delay_bitstream_buffer_id_(-1), |
| decoder_current_input_buffer_(-1), |
| @@ -201,7 +229,7 @@ ExynosVideoDecodeAccelerator::ExynosVideoDecodeAccelerator( |
| resolution_change_pending_(false), |
| resolution_change_reset_pending_(false), |
| decoder_partial_frame_pending_(false), |
| - mfc_fd_(-1), |
| + videodec_fd_(-1), |
| mfc_input_streamon_(false), |
| mfc_input_buffer_queued_count_(0), |
| mfc_output_streamon_(false), |
| @@ -209,26 +237,25 @@ ExynosVideoDecodeAccelerator::ExynosVideoDecodeAccelerator( |
| mfc_output_buffer_pixelformat_(0), |
| mfc_output_dpb_size_(0), |
| picture_clearing_count_(0), |
| - device_poll_thread_("ExynosDevicePollThread"), |
| + device_poll_thread_("V4L2DevicePollThread"), |
| device_poll_interrupt_fd_(-1), |
| make_context_current_(make_context_current), |
| egl_display_(egl_display), |
| - egl_context_(egl_context), |
| video_profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN) {} |
| -ExynosVideoDecodeAccelerator::~ExynosVideoDecodeAccelerator() { |
| +V4L2VideoDecodeAccelerator::~V4L2VideoDecodeAccelerator() { |
| DCHECK(!decoder_thread_.IsRunning()); |
| DCHECK(!device_poll_thread_.IsRunning()); |
| if (device_poll_interrupt_fd_ != -1) { |
| - close(device_poll_interrupt_fd_); |
| + device->dev_close(device_poll_interrupt_fd_); |
|
Pawel Osciak
2013/12/24 03:45:24
What if device has never been allocated (before In
|
| device_poll_interrupt_fd_ = -1; |
| } |
| - if (mfc_fd_ != -1) { |
| + if (videodec_fd_ != -1) { |
| DestroyMfcInputBuffers(); |
| DestroyMfcOutputBuffers(); |
| - close(mfc_fd_); |
| - mfc_fd_ = -1; |
| + device->dev_close(videodec_fd_); |
| + videodec_fd_ = -1; |
| } |
| // These maps have members that should be manually destroyed, e.g. file |
| @@ -237,7 +264,7 @@ ExynosVideoDecodeAccelerator::~ExynosVideoDecodeAccelerator() { |
| DCHECK(mfc_output_buffer_map_.empty()); |
| } |
| -bool ExynosVideoDecodeAccelerator::Initialize( |
| +bool V4L2VideoDecodeAccelerator::Initialize( |
| media::VideoCodecProfile profile) { |
| DVLOG(3) << "Initialize()"; |
| DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
| @@ -268,12 +295,6 @@ bool ExynosVideoDecodeAccelerator::Initialize( |
| return false; |
| } |
| - if (egl_context_ == EGL_NO_CONTEXT) { |
| - DLOG(ERROR) << "Initialize(): could not get EGLContext"; |
| - NOTIFY_ERROR(PLATFORM_FAILURE); |
| - return false; |
| - } |
| - |
| // We need the context to be initialized to query extensions. |
| if (!make_context_current_.Run()) { |
| DLOG(ERROR) << "Initialize(): could not make context current"; |
| @@ -289,9 +310,12 @@ bool ExynosVideoDecodeAccelerator::Initialize( |
| // Open the video devices. |
| DVLOG(2) << "Initialize(): opening MFC device: " << kExynosMfcDevice; |
|
Pawel Osciak
2013/12/24 03:45:24
Please scrub Exynos from this class.
|
| - mfc_fd_ = HANDLE_EINTR(open(kExynosMfcDevice, |
| - O_RDWR | O_NONBLOCK | O_CLOEXEC)); |
| - if (mfc_fd_ == -1) { |
| + device = new ExynosV4L2Device; |
|
Pawel Osciak
2013/12/24 03:45:24
I don't see this being freed anywhere.?
In any cas
|
| + |
| + videodec_fd_ = device->dev_open(kExynosMfcDevice, |
| + O_RDWR | O_NONBLOCK | O_CLOEXEC); |
| + |
| + if (videodec_fd_ == -1) { |
| DPLOG(ERROR) << "Initialize(): could not open MFC device: " |
| << kExynosMfcDevice; |
| NOTIFY_ERROR(PLATFORM_FAILURE); |
| @@ -313,7 +337,7 @@ bool ExynosVideoDecodeAccelerator::Initialize( |
| V4L2_CAP_VIDEO_CAPTURE_MPLANE | |
| V4L2_CAP_VIDEO_OUTPUT_MPLANE | |
| V4L2_CAP_STREAMING; |
| - IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_QUERYCAP, &caps); |
| + IOCTL_OR_ERROR_RETURN_FALSE(videodec_fd_, VIDIOC_QUERYCAP, &caps); |
| if ((caps.capabilities & kCapsRequired) != kCapsRequired) { |
| DLOG(ERROR) << "Initialize(): ioctl() failed: VIDIOC_QUERYCAP" |
| ", caps check failed: 0x" << std::hex << caps.capabilities; |
| @@ -329,13 +353,13 @@ bool ExynosVideoDecodeAccelerator::Initialize( |
| memset(&format, 0, sizeof(format)); |
| format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| format.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_NV12M; |
| - IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_S_FMT, &format); |
| + IOCTL_OR_ERROR_RETURN_FALSE(videodec_fd_, VIDIOC_S_FMT, &format); |
| // Subscribe to the resolution change event. |
| struct v4l2_event_subscription sub; |
| memset(&sub, 0, sizeof(sub)); |
| sub.type = V4L2_EVENT_RESOLUTION_CHANGE; |
| - IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_SUBSCRIBE_EVENT, &sub); |
| + IOCTL_OR_ERROR_RETURN_FALSE(videodec_fd_, VIDIOC_SUBSCRIBE_EVENT, &sub); |
| // Initialize format-specific bits. |
| if (video_profile_ >= media::H264PROFILE_MIN && |
| @@ -356,7 +380,7 @@ bool ExynosVideoDecodeAccelerator::Initialize( |
| return true; |
| } |
| -void ExynosVideoDecodeAccelerator::Decode( |
| +void V4L2VideoDecodeAccelerator::Decode( |
| const media::BitstreamBuffer& bitstream_buffer) { |
| DVLOG(1) << "Decode(): input_id=" << bitstream_buffer.id() |
| << ", size=" << bitstream_buffer.size(); |
| @@ -364,11 +388,11 @@ void ExynosVideoDecodeAccelerator::Decode( |
| // DecodeTask() will take care of running a DecodeBufferTask(). |
| decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| - &ExynosVideoDecodeAccelerator::DecodeTask, base::Unretained(this), |
| + &V4L2VideoDecodeAccelerator::DecodeTask, base::Unretained(this), |
| bitstream_buffer)); |
| } |
| -void ExynosVideoDecodeAccelerator::AssignPictureBuffers( |
| +void V4L2VideoDecodeAccelerator::AssignPictureBuffers( |
| const std::vector<media::PictureBuffer>& buffers) { |
| DVLOG(3) << "AssignPictureBuffers(): buffer_count=" << buffers.size(); |
| DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
| @@ -423,12 +447,12 @@ void ExynosVideoDecodeAccelerator::AssignPictureBuffers( |
| } |
| decoder_thread_.message_loop()->PostTask( |
| FROM_HERE, |
| - base::Bind(&ExynosVideoDecodeAccelerator::AssignPictureBuffersTask, |
| + base::Bind(&V4L2VideoDecodeAccelerator::AssignPictureBuffersTask, |
| base::Unretained(this), |
| base::Passed(&picture_buffers_ref))); |
| } |
| -void ExynosVideoDecodeAccelerator::ReusePictureBuffer(int32 picture_buffer_id) { |
| +void V4L2VideoDecodeAccelerator::ReusePictureBuffer(int32 picture_buffer_id) { |
| DVLOG(3) << "ReusePictureBuffer(): picture_buffer_id=" << picture_buffer_id; |
| // Must be run on child thread, as we'll insert a sync in the EGL context. |
| DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
| @@ -450,25 +474,25 @@ void ExynosVideoDecodeAccelerator::ReusePictureBuffer(int32 picture_buffer_id) { |
| scoped_ptr<EGLSyncKHRRef> egl_sync_ref(new EGLSyncKHRRef( |
| egl_display_, egl_sync)); |
| decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| - &ExynosVideoDecodeAccelerator::ReusePictureBufferTask, |
| + &V4L2VideoDecodeAccelerator::ReusePictureBufferTask, |
| base::Unretained(this), picture_buffer_id, base::Passed(&egl_sync_ref))); |
| } |
| -void ExynosVideoDecodeAccelerator::Flush() { |
| +void V4L2VideoDecodeAccelerator::Flush() { |
| DVLOG(3) << "Flush()"; |
| DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
| decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| - &ExynosVideoDecodeAccelerator::FlushTask, base::Unretained(this))); |
| + &V4L2VideoDecodeAccelerator::FlushTask, base::Unretained(this))); |
| } |
| -void ExynosVideoDecodeAccelerator::Reset() { |
| +void V4L2VideoDecodeAccelerator::Reset() { |
| DVLOG(3) << "Reset()"; |
| DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
| decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| - &ExynosVideoDecodeAccelerator::ResetTask, base::Unretained(this))); |
| + &V4L2VideoDecodeAccelerator::ResetTask, base::Unretained(this))); |
| } |
| -void ExynosVideoDecodeAccelerator::Destroy() { |
| +void V4L2VideoDecodeAccelerator::Destroy() { |
| DVLOG(3) << "Destroy()"; |
| DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
| @@ -478,7 +502,7 @@ void ExynosVideoDecodeAccelerator::Destroy() { |
| // If the decoder thread is running, destroy using posted task. |
| if (decoder_thread_.IsRunning()) { |
| decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| - &ExynosVideoDecodeAccelerator::DestroyTask, base::Unretained(this))); |
| + &V4L2VideoDecodeAccelerator::DestroyTask, base::Unretained(this))); |
| // DestroyTask() will cause the decoder_thread_ to flush all tasks. |
| decoder_thread_.Stop(); |
| } else { |
| @@ -492,9 +516,9 @@ void ExynosVideoDecodeAccelerator::Destroy() { |
| delete this; |
| } |
| -bool ExynosVideoDecodeAccelerator::CanDecodeOnIOThread() { return true; } |
| +bool V4L2VideoDecodeAccelerator::CanDecodeOnIOThread() { return true; } |
| -void ExynosVideoDecodeAccelerator::DecodeTask( |
| +void V4L2VideoDecodeAccelerator::DecodeTask( |
| const media::BitstreamBuffer& bitstream_buffer) { |
| DVLOG(3) << "DecodeTask(): input_id=" << bitstream_buffer.id(); |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| @@ -532,7 +556,7 @@ void ExynosVideoDecodeAccelerator::DecodeTask( |
| DecodeBufferTask(); |
| } |
| -void ExynosVideoDecodeAccelerator::DecodeBufferTask() { |
| +void V4L2VideoDecodeAccelerator::DecodeBufferTask() { |
| DVLOG(3) << "DecodeBufferTask()"; |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| DCHECK_NE(decoder_state_, kUninitialized); |
| @@ -653,7 +677,7 @@ void ExynosVideoDecodeAccelerator::DecodeBufferTask() { |
| } |
| } |
| -bool ExynosVideoDecodeAccelerator::AdvanceFrameFragment( |
| +bool V4L2VideoDecodeAccelerator::AdvanceFrameFragment( |
| const uint8* data, |
| size_t size, |
| size_t* endpos) { |
| @@ -733,7 +757,7 @@ bool ExynosVideoDecodeAccelerator::AdvanceFrameFragment( |
| } |
| } |
| -void ExynosVideoDecodeAccelerator::ScheduleDecodeBufferTaskIfNeeded() { |
| +void V4L2VideoDecodeAccelerator::ScheduleDecodeBufferTaskIfNeeded() { |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| // If we're behind on tasks, schedule another one. |
| @@ -743,12 +767,12 @@ void ExynosVideoDecodeAccelerator::ScheduleDecodeBufferTaskIfNeeded() { |
| if (decoder_decode_buffer_tasks_scheduled_ < buffers_to_decode) { |
| decoder_decode_buffer_tasks_scheduled_++; |
| decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| - &ExynosVideoDecodeAccelerator::DecodeBufferTask, |
| + &V4L2VideoDecodeAccelerator::DecodeBufferTask, |
| base::Unretained(this))); |
| } |
| } |
| -bool ExynosVideoDecodeAccelerator::DecodeBufferInitial( |
| +bool V4L2VideoDecodeAccelerator::DecodeBufferInitial( |
| const void* data, size_t size, size_t* endpos) { |
| DVLOG(3) << "DecodeBufferInitial(): data=" << data << ", size=" << size; |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| @@ -809,7 +833,7 @@ bool ExynosVideoDecodeAccelerator::DecodeBufferInitial( |
| return true; |
| } |
| -bool ExynosVideoDecodeAccelerator::DecodeBufferContinue( |
| +bool V4L2VideoDecodeAccelerator::DecodeBufferContinue( |
| const void* data, size_t size) { |
| DVLOG(3) << "DecodeBufferContinue(): data=" << data << ", size=" << size; |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| @@ -821,7 +845,7 @@ bool ExynosVideoDecodeAccelerator::DecodeBufferContinue( |
| (decoder_partial_frame_pending_ || FlushInputFrame())); |
| } |
| -bool ExynosVideoDecodeAccelerator::AppendToInputFrame( |
| +bool V4L2VideoDecodeAccelerator::AppendToInputFrame( |
| const void* data, size_t size) { |
| DVLOG(3) << "AppendToInputFrame()"; |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| @@ -888,7 +912,7 @@ bool ExynosVideoDecodeAccelerator::AppendToInputFrame( |
| return true; |
| } |
| -bool ExynosVideoDecodeAccelerator::FlushInputFrame() { |
| +bool V4L2VideoDecodeAccelerator::FlushInputFrame() { |
| DVLOG(3) << "FlushInputFrame()"; |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| DCHECK_NE(decoder_state_, kUninitialized); |
| @@ -926,7 +950,7 @@ bool ExynosVideoDecodeAccelerator::FlushInputFrame() { |
| return (decoder_state_ != kError); |
| } |
| -void ExynosVideoDecodeAccelerator::AssignPictureBuffersTask( |
| +void V4L2VideoDecodeAccelerator::AssignPictureBuffersTask( |
| scoped_ptr<PictureBufferArrayRef> pic_buffers) { |
| DVLOG(3) << "AssignPictureBuffersTask()"; |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| @@ -966,7 +990,7 @@ void ExynosVideoDecodeAccelerator::AssignPictureBuffersTask( |
| ResumeAfterResolutionChange(); |
| } |
| -void ExynosVideoDecodeAccelerator::ServiceDeviceTask(bool mfc_event_pending) { |
| +void V4L2VideoDecodeAccelerator::ServiceDeviceTask(bool mfc_event_pending) { |
| DVLOG(3) << "ServiceDeviceTask()"; |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| DCHECK_NE(decoder_state_, kUninitialized); |
| @@ -991,8 +1015,10 @@ void ExynosVideoDecodeAccelerator::ServiceDeviceTask(bool mfc_event_pending) { |
| EnqueueMfc(); |
| // Clear the interrupt fd. |
| - if (!ClearDevicePollInterrupt()) |
| + if (!device->ClearDevicePollInterrupt(device_poll_interrupt_fd_)) { |
| + NOTIFY_ERROR(PLATFORM_FAILURE); |
| return; |
| + } |
| unsigned int poll_fds = 0; |
| // Add MFC fd, if we should poll on it. |
| @@ -1009,7 +1035,7 @@ void ExynosVideoDecodeAccelerator::ServiceDeviceTask(bool mfc_event_pending) { |
| DCHECK(device_poll_thread_.message_loop()); |
| // Queue the DevicePollTask() now. |
| device_poll_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| - &ExynosVideoDecodeAccelerator::DevicePollTask, |
| + &V4L2VideoDecodeAccelerator::DevicePollTask, |
| base::Unretained(this), |
| poll_fds)); |
| @@ -1028,7 +1054,7 @@ void ExynosVideoDecodeAccelerator::ServiceDeviceTask(bool mfc_event_pending) { |
| StartResolutionChangeIfNeeded(); |
| } |
| -void ExynosVideoDecodeAccelerator::EnqueueMfc() { |
| +void V4L2VideoDecodeAccelerator::EnqueueMfc() { |
| DVLOG(3) << "EnqueueMfc()"; |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| DCHECK_NE(decoder_state_, kUninitialized); |
| @@ -1043,12 +1069,14 @@ void ExynosVideoDecodeAccelerator::EnqueueMfc() { |
| if (old_mfc_inputs_queued == 0 && mfc_input_buffer_queued_count_ != 0) { |
| // We just started up a previously empty queue. |
| // Queue state changed; signal interrupt. |
| - if (!SetDevicePollInterrupt()) |
| + if (!device->SetDevicePollInterrupt(device_poll_interrupt_fd_)) { |
| + NOTIFY_ERROR(PLATFORM_FAILURE); |
| return; |
| + } |
| // Start VIDIOC_STREAMON if we haven't yet. |
| if (!mfc_input_streamon_) { |
| __u32 type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| - IOCTL_OR_ERROR_RETURN(mfc_fd_, VIDIOC_STREAMON, &type); |
| + IOCTL_OR_ERROR_RETURN(videodec_fd_, VIDIOC_STREAMON, &type); |
| mfc_input_streamon_ = true; |
| } |
| } |
| @@ -1062,18 +1090,20 @@ void ExynosVideoDecodeAccelerator::EnqueueMfc() { |
| if (old_mfc_outputs_queued == 0 && mfc_output_buffer_queued_count_ != 0) { |
| // We just started up a previously empty queue. |
| // Queue state changed; signal interrupt. |
| - if (!SetDevicePollInterrupt()) |
| + if (!device->SetDevicePollInterrupt(device_poll_interrupt_fd_)) { |
| + NOTIFY_ERROR(PLATFORM_FAILURE); |
| return; |
| + } |
| // Start VIDIOC_STREAMON if we haven't yet. |
| if (!mfc_output_streamon_) { |
| __u32 type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| - IOCTL_OR_ERROR_RETURN(mfc_fd_, VIDIOC_STREAMON, &type); |
| + IOCTL_OR_ERROR_RETURN(videodec_fd_, VIDIOC_STREAMON, &type); |
| mfc_output_streamon_ = true; |
| } |
| } |
| } |
| -void ExynosVideoDecodeAccelerator::DequeueMfcEvents() { |
| +void V4L2VideoDecodeAccelerator::DequeueMfcEvents() { |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| DCHECK_NE(decoder_state_, kUninitialized); |
| DVLOG(3) << "DequeueMfcEvents()"; |
| @@ -1081,7 +1111,7 @@ void ExynosVideoDecodeAccelerator::DequeueMfcEvents() { |
| struct v4l2_event ev; |
| memset(&ev, 0, sizeof(ev)); |
| - while (ioctl(mfc_fd_, VIDIOC_DQEVENT, &ev) == 0) { |
| + while (device->dev_ioctl(videodec_fd_, VIDIOC_DQEVENT, &ev) == 0) { |
| if (ev.type == V4L2_EVENT_RESOLUTION_CHANGE) { |
| DVLOG(3) << "DequeueMfcEvents(): got resolution change event."; |
| DCHECK(!resolution_change_pending_); |
| @@ -1093,7 +1123,7 @@ void ExynosVideoDecodeAccelerator::DequeueMfcEvents() { |
| } |
| } |
| -void ExynosVideoDecodeAccelerator::DequeueMfc() { |
| +void V4L2VideoDecodeAccelerator::DequeueMfc() { |
| DVLOG(3) << "DequeueMfc()"; |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| DCHECK_NE(decoder_state_, kUninitialized); |
| @@ -1111,7 +1141,7 @@ void ExynosVideoDecodeAccelerator::DequeueMfc() { |
| dqbuf.memory = V4L2_MEMORY_MMAP; |
| dqbuf.m.planes = planes; |
| dqbuf.length = 1; |
| - if (ioctl(mfc_fd_, VIDIOC_DQBUF, &dqbuf) != 0) { |
| + if (device->dev_ioctl(videodec_fd_, VIDIOC_DQBUF, &dqbuf) != 0) { |
| if (errno == EAGAIN) { |
| // EAGAIN if we're just out of buffers to dequeue. |
| break; |
| @@ -1139,7 +1169,7 @@ void ExynosVideoDecodeAccelerator::DequeueMfc() { |
| dqbuf.memory = V4L2_MEMORY_MMAP; |
| dqbuf.m.planes = planes; |
| dqbuf.length = 2; |
| - if (ioctl(mfc_fd_, VIDIOC_DQBUF, &dqbuf) != 0) { |
| + if (device->dev_ioctl(videodec_fd_, VIDIOC_DQBUF, &dqbuf) != 0) { |
| if (errno == EAGAIN) { |
| // EAGAIN if we're just out of buffers to dequeue. |
| break; |
| @@ -1176,7 +1206,7 @@ void ExynosVideoDecodeAccelerator::DequeueMfc() { |
| NotifyFlushDoneIfNeeded(); |
| } |
| -bool ExynosVideoDecodeAccelerator::EnqueueMfcInputRecord() { |
| +bool V4L2VideoDecodeAccelerator::EnqueueMfcInputRecord() { |
| DVLOG(3) << "EnqueueMfcInputRecord()"; |
| DCHECK(!mfc_input_ready_queue_.empty()); |
| @@ -1195,7 +1225,7 @@ bool ExynosVideoDecodeAccelerator::EnqueueMfcInputRecord() { |
| qbuf.m.planes = &qbuf_plane; |
| qbuf.m.planes[0].bytesused = input_record.bytes_used; |
| qbuf.length = 1; |
| - IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_QBUF, &qbuf); |
| + IOCTL_OR_ERROR_RETURN_FALSE(videodec_fd_, VIDIOC_QBUF, &qbuf); |
| mfc_input_ready_queue_.pop(); |
| input_record.at_device = true; |
| mfc_input_buffer_queued_count_++; |
| @@ -1204,7 +1234,7 @@ bool ExynosVideoDecodeAccelerator::EnqueueMfcInputRecord() { |
| return true; |
| } |
| -bool ExynosVideoDecodeAccelerator::EnqueueMfcOutputRecord() { |
| +bool V4L2VideoDecodeAccelerator::EnqueueMfcOutputRecord() { |
| DVLOG(3) << "EnqueueMfcOutputRecord()"; |
| DCHECK(!mfc_free_output_buffers_.empty()); |
| @@ -1235,14 +1265,14 @@ bool ExynosVideoDecodeAccelerator::EnqueueMfcOutputRecord() { |
| qbuf.memory = V4L2_MEMORY_MMAP; |
| qbuf.m.planes = qbuf_planes; |
| qbuf.length = arraysize(output_record.fds); |
| - IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_QBUF, &qbuf); |
| + IOCTL_OR_ERROR_RETURN_FALSE(videodec_fd_, VIDIOC_QBUF, &qbuf); |
| mfc_free_output_buffers_.pop(); |
| output_record.at_device = true; |
| mfc_output_buffer_queued_count_++; |
| return true; |
| } |
| -void ExynosVideoDecodeAccelerator::ReusePictureBufferTask( |
| +void V4L2VideoDecodeAccelerator::ReusePictureBufferTask( |
| int32 picture_buffer_id, scoped_ptr<EGLSyncKHRRef> egl_sync_ref) { |
| DVLOG(3) << "ReusePictureBufferTask(): picture_buffer_id=" |
| << picture_buffer_id; |
| @@ -1289,7 +1319,7 @@ void ExynosVideoDecodeAccelerator::ReusePictureBufferTask( |
| EnqueueMfc(); |
| } |
| -void ExynosVideoDecodeAccelerator::FlushTask() { |
| +void V4L2VideoDecodeAccelerator::FlushTask() { |
| DVLOG(3) << "FlushTask()"; |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| TRACE_EVENT0("Video Decoder", "EVDA::FlushTask"); |
| @@ -1319,7 +1349,7 @@ void ExynosVideoDecodeAccelerator::FlushTask() { |
| ScheduleDecodeBufferTaskIfNeeded(); |
| } |
| -void ExynosVideoDecodeAccelerator::NotifyFlushDoneIfNeeded() { |
| +void V4L2VideoDecodeAccelerator::NotifyFlushDoneIfNeeded() { |
| if (!decoder_flushing_) |
| return; |
| @@ -1363,7 +1393,7 @@ void ExynosVideoDecodeAccelerator::NotifyFlushDoneIfNeeded() { |
| ScheduleDecodeBufferTaskIfNeeded(); |
| } |
| -void ExynosVideoDecodeAccelerator::ResetTask() { |
| +void V4L2VideoDecodeAccelerator::ResetTask() { |
| DVLOG(3) << "ResetTask()"; |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| TRACE_EVENT0("Video Decoder", "EVDA::ResetTask"); |
| @@ -1404,10 +1434,10 @@ void ExynosVideoDecodeAccelerator::ResetTask() { |
| decoder_state_ = kResetting; |
| SendPictureReady(); // Send all pending PictureReady. |
| decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| - &ExynosVideoDecodeAccelerator::ResetDoneTask, base::Unretained(this))); |
| + &V4L2VideoDecodeAccelerator::ResetDoneTask, base::Unretained(this))); |
| } |
| -void ExynosVideoDecodeAccelerator::ResetDoneTask() { |
| +void V4L2VideoDecodeAccelerator::ResetDoneTask() { |
| DVLOG(3) << "ResetDoneTask()"; |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| TRACE_EVENT0("Video Decoder", "EVDA::ResetDoneTask"); |
| @@ -1441,7 +1471,7 @@ void ExynosVideoDecodeAccelerator::ResetDoneTask() { |
| ScheduleDecodeBufferTaskIfNeeded(); |
| } |
| -void ExynosVideoDecodeAccelerator::DestroyTask() { |
| +void V4L2VideoDecodeAccelerator::DestroyTask() { |
| DVLOG(3) << "DestroyTask()"; |
| TRACE_EVENT0("Video Decoder", "EVDA::DestroyTask"); |
| @@ -1462,7 +1492,7 @@ void ExynosVideoDecodeAccelerator::DestroyTask() { |
| decoder_state_ = kError; |
| } |
| -bool ExynosVideoDecodeAccelerator::StartDevicePoll() { |
| +bool V4L2VideoDecodeAccelerator::StartDevicePoll() { |
| DVLOG(3) << "StartDevicePoll()"; |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| DCHECK(!device_poll_thread_.IsRunning()); |
| @@ -1474,36 +1504,41 @@ bool ExynosVideoDecodeAccelerator::StartDevicePoll() { |
| return false; |
| } |
| device_poll_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| - &ExynosVideoDecodeAccelerator::DevicePollTask, |
| + &V4L2VideoDecodeAccelerator::DevicePollTask, |
| base::Unretained(this), |
| 0)); |
| return true; |
| } |
| -bool ExynosVideoDecodeAccelerator::StopDevicePoll(bool keep_mfc_input_state) { |
| +bool V4L2VideoDecodeAccelerator::StopDevicePoll(bool keep_mfc_input_state) { |
| DVLOG(3) << "StopDevicePoll()"; |
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| + if (decoder_thread_.IsRunning()) |
| + DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| // Signal the DevicePollTask() to stop, and stop the device poll thread. |
| - if (!SetDevicePollInterrupt()) |
| + if (!device->SetDevicePollInterrupt(device_poll_interrupt_fd_)) { |
| + NOTIFY_ERROR(PLATFORM_FAILURE); |
| return false; |
| + } |
| device_poll_thread_.Stop(); |
| // Clear the interrupt now, to be sure. |
| - if (!ClearDevicePollInterrupt()) |
| + if (!device->ClearDevicePollInterrupt(device_poll_interrupt_fd_)) { |
| + NOTIFY_ERROR(PLATFORM_FAILURE); |
| return false; |
| + } |
| // Stop streaming. |
| if (!keep_mfc_input_state) { |
| if (mfc_input_streamon_) { |
| __u32 type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| - IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_STREAMOFF, &type); |
| + IOCTL_OR_ERROR_RETURN_FALSE(videodec_fd_, VIDIOC_STREAMOFF, &type); |
| } |
| mfc_input_streamon_ = false; |
| } |
| if (mfc_output_streamon_) { |
| __u32 type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| - IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_STREAMOFF, &type); |
| + IOCTL_OR_ERROR_RETURN_FALSE(videodec_fd_, VIDIOC_STREAMOFF, &type); |
| } |
| mfc_output_streamon_ = false; |
| @@ -1537,38 +1572,34 @@ bool ExynosVideoDecodeAccelerator::StopDevicePoll(bool keep_mfc_input_state) { |
| return true; |
| } |
| -bool ExynosVideoDecodeAccelerator::SetDevicePollInterrupt() { |
| +bool V4L2VideoDecodeAccelerator:: ExynosV4L2Device :: SetDevicePollInterrupt(int fd) { |
|
Pawel Osciak
2013/12/24 03:45:24
Please keep methods of one class together (althoug
|
| DVLOG(3) << "SetDevicePollInterrupt()"; |
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| const uint64 buf = 1; |
| - if (HANDLE_EINTR(write(device_poll_interrupt_fd_, &buf, sizeof(buf))) == -1) { |
| + if (HANDLE_EINTR(write(fd, &buf, sizeof(buf))) == -1) { |
| DPLOG(ERROR) << "SetDevicePollInterrupt(): write() failed"; |
| - NOTIFY_ERROR(PLATFORM_FAILURE); |
| return false; |
| } |
| return true; |
| } |
| -bool ExynosVideoDecodeAccelerator::ClearDevicePollInterrupt() { |
| +bool V4L2VideoDecodeAccelerator:: ExynosV4L2Device :: ClearDevicePollInterrupt(int fd) { |
| DVLOG(3) << "ClearDevicePollInterrupt()"; |
| - DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| uint64 buf; |
| - if (HANDLE_EINTR(read(device_poll_interrupt_fd_, &buf, sizeof(buf))) == -1) { |
| + if (HANDLE_EINTR(read(fd, &buf, sizeof(buf))) == -1) { |
| if (errno == EAGAIN) { |
| // No interrupt flag set, and we're reading nonblocking. Not an error. |
| return true; |
| } else { |
| DPLOG(ERROR) << "ClearDevicePollInterrupt(): read() failed"; |
| - NOTIFY_ERROR(PLATFORM_FAILURE); |
| return false; |
| } |
| } |
| return true; |
| } |
| -void ExynosVideoDecodeAccelerator::StartResolutionChangeIfNeeded() { |
| +void V4L2VideoDecodeAccelerator::StartResolutionChangeIfNeeded() { |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| DCHECK_EQ(decoder_state_, kDecoding); |
| @@ -1588,11 +1619,11 @@ void ExynosVideoDecodeAccelerator::StartResolutionChangeIfNeeded() { |
| // Post a task to clean up buffers on child thread. This will also ensure |
| // that we won't accept ReusePictureBuffer() anymore after that. |
| child_message_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
| - &ExynosVideoDecodeAccelerator::ResolutionChangeDestroyBuffers, |
| + &V4L2VideoDecodeAccelerator::ResolutionChangeDestroyBuffers, |
| weak_this_)); |
| } |
| -void ExynosVideoDecodeAccelerator::FinishResolutionChange() { |
| +void V4L2VideoDecodeAccelerator::FinishResolutionChange() { |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| DVLOG(3) << "FinishResolutionChange()"; |
| @@ -1620,7 +1651,7 @@ void ExynosVideoDecodeAccelerator::FinishResolutionChange() { |
| // AssignPictureBuffers() before we can resume. |
| } |
| -void ExynosVideoDecodeAccelerator::ResumeAfterResolutionChange() { |
| +void V4L2VideoDecodeAccelerator::ResumeAfterResolutionChange() { |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| DVLOG(3) << "ResumeAfterResolutionChange()"; |
| @@ -1639,7 +1670,7 @@ void ExynosVideoDecodeAccelerator::ResumeAfterResolutionChange() { |
| ScheduleDecodeBufferTaskIfNeeded(); |
| } |
| -void ExynosVideoDecodeAccelerator::DevicePollTask(unsigned int poll_fds) { |
| +void V4L2VideoDecodeAccelerator::DevicePollTask(unsigned int poll_fds) { |
| DVLOG(3) << "DevicePollTask()"; |
| DCHECK_EQ(device_poll_thread_.message_loop(), base::MessageLoop::current()); |
| TRACE_EVENT0("Video Decoder", "EVDA::DevicePollTask"); |
| @@ -1659,14 +1690,14 @@ void ExynosVideoDecodeAccelerator::DevicePollTask(unsigned int poll_fds) { |
| if (poll_fds & kPollMfc) { |
| DVLOG(3) << "DevicePollTask(): adding MFC to poll() set"; |
| - pollfds[nfds].fd = mfc_fd_; |
| + pollfds[nfds].fd = videodec_fd_; |
| pollfds[nfds].events = POLLIN | POLLOUT | POLLERR | POLLPRI; |
| mfc_pollfd = nfds; |
| nfds++; |
| } |
| // Poll it! |
| - if (HANDLE_EINTR(poll(pollfds, nfds, -1)) == -1) { |
| + if (HANDLE_EINTR(device->dev_poll(pollfds, nfds, -1)) == -1) { |
| DPLOG(ERROR) << "DevicePollTask(): poll() failed"; |
| NOTIFY_ERROR(PLATFORM_FAILURE); |
| return; |
| @@ -1678,16 +1709,16 @@ void ExynosVideoDecodeAccelerator::DevicePollTask(unsigned int poll_fds) { |
| // All processing should happen on ServiceDeviceTask(), since we shouldn't |
| // touch decoder state from this thread. |
| decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| - &ExynosVideoDecodeAccelerator::ServiceDeviceTask, |
| + &V4L2VideoDecodeAccelerator::ServiceDeviceTask, |
| base::Unretained(this), mfc_event_pending)); |
| } |
| -void ExynosVideoDecodeAccelerator::NotifyError(Error error) { |
| +void V4L2VideoDecodeAccelerator::NotifyError(Error error) { |
| DVLOG(2) << "NotifyError()"; |
| if (!child_message_loop_proxy_->BelongsToCurrentThread()) { |
| child_message_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
| - &ExynosVideoDecodeAccelerator::NotifyError, weak_this_, error)); |
| + &V4L2VideoDecodeAccelerator::NotifyError, weak_this_, error)); |
| return; |
| } |
| @@ -1697,7 +1728,7 @@ void ExynosVideoDecodeAccelerator::NotifyError(Error error) { |
| } |
| } |
| -void ExynosVideoDecodeAccelerator::SetDecoderState(State state) { |
| +void V4L2VideoDecodeAccelerator::SetDecoderState(State state) { |
| DVLOG(3) << "SetDecoderState(): state=" << state; |
| // We can touch decoder_state_ only if this is the decoder thread or the |
| @@ -1705,21 +1736,21 @@ void ExynosVideoDecodeAccelerator::SetDecoderState(State state) { |
| if (decoder_thread_.message_loop() != NULL && |
| decoder_thread_.message_loop() != base::MessageLoop::current()) { |
| decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| - &ExynosVideoDecodeAccelerator::SetDecoderState, |
| + &V4L2VideoDecodeAccelerator::SetDecoderState, |
| base::Unretained(this), state)); |
| } else { |
| decoder_state_ = state; |
| } |
| } |
| -bool ExynosVideoDecodeAccelerator::GetFormatInfo(struct v4l2_format* format, |
| +bool V4L2VideoDecodeAccelerator::GetFormatInfo(struct v4l2_format* format, |
| bool* again) { |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| *again = false; |
| memset(format, 0, sizeof(*format)); |
| format->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| - if (HANDLE_EINTR(ioctl(mfc_fd_, VIDIOC_G_FMT, format)) != 0) { |
| + if (HANDLE_EINTR(device->dev_ioctl(videodec_fd_, VIDIOC_G_FMT, format)) != 0) { |
| if (errno == EINVAL) { |
| // EINVAL means we haven't seen sufficient stream to decode the format. |
| *again = true; |
| @@ -1734,7 +1765,7 @@ bool ExynosVideoDecodeAccelerator::GetFormatInfo(struct v4l2_format* format, |
| return true; |
| } |
| -bool ExynosVideoDecodeAccelerator::CreateBuffersForFormat( |
| +bool V4L2VideoDecodeAccelerator::CreateBuffersForFormat( |
| const struct v4l2_format& format) { |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| CHECK_EQ(format.fmt.pix_mp.num_planes, 2); |
| @@ -1751,7 +1782,7 @@ bool ExynosVideoDecodeAccelerator::CreateBuffersForFormat( |
| return true; |
| } |
| -bool ExynosVideoDecodeAccelerator::CreateMfcInputBuffers() { |
| +bool V4L2VideoDecodeAccelerator::CreateMfcInputBuffers() { |
| DVLOG(3) << "CreateMfcInputBuffers()"; |
| // We always run this as we prepare to initialize. |
| DCHECK_EQ(decoder_state_, kUninitialized); |
| @@ -1775,14 +1806,14 @@ bool ExynosVideoDecodeAccelerator::CreateMfcInputBuffers() { |
| format.fmt.pix_mp.pixelformat = pixelformat; |
| format.fmt.pix_mp.plane_fmt[0].sizeimage = kMfcInputBufferMaxSize; |
| format.fmt.pix_mp.num_planes = 1; |
| - IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_S_FMT, &format); |
| + IOCTL_OR_ERROR_RETURN_FALSE(videodec_fd_, VIDIOC_S_FMT, &format); |
| struct v4l2_requestbuffers reqbufs; |
| memset(&reqbufs, 0, sizeof(reqbufs)); |
| reqbufs.count = kMfcInputBufferCount; |
| reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| reqbufs.memory = V4L2_MEMORY_MMAP; |
| - IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_REQBUFS, &reqbufs); |
| + IOCTL_OR_ERROR_RETURN_FALSE(videodec_fd_, VIDIOC_REQBUFS, &reqbufs); |
| mfc_input_buffer_map_.resize(reqbufs.count); |
| for (size_t i = 0; i < mfc_input_buffer_map_.size(); ++i) { |
| mfc_free_input_buffers_.push_back(i); |
| @@ -1797,9 +1828,9 @@ bool ExynosVideoDecodeAccelerator::CreateMfcInputBuffers() { |
| buffer.memory = V4L2_MEMORY_MMAP; |
| buffer.m.planes = planes; |
| buffer.length = 1; |
| - IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_QUERYBUF, &buffer); |
| - void* address = mmap(NULL, buffer.m.planes[0].length, |
| - PROT_READ | PROT_WRITE, MAP_SHARED, mfc_fd_, |
| + IOCTL_OR_ERROR_RETURN_FALSE(videodec_fd_, VIDIOC_QUERYBUF, &buffer); |
| + void* address = device->dev_mmap(NULL, buffer.m.planes[0].length, |
| + PROT_READ | PROT_WRITE, MAP_SHARED, videodec_fd_, |
| buffer.m.planes[0].m.mem_offset); |
| if (address == MAP_FAILED) { |
| DPLOG(ERROR) << "CreateMfcInputBuffers(): mmap() failed"; |
| @@ -1812,7 +1843,7 @@ bool ExynosVideoDecodeAccelerator::CreateMfcInputBuffers() { |
| return true; |
| } |
| -bool ExynosVideoDecodeAccelerator::CreateMfcOutputBuffers() { |
| +bool V4L2VideoDecodeAccelerator::CreateMfcOutputBuffers() { |
| DVLOG(3) << "CreateMfcOutputBuffers()"; |
| DCHECK(decoder_state_ == kInitialized || |
| decoder_state_ == kChangingResolution); |
| @@ -1823,7 +1854,7 @@ bool ExynosVideoDecodeAccelerator::CreateMfcOutputBuffers() { |
| struct v4l2_control ctrl; |
| memset(&ctrl, 0, sizeof(ctrl)); |
| ctrl.id = V4L2_CID_MIN_BUFFERS_FOR_CAPTURE; |
| - IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_G_CTRL, &ctrl); |
| + IOCTL_OR_ERROR_RETURN_FALSE(videodec_fd_, VIDIOC_G_CTRL, &ctrl); |
| mfc_output_dpb_size_ = ctrl.value; |
| // Output format setup in Initialize(). |
| @@ -1834,7 +1865,7 @@ bool ExynosVideoDecodeAccelerator::CreateMfcOutputBuffers() { |
| reqbufs.count = mfc_output_dpb_size_ + kDpbOutputBufferExtraCount; |
| reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| reqbufs.memory = V4L2_MEMORY_MMAP; |
| - IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_REQBUFS, &reqbufs); |
| + IOCTL_OR_ERROR_RETURN_FALSE(videodec_fd_, VIDIOC_REQBUFS, &reqbufs); |
| // Create DMABUFs from output buffers. |
| mfc_output_buffer_map_.resize(reqbufs.count); |
| @@ -1848,7 +1879,7 @@ bool ExynosVideoDecodeAccelerator::CreateMfcOutputBuffers() { |
| expbuf.index = i; |
| expbuf.plane = j; |
| expbuf.flags = O_CLOEXEC; |
| - IOCTL_OR_ERROR_RETURN_FALSE(mfc_fd_, VIDIOC_EXPBUF, &expbuf); |
| + IOCTL_OR_ERROR_RETURN_FALSE(videodec_fd_, VIDIOC_EXPBUF, &expbuf); |
| output_record.fds[j] = expbuf.fd; |
| } |
| } |
| @@ -1867,14 +1898,14 @@ bool ExynosVideoDecodeAccelerator::CreateMfcOutputBuffers() { |
| return true; |
| } |
| -void ExynosVideoDecodeAccelerator::DestroyMfcInputBuffers() { |
| +void V4L2VideoDecodeAccelerator::DestroyMfcInputBuffers() { |
| DVLOG(3) << "DestroyMfcInputBuffers()"; |
| DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
| DCHECK(!mfc_input_streamon_); |
| for (size_t i = 0; i < mfc_input_buffer_map_.size(); ++i) { |
| if (mfc_input_buffer_map_[i].address != NULL) { |
| - munmap(mfc_input_buffer_map_[i].address, |
| + device->dev_munmap(mfc_input_buffer_map_[i].address, |
| mfc_input_buffer_map_[i].length); |
| } |
| } |
| @@ -1884,19 +1915,21 @@ void ExynosVideoDecodeAccelerator::DestroyMfcInputBuffers() { |
| reqbufs.count = 0; |
| reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
| reqbufs.memory = V4L2_MEMORY_MMAP; |
| - if (ioctl(mfc_fd_, VIDIOC_REQBUFS, &reqbufs) != 0) |
| + if (device->dev_ioctl(videodec_fd_, VIDIOC_REQBUFS, &reqbufs) != 0) |
| DPLOG(ERROR) << "DestroyMfcInputBuffers(): ioctl() failed: VIDIOC_REQBUFS"; |
| mfc_input_buffer_map_.clear(); |
| mfc_free_input_buffers_.clear(); |
| } |
| -void ExynosVideoDecodeAccelerator::DestroyMfcOutputBuffers() { |
| +void V4L2VideoDecodeAccelerator::DestroyMfcOutputBuffers() { |
| DVLOG(3) << "DestroyMfcOutputBuffers()"; |
| DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
| DCHECK(!mfc_output_streamon_); |
| if (mfc_output_buffer_map_.size() != 0) { |
| + // TODO(sheu, posciak): Making the context current should not be required |
| + // anymore. Remove it and verify (crbug.com/327869). |
| if (!make_context_current_.Run()) { |
| DLOG(ERROR) << "DestroyMfcOutputBuffers(): " |
| << "could not make context current"; |
| @@ -1906,7 +1939,7 @@ void ExynosVideoDecodeAccelerator::DestroyMfcOutputBuffers() { |
| MfcOutputRecord& output_record = mfc_output_buffer_map_[i]; |
| for (size_t j = 0; j < arraysize(output_record.fds); ++j) { |
| if (output_record.fds[j] != -1) |
| - close(output_record.fds[j]); |
| + device->dev_close(output_record.fds[j]); |
| if (output_record.egl_image != EGL_NO_IMAGE_KHR) |
| eglDestroyImageKHR(egl_display_, output_record.egl_image); |
| if (output_record.egl_sync != EGL_NO_SYNC_KHR) |
| @@ -1929,7 +1962,7 @@ void ExynosVideoDecodeAccelerator::DestroyMfcOutputBuffers() { |
| reqbufs.count = 0; |
| reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
| reqbufs.memory = V4L2_MEMORY_MMAP; |
| - if (ioctl(mfc_fd_, VIDIOC_REQBUFS, &reqbufs) != 0) |
| + if (device->dev_ioctl(videodec_fd_, VIDIOC_REQBUFS, &reqbufs) != 0) |
| DPLOG(ERROR) << "DestroyMfcOutputBuffers() ioctl() failed: VIDIOC_REQBUFS"; |
| mfc_output_buffer_map_.clear(); |
| @@ -1937,7 +1970,7 @@ void ExynosVideoDecodeAccelerator::DestroyMfcOutputBuffers() { |
| mfc_free_output_buffers_.pop(); |
| } |
| -void ExynosVideoDecodeAccelerator::ResolutionChangeDestroyBuffers() { |
| +void V4L2VideoDecodeAccelerator::ResolutionChangeDestroyBuffers() { |
| DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
| DVLOG(3) << "ResolutionChangeDestroyBuffers()"; |
| @@ -1945,11 +1978,11 @@ void ExynosVideoDecodeAccelerator::ResolutionChangeDestroyBuffers() { |
| // Finish resolution change on decoder thread. |
| decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| - &ExynosVideoDecodeAccelerator::FinishResolutionChange, |
| + &V4L2VideoDecodeAccelerator::FinishResolutionChange, |
| base::Unretained(this))); |
| } |
| -void ExynosVideoDecodeAccelerator::SendPictureReady() { |
| +void V4L2VideoDecodeAccelerator::SendPictureReady() { |
| DVLOG(3) << "SendPictureReady()"; |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| bool resetting_or_flushing = |
| @@ -1978,7 +2011,7 @@ void ExynosVideoDecodeAccelerator::SendPictureReady() { |
| base::Bind(&Client::PictureReady, client_, picture), |
| // Unretained is safe. If Client::PictureReady gets to run, |this| is |
| // alive. Destroy() will wait the decode thread to finish. |
| - base::Bind(&ExynosVideoDecodeAccelerator::PictureCleared, |
| + base::Bind(&V4L2VideoDecodeAccelerator::PictureCleared, |
| base::Unretained(this))); |
| picture_clearing_count_++; |
| pending_picture_ready_.pop(); |
| @@ -1991,7 +2024,7 @@ void ExynosVideoDecodeAccelerator::SendPictureReady() { |
| } |
| } |
| -void ExynosVideoDecodeAccelerator::PictureCleared() { |
| +void V4L2VideoDecodeAccelerator::PictureCleared() { |
| DVLOG(3) << "PictureCleared(). clearing count=" << picture_clearing_count_; |
| DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
| DCHECK_GT(picture_clearing_count_, 0); |