libcamera: base: file_descriptor: Move inode() function to frame_buffer.cpp
The inode() function has always been a bit of an outcast in the FileDescriptor class, as it's not related to the core feature provided by FileDescriptor, a shared ownership wrapper around file descriptors. As it's only used in the FrameBuffer implementation, move it to frame_buffer.cpp as a static function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
#include <libcamera/framebuffer.h>
|
||||
#include "libcamera/internal/framebuffer.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <libcamera/base/file_descriptor.h>
|
||||
#include <libcamera/base/log.h>
|
||||
|
||||
/**
|
||||
@@ -207,6 +210,27 @@ FrameBuffer::Private::Private()
|
||||
* \brief The plane length in bytes
|
||||
*/
|
||||
|
||||
namespace {
|
||||
|
||||
ino_t fileDescriptorInode(const FileDescriptor &fd)
|
||||
{
|
||||
if (!fd.isValid())
|
||||
return 0;
|
||||
|
||||
struct stat st;
|
||||
int ret = fstat(fd.fd(), &st);
|
||||
if (ret < 0) {
|
||||
ret = -errno;
|
||||
LOG(Buffer, Fatal)
|
||||
<< "Failed to fstat() fd: " << strerror(-ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return st.st_ino;
|
||||
}
|
||||
|
||||
} /* namespace */
|
||||
|
||||
/**
|
||||
* \brief Construct a FrameBuffer with an array of planes
|
||||
* \param[in] planes The frame memory planes
|
||||
@@ -236,8 +260,8 @@ FrameBuffer::FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie)
|
||||
*/
|
||||
if (plane.fd.fd() != planes_[0].fd.fd()) {
|
||||
if (!inode)
|
||||
inode = planes_[0].fd.inode();
|
||||
if (plane.fd.inode() != inode) {
|
||||
inode = fileDescriptorInode(planes_[0].fd);
|
||||
if (fileDescriptorInode(plane.fd) != inode) {
|
||||
isContiguous = false;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user