summaryrefslogtreecommitdiff
path: root/src/libcamera/v4l2_videodevice.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-04-26 03:43:08 +0300
committerJacopo Mondi <jacopo@jmondi.org>2020-04-26 15:15:47 +0200
commit66a1928a0a7a14c19f10d8fd09980258912f515e (patch)
tree0f13c8157095e8173b98a57687c26dbd9f3aaeea /src/libcamera/v4l2_videodevice.cpp
parent058407bb9ba4e122f464b3515f30ae1205ff803d (diff)
libcamera: v4l2_videodevice: Rename fdEvent_ to fdBufferNotifier_
To prepare for the addition of a second notifier for V4L2 events, rename the current fdEvent_ member to fdBufferNotifier_ to better reflect its usage. While at it, simplify allocation of the fdEvent_ notifier. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/libcamera/v4l2_videodevice.cpp')
-rw-r--r--src/libcamera/v4l2_videodevice.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index a959cfe6..18a71e4f 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -544,7 +544,7 @@ const std::string V4L2DeviceFormat::toString() const
* \param[in] deviceNode The file-system path to the video device node
*/
V4L2VideoDevice::V4L2VideoDevice(const std::string &deviceNode)
- : V4L2Device(deviceNode), cache_(nullptr), fdEvent_(nullptr)
+ : V4L2Device(deviceNode), cache_(nullptr), fdBufferNotifier_(nullptr)
{
/*
* We default to an MMAP based CAPTURE video device, however this will
@@ -610,29 +610,32 @@ int V4L2VideoDevice::open()
* devices (POLLIN), and write notifications for OUTPUT video devices
* (POLLOUT).
*/
+ EventNotifier::Type notifierType;
+
if (caps_.isVideoCapture()) {
- fdEvent_ = new EventNotifier(fd(), EventNotifier::Read);
+ notifierType = EventNotifier::Read;
bufferType_ = caps_.isMultiplanar()
? V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
: V4L2_BUF_TYPE_VIDEO_CAPTURE;
} else if (caps_.isVideoOutput()) {
- fdEvent_ = new EventNotifier(fd(), EventNotifier::Write);
+ notifierType = EventNotifier::Write;
bufferType_ = caps_.isMultiplanar()
? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
: V4L2_BUF_TYPE_VIDEO_OUTPUT;
} else if (caps_.isMetaCapture()) {
- fdEvent_ = new EventNotifier(fd(), EventNotifier::Read);
+ notifierType = EventNotifier::Read;
bufferType_ = V4L2_BUF_TYPE_META_CAPTURE;
} else if (caps_.isMetaOutput()) {
- fdEvent_ = new EventNotifier(fd(), EventNotifier::Write);
+ notifierType = EventNotifier::Write;
bufferType_ = V4L2_BUF_TYPE_META_OUTPUT;
} else {
LOG(V4L2, Error) << "Device is not a supported type";
return -EINVAL;
}
- fdEvent_->activated.connect(this, &V4L2VideoDevice::bufferAvailable);
- fdEvent_->setEnabled(false);
+ fdBufferNotifier_ = new EventNotifier(fd(), notifierType);
+ fdBufferNotifier_->activated.connect(this, &V4L2VideoDevice::bufferAvailable);
+ fdBufferNotifier_->setEnabled(false);
LOG(V4L2, Debug)
<< "Opened device " << caps_.bus_info() << ": "
@@ -699,15 +702,17 @@ int V4L2VideoDevice::open(int handle, enum v4l2_buf_type type)
* devices (POLLIN), and write notifications for OUTPUT video devices
* (POLLOUT).
*/
+ EventNotifier::Type notifierType;
+
switch (type) {
case V4L2_BUF_TYPE_VIDEO_OUTPUT:
- fdEvent_ = new EventNotifier(fd(), EventNotifier::Write);
+ notifierType = EventNotifier::Write;
bufferType_ = caps_.isMultiplanar()
? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
: V4L2_BUF_TYPE_VIDEO_OUTPUT;
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
- fdEvent_ = new EventNotifier(fd(), EventNotifier::Read);
+ notifierType = EventNotifier::Read;
bufferType_ = caps_.isMultiplanar()
? V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
: V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -717,8 +722,9 @@ int V4L2VideoDevice::open(int handle, enum v4l2_buf_type type)
return -EINVAL;
}
- fdEvent_->activated.connect(this, &V4L2VideoDevice::bufferAvailable);
- fdEvent_->setEnabled(false);
+ fdBufferNotifier_ = new EventNotifier(fd(), notifierType);
+ fdBufferNotifier_->activated.connect(this, &V4L2VideoDevice::bufferAvailable);
+ fdBufferNotifier_->setEnabled(false);
LOG(V4L2, Debug)
<< "Opened device " << caps_.bus_info() << ": "
@@ -736,7 +742,7 @@ void V4L2VideoDevice::close()
return;
releaseBuffers();
- delete fdEvent_;
+ delete fdBufferNotifier_;
V4L2Device::close();
}
@@ -1477,7 +1483,7 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)
}
if (queuedBuffers_.empty())
- fdEvent_->setEnabled(true);
+ fdBufferNotifier_->setEnabled(true);
queuedBuffers_[buf.index] = buffer;
@@ -1544,7 +1550,7 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()
queuedBuffers_.erase(it);
if (queuedBuffers_.empty())
- fdEvent_->setEnabled(false);
+ fdBufferNotifier_->setEnabled(false);
buffer->metadata_.status = buf.flags & V4L2_BUF_FLAG_ERROR
? FrameMetadata::FrameError
@@ -1617,7 +1623,7 @@ int V4L2VideoDevice::streamOff()
}
queuedBuffers_.clear();
- fdEvent_->setEnabled(false);
+ fdBufferNotifier_->setEnabled(false);
return 0;
}