Loading apex/Android.bp +16 −2 Original line number Original line Diff line number Diff line Loading @@ -44,8 +44,15 @@ apex_defaults { // Use a custom AndroidManifest.xml used for API targeting. // Use a custom AndroidManifest.xml used for API targeting. androidManifest: ":com.android.media-androidManifest", androidManifest: ":com.android.media-androidManifest", // IMPORTANT: For the APEX to be installed on Android 10 (API 29), // min_sdk_version should be 29. This enables the build system to make // sure the package compatible to Android 10 in two ways: // - build the APEX package compatible to Android 10 // so that the package can be installed. // - build artifacts (lib/javalib/bin) against Android 10 SDK // so that the artifacts can run. min_sdk_version: "29", min_sdk_version: "29", legacy_android10_support: true, } } apex { apex { Loading Loading @@ -84,8 +91,15 @@ apex_defaults { // Use a custom AndroidManifest.xml used for API targeting. // Use a custom AndroidManifest.xml used for API targeting. androidManifest: ":com.android.media.swcodec-androidManifest", androidManifest: ":com.android.media.swcodec-androidManifest", // IMPORTANT: For the APEX to be installed on Android 10 (API 29), // min_sdk_version should be 29. This enables the build system to make // sure the package compatible to Android 10 in two ways: // - build the APEX package compatible to Android 10 // so that the package can be installed. // - build artifacts (lib/javalib/bin) against Android 10 SDK // so that the artifacts can run. min_sdk_version: "29", min_sdk_version: "29", legacy_android10_support: true, } } prebuilt_etc { prebuilt_etc { Loading camera/ndk/impl/ACameraMetadata.cpp +9 −1 Original line number Original line Diff line number Diff line Loading @@ -139,12 +139,20 @@ ACameraMetadata::filterDurations(uint32_t tag) { const int STREAM_WIDTH_OFFSET = 1; const int STREAM_WIDTH_OFFSET = 1; const int STREAM_HEIGHT_OFFSET = 2; const int STREAM_HEIGHT_OFFSET = 2; const int STREAM_DURATION_OFFSET = 3; const int STREAM_DURATION_OFFSET = 3; camera_metadata_entry entry = mData->find(tag); camera_metadata_entry entry = mData->find(tag); if (entry.count == 0 || entry.count % 4 || entry.type != TYPE_INT64) { if (entry.count == 0) { // Duration keys can be missing when corresponding capture feature is not supported return; } if (entry.count % 4 || entry.type != TYPE_INT64) { ALOGE("%s: malformed duration key %d! count %zu, type %d", ALOGE("%s: malformed duration key %d! count %zu, type %d", __FUNCTION__, tag, entry.count, entry.type); __FUNCTION__, tag, entry.count, entry.type); return; return; } } Vector<int64_t> filteredDurations; Vector<int64_t> filteredDurations; filteredDurations.setCapacity(entry.count * 2); filteredDurations.setCapacity(entry.count * 2); Loading media/libaaudio/src/utility/FixedBlockAdapter.cpp +2 −7 Original line number Original line Diff line number Diff line Loading @@ -18,22 +18,17 @@ #include "FixedBlockAdapter.h" #include "FixedBlockAdapter.h" FixedBlockAdapter::~FixedBlockAdapter() { close(); } int32_t FixedBlockAdapter::open(int32_t bytesPerFixedBlock) int32_t FixedBlockAdapter::open(int32_t bytesPerFixedBlock) { { mSize = bytesPerFixedBlock; mSize = bytesPerFixedBlock; mStorage = new uint8_t[bytesPerFixedBlock]; mStorage = std::make_unique<uint8_t[]>(bytesPerFixedBlock); mPosition = 0; mPosition = 0; return 0; return 0; } } int32_t FixedBlockAdapter::close() int32_t FixedBlockAdapter::close() { { delete[] mStorage; mStorage.reset(); mStorage = nullptr; mSize = 0; mSize = 0; mPosition = 0; mPosition = 0; return 0; return 0; Loading media/libaaudio/src/utility/FixedBlockAdapter.h +3 −2 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ #ifndef AAUDIO_FIXED_BLOCK_ADAPTER_H #ifndef AAUDIO_FIXED_BLOCK_ADAPTER_H #define AAUDIO_FIXED_BLOCK_ADAPTER_H #define AAUDIO_FIXED_BLOCK_ADAPTER_H #include <memory> #include <stdio.h> #include <stdio.h> /** /** Loading @@ -37,7 +38,7 @@ public: FixedBlockAdapter(FixedBlockProcessor &fixedBlockProcessor) FixedBlockAdapter(FixedBlockProcessor &fixedBlockProcessor) : mFixedBlockProcessor(fixedBlockProcessor) {} : mFixedBlockProcessor(fixedBlockProcessor) {} virtual ~FixedBlockAdapter(); virtual ~FixedBlockAdapter() = default; /** /** * Allocate internal resources needed for buffering data. * Allocate internal resources needed for buffering data. Loading @@ -63,7 +64,7 @@ public: protected: protected: FixedBlockProcessor &mFixedBlockProcessor; FixedBlockProcessor &mFixedBlockProcessor; uint8_t *mStorage = nullptr; // Store data here while assembling buffers. std::unique_ptr<uint8_t[]> mStorage; // Store data here while assembling buffers. int32_t mSize = 0; // Size in bytes of the fixed size buffer. int32_t mSize = 0; // Size in bytes of the fixed size buffer. int32_t mPosition = 0; // Offset of the last byte read or written. int32_t mPosition = 0; // Offset of the last byte read or written. }; }; Loading media/libaaudio/src/utility/FixedBlockReader.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -39,7 +39,7 @@ int32_t FixedBlockReader::readFromStorage(uint8_t *buffer, int32_t numBytes) { if (bytesToRead > dataAvailable) { if (bytesToRead > dataAvailable) { bytesToRead = dataAvailable; bytesToRead = dataAvailable; } } memcpy(buffer, mStorage + mPosition, bytesToRead); memcpy(buffer, &mStorage[mPosition], bytesToRead); mPosition += bytesToRead; mPosition += bytesToRead; return bytesToRead; return bytesToRead; } } Loading @@ -60,7 +60,7 @@ int32_t FixedBlockReader::processVariableBlock(uint8_t *buffer, int32_t numBytes bytesLeft -= mSize; bytesLeft -= mSize; } else { } else { // Just need a partial block so we have to use storage. // Just need a partial block so we have to use storage. result = mFixedBlockProcessor.onProcessFixedBlock(mStorage, mSize); result = mFixedBlockProcessor.onProcessFixedBlock(mStorage.get(), mSize); mPosition = 0; mPosition = 0; } } } } Loading Loading
apex/Android.bp +16 −2 Original line number Original line Diff line number Diff line Loading @@ -44,8 +44,15 @@ apex_defaults { // Use a custom AndroidManifest.xml used for API targeting. // Use a custom AndroidManifest.xml used for API targeting. androidManifest: ":com.android.media-androidManifest", androidManifest: ":com.android.media-androidManifest", // IMPORTANT: For the APEX to be installed on Android 10 (API 29), // min_sdk_version should be 29. This enables the build system to make // sure the package compatible to Android 10 in two ways: // - build the APEX package compatible to Android 10 // so that the package can be installed. // - build artifacts (lib/javalib/bin) against Android 10 SDK // so that the artifacts can run. min_sdk_version: "29", min_sdk_version: "29", legacy_android10_support: true, } } apex { apex { Loading Loading @@ -84,8 +91,15 @@ apex_defaults { // Use a custom AndroidManifest.xml used for API targeting. // Use a custom AndroidManifest.xml used for API targeting. androidManifest: ":com.android.media.swcodec-androidManifest", androidManifest: ":com.android.media.swcodec-androidManifest", // IMPORTANT: For the APEX to be installed on Android 10 (API 29), // min_sdk_version should be 29. This enables the build system to make // sure the package compatible to Android 10 in two ways: // - build the APEX package compatible to Android 10 // so that the package can be installed. // - build artifacts (lib/javalib/bin) against Android 10 SDK // so that the artifacts can run. min_sdk_version: "29", min_sdk_version: "29", legacy_android10_support: true, } } prebuilt_etc { prebuilt_etc { Loading
camera/ndk/impl/ACameraMetadata.cpp +9 −1 Original line number Original line Diff line number Diff line Loading @@ -139,12 +139,20 @@ ACameraMetadata::filterDurations(uint32_t tag) { const int STREAM_WIDTH_OFFSET = 1; const int STREAM_WIDTH_OFFSET = 1; const int STREAM_HEIGHT_OFFSET = 2; const int STREAM_HEIGHT_OFFSET = 2; const int STREAM_DURATION_OFFSET = 3; const int STREAM_DURATION_OFFSET = 3; camera_metadata_entry entry = mData->find(tag); camera_metadata_entry entry = mData->find(tag); if (entry.count == 0 || entry.count % 4 || entry.type != TYPE_INT64) { if (entry.count == 0) { // Duration keys can be missing when corresponding capture feature is not supported return; } if (entry.count % 4 || entry.type != TYPE_INT64) { ALOGE("%s: malformed duration key %d! count %zu, type %d", ALOGE("%s: malformed duration key %d! count %zu, type %d", __FUNCTION__, tag, entry.count, entry.type); __FUNCTION__, tag, entry.count, entry.type); return; return; } } Vector<int64_t> filteredDurations; Vector<int64_t> filteredDurations; filteredDurations.setCapacity(entry.count * 2); filteredDurations.setCapacity(entry.count * 2); Loading
media/libaaudio/src/utility/FixedBlockAdapter.cpp +2 −7 Original line number Original line Diff line number Diff line Loading @@ -18,22 +18,17 @@ #include "FixedBlockAdapter.h" #include "FixedBlockAdapter.h" FixedBlockAdapter::~FixedBlockAdapter() { close(); } int32_t FixedBlockAdapter::open(int32_t bytesPerFixedBlock) int32_t FixedBlockAdapter::open(int32_t bytesPerFixedBlock) { { mSize = bytesPerFixedBlock; mSize = bytesPerFixedBlock; mStorage = new uint8_t[bytesPerFixedBlock]; mStorage = std::make_unique<uint8_t[]>(bytesPerFixedBlock); mPosition = 0; mPosition = 0; return 0; return 0; } } int32_t FixedBlockAdapter::close() int32_t FixedBlockAdapter::close() { { delete[] mStorage; mStorage.reset(); mStorage = nullptr; mSize = 0; mSize = 0; mPosition = 0; mPosition = 0; return 0; return 0; Loading
media/libaaudio/src/utility/FixedBlockAdapter.h +3 −2 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ #ifndef AAUDIO_FIXED_BLOCK_ADAPTER_H #ifndef AAUDIO_FIXED_BLOCK_ADAPTER_H #define AAUDIO_FIXED_BLOCK_ADAPTER_H #define AAUDIO_FIXED_BLOCK_ADAPTER_H #include <memory> #include <stdio.h> #include <stdio.h> /** /** Loading @@ -37,7 +38,7 @@ public: FixedBlockAdapter(FixedBlockProcessor &fixedBlockProcessor) FixedBlockAdapter(FixedBlockProcessor &fixedBlockProcessor) : mFixedBlockProcessor(fixedBlockProcessor) {} : mFixedBlockProcessor(fixedBlockProcessor) {} virtual ~FixedBlockAdapter(); virtual ~FixedBlockAdapter() = default; /** /** * Allocate internal resources needed for buffering data. * Allocate internal resources needed for buffering data. Loading @@ -63,7 +64,7 @@ public: protected: protected: FixedBlockProcessor &mFixedBlockProcessor; FixedBlockProcessor &mFixedBlockProcessor; uint8_t *mStorage = nullptr; // Store data here while assembling buffers. std::unique_ptr<uint8_t[]> mStorage; // Store data here while assembling buffers. int32_t mSize = 0; // Size in bytes of the fixed size buffer. int32_t mSize = 0; // Size in bytes of the fixed size buffer. int32_t mPosition = 0; // Offset of the last byte read or written. int32_t mPosition = 0; // Offset of the last byte read or written. }; }; Loading
media/libaaudio/src/utility/FixedBlockReader.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -39,7 +39,7 @@ int32_t FixedBlockReader::readFromStorage(uint8_t *buffer, int32_t numBytes) { if (bytesToRead > dataAvailable) { if (bytesToRead > dataAvailable) { bytesToRead = dataAvailable; bytesToRead = dataAvailable; } } memcpy(buffer, mStorage + mPosition, bytesToRead); memcpy(buffer, &mStorage[mPosition], bytesToRead); mPosition += bytesToRead; mPosition += bytesToRead; return bytesToRead; return bytesToRead; } } Loading @@ -60,7 +60,7 @@ int32_t FixedBlockReader::processVariableBlock(uint8_t *buffer, int32_t numBytes bytesLeft -= mSize; bytesLeft -= mSize; } else { } else { // Just need a partial block so we have to use storage. // Just need a partial block so we have to use storage. result = mFixedBlockProcessor.onProcessFixedBlock(mStorage, mSize); result = mFixedBlockProcessor.onProcessFixedBlock(mStorage.get(), mSize); mPosition = 0; mPosition = 0; } } } } Loading