universal7885: run clang-format based on system-clang-format

* On every *.cpp *.h files

Signed-off-by: roynatech2544 <whiteshell2544@naver.com>
This commit is contained in:
roynatech2544 2021-12-12 20:37:53 +09:00
commit 098179eabb
No known key found for this signature in database
GPG key ID: 9675C32163D88D30
47 changed files with 1545 additions and 1709 deletions

View file

@ -24,41 +24,34 @@
namespace android {
#define ALIGN_TO(val, alignment) \
(((uintptr_t)(val) + ((alignment) - 1)) & ~((alignment) - 1))
#define ALIGN_TO(val, alignment) (((uintptr_t)(val) + ((alignment)-1)) & ~((alignment)-1))
CameraMetadata::CameraMetadata() :
mBuffer(NULL), mLocked(false) {
}
CameraMetadata::CameraMetadata() : mBuffer(NULL), mLocked(false) {}
CameraMetadata::CameraMetadata(size_t entryCapacity, size_t dataCapacity) :
mLocked(false)
{
CameraMetadata::CameraMetadata(size_t entryCapacity, size_t dataCapacity) : mLocked(false) {
mBuffer = allocate_camera_metadata(entryCapacity, dataCapacity);
}
CameraMetadata::CameraMetadata(const CameraMetadata &other) :
mLocked(false) {
CameraMetadata::CameraMetadata(const CameraMetadata& other) : mLocked(false) {
mBuffer = clone_camera_metadata(other.mBuffer);
}
CameraMetadata::CameraMetadata(camera_metadata_t *buffer) :
mBuffer(NULL), mLocked(false) {
CameraMetadata::CameraMetadata(camera_metadata_t* buffer) : mBuffer(NULL), mLocked(false) {
acquire(buffer);
}
CameraMetadata &CameraMetadata::operator=(const CameraMetadata &other) {
CameraMetadata& CameraMetadata::operator=(const CameraMetadata& other) {
return operator=(other.mBuffer);
}
CameraMetadata &CameraMetadata::operator=(const camera_metadata_t *buffer) {
CameraMetadata& CameraMetadata::operator=(const camera_metadata_t* buffer) {
if (mLocked) {
ALOGE("%s: Assignment to a locked CameraMetadata!", __FUNCTION__);
return *this;
}
if (CC_LIKELY(buffer != mBuffer)) {
camera_metadata_t *newBuffer = clone_camera_metadata(buffer);
camera_metadata_t* newBuffer = clone_camera_metadata(buffer);
clear();
mBuffer = newBuffer;
}
@ -75,14 +68,13 @@ const camera_metadata_t* CameraMetadata::getAndLock() const {
return mBuffer;
}
status_t CameraMetadata::unlock(const camera_metadata_t *buffer) const {
status_t CameraMetadata::unlock(const camera_metadata_t* buffer) const {
if (!mLocked) {
ALOGE("%s: Can't unlock a non-locked CameraMetadata!", __FUNCTION__);
return INVALID_OPERATION;
}
if (buffer != mBuffer) {
ALOGE("%s: Can't unlock CameraMetadata with wrong pointer!",
__FUNCTION__);
ALOGE("%s: Can't unlock CameraMetadata with wrong pointer!", __FUNCTION__);
return BAD_VALUE;
}
mLocked = false;
@ -94,7 +86,7 @@ camera_metadata_t* CameraMetadata::release() {
ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
return NULL;
}
camera_metadata_t *released = mBuffer;
camera_metadata_t* released = mBuffer;
mBuffer = NULL;
return released;
}
@ -110,7 +102,7 @@ void CameraMetadata::clear() {
}
}
void CameraMetadata::acquire(camera_metadata_t *buffer) {
void CameraMetadata::acquire(camera_metadata_t* buffer) {
if (mLocked) {
ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
return;
@ -118,12 +110,11 @@ void CameraMetadata::acquire(camera_metadata_t *buffer) {
clear();
mBuffer = buffer;
ALOGE_IF(validate_camera_metadata_structure(mBuffer, /*size*/NULL) != OK,
"%s: Failed to validate metadata structure %p",
__FUNCTION__, buffer);
ALOGE_IF(validate_camera_metadata_structure(mBuffer, /*size*/ NULL) != OK,
"%s: Failed to validate metadata structure %p", __FUNCTION__, buffer);
}
void CameraMetadata::acquire(CameraMetadata &other) {
void CameraMetadata::acquire(CameraMetadata& other) {
if (mLocked) {
ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
return;
@ -131,7 +122,7 @@ void CameraMetadata::acquire(CameraMetadata &other) {
acquire(other.release());
}
status_t CameraMetadata::append(const CameraMetadata &other) {
status_t CameraMetadata::append(const CameraMetadata& other) {
return append(other.mBuffer);
}
@ -148,8 +139,7 @@ status_t CameraMetadata::append(const camera_metadata_t* other) {
}
size_t CameraMetadata::entryCount() const {
return (mBuffer == NULL) ? 0 :
get_camera_metadata_entry_count(mBuffer);
return (mBuffer == NULL) ? 0 : get_camera_metadata_entry_count(mBuffer);
}
bool CameraMetadata::isEmpty() const {
@ -166,127 +156,119 @@ status_t CameraMetadata::sort() {
status_t CameraMetadata::checkType(uint32_t tag, uint8_t expectedType) {
int tagType = get_local_camera_metadata_tag_type(tag, mBuffer);
if ( CC_UNLIKELY(tagType == -1)) {
if (CC_UNLIKELY(tagType == -1)) {
ALOGE("Update metadata entry: Unknown tag %d", tag);
return INVALID_OPERATION;
}
if ( CC_UNLIKELY(tagType != expectedType) ) {
if (CC_UNLIKELY(tagType != expectedType)) {
ALOGE("Mismatched tag type when updating entry %s (%d) of type %s; "
"got type %s data instead ",
get_local_camera_metadata_tag_name(tag, mBuffer), tag,
camera_metadata_type_names[tagType],
camera_metadata_type_names[expectedType]);
"got type %s data instead ",
get_local_camera_metadata_tag_name(tag, mBuffer), tag,
camera_metadata_type_names[tagType], camera_metadata_type_names[expectedType]);
return INVALID_OPERATION;
}
return OK;
}
status_t CameraMetadata::update(uint32_t tag,
const int32_t *data, size_t data_count) {
status_t CameraMetadata::update(uint32_t tag, const int32_t* data, size_t data_count) {
status_t res;
if (mLocked) {
ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
return INVALID_OPERATION;
}
if ( (res = checkType(tag, TYPE_INT32)) != OK) {
if ((res = checkType(tag, TYPE_INT32)) != OK) {
return res;
}
return updateImpl(tag, (const void*)data, data_count);
}
status_t CameraMetadata::update(uint32_t tag,
const uint8_t *data, size_t data_count) {
status_t CameraMetadata::update(uint32_t tag, const uint8_t* data, size_t data_count) {
status_t res;
if (mLocked) {
ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
return INVALID_OPERATION;
}
if ( (res = checkType(tag, TYPE_BYTE)) != OK) {
if ((res = checkType(tag, TYPE_BYTE)) != OK) {
return res;
}
return updateImpl(tag, (const void*)data, data_count);
}
status_t CameraMetadata::update(uint32_t tag,
const float *data, size_t data_count) {
status_t CameraMetadata::update(uint32_t tag, const float* data, size_t data_count) {
status_t res;
if (mLocked) {
ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
return INVALID_OPERATION;
}
if ( (res = checkType(tag, TYPE_FLOAT)) != OK) {
if ((res = checkType(tag, TYPE_FLOAT)) != OK) {
return res;
}
return updateImpl(tag, (const void*)data, data_count);
}
status_t CameraMetadata::update(uint32_t tag,
const int64_t *data, size_t data_count) {
status_t CameraMetadata::update(uint32_t tag, const int64_t* data, size_t data_count) {
status_t res;
if (mLocked) {
ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
return INVALID_OPERATION;
}
if ( (res = checkType(tag, TYPE_INT64)) != OK) {
if ((res = checkType(tag, TYPE_INT64)) != OK) {
return res;
}
return updateImpl(tag, (const void*)data, data_count);
}
status_t CameraMetadata::update(uint32_t tag,
const double *data, size_t data_count) {
status_t CameraMetadata::update(uint32_t tag, const double* data, size_t data_count) {
status_t res;
if (mLocked) {
ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
return INVALID_OPERATION;
}
if ( (res = checkType(tag, TYPE_DOUBLE)) != OK) {
if ((res = checkType(tag, TYPE_DOUBLE)) != OK) {
return res;
}
return updateImpl(tag, (const void*)data, data_count);
}
status_t CameraMetadata::update(uint32_t tag,
const camera_metadata_rational_t *data, size_t data_count) {
status_t CameraMetadata::update(uint32_t tag, const camera_metadata_rational_t* data,
size_t data_count) {
status_t res;
if (mLocked) {
ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
return INVALID_OPERATION;
}
if ( (res = checkType(tag, TYPE_RATIONAL)) != OK) {
if ((res = checkType(tag, TYPE_RATIONAL)) != OK) {
return res;
}
return updateImpl(tag, (const void*)data, data_count);
}
status_t CameraMetadata::update(uint32_t tag,
const String8 &string) {
status_t CameraMetadata::update(uint32_t tag, const String8& string) {
status_t res;
if (mLocked) {
ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
return INVALID_OPERATION;
}
if ( (res = checkType(tag, TYPE_BYTE)) != OK) {
if ((res = checkType(tag, TYPE_BYTE)) != OK) {
return res;
}
// string.size() doesn't count the null termination character.
return updateImpl(tag, (const void*)string.string(), string.size() + 1);
}
status_t CameraMetadata::update(const camera_metadata_ro_entry &entry) {
status_t CameraMetadata::update(const camera_metadata_ro_entry& entry) {
status_t res;
if (mLocked) {
ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
return INVALID_OPERATION;
}
if ( (res = checkType(entry.tag, entry.type)) != OK) {
if ((res = checkType(entry.tag, entry.type)) != OK) {
return res;
}
return updateImpl(entry.tag, (const void*)entry.data.u8, entry.count);
}
status_t CameraMetadata::updateImpl(uint32_t tag, const void *data,
size_t data_count) {
status_t CameraMetadata::updateImpl(uint32_t tag, const void* data, size_t data_count) {
status_t res;
if (mLocked) {
ALOGE("%s: CameraMetadata is locked", __FUNCTION__);
@ -303,13 +285,11 @@ status_t CameraMetadata::updateImpl(uint32_t tag, const void *data,
uintptr_t bufAddr = reinterpret_cast<uintptr_t>(mBuffer);
uintptr_t dataAddr = reinterpret_cast<uintptr_t>(data);
if (dataAddr > bufAddr && dataAddr < (bufAddr + bufferSize)) {
ALOGE("%s: Update attempted with data from the same metadata buffer!",
__FUNCTION__);
ALOGE("%s: Update attempted with data from the same metadata buffer!", __FUNCTION__);
return INVALID_OPERATION;
}
size_t data_size = calculate_camera_metadata_entry_data_size(type,
data_count);
size_t data_size = calculate_camera_metadata_entry_data_size(type, data_count);
res = resizeIfNeeded(1, data_size);
@ -317,27 +297,23 @@ status_t CameraMetadata::updateImpl(uint32_t tag, const void *data,
camera_metadata_entry_t entry;
res = find_camera_metadata_entry(mBuffer, tag, &entry);
if (res == NAME_NOT_FOUND) {
res = add_camera_metadata_entry(mBuffer,
tag, data, data_count);
res = add_camera_metadata_entry(mBuffer, tag, data, data_count);
} else if (res == OK) {
res = update_camera_metadata_entry(mBuffer,
entry.index, data, data_count, NULL);
res = update_camera_metadata_entry(mBuffer, entry.index, data, data_count, NULL);
}
}
if (res != OK) {
ALOGE("%s: Unable to update metadata entry %s.%s (%x): %s (%d)",
__FUNCTION__, get_local_camera_metadata_section_name(tag, mBuffer),
get_local_camera_metadata_tag_name(tag, mBuffer), tag,
strerror(-res), res);
ALOGE("%s: Unable to update metadata entry %s.%s (%x): %s (%d)", __FUNCTION__,
get_local_camera_metadata_section_name(tag, mBuffer),
get_local_camera_metadata_tag_name(tag, mBuffer), tag, strerror(-res), res);
}
IF_ALOGV() {
ALOGE_IF(validate_camera_metadata_structure(mBuffer, /*size*/NULL) !=
OK,
ALOGE_IF(validate_camera_metadata_structure(mBuffer, /*size*/ NULL) != OK,
"%s: Failed to validate metadata structure after update %p",
__FUNCTION__, mBuffer);
"%s: Failed to validate metadata structure after update %p", __FUNCTION__,
mBuffer);
}
return res;
@ -357,7 +333,7 @@ camera_metadata_entry_t CameraMetadata::find(uint32_t tag) {
return entry;
}
res = find_camera_metadata_entry(mBuffer, tag, &entry);
if (CC_UNLIKELY( res != OK )) {
if (CC_UNLIKELY(res != OK)) {
entry.count = 0;
entry.data.u8 = NULL;
}
@ -368,7 +344,7 @@ camera_metadata_ro_entry_t CameraMetadata::find(uint32_t tag) const {
status_t res;
camera_metadata_ro_entry entry;
res = find_camera_metadata_ro_entry(mBuffer, tag, &entry);
if (CC_UNLIKELY( res != OK )) {
if (CC_UNLIKELY(res != OK)) {
entry.count = 0;
entry.data.u8 = NULL;
}
@ -386,20 +362,16 @@ status_t CameraMetadata::erase(uint32_t tag) {
if (res == NAME_NOT_FOUND) {
return OK;
} else if (res != OK) {
ALOGE("%s: Error looking for entry %s.%s (%x): %s %d",
__FUNCTION__,
get_local_camera_metadata_section_name(tag, mBuffer),
get_local_camera_metadata_tag_name(tag, mBuffer),
tag, strerror(-res), res);
ALOGE("%s: Error looking for entry %s.%s (%x): %s %d", __FUNCTION__,
get_local_camera_metadata_section_name(tag, mBuffer),
get_local_camera_metadata_tag_name(tag, mBuffer), tag, strerror(-res), res);
return res;
}
res = delete_camera_metadata_entry(mBuffer, entry.index);
if (res != OK) {
ALOGE("%s: Error deleting entry %s.%s (%x): %s %d",
__FUNCTION__,
get_local_camera_metadata_section_name(tag, mBuffer),
get_local_camera_metadata_tag_name(tag, mBuffer),
tag, strerror(-res), res);
ALOGE("%s: Error deleting entry %s.%s (%x): %s %d", __FUNCTION__,
get_local_camera_metadata_section_name(tag, mBuffer),
get_local_camera_metadata_tag_name(tag, mBuffer), tag, strerror(-res), res);
}
return res;
}
@ -418,23 +390,17 @@ status_t CameraMetadata::resizeIfNeeded(size_t extraEntries, size_t extraData) {
} else {
size_t currentEntryCount = get_camera_metadata_entry_count(mBuffer);
size_t currentEntryCap = get_camera_metadata_entry_capacity(mBuffer);
size_t newEntryCount = currentEntryCount +
extraEntries;
newEntryCount = (newEntryCount > currentEntryCap) ?
newEntryCount * 2 : currentEntryCap;
size_t newEntryCount = currentEntryCount + extraEntries;
newEntryCount = (newEntryCount > currentEntryCap) ? newEntryCount * 2 : currentEntryCap;
size_t currentDataCount = get_camera_metadata_data_count(mBuffer);
size_t currentDataCap = get_camera_metadata_data_capacity(mBuffer);
size_t newDataCount = currentDataCount +
extraData;
newDataCount = (newDataCount > currentDataCap) ?
newDataCount * 2 : currentDataCap;
size_t newDataCount = currentDataCount + extraData;
newDataCount = (newDataCount > currentDataCap) ? newDataCount * 2 : currentDataCap;
if (newEntryCount > currentEntryCap ||
newDataCount > currentDataCap) {
camera_metadata_t *oldBuffer = mBuffer;
mBuffer = allocate_camera_metadata(newEntryCount,
newDataCount);
if (newEntryCount > currentEntryCap || newDataCount > currentDataCap) {
camera_metadata_t* oldBuffer = mBuffer;
mBuffer = allocate_camera_metadata(newEntryCount, newDataCount);
if (mBuffer == NULL) {
ALOGE("%s: Can't allocate larger metadata buffer", __FUNCTION__);
return NO_MEMORY;
@ -462,5 +428,4 @@ void CameraMetadata::swap(CameraMetadata& other) {
mBuffer = otherBuf;
}
}; // namespace android
}; // namespace android