Index: content/common/gpu/media/v4l2_video_decode_accelerator.cc |
diff --git a/content/common/gpu/media/v4l2_video_decode_accelerator.cc b/content/common/gpu/media/v4l2_video_decode_accelerator.cc |
index 68baaa85c845c91dda916e544ddd9e15e27431a3..9ee1efd3115d0db924f4e00e73be0ce014f054f3 100644 |
--- a/content/common/gpu/media/v4l2_video_decode_accelerator.cc |
+++ b/content/common/gpu/media/v4l2_video_decode_accelerator.cc |
@@ -160,7 +160,6 @@ V4L2VideoDecodeAccelerator::V4L2VideoDecodeAccelerator( |
const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy) |
: child_message_loop_proxy_(base::MessageLoopProxy::current()), |
io_message_loop_proxy_(io_message_loop_proxy), |
- weak_this_(base::AsWeakPtr(this)), |
io_client_(io_client), |
decoder_thread_("V4L2DecoderThread"), |
decoder_state_(kUninitialized), |
@@ -184,7 +183,10 @@ V4L2VideoDecodeAccelerator::V4L2VideoDecodeAccelerator( |
device_poll_thread_("V4L2DevicePollThread"), |
make_context_current_(make_context_current), |
egl_display_(egl_display), |
- video_profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN) {} |
+ video_profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN), |
+ weak_this_factory_(this) { |
+ weak_this_ = weak_this_factory_.GetWeakPtr(); |
+} |
V4L2VideoDecodeAccelerator::~V4L2VideoDecodeAccelerator() { |
DCHECK(!decoder_thread_.IsRunning()); |
@@ -289,9 +291,6 @@ bool V4L2VideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile, |
} |
SetDecoderState(kInitialized); |
- |
- child_message_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
- &Client::NotifyInitializeDone, client_)); |
return true; |
} |
@@ -428,6 +427,7 @@ void V4L2VideoDecodeAccelerator::Destroy() { |
// We're destroying; cancel all callbacks. |
client_ptr_factory_.reset(); |
+ weak_this_factory_.InvalidateWeakPtrs(); |
// If the decoder thread is running, destroy using posted task. |
if (decoder_thread_.IsRunning()) { |
@@ -755,9 +755,10 @@ bool V4L2VideoDecodeAccelerator::DecodeBufferInitial( |
*endpos = size; |
} |
- // StartDevicePoll will raise the error if there is one. |
- if (!StartDevicePoll()) |
+ if (!StartDevicePoll()) { |
+ NOTIFY_ERROR(PLATFORM_FAILURE); |
return false; |
+ } |
decoder_state_ = kDecoding; |
ScheduleDecodeBufferTaskIfNeeded(); |
@@ -1284,11 +1285,15 @@ void V4L2VideoDecodeAccelerator::NotifyFlushDoneIfNeeded() { |
// transitioning to next chunk. |
// For now, do the streamoff-streamon cycle to satisfy Exynos and not freeze |
// when doing MSE. This should be harmless otherwise. |
- if (!StopDevicePoll(false)) |
+ if (!StopDevicePoll(false)) { |
+ NOTIFY_ERROR(PLATFORM_FAILURE); |
return; |
+ } |
- if (!StartDevicePoll()) |
+ if (!StartDevicePoll()) { |
+ NOTIFY_ERROR(PLATFORM_FAILURE); |
return; |
+ } |
decoder_delay_bitstream_buffer_id_ = -1; |
decoder_flushing_ = false; |
@@ -1322,8 +1327,10 @@ void V4L2VideoDecodeAccelerator::ResetTask() { |
// We stop streaming and clear buffer tracking info (not preserving inputs). |
// StopDevicePoll() unconditionally does _not_ destroy buffers, however. |
- if (!StopDevicePoll(false)) |
+ if (!StopDevicePoll(false)) { |
+ NOTIFY_ERROR(PLATFORM_FAILURE); |
return; |
+ } |
decoder_current_bitstream_buffer_.reset(); |
while (!decoder_input_queue_.empty()) |
@@ -1413,7 +1420,6 @@ bool V4L2VideoDecodeAccelerator::StartDevicePoll() { |
// Start up the device poll thread and schedule its first DevicePollTask(). |
if (!device_poll_thread_.Start()) { |
DLOG(ERROR) << "StartDevicePoll(): Device thread failed to start"; |
- NOTIFY_ERROR(PLATFORM_FAILURE); |
return false; |
} |
device_poll_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
@@ -1432,13 +1438,11 @@ bool V4L2VideoDecodeAccelerator::StopDevicePoll(bool keep_input_state) { |
// Signal the DevicePollTask() to stop, and stop the device poll thread. |
if (!device_->SetDevicePollInterrupt()) { |
DPLOG(ERROR) << "SetDevicePollInterrupt(): failed"; |
- NOTIFY_ERROR(PLATFORM_FAILURE); |
return false; |
} |
device_poll_thread_.Stop(); |
// Clear the interrupt now, to be sure. |
if (!device_->ClearDevicePollInterrupt()) { |
- NOTIFY_ERROR(PLATFORM_FAILURE); |
return false; |
} |
@@ -1503,8 +1507,10 @@ void V4L2VideoDecodeAccelerator::StartResolutionChangeIfNeeded() { |
DVLOG(3) << "No more work, initiate resolution change"; |
// Keep input queue. |
- if (!StopDevicePoll(true)) |
+ if (!StopDevicePoll(true)) { |
+ NOTIFY_ERROR(PLATFORM_FAILURE); |
return; |
+ } |
decoder_state_ = kChangingResolution; |
DCHECK(resolution_change_pending_); |