libcamera: request: Add a toString()
Provide a toString helper to assist in printing Request state for debug and logging contexts. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
d874b3e341
commit
1dfb8d45dc
2 changed files with 28 additions and 3 deletions
|
@ -10,6 +10,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <string>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
#include <libcamera/class.h>
|
#include <libcamera/class.h>
|
||||||
|
@ -56,6 +57,8 @@ public:
|
||||||
|
|
||||||
bool hasPendingBuffers() const { return !pending_.empty(); }
|
bool hasPendingBuffers() const { return !pending_.empty(); }
|
||||||
|
|
||||||
|
std::string toString() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LIBCAMERA_DISABLE_COPY(Request)
|
LIBCAMERA_DISABLE_COPY(Request)
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <libcamera/request.h>
|
#include <libcamera/request.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#include <libcamera/buffer.h>
|
#include <libcamera/buffer.h>
|
||||||
#include <libcamera/camera.h>
|
#include <libcamera/camera.h>
|
||||||
|
@ -286,9 +287,7 @@ void Request::complete()
|
||||||
|
|
||||||
status_ = cancelled_ ? RequestCancelled : RequestComplete;
|
status_ = cancelled_ ? RequestCancelled : RequestComplete;
|
||||||
|
|
||||||
LOG(Request, Debug)
|
LOG(Request, Debug) << toString();
|
||||||
<< "Request has completed - cookie: " << cookie_
|
|
||||||
<< (cancelled_ ? " [Cancelled]" : "");
|
|
||||||
|
|
||||||
LIBCAMERA_TRACEPOINT(request_complete, this);
|
LIBCAMERA_TRACEPOINT(request_complete, this);
|
||||||
}
|
}
|
||||||
|
@ -321,4 +320,27 @@ bool Request::completeBuffer(FrameBuffer *buffer)
|
||||||
return !hasPendingBuffers();
|
return !hasPendingBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Generate a string representation of the Request internals
|
||||||
|
*
|
||||||
|
* This function facilitates debugging of Request state while it is used
|
||||||
|
* internally within libcamera.
|
||||||
|
*
|
||||||
|
* \return A string representing the current state of the request
|
||||||
|
*/
|
||||||
|
std::string Request::toString() const
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
|
||||||
|
/* Pending, Completed, Cancelled(X). */
|
||||||
|
static const char *statuses = "PCX";
|
||||||
|
|
||||||
|
/* Example Output: Request(55:P:1/2:6523524) */
|
||||||
|
ss << "Request(" << sequence_ << ":" << statuses[status_] << ":"
|
||||||
|
<< pending_.size() << "/" << bufferMap_.size() << ":"
|
||||||
|
<< cookie_ << ")";
|
||||||
|
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace libcamera */
|
} /* namespace libcamera */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue