Index: media/capture/video/linux/video_capture_device_linux.cc |
diff --git a/media/capture/video/linux/video_capture_device_linux.cc b/media/capture/video/linux/video_capture_device_linux.cc |
index 32f30e049ce376e45fe486bc1575696dc26eb9db..128f62fe9d306f0d38adf658093147ca6dda8f37 100644 |
--- a/media/capture/video/linux/video_capture_device_linux.cc |
+++ b/media/capture/video/linux/video_capture_device_linux.cc |
@@ -81,8 +81,9 @@ const std::string VideoCaptureDevice::Name::GetModel() const { |
} |
VideoCaptureDeviceLinux::VideoCaptureDeviceLinux(const Name& device_name) |
- : v4l2_thread_("V4L2CaptureThread"), device_name_(device_name) { |
-} |
+ : capture_impl_(nullptr), |
+ v4l2_thread_("V4L2CaptureThread"), |
+ device_name_(device_name) {} |
VideoCaptureDeviceLinux::~VideoCaptureDeviceLinux() { |
// Check if the thread is running. |
@@ -101,7 +102,7 @@ void VideoCaptureDeviceLinux::AllocateAndStart( |
const int line_frequency = |
TranslatePowerLineFrequencyToV4L2(GetPowerLineFrequency(params)); |
- capture_impl_ = V4L2CaptureDelegate::CreateV4L2CaptureDelegate( |
+ capture_impl_ = new V4L2CaptureDelegate( |
device_name_, v4l2_thread_.task_runner(), line_frequency); |
if (!capture_impl_) { |
client->OnError(FROM_HERE, "Failed to create VideoCaptureDelegate"); |
@@ -109,7 +110,8 @@ void VideoCaptureDeviceLinux::AllocateAndStart( |
} |
v4l2_thread_.message_loop()->PostTask( |
FROM_HERE, |
- base::Bind(&V4L2CaptureDelegate::AllocateAndStart, capture_impl_, |
+ base::Bind(&V4L2CaptureDelegate::AllocateAndStart, |
+ capture_impl_->AsWeakPtr(), |
params.requested_format.frame_size.width(), |
params.requested_format.frame_size.height(), |
params.requested_format.frame_rate, base::Passed(&client))); |
@@ -119,8 +121,8 @@ void VideoCaptureDeviceLinux::StopAndDeAllocate() { |
if (!v4l2_thread_.IsRunning()) |
return; // Wrong state. |
v4l2_thread_.message_loop()->PostTask( |
- FROM_HERE, |
- base::Bind(&V4L2CaptureDelegate::StopAndDeAllocate, capture_impl_)); |
+ FROM_HERE, base::Bind(&V4L2CaptureDelegate::StopAndDeAllocate, |
+ capture_impl_->AsWeakPtr())); |
v4l2_thread_.Stop(); |
perkj_chrome
2016/02/12 11:01:40
actually - since this own the thread where delegat
mcasas
2016/02/12 21:32:43
Acknowledged.
|
capture_impl_ = NULL; |
@@ -129,8 +131,8 @@ void VideoCaptureDeviceLinux::StopAndDeAllocate() { |
void VideoCaptureDeviceLinux::SetRotation(int rotation) { |
if (v4l2_thread_.IsRunning()) { |
v4l2_thread_.message_loop()->PostTask( |
- FROM_HERE, |
- base::Bind(&V4L2CaptureDelegate::SetRotation, capture_impl_, rotation)); |
+ FROM_HERE, base::Bind(&V4L2CaptureDelegate::SetRotation, |
+ capture_impl_->AsWeakPtr(), rotation)); |
} |
} |