summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2021-03-18 14:59:42 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2021-03-29 12:33:50 +0100
commit651e3fab6329498a7f46703ce5bb92c49cc37624 (patch)
tree121753ecb9effabac69232fb2917a2057807c9d0 /src
parent5718b4d5b7c8808b1d6137f90fc4690e15349c3d (diff)
libcamera: camera: Report function which fails access control
The camera object has a state machine to ensure calls are only made when in the correct state. It isn't easy to identify where things happen when assertions fail so add extra information to make this clearer. The error level of the isAccessAllowed is raised from Debug to Error as this is important information for applications to know if they have made a request in an invalid state. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/camera.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index dec8171e..96a579eb 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -346,9 +346,11 @@ public:
const std::set<Stream *> &streams);
~Private();
- int isAccessAllowed(State state, bool allowDisconnected = false) const;
+ int isAccessAllowed(State state, bool allowDisconnected = false,
+ const char *from = __builtin_FUNCTION()) const;
int isAccessAllowed(State low, State high,
- bool allowDisconnected = false) const;
+ bool allowDisconnected = false,
+ const char *from = __builtin_FUNCTION()) const;
void disconnect();
void setState(State state);
@@ -384,7 +386,8 @@ static const char *const camera_state_names[] = {
"Running",
};
-int Camera::Private::isAccessAllowed(State state, bool allowDisconnected) const
+int Camera::Private::isAccessAllowed(State state, bool allowDisconnected,
+ const char *from) const
{
if (!allowDisconnected && disconnected_)
return -ENODEV;
@@ -395,15 +398,16 @@ int Camera::Private::isAccessAllowed(State state, bool allowDisconnected) const
ASSERT(static_cast<unsigned int>(state) < std::size(camera_state_names));
- LOG(Camera, Debug) << "Camera in " << camera_state_names[currentState]
- << " state trying operation requiring state "
+ LOG(Camera, Error) << "Camera in " << camera_state_names[currentState]
+ << " state trying " << from << "() requiring state "
<< camera_state_names[state];
return -EACCES;
}
int Camera::Private::isAccessAllowed(State low, State high,
- bool allowDisconnected) const
+ bool allowDisconnected,
+ const char *from) const
{
if (!allowDisconnected && disconnected_)
return -ENODEV;
@@ -415,8 +419,9 @@ int Camera::Private::isAccessAllowed(State low, State high,
ASSERT(static_cast<unsigned int>(low) < std::size(camera_state_names) &&
static_cast<unsigned int>(high) < std::size(camera_state_names));
- LOG(Camera, Debug) << "Camera in " << camera_state_names[currentState]
- << " state trying operation requiring state between "
+ LOG(Camera, Error) << "Camera in " << camera_state_names[currentState]
+ << " state trying " << from
+ << "() requiring state between "
<< camera_state_names[low] << " and "
<< camera_state_names[high];