mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 15:29:45 +03:00
android: Replace ThreadRPC with blocking method call
Use the newly introduced InvocationTypeBlocking message type to replace the blocking message delivery implemented with the ThreadRPC class in the Android camera HAL. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
parent
1f1d27cc14
commit
53eab99680
7 changed files with 11 additions and 118 deletions
|
@ -11,7 +11,6 @@
|
|||
#include "utils.h"
|
||||
|
||||
#include "camera_metadata.h"
|
||||
#include "thread_rpc.h"
|
||||
|
||||
using namespace libcamera;
|
||||
|
||||
|
@ -64,25 +63,6 @@ CameraDevice::~CameraDevice()
|
|||
delete it.second;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle RPC request received from the associated proxy.
|
||||
*/
|
||||
void CameraDevice::call(ThreadRpc *rpc)
|
||||
{
|
||||
switch (rpc->tag) {
|
||||
case ThreadRpc::ProcessCaptureRequest:
|
||||
processCaptureRequest(rpc->request);
|
||||
break;
|
||||
case ThreadRpc::Close:
|
||||
close();
|
||||
break;
|
||||
default:
|
||||
LOG(HAL, Error) << "Unknown RPC operation: " << rpc->tag;
|
||||
}
|
||||
|
||||
rpc->notifyReception();
|
||||
}
|
||||
|
||||
int CameraDevice::open()
|
||||
{
|
||||
int ret = camera_->acquire();
|
||||
|
@ -698,7 +678,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Request)
|
||||
void CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Request)
|
||||
{
|
||||
StreamConfiguration *streamConfiguration = &config_->at(0);
|
||||
Stream *stream = streamConfiguration->stream();
|
||||
|
@ -706,7 +686,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
|
|||
if (camera3Request->num_output_buffers != 1) {
|
||||
LOG(HAL, Error) << "Invalid number of output buffers: "
|
||||
<< camera3Request->num_output_buffers;
|
||||
return -EINVAL;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Start the camera if that's the first request we handle. */
|
||||
|
@ -714,14 +694,14 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
|
|||
int ret = camera_->allocateBuffers();
|
||||
if (ret) {
|
||||
LOG(HAL, Error) << "Failed to allocate buffers";
|
||||
return ret;
|
||||
return;
|
||||
}
|
||||
|
||||
ret = camera_->start();
|
||||
if (ret) {
|
||||
LOG(HAL, Error) << "Failed to start camera";
|
||||
camera_->freeBuffers();
|
||||
return ret;
|
||||
return;
|
||||
}
|
||||
|
||||
running_ = true;
|
||||
|
@ -769,7 +749,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
|
|||
if (!buffer) {
|
||||
LOG(HAL, Error) << "Failed to create buffer";
|
||||
delete descriptor;
|
||||
return -EINVAL;
|
||||
return;
|
||||
}
|
||||
|
||||
Request *request =
|
||||
|
@ -782,13 +762,11 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
|
|||
goto error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return;
|
||||
|
||||
error:
|
||||
delete request;
|
||||
delete descriptor;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CameraDevice::requestComplete(Request *request,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue