[libcamera-devel] [PATCH v5 7/8] android: camera_device: Free metadata in error path
Jacopo Mondi
jacopo at jmondi.org
Wed Sep 4 16:18:24 CEST 2019
The current assertion macro on camera metadata handling operations
does not free the allocated metadata pack in case of errors.
Fix this by freeing the metadata pack in the error path.
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
src/android/camera_device.cpp | 140 +++++++++++++++++-----------------
src/android/camera_device.h | 3 +-
2 files changed, 72 insertions(+), 71 deletions(-)
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index c4f11e91bcf1..a153972fbef0 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -141,7 +141,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES,
aberrationModes.data(), aberrationModes.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
/* Control static metadata. */
std::vector<uint8_t> aeAvailableAntiBandingModes = {
@@ -154,7 +154,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES,
aeAvailableAntiBandingModes.data(),
aeAvailableAntiBandingModes.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<uint8_t> aeAvailableModes = {
ANDROID_CONTROL_AE_MODE_ON,
@@ -162,7 +162,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_CONTROL_AE_AVAILABLE_MODES,
aeAvailableModes.data(), aeAvailableModes.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<int32_t> availableAeFpsTarget = {
15, 30,
@@ -171,7 +171,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES,
availableAeFpsTarget.data(),
availableAeFpsTarget.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<int32_t> aeCompensationRange = {
0, 0,
@@ -180,7 +180,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ANDROID_CONTROL_AE_COMPENSATION_RANGE,
aeCompensationRange.data(),
aeCompensationRange.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
const camera_metadata_rational_t aeCompensationStep[] = {
{ 0, 1 }
@@ -188,7 +188,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_CONTROL_AE_COMPENSATION_STEP,
aeCompensationStep, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<uint8_t> availableAfModes = {
ANDROID_CONTROL_AF_MODE_OFF,
@@ -196,7 +196,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_CONTROL_AF_AVAILABLE_MODES,
availableAfModes.data(), availableAfModes.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<uint8_t> availableEffects = {
ANDROID_CONTROL_EFFECT_MODE_OFF,
@@ -204,7 +204,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_CONTROL_AVAILABLE_EFFECTS,
availableEffects.data(), availableEffects.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<uint8_t> availableSceneModes = {
ANDROID_CONTROL_SCENE_MODE_DISABLED,
@@ -212,7 +212,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_CONTROL_AVAILABLE_SCENE_MODES,
availableSceneModes.data(), availableSceneModes.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<uint8_t> availableStabilizationModes = {
ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF,
@@ -221,7 +221,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES,
availableStabilizationModes.data(),
availableStabilizationModes.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<uint8_t> availableAwbModes = {
ANDROID_CONTROL_AWB_MODE_OFF,
@@ -229,7 +229,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_CONTROL_AWB_AVAILABLE_MODES,
availableAwbModes.data(), availableAwbModes.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<int32_t> availableMaxRegions = {
0, 0, 0,
@@ -237,7 +237,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_CONTROL_MAX_REGIONS,
availableMaxRegions.data(), availableMaxRegions.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<uint8_t> sceneModesOverride = {
ANDROID_CONTROL_AE_MODE_ON,
@@ -247,25 +247,25 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_CONTROL_SCENE_MODE_OVERRIDES,
sceneModesOverride.data(), sceneModesOverride.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
uint8_t aeLockAvailable = ANDROID_CONTROL_AE_LOCK_AVAILABLE_FALSE;
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_CONTROL_AE_LOCK_AVAILABLE,
&aeLockAvailable, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
uint8_t awbLockAvailable = ANDROID_CONTROL_AWB_LOCK_AVAILABLE_FALSE;
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_CONTROL_AWB_LOCK_AVAILABLE,
&awbLockAvailable, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
char availableControlModes = ANDROID_CONTROL_MODE_AUTO;
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_CONTROL_AVAILABLE_MODES,
&availableControlModes, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
/* JPEG static metadata. */
std::vector<int32_t> availableThumbnailSizes = {
@@ -275,7 +275,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES,
availableThumbnailSizes.data(),
availableThumbnailSizes.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
/* Sensor static metadata. */
int32_t pixelArraySize[] = {
@@ -284,7 +284,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE,
&pixelArraySize, 2);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
int32_t sensorSizes[] = {
0, 0, 2560, 1920,
@@ -292,7 +292,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE,
&sensorSizes, 4);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
int32_t sensitivityRange[] = {
32, 2400,
@@ -300,13 +300,13 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_SENSOR_INFO_SENSITIVITY_RANGE,
&sensitivityRange, 2);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
uint16_t filterArr = ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_GRBG;
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT,
&filterArr, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
int64_t exposureTimeRange[] = {
100000, 200000000,
@@ -314,13 +314,13 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE,
&exposureTimeRange, 2);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
int32_t orientation = 0;
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_SENSOR_ORIENTATION,
&orientation, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<int32_t> testPatterModes = {
ANDROID_SENSOR_TEST_PATTERN_MODE_OFF,
@@ -328,7 +328,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_SENSOR_AVAILABLE_TEST_PATTERN_MODES,
testPatterModes.data(), testPatterModes.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<float> physicalSize = {
2592, 1944,
@@ -336,39 +336,39 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_SENSOR_INFO_PHYSICAL_SIZE,
physicalSize.data(), physicalSize.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
uint8_t timestampSource = ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN;
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE,
×tampSource, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
/* Statistics static metadata. */
uint8_t faceDetectMode = ANDROID_STATISTICS_FACE_DETECT_MODE_OFF;
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES,
&faceDetectMode, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
int32_t maxFaceCount = 0;
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_STATISTICS_INFO_MAX_FACE_COUNT,
&maxFaceCount, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
/* Sync static metadata. */
int32_t maxLatency = ANDROID_SYNC_MAX_LATENCY_UNKNOWN;
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_SYNC_MAX_LATENCY, &maxLatency, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
/* Flash static metadata. */
char flashAvailable = ANDROID_FLASH_INFO_AVAILABLE_FALSE;
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_FLASH_INFO_AVAILABLE,
&flashAvailable, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
/* Lens static metadata. */
std::vector<float> lensApertures = {
@@ -377,12 +377,12 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_LENS_INFO_AVAILABLE_APERTURES,
lensApertures.data(), lensApertures.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
uint8_t lensFacing = ANDROID_LENS_FACING_FRONT;
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_LENS_FACING, &lensFacing, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<float> lensFocalLenghts = {
1,
@@ -391,7 +391,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS,
lensFocalLenghts.data(),
lensFocalLenghts.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<uint8_t> opticalStabilizations = {
ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF,
@@ -400,33 +400,33 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION,
opticalStabilizations.data(),
opticalStabilizations.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
float hypeFocalDistance = 0;
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_LENS_INFO_HYPERFOCAL_DISTANCE,
&hypeFocalDistance, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
float minFocusDistance = 0;
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE,
&minFocusDistance, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
/* Noise reduction modes. */
uint8_t noiseReductionModes = ANDROID_NOISE_REDUCTION_MODE_OFF;
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES,
&noiseReductionModes, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
/* Scaler static metadata. */
float maxDigitalZoom = 1;
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM,
&maxDigitalZoom, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<uint32_t> availableStreamFormats = {
ANDROID_SCALER_AVAILABLE_FORMATS_BLOB,
@@ -437,7 +437,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ANDROID_SCALER_AVAILABLE_FORMATS,
availableStreamFormats.data(),
availableStreamFormats.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<uint32_t> availableStreamConfigurations = {
ANDROID_SCALER_AVAILABLE_FORMATS_BLOB, 2560, 1920,
@@ -451,7 +451,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS,
availableStreamConfigurations.data(),
availableStreamConfigurations.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<int64_t> availableStallDurations = {
ANDROID_SCALER_AVAILABLE_FORMATS_BLOB, 2560, 1920, 33333333,
@@ -460,7 +460,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ANDROID_SCALER_AVAILABLE_STALL_DURATIONS,
availableStallDurations.data(),
availableStallDurations.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<int64_t> minFrameDurations = {
ANDROID_SCALER_AVAILABLE_FORMATS_BLOB, 2560, 1920, 33333333,
@@ -470,12 +470,12 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS,
minFrameDurations.data(), minFrameDurations.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
uint8_t croppingType = ANDROID_SCALER_CROPPING_TYPE_CENTER_ONLY;
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_SCALER_CROPPING_TYPE, &croppingType, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
/* Info static metadata. */
uint8_t supportedHWLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED;
@@ -488,13 +488,13 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_REQUEST_PARTIAL_RESULT_COUNT,
&partialResultCount, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
uint8_t maxPipelineDepth = 2;
ret = add_camera_metadata_entry(staticMetadata_,
ANDROID_REQUEST_PIPELINE_MAX_DEPTH,
&maxPipelineDepth, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
std::vector<uint8_t> availableCapabilities = {
ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE,
@@ -503,7 +503,7 @@ camera_metadata_t *CameraDevice::getStaticMetadata()
ANDROID_REQUEST_AVAILABLE_CAPABILITIES,
availableCapabilities.data(),
availableCapabilities.size());
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, staticMetadata_);
return staticMetadata_;
}
@@ -532,66 +532,66 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type)
ret = add_camera_metadata_entry(requestTemplate,
ANDROID_CONTROL_AE_MODE,
&aeMode, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, requestTemplate);
int32_t aeExposureCompensation = 0;
ret = add_camera_metadata_entry(requestTemplate,
ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION,
&aeExposureCompensation, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, requestTemplate);
uint8_t aePrecaptureTrigger = ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE;
ret = add_camera_metadata_entry(requestTemplate,
ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER,
&aePrecaptureTrigger, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, requestTemplate);
uint8_t aeLock = ANDROID_CONTROL_AE_LOCK_OFF;
ret = add_camera_metadata_entry(requestTemplate,
ANDROID_CONTROL_AE_LOCK,
&aeLock, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, requestTemplate);
uint8_t afTrigger = ANDROID_CONTROL_AF_TRIGGER_IDLE;
ret = add_camera_metadata_entry(requestTemplate,
ANDROID_CONTROL_AF_TRIGGER,
&afTrigger, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, requestTemplate);
uint8_t awbMode = ANDROID_CONTROL_AWB_MODE_AUTO;
ret = add_camera_metadata_entry(requestTemplate,
ANDROID_CONTROL_AWB_MODE,
&awbMode, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, requestTemplate);
uint8_t awbLock = ANDROID_CONTROL_AWB_LOCK_OFF;
ret = add_camera_metadata_entry(requestTemplate,
ANDROID_CONTROL_AWB_LOCK,
&awbLock, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, requestTemplate);
uint8_t flashMode = ANDROID_FLASH_MODE_OFF;
ret = add_camera_metadata_entry(requestTemplate,
ANDROID_FLASH_MODE,
&flashMode, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, requestTemplate);
uint8_t faceDetectMode = ANDROID_STATISTICS_FACE_DETECT_MODE_OFF;
ret = add_camera_metadata_entry(requestTemplate,
ANDROID_STATISTICS_FACE_DETECT_MODE,
&faceDetectMode, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, requestTemplate);
uint8_t noiseReduction = ANDROID_NOISE_REDUCTION_MODE_OFF;
ret = add_camera_metadata_entry(requestTemplate,
ANDROID_NOISE_REDUCTION_MODE, &noiseReduction, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, requestTemplate);
uint8_t aberrationMode = ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF;
ret = add_camera_metadata_entry(requestTemplate,
ANDROID_COLOR_CORRECTION_ABERRATION_MODE,
&aberrationMode, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, requestTemplate);
/* Use the capture intent matching the requested template type. */
uint8_t captureIntent;
@@ -621,7 +621,7 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type)
ret = add_camera_metadata_entry(requestTemplate,
ANDROID_CONTROL_CAPTURE_INTENT,
&captureIntent, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, requestTemplate);
requestTemplates_[type] = requestTemplate;
@@ -887,35 +887,35 @@ camera_metadata_t *CameraDevice::getResultMetadata(int frame_number,
const uint8_t ae_state = ANDROID_CONTROL_AE_STATE_CONVERGED;
ret = add_camera_metadata_entry(resultMetadata, ANDROID_CONTROL_AE_STATE,
&ae_state, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, resultMetadata);
const uint8_t ae_lock = ANDROID_CONTROL_AE_LOCK_OFF;
ret = add_camera_metadata_entry(resultMetadata, ANDROID_CONTROL_AE_LOCK,
&ae_lock, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, resultMetadata);
uint8_t af_state = ANDROID_CONTROL_AF_STATE_INACTIVE;
ret = add_camera_metadata_entry(resultMetadata, ANDROID_CONTROL_AF_STATE,
&af_state, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, resultMetadata);
const uint8_t awb_state = ANDROID_CONTROL_AWB_STATE_CONVERGED;
ret = add_camera_metadata_entry(resultMetadata,
ANDROID_CONTROL_AWB_STATE,
&awb_state, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, resultMetadata);
const uint8_t awb_lock = ANDROID_CONTROL_AWB_LOCK_OFF;
ret = add_camera_metadata_entry(resultMetadata,
ANDROID_CONTROL_AWB_LOCK,
&awb_lock, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, resultMetadata);
const uint8_t lens_state = ANDROID_LENS_STATE_STATIONARY;
ret = add_camera_metadata_entry(resultMetadata,
ANDROID_LENS_STATE,
&lens_state, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, resultMetadata);
int32_t sensorSizes[] = {
0, 0, 2560, 1920,
@@ -923,39 +923,39 @@ camera_metadata_t *CameraDevice::getResultMetadata(int frame_number,
ret = add_camera_metadata_entry(resultMetadata,
ANDROID_SCALER_CROP_REGION,
sensorSizes, 4);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, resultMetadata);
ret = add_camera_metadata_entry(resultMetadata,
ANDROID_SENSOR_TIMESTAMP,
×tamp, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, resultMetadata);
/* 33.3 msec */
const int64_t rolling_shutter_skew = 33300000;
ret = add_camera_metadata_entry(resultMetadata,
ANDROID_SENSOR_ROLLING_SHUTTER_SKEW,
&rolling_shutter_skew, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, resultMetadata);
/* 16.6 msec */
const int64_t exposure_time = 16600000;
ret = add_camera_metadata_entry(resultMetadata,
ANDROID_SENSOR_EXPOSURE_TIME,
&exposure_time, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, resultMetadata);
const uint8_t lens_shading_map_mode =
ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_OFF;
ret = add_camera_metadata_entry(resultMetadata,
ANDROID_STATISTICS_LENS_SHADING_MAP_MODE,
&lens_shading_map_mode, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, resultMetadata);
const uint8_t scene_flicker = ANDROID_STATISTICS_SCENE_FLICKER_NONE;
ret = add_camera_metadata_entry(resultMetadata,
ANDROID_STATISTICS_SCENE_FLICKER,
&scene_flicker, 1);
- METADATA_ASSERT(ret);
+ METADATA_ASSERT(ret, resultMetadata);
return resultMetadata;
}
diff --git a/src/android/camera_device.h b/src/android/camera_device.h
index 64382bbac76a..9880168a7581 100644
--- a/src/android/camera_device.h
+++ b/src/android/camera_device.h
@@ -19,10 +19,11 @@
#include "message.h"
-#define METADATA_ASSERT(_r) \
+#define METADATA_ASSERT(_r, _p) \
do { \
if (!(_r)) break; \
LOG(HAL, Error) << "Error: " << __func__ << ":" << __LINE__; \
+ free_camera_metadata((_p)); \
return nullptr; \
} while(0);
--
2.23.0
More information about the libcamera-devel
mailing list