libcamera: v4l2_subdevice: Replace Routing::toString() with operator<<()
The main (and only at the moment) use case for the Routing::toString() function is to print a representation of the routing table in a log message. The function is implemented using an std::stringstream, and the returned std::string is then inserted into an std::ostream. This is inefficient. Replace the function with a specialization of the operator<<() and use it in the caller. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
0d2ad0cd84
commit
e8f01b37e8
3 changed files with 18 additions and 20 deletions
|
@ -95,11 +95,7 @@ public:
|
||||||
unsigned int stream;
|
unsigned int stream;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Routing : public std::vector<struct v4l2_subdev_route>
|
using Routing = std::vector<struct v4l2_subdev_route>;
|
||||||
{
|
|
||||||
public:
|
|
||||||
std::string toString() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit V4L2Subdevice(const MediaEntity *entity);
|
explicit V4L2Subdevice(const MediaEntity *entity);
|
||||||
~V4L2Subdevice();
|
~V4L2Subdevice();
|
||||||
|
@ -178,5 +174,6 @@ static inline bool operator!=(const V4L2Subdevice::Stream &lhs,
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const V4L2Subdevice::Stream &stream);
|
std::ostream &operator<<(std::ostream &out, const V4L2Subdevice::Stream &stream);
|
||||||
|
std::ostream &operator<<(std::ostream &out, const V4L2Subdevice::Routing &routing);
|
||||||
|
|
||||||
} /* namespace libcamera */
|
} /* namespace libcamera */
|
||||||
|
|
|
@ -1388,7 +1388,7 @@ int SimplePipelineHandler::resetRoutingTable(V4L2Subdevice *subdev)
|
||||||
|
|
||||||
LOG(SimplePipeline, Debug)
|
LOG(SimplePipeline, Debug)
|
||||||
<< "Routing table of " << subdev->deviceNode()
|
<< "Routing table of " << subdev->deviceNode()
|
||||||
<< " reset to " << routing.toString();
|
<< " reset to " << routing;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -899,30 +899,31 @@ std::ostream &operator<<(std::ostream &out, const V4L2Subdevice::Stream &stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class V4L2Subdevice::Routing
|
* \typedef V4L2Subdevice::Routing
|
||||||
* \brief V4L2 subdevice routing table
|
* \brief V4L2 subdevice routing table
|
||||||
*
|
*
|
||||||
* This class stores a subdevice routing table as a vector of routes.
|
* This class stores a subdevice routing table as a vector of routes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Assemble and return a string describing the routing table
|
* \brief Insert a text representation of a V4L2Subdevice::Routing into an
|
||||||
* \return A string describing the routing table
|
* output stream
|
||||||
|
* \param[in] out The output stream
|
||||||
|
* \param[in] routing The V4L2Subdevice::Routing
|
||||||
|
* \return The output stream \a out
|
||||||
*/
|
*/
|
||||||
std::string V4L2Subdevice::Routing::toString() const
|
std::ostream &operator<<(std::ostream &out, const V4L2Subdevice::Routing &routing)
|
||||||
{
|
{
|
||||||
std::stringstream routing;
|
for (const auto &[i, route] : utils::enumerate(routing)) {
|
||||||
|
out << "[" << i << "] "
|
||||||
for (const auto &[i, route] : utils::enumerate(*this)) {
|
<< route.sink_pad << "/" << route.sink_stream << " -> "
|
||||||
routing << "[" << i << "] "
|
<< route.source_pad << "/" << route.source_stream
|
||||||
<< route.sink_pad << "/" << route.sink_stream << " -> "
|
<< " (" << utils::hex(route.flags) << ")";
|
||||||
<< route.source_pad << "/" << route.source_stream
|
if (i != routing.size() - 1)
|
||||||
<< " (" << utils::hex(route.flags) << ")";
|
out << ", ";
|
||||||
if (i != size() - 1)
|
|
||||||
routing << ", ";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return routing.str();
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue