summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libcamera/base/shared_fd.h10
-rw-r--r--src/libcamera/base/shared_fd.cpp26
-rw-r--r--src/libcamera/framebuffer.cpp2
3 files changed, 37 insertions, 1 deletions
diff --git a/include/libcamera/base/shared_fd.h b/include/libcamera/base/shared_fd.h
index 20219224..e53a8b88 100644
--- a/include/libcamera/base/shared_fd.h
+++ b/include/libcamera/base/shared_fd.h
@@ -46,4 +46,14 @@ private:
std::shared_ptr<Descriptor> fd_;
};
+static inline bool operator==(const SharedFD &lhs, const SharedFD &rhs)
+{
+ return lhs.get() == rhs.get();
+}
+
+static inline bool operator!=(const SharedFD &lhs, const SharedFD &rhs)
+{
+ return !(lhs == rhs);
+}
+
} /* namespace libcamera */
diff --git a/src/libcamera/base/shared_fd.cpp b/src/libcamera/base/shared_fd.cpp
index bb35b448..bd2ab5aa 100644
--- a/src/libcamera/base/shared_fd.cpp
+++ b/src/libcamera/base/shared_fd.cpp
@@ -215,6 +215,32 @@ SharedFD &SharedFD::operator=(SharedFD &&other)
*/
/**
+ * \fn bool operator==(const SharedFD &lhs, const SharedFD &rhs)
+ * \brief Compare the owned file descriptors of two SharedFD for equality
+ * \param[in] lhs The first SharedFD
+ * \param[in] rhs The second SharedFD
+ *
+ * Two file descriptors are considered equal if they have the same numerical
+ * value. File descriptors with different values that both reference the same
+ * file (for instance obtained using dup()) are considered not equal.
+ *
+ * \return True if the two file descriptors are equal, false otherwise
+ */
+
+/**
+ * \fn bool operator!=(const SharedFD &lhs, const SharedFD &rhs)
+ * \brief Compare the owned file descriptors of two SharedFD for equality
+ * \param[in] lhs The first SharedFD
+ * \param[in] rhs The second SharedFD
+ *
+ * Two file descriptors are considered equal if they have the same numerical
+ * value. File descriptors with different values that both reference the same
+ * file (for instance obtained using dup()) are considered not equal.
+ *
+ * \return True if the two file descriptors are not equal, false otherwise
+ */
+
+/**
* \brief Duplicate a SharedFD
*
* Duplicating a SharedFD creates a duplicate of the wrapped file descriptor and
diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp
index ee93ba4d..8857049e 100644
--- a/src/libcamera/framebuffer.cpp
+++ b/src/libcamera/framebuffer.cpp
@@ -258,7 +258,7 @@ FrameBuffer::FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie)
* Two different dmabuf file descriptors may still refer to the
* same dmabuf instance. Check this using inodes.
*/
- if (plane.fd.fd() != planes_[0].fd.fd()) {
+ if (plane.fd != planes_[0].fd) {
if (!inode)
inode = fileDescriptorInode(planes_[0].fd);
if (fileDescriptorInode(plane.fd) != inode) {