Merge "Add API to update mix rule for registered AudioMix-es" into main
diff --git a/camera/VendorTagDescriptor.cpp b/camera/VendorTagDescriptor.cpp
index ecf8a91..fb26f83 100644
--- a/camera/VendorTagDescriptor.cpp
+++ b/camera/VendorTagDescriptor.cpp
@@ -152,7 +152,7 @@
break;
}
String8 tagName = parcel->readString8();
- if (tagName.isEmpty()) {
+ if (tagName.empty()) {
ALOGE("%s: parcel tag name was NULL for tag %d.", __FUNCTION__, tag);
res = NOT_ENOUGH_DATA;
break;
@@ -190,7 +190,7 @@
"Vector capacity must be positive");
for (size_t i = 0; i < sectionCount; ++i) {
String8 sectionName = parcel->readString8();
- if (sectionName.isEmpty()) {
+ if (sectionName.empty()) {
ALOGE("%s: parcel section name was NULL for section %zu.",
__FUNCTION__, i);
return NOT_ENOUGH_DATA;
diff --git a/camera/include/camera/StringUtils.h b/camera/include/camera/StringUtils.h
index 547750f..80c419f 100644
--- a/camera/include/camera/StringUtils.h
+++ b/camera/include/camera/StringUtils.h
@@ -17,8 +17,6 @@
#ifndef ANDROID_SERVERS_CAMERA_STRINGUTILS_H
#define ANDROID_SERVERS_CAMERA_STRINGUTILS_H
-#include <codecvt>
-#include <locale>
#include <memory>
#include <optional>
#include <string>
@@ -65,8 +63,8 @@
}
inline std::string toStdString(const String16 &str) {
- std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
- return convert.to_bytes(str.c_str());
+ String8 str8(str);
+ return std::string(str8.c_str());
}
/**
@@ -74,8 +72,9 @@
* len is the number of characters.
*/
inline std::string toStdString(const char16_t *str, size_t len) {
- std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
- return convert.to_bytes(str, str + len);
+ String16 str16(str, len);
+ String8 str8(str16);
+ return std::string(str8.c_str());
}
} // namespace android
diff --git a/camera/ndk/impl/ACameraDevice.cpp b/camera/ndk/impl/ACameraDevice.cpp
index 024ed20..97d65b0 100644
--- a/camera/ndk/impl/ACameraDevice.cpp
+++ b/camera/ndk/impl/ACameraDevice.cpp
@@ -368,24 +368,24 @@
// ndk as well.
if (remoteRet.exceptionCode() != EX_SERVICE_SPECIFIC) {
ALOGE("Camera device %s failed to prepare output window %p: %s", getId(), window,
- remoteRet.toString8().string());
+ remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}
switch (remoteRet.serviceSpecificErrorCode()) {
case hardware::ICameraService::ERROR_INVALID_OPERATION:
ALOGE("Camera device %s invalid operation: %s", getId(),
- remoteRet.toString8().string());
+ remoteRet.toString8().c_str());
return ACAMERA_ERROR_INVALID_OPERATION;
break;
case hardware::ICameraService::ERROR_ILLEGAL_ARGUMENT:
ALOGE("Camera device %s invalid input argument: %s", getId(),
- remoteRet.toString8().string());
+ remoteRet.toString8().c_str());
return ACAMERA_ERROR_INVALID_PARAMETER;
break;
default:
ALOGE("Camera device %s failed to prepare output window %p: %s", getId(), window,
- remoteRet.toString8().string());
+ remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}
}
diff --git a/cmds/stagefright/stagefright.cpp b/cmds/stagefright/stagefright.cpp
index 989b127..f26e3a8 100644
--- a/cmds/stagefright/stagefright.cpp
+++ b/cmds/stagefright/stagefright.cpp
@@ -212,8 +212,8 @@
}
rawSource = SimpleDecodingSource::Create(
source, flags, gSurface,
- gComponentNameOverride.isEmpty() ? nullptr : gComponentNameOverride.c_str(),
- !gComponentNameOverride.isEmpty());
+ gComponentNameOverride.empty() ? nullptr : gComponentNameOverride.c_str(),
+ !gComponentNameOverride.empty());
if (rawSource == NULL) {
return;
}
diff --git a/drm/drmserver/Android.bp b/drm/drmserver/Android.bp
index cee44b9..81c2003 100644
--- a/drm/drmserver/Android.bp
+++ b/drm/drmserver/Android.bp
@@ -78,6 +78,9 @@
"libselinux",
"libstagefright_foundation",
],
+ whole_static_libs: [
+ "libc++fs",
+ ],
cflags: [
"-Wall",
@@ -124,6 +127,7 @@
],
static_libs: [
+ "libc++fs",
"libmediautils",
"liblog",
"libdrmframeworkcommon",
diff --git a/drm/drmserver/DrmManager.cpp b/drm/drmserver/DrmManager.cpp
index f7989bd..d32228b 100644
--- a/drm/drmserver/DrmManager.cpp
+++ b/drm/drmserver/DrmManager.cpp
@@ -39,6 +39,7 @@
#include "ReadWriteUtils.h"
#include <algorithm>
+#include <filesystem>
#define DECRYPT_FILE_ERROR (-1)
@@ -114,7 +115,7 @@
std::unique_ptr<DrmSupportInfo> info(engine.getSupportInfo(0));
uid_t callingUid = IPCThreadState::self()->getCallingUid();
- std::string plugInId(plugInId8.getPathLeaf().getBasePath().c_str());
+ std::string plugInId = std::filesystem::path(plugInId8.c_str()).stem();
ALOGV("%d calling %s %s", callingUid, plugInId.c_str(), func);
Mutex::Autolock _l(mMetricsLock);
@@ -127,7 +128,7 @@
}
}
- if (!mimeType.isEmpty()) {
+ if (!mimeType.empty()) {
metrics.mMimeTypes.insert(mimeType.c_str());
} else if (NULL != info) {
DrmSupportInfo::MimeTypeIterator mimeIter = info->getMimeTypeIterator();
@@ -316,8 +317,8 @@
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
result = rDrmEngine.canHandle(uniqueId, path);
} else {
- String8 extension = path.getPathExtension();
- if (String8("") != extension) {
+ const auto extension = std::filesystem::path(path.c_str()).extension();
+ if (!extension.empty()) {
result = canHandle(uniqueId, path);
}
}
@@ -395,7 +396,7 @@
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
mimeType = rDrmEngine.getOriginalMimeType(uniqueId, path, fd);
}
- if (!mimeType.isEmpty()) {
+ if (!mimeType.empty()) {
recordEngineMetrics(__func__, plugInId, mimeType);
}
return mimeType;
@@ -745,7 +746,7 @@
String8 DrmManager::getSupportedPlugInIdFromPath(int uniqueId, const String8& path) {
String8 plugInId("");
- const String8 fileSuffix = path.getPathExtension();
+ const String8 fileSuffix(std::filesystem::path(path.c_str()).extension().c_str());
for (size_t index = 0; index < mSupportInfoToPlugInIdMap.size(); index++) {
const DrmSupportInfo& drmSupportInfo = mSupportInfoToPlugInIdMap.keyAt(index);
diff --git a/drm/drmserver/PlugInManager.h b/drm/drmserver/PlugInManager.h
index df40476..8a60b78 100644
--- a/drm/drmserver/PlugInManager.h
+++ b/drm/drmserver/PlugInManager.h
@@ -25,6 +25,8 @@
#include <utils/Vector.h>
#include <utils/KeyedVector.h>
+#include <filesystem>
+
namespace android {
const char* const PLUGIN_MANAGER_CREATE = "create";
@@ -227,10 +229,9 @@
* True if the input name denotes plug-in
*/
bool isPlugIn(const struct dirent* pEntry) const {
- String8 sName(pEntry->d_name);
- String8 extension(sName.getPathExtension());
+ const auto extension = std::filesystem::path(pEntry->d_name).extension();
// Note that the plug-in extension must exactly match case
- return extension == String8(PLUGIN_EXTENSION);
+ return extension.string() == PLUGIN_EXTENSION;
}
/**
diff --git a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.bp b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.bp
index 6e55a16..16ea15e 100644
--- a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.bp
+++ b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.bp
@@ -64,6 +64,10 @@
"libfwdlock-decoder",
],
+ whole_static_libs: [
+ "libc++fs",
+ ],
+
local_include_dirs: ["include"],
relative_install_path: "drm",
diff --git a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp
index 1d8c724..1ade2f7 100644
--- a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp
+++ b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp
@@ -37,6 +37,8 @@
#include "FwdLockGlue.h"
#include "MimeTypeUtil.h"
+#include <filesystem>
+
#undef LOG_TAG
#define LOG_TAG "FwdLockEngine"
@@ -227,7 +229,7 @@
bool FwdLockEngine::onCanHandle(int /* uniqueId */, const String8& path) {
bool result = false;
- String8 extString = path.getPathExtension();
+ String8 extString(std::filesystem::path(path.c_str()).extension().c_str());
return IsFileSuffixSupported(extString);
}
diff --git a/drm/libdrmframework/plugins/passthru/Android.bp b/drm/libdrmframework/plugins/passthru/Android.bp
index 6dffd49..0a6cd47 100644
--- a/drm/libdrmframework/plugins/passthru/Android.bp
+++ b/drm/libdrmframework/plugins/passthru/Android.bp
@@ -39,11 +39,15 @@
srcs: ["src/DrmPassthruPlugIn.cpp"],
shared_libs: [
+ "libbase",
"libutils",
"liblog",
"libdl",
"libdrmframeworkcommon",
],
+ whole_static_libs: [
+ "libc++fs",
+ ],
local_include_dirs: ["include"],
diff --git a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
index 44b4438..55b4b08 100644
--- a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
+++ b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
@@ -18,6 +18,7 @@
#define LOG_TAG "DrmPassthruPlugIn"
#include <utils/Log.h>
+#include <android-base/strings.h>
#include <drm/DrmRights.h>
#include <drm/DrmConstraints.h>
#include <drm/DrmMetadata.h>
@@ -29,6 +30,8 @@
#include <drm/DrmSupportInfo.h>
#include <DrmPassthruPlugIn.h>
+#include <filesystem>
+
using namespace android;
@@ -159,9 +162,8 @@
bool DrmPassthruPlugIn::onCanHandle(int /*uniqueId*/, const String8& path) {
ALOGV("DrmPassthruPlugIn::canHandle: %s ", path.c_str());
- String8 extension = path.getPathExtension();
- extension.toLower();
- return (String8(".passthru") == extension);
+ const auto extension = std::filesystem::path(path.c_str()).extension();
+ return base::EqualsIgnoreCase(extension.string(), ".passthru");
}
String8 DrmPassthruPlugIn::onGetOriginalMimeType(int uniqueId,
diff --git a/drm/libmediadrm/DrmHalAidl.cpp b/drm/libmediadrm/DrmHalAidl.cpp
index 9e30708..7106d66 100644
--- a/drm/libmediadrm/DrmHalAidl.cpp
+++ b/drm/libmediadrm/DrmHalAidl.cpp
@@ -375,7 +375,7 @@
sp<DrmHalAidl> drm = mDrm.promote();
if (drm == NULL) {
name.append("<deleted>");
- } else if (drm->getPropertyStringInternal(String8("vendor"), name) != OK || name.isEmpty()) {
+ } else if (drm->getPropertyStringInternal(String8("vendor"), name) != OK || name.empty()) {
name.append("<Get vendor failed or is empty>");
}
name.append("[");
@@ -947,12 +947,12 @@
String8 vendor;
String8 description;
- if (getPropertyStringInternal(String8("vendor"), vendor) != OK || vendor.isEmpty()) {
+ if (getPropertyStringInternal(String8("vendor"), vendor) != OK || vendor.empty()) {
ALOGE("Get vendor failed or is empty");
vendor = "NONE";
}
if (getPropertyStringInternal(String8("description"), description) != OK ||
- description.isEmpty()) {
+ description.empty()) {
ALOGE("Get description failed or is empty.");
description = "NONE";
}
diff --git a/drm/libmediadrm/DrmHalHidl.cpp b/drm/libmediadrm/DrmHalHidl.cpp
index 9d2638d..c8c6e8e 100644
--- a/drm/libmediadrm/DrmHalHidl.cpp
+++ b/drm/libmediadrm/DrmHalHidl.cpp
@@ -273,7 +273,7 @@
sp<DrmHalHidl> drm = mDrm.promote();
if (drm == NULL) {
name.append("<deleted>");
- } else if (drm->getPropertyStringInternal(String8("vendor"), name) != OK || name.isEmpty()) {
+ } else if (drm->getPropertyStringInternal(String8("vendor"), name) != OK || name.empty()) {
name.append("<Get vendor failed or is empty>");
}
name.append("[");
@@ -1261,12 +1261,12 @@
if (mPluginV1_1 != NULL) {
String8 vendor;
String8 description;
- if (getPropertyStringInternal(String8("vendor"), vendor) != OK || vendor.isEmpty()) {
+ if (getPropertyStringInternal(String8("vendor"), vendor) != OK || vendor.empty()) {
ALOGE("Get vendor failed or is empty");
vendor = "NONE";
}
if (getPropertyStringInternal(String8("description"), description) != OK ||
- description.isEmpty()) {
+ description.empty()) {
ALOGE("Get description failed or is empty.");
description = "NONE";
}
diff --git a/drm/mediacas/plugins/clearkey/ClearKeyCasPlugin.cpp b/drm/mediacas/plugins/clearkey/ClearKeyCasPlugin.cpp
index 37051d5..c364bbb 100644
--- a/drm/mediacas/plugins/clearkey/ClearKeyCasPlugin.cpp
+++ b/drm/mediacas/plugins/clearkey/ClearKeyCasPlugin.cpp
@@ -131,7 +131,7 @@
for (size_t i = 0; i < array.size(); i++) {
result.appendFormat("%02x ", array[i]);
}
- if (result.isEmpty()) {
+ if (result.empty()) {
result.append("(null)");
}
return result;
diff --git a/drm/mediacas/plugins/clearkey/JsonAssetLoader.cpp b/drm/mediacas/plugins/clearkey/JsonAssetLoader.cpp
index a54ae47..07de1d2 100644
--- a/drm/mediacas/plugins/clearkey/JsonAssetLoader.cpp
+++ b/drm/mediacas/plugins/clearkey/JsonAssetLoader.cpp
@@ -187,7 +187,7 @@
*/
bool JsonAssetLoader::parseJsonAssetString(const String8& jsonAsset,
Vector<String8>* jsonObjects) {
- if (jsonAsset.isEmpty()) {
+ if (jsonAsset.empty()) {
ALOGE("Empty JSON Web Key");
return false;
}
diff --git a/drm/mediacas/plugins/mock/MockCasPlugin.cpp b/drm/mediacas/plugins/mock/MockCasPlugin.cpp
index 671fba1..cbff6cb 100644
--- a/drm/mediacas/plugins/mock/MockCasPlugin.cpp
+++ b/drm/mediacas/plugins/mock/MockCasPlugin.cpp
@@ -96,7 +96,7 @@
for (size_t i = 0; i < array.size(); i++) {
result.appendFormat("%02x ", array[i]);
}
- if (result.isEmpty()) {
+ if (result.empty()) {
result.append("(null)");
}
return result;
diff --git a/drm/mediadrm/plugins/clearkey/default/JsonWebKey.cpp b/drm/mediadrm/plugins/clearkey/default/JsonWebKey.cpp
index a12b1d1..6db70c1 100644
--- a/drm/mediadrm/plugins/clearkey/default/JsonWebKey.cpp
+++ b/drm/mediadrm/plugins/clearkey/default/JsonWebKey.cpp
@@ -77,7 +77,7 @@
return false;
if (findKey(mJsonObjects[i], &encodedKeyId, &encodedKey)) {
- if (encodedKeyId.isEmpty() || encodedKey.isEmpty()) {
+ if (encodedKeyId.empty() || encodedKey.empty()) {
ALOGE("Must have both key id and key in the JsonWebKey set.");
continue;
}
@@ -225,7 +225,7 @@
*/
bool JsonWebKey::parseJsonWebKeySet(const String8& jsonWebKeySet,
Vector<String8>* jsonObjects) {
- if (jsonWebKeySet.isEmpty()) {
+ if (jsonWebKeySet.empty()) {
ALOGE("Empty JSON Web Key");
return false;
}
diff --git a/media/libaudioclient/tests/audiotrack_tests.cpp b/media/libaudioclient/tests/audiotrack_tests.cpp
index 8daba0a..2b68225 100644
--- a/media/libaudioclient/tests/audiotrack_tests.cpp
+++ b/media/libaudioclient/tests/audiotrack_tests.cpp
@@ -144,7 +144,7 @@
EXPECT_EQ(cb->mDeviceId, ap->getAudioTrackHandle()->getRoutedDeviceId());
String8 keys;
keys = ap->getAudioTrackHandle()->getParameters(keys);
- if (!keys.isEmpty()) {
+ if (!keys.empty()) {
std::cerr << "track parameters :: " << keys << std::endl;
}
EXPECT_TRUE(checkPatchPlayback(cb->mAudioIo, cb->mDeviceId));
diff --git a/media/libdatasource/DataSourceFactory.cpp b/media/libdatasource/DataSourceFactory.cpp
index 81a6cd0..e9936a3 100644
--- a/media/libdatasource/DataSourceFactory.cpp
+++ b/media/libdatasource/DataSourceFactory.cpp
@@ -92,7 +92,7 @@
source = NuCachedSource2::Create(
mediaHTTP,
- cacheConfig.isEmpty() ? NULL : cacheConfig.c_str(),
+ cacheConfig.empty() ? NULL : cacheConfig.c_str(),
disconnectAtHighwatermark);
} else if (!strncasecmp("data:", uri, 5)) {
source = DataURISource::Create(uri);
diff --git a/media/libmediaplayerservice/StagefrightMetadataRetriever.cpp b/media/libmediaplayerservice/StagefrightMetadataRetriever.cpp
index 51cd1f9..605e659 100644
--- a/media/libmediaplayerservice/StagefrightMetadataRetriever.cpp
+++ b/media/libmediaplayerservice/StagefrightMetadataRetriever.cpp
@@ -704,7 +704,7 @@
// To save the language codes for all timed text tracks
// If multiple text tracks present, the format will look
// like "eng:chi"
- if (!timedTextLang.isEmpty()) {
+ if (!timedTextLang.empty()) {
mMetaData.add(METADATA_KEY_TIMED_TEXT_LANGUAGES, timedTextLang);
}
diff --git a/media/libnblog/PerformanceAnalysis.cpp b/media/libnblog/PerformanceAnalysis.cpp
index 507295a..7982805 100644
--- a/media/libnblog/PerformanceAnalysis.cpp
+++ b/media/libnblog/PerformanceAnalysis.cpp
@@ -393,7 +393,7 @@
PerformanceAnalysis& curr = hash.second;
// write performance data to console
curr.reportPerformance(&body, thread.first, hash.first);
- if (!body.isEmpty()) {
+ if (!body.empty()) {
dumpLine(fd, indent, body);
body.clear();
}
diff --git a/media/libnblog/Reader.cpp b/media/libnblog/Reader.cpp
index a7d6ca2..71ebfd1 100644
--- a/media/libnblog/Reader.cpp
+++ b/media/libnblog/Reader.cpp
@@ -282,7 +282,7 @@
default:
break;
}
- if (!body.isEmpty()) {
+ if (!body.empty()) {
dprintf(fd, "%.*s%s %s\n", (int)indent, "", timestamp.c_str(), body.c_str());
body.clear();
}
diff --git a/media/libstagefright/NuMediaExtractor.cpp b/media/libstagefright/NuMediaExtractor.cpp
index 19e3e6a..92ec56b 100644
--- a/media/libstagefright/NuMediaExtractor.cpp
+++ b/media/libstagefright/NuMediaExtractor.cpp
@@ -172,7 +172,7 @@
for (size_t i = 0; i < array.size(); i++) {
result.appendFormat("%02x ", array[i]);
}
- if (result.isEmpty()) {
+ if (result.empty()) {
result.append("(null)");
}
return result;
diff --git a/media/libstagefright/colorconversion/ColorConverter.cpp b/media/libstagefright/colorconversion/ColorConverter.cpp
index f91a8b2..6c26c28 100644
--- a/media/libstagefright/colorconversion/ColorConverter.cpp
+++ b/media/libstagefright/colorconversion/ColorConverter.cpp
@@ -363,6 +363,7 @@
int32_t _g_u;
int32_t _g_v;
int32_t _b_u;
+ int32_t _c16; // 16 for limited range matrix, 0 for full rance
};
/*
@@ -425,18 +426,18 @@
*
* clip range 8-bit: [-277, 535], 10-bit: [-1111, 2155]
*/
-const struct ColorConverter::Coeffs BT601_FULL = { 256, 359, 88, 183, 454 };
-const struct ColorConverter::Coeffs BT601_LIMITED = { 298, 409, 100, 208, 516 };
-const struct ColorConverter::Coeffs BT601_LTD_10BIT = { 299, 410, 101, 209, 518 };
+const struct ColorConverter::Coeffs BT601_FULL = { 256, 359, 88, 183, 454, 0 };
+const struct ColorConverter::Coeffs BT601_LIMITED = { 298, 409, 100, 208, 516, 16 };
+const struct ColorConverter::Coeffs BT601_LTD_10BIT = { 299, 410, 101, 209, 518, 16 };
/**
* BT.709: K_R = 0.2126; K_B = 0.0722
*
* clip range 8-bit: [-289, 547], 10-bit: [-1159, 2202]
*/
-const struct ColorConverter::Coeffs BT709_FULL = { 256, 403, 48, 120, 475 };
-const struct ColorConverter::Coeffs BT709_LIMITED = { 298, 459, 55, 136, 541 };
-const struct ColorConverter::Coeffs BT709_LTD_10BIT = { 290, 460, 55, 137, 542 };
+const struct ColorConverter::Coeffs BT709_FULL = { 256, 403, 48, 120, 475, 0 };
+const struct ColorConverter::Coeffs BT709_LIMITED = { 298, 459, 55, 136, 541, 16 };
+const struct ColorConverter::Coeffs BT709_LTD_10BIT = { 299, 460, 55, 137, 542, 16 };
/**
* BT.2020: K_R = 0.2627; K_B = 0.0593
@@ -445,9 +446,9 @@
*
* This is the largest clip range.
*/
-const struct ColorConverter::Coeffs BT2020_FULL = { 256, 377, 42, 146, 482 };
-const struct ColorConverter::Coeffs BT2020_LIMITED = { 298, 430, 48, 167, 548 };
-const struct ColorConverter::Coeffs BT2020_LTD_10BIT = { 299, 431, 48, 167, 550 };
+const struct ColorConverter::Coeffs BT2020_FULL = { 256, 377, 42, 146, 482, 0 };
+const struct ColorConverter::Coeffs BT2020_LIMITED = { 298, 430, 48, 167, 548, 16 };
+const struct ColorConverter::Coeffs BT2020_LTD_10BIT = { 299, 431, 48, 167, 550, 16 };
constexpr int CLIP_RANGE_MIN_8BIT = -294;
constexpr int CLIP_RANGE_MAX_8BIT = 552;
@@ -781,7 +782,7 @@
signed _neg_g_v = -matrix->_g_v;
signed _r_v = matrix->_r_v;
signed _y = matrix->_y;
- signed _c16 = mSrcColorSpace.mRange == ColorUtils::kColorRangeLimited ? 16 : 0;
+ signed _c16 = matrix->_c16;
uint8_t *kAdjustedClip = initClip();
@@ -1257,6 +1258,7 @@
signed _neg_g_v = -matrix->_g_v;
signed _r_v = matrix->_r_v;
signed _y = matrix->_y;
+ signed _c16 = matrix->_c16;
uint8_t *dst_ptr = (uint8_t *)dst.mBits
+ dst.mCropTop * dst.mStride + dst.mCropLeft * dst.mBpp;
@@ -1275,13 +1277,12 @@
//TODO: optimize for chroma sampling, reading and writing multiple pixels
// within the same loop
- signed _c16 = 0;
+
void *kAdjustedClip = nullptr;
if (mSrcImage->getBitDepth() != ImageBitDepth8) {
ALOGE("BitDepth != 8 for MediaImage2");
return ERROR_UNSUPPORTED;
}
- _c16 = mSrcColorSpace.mRange == ColorUtils::kColorRangeLimited ? 16 : 0;
kAdjustedClip = initClip();
auto writeToDst = getWriteToDst(mDstFormat, (void *)kAdjustedClip);
@@ -1388,7 +1389,7 @@
signed _neg_g_v = -matrix->_g_v;
signed _r_v = matrix->_r_v;
signed _y = matrix->_y;
- signed _c16 = mSrcColorSpace.mRange == ColorUtils::kColorRangeLimited ? 16 : 0;
+ signed _c16 = matrix->_c16;
uint8_t *kAdjustedClip = initClip();
@@ -1463,7 +1464,7 @@
signed _neg_g_v = -matrix->_g_v;
signed _r_v = matrix->_r_v;
signed _y = matrix->_y;
- signed _c16 = mSrcColorSpace.mRange == ColorUtils::kColorRangeLimited ? 64 : 0;
+ signed _c64 = matrix->_c16 * 4;
uint16_t *kAdjustedClip10bit = initClip10Bit();
@@ -1483,8 +1484,8 @@
for (size_t y = 0; y < src.cropHeight(); ++y) {
for (size_t x = 0; x < src.cropWidth(); x += 2) {
signed y1, y2, u, v;
- y1 = (src_y[x] >> 6) - _c16;
- y2 = (src_y[x + 1] >> 6) - _c16;
+ y1 = (src_y[x] >> 6) - _c64;
+ y2 = (src_y[x + 1] >> 6) - _c64;
u = int(src_uv[x] >> 6) - 512;
v = int(src_uv[x + 1] >> 6) - 512;
diff --git a/media/libstagefright/httplive/HTTPDownloader.cpp b/media/libstagefright/httplive/HTTPDownloader.cpp
index a15b66d..5ac1b9f 100644
--- a/media/libstagefright/httplive/HTTPDownloader.cpp
+++ b/media/libstagefright/httplive/HTTPDownloader.cpp
@@ -209,7 +209,7 @@
*out = buffer;
if (actualUrl != NULL) {
*actualUrl = mDataSource->getUri();
- if (actualUrl->isEmpty()) {
+ if (actualUrl->empty()) {
*actualUrl = url;
}
}
diff --git a/services/audioflinger/Effects.cpp b/services/audioflinger/Effects.cpp
index 610ce26..22733a6 100644
--- a/services/audioflinger/Effects.cpp
+++ b/services/audioflinger/Effects.cpp
@@ -997,13 +997,6 @@
&size,
&cmdStatus);
}
-
- if (isVolumeControl()) {
- // Force initializing the volume as 0 for volume control effect for safer ramping
- uint32_t left = 0;
- uint32_t right = 0;
- setVolumeInternal(&left, &right, true /*controller*/);
- }
}
// mConfig.outputCfg.buffer.frameCount cannot be zero.
@@ -2129,7 +2122,7 @@
EffectChain::EffectChain(const sp<IAfThreadBase>& thread,
audio_session_t sessionId)
: mSessionId(sessionId), mActiveTrackCnt(0), mTrackCnt(0), mTailBufferCount(0),
- mVolumeCtrlIdx(-1), mLeftVolume(UINT_MAX), mRightVolume(UINT_MAX),
+ mLeftVolume(UINT_MAX), mRightVolume(UINT_MAX),
mNewLeftVolume(UINT_MAX), mNewRightVolume(UINT_MAX),
mEffectCallback(new EffectCallback(wp<EffectChain>(this), thread))
{
@@ -2367,6 +2360,15 @@
return NO_ERROR;
}
+std::optional<size_t> EffectChain::findVolumeControl_l(size_t from, size_t to) const {
+ for (size_t i = std::min(to, mEffects.size()); i > from; i--) {
+ if (mEffects[i - 1]->isVolumeControlEnabled()) {
+ return i - 1;
+ }
+ }
+ return std::nullopt;
+}
+
ssize_t EffectChain::getInsertIndex(const effect_descriptor_t& desc) {
// Insert effects are inserted at the end of mEffects vector as they are processed
// after track and auxiliary effects.
@@ -2536,29 +2538,38 @@
{
uint32_t newLeft = *left;
uint32_t newRight = *right;
- bool hasControl = false;
- int ctrlIdx = -1;
- size_t size = mEffects.size();
+ const size_t size = mEffects.size();
// first update volume controller
- for (size_t i = size; i > 0; i--) {
- if (mEffects[i - 1]->isVolumeControlEnabled()) {
- ctrlIdx = i - 1;
- hasControl = true;
- break;
- }
- }
+ const auto volumeControlIndex = findVolumeControl_l(0, size);
+ const int ctrlIdx = volumeControlIndex.value_or(-1);
+ const sp<IAfEffectModule> volumeControlEffect =
+ volumeControlIndex.has_value() ? mEffects[ctrlIdx] : nullptr;
+ const sp<IAfEffectModule> cachedVolumeControlEffect = mVolumeControlEffect.promote();
- if (!force && ctrlIdx == mVolumeCtrlIdx &&
+ if (!force && volumeControlEffect == cachedVolumeControlEffect &&
*left == mLeftVolume && *right == mRightVolume) {
- if (hasControl) {
+ if (volumeControlIndex.has_value()) {
*left = mNewLeftVolume;
*right = mNewRightVolume;
}
- return hasControl;
+ return volumeControlIndex.has_value();
}
- mVolumeCtrlIdx = ctrlIdx;
+ if (volumeControlEffect != cachedVolumeControlEffect) {
+ // The volume control effect is a new one. Set the old one as full volume. Set the new onw
+ // as zero for safe ramping.
+ if (cachedVolumeControlEffect != nullptr) {
+ uint32_t leftMax = 1 << 24;
+ uint32_t rightMax = 1 << 24;
+ cachedVolumeControlEffect->setVolume(&leftMax, &rightMax, true /*controller*/);
+ }
+ if (volumeControlEffect != nullptr) {
+ uint32_t leftZero = 0;
+ uint32_t rightZero = 0;
+ volumeControlEffect->setVolume(&leftZero, &rightZero, true /*controller*/);
+ }
+ }
mLeftVolume = newLeft;
mRightVolume = newRight;
@@ -2595,7 +2606,7 @@
setVolumeForOutput_l(*left, *right);
- return hasControl;
+ return volumeControlIndex.has_value();
}
// resetVolume_l() must be called with IAfThreadBase::mutex() or EffectChain::mLock held
diff --git a/services/audioflinger/Effects.h b/services/audioflinger/Effects.h
index 79b4e63..aa5935a 100644
--- a/services/audioflinger/Effects.h
+++ b/services/audioflinger/Effects.h
@@ -622,6 +622,8 @@
ssize_t getInsertIndex(const effect_descriptor_t& desc);
+ std::optional<size_t> findVolumeControl_l(size_t from, size_t to) const;
+
mutable Mutex mLock; // mutex protecting effect list
Vector<sp<IAfEffectModule>> mEffects; // list of effect modules
audio_session_t mSessionId; // audio session ID
@@ -634,7 +636,6 @@
int32_t mTailBufferCount; // current effect tail buffer count
int32_t mMaxTailBuffers; // maximum effect tail buffers
- int mVolumeCtrlIdx; // index of insert effect having control over volume
uint32_t mLeftVolume; // previous volume on left channel
uint32_t mRightVolume; // previous volume on right channel
uint32_t mNewLeftVolume; // new volume on left channel
@@ -647,6 +648,8 @@
KeyedVector< int, sp<SuspendedEffectDesc> > mSuspendedEffects;
const sp<EffectCallback> mEffectCallback;
+
+ wp<IAfEffectModule> mVolumeControlEffect;
};
class DeviceEffectProxy : public IAfDeviceEffectProxy, public EffectBase {
diff --git a/services/audioflinger/PatchPanel.cpp b/services/audioflinger/PatchPanel.cpp
index c477c93..554272a 100644
--- a/services/audioflinger/PatchPanel.cpp
+++ b/services/audioflinger/PatchPanel.cpp
@@ -937,7 +937,7 @@
}
}
- if (!patchPanelDump.isEmpty()) {
+ if (!patchPanelDump.empty()) {
write(fd, patchPanelDump.c_str(), patchPanelDump.size());
}
}
diff --git a/services/audiopolicy/enginedefault/src/Engine.cpp b/services/audiopolicy/enginedefault/src/Engine.cpp
index 15f7842..fa6be39 100644
--- a/services/audiopolicy/enginedefault/src/Engine.cpp
+++ b/services/audiopolicy/enginedefault/src/Engine.cpp
@@ -175,34 +175,37 @@
// - cannot route from voice call RX OR
// - audio HAL version is < 3.0 and TX device is on the primary HW module
if (getPhoneState() == AUDIO_MODE_IN_CALL) {
- audio_devices_t txDevice = AUDIO_DEVICE_NONE;
- sp<DeviceDescriptor> txDeviceDesc =
- getDeviceForInputSource(AUDIO_SOURCE_VOICE_COMMUNICATION);
- if (txDeviceDesc != nullptr) {
- txDevice = txDeviceDesc->type();
- }
sp<AudioOutputDescriptor> primaryOutput = outputs.getPrimaryOutput();
- LOG_ALWAYS_FATAL_IF(primaryOutput == nullptr, "Primary output not found");
- DeviceVector availPrimaryInputDevices =
- availableInputDevices.getDevicesFromHwModule(primaryOutput->getModuleHandle());
+ if (primaryOutput != nullptr) {
+ audio_devices_t txDevice = AUDIO_DEVICE_NONE;
+ sp<DeviceDescriptor> txDeviceDesc =
+ getDeviceForInputSource(AUDIO_SOURCE_VOICE_COMMUNICATION);
+ if (txDeviceDesc != nullptr) {
+ txDevice = txDeviceDesc->type();
+ }
+ DeviceVector availPrimaryInputDevices =
+ availableInputDevices.getDevicesFromHwModule(
+ primaryOutput->getModuleHandle());
- // TODO: getPrimaryOutput return only devices from first module in
- // audio_policy_configuration.xml, hearing aid is not there, but it's
- // a primary device
- // FIXME: this is not the right way of solving this problem
- DeviceVector availPrimaryOutputDevices = availableOutputDevices.getDevicesFromTypes(
- primaryOutput->supportedDevices().types());
- availPrimaryOutputDevices.add(
- availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_HEARING_AID));
+ // TODO: getPrimaryOutput return only devices from first module in
+ // audio_policy_configuration.xml, hearing aid is not there, but it's
+ // a primary device
+ // FIXME: this is not the right way of solving this problem
+ DeviceVector availPrimaryOutputDevices = availableOutputDevices.getDevicesFromTypes(
+ primaryOutput->supportedDevices().types());
+ availPrimaryOutputDevices.add(
+ availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_HEARING_AID));
- if ((availableInputDevices.getDevice(AUDIO_DEVICE_IN_TELEPHONY_RX,
- String8(""), AUDIO_FORMAT_DEFAULT) == nullptr) ||
- ((availPrimaryInputDevices.getDevice(
- txDevice, String8(""), AUDIO_FORMAT_DEFAULT) != nullptr) &&
- (primaryOutput->getPolicyAudioPort()->getModuleVersionMajor() < 3))) {
- availableOutputDevices = availPrimaryOutputDevices;
+ if ((availableInputDevices.getDevice(AUDIO_DEVICE_IN_TELEPHONY_RX,
+ String8(""), AUDIO_FORMAT_DEFAULT) == nullptr)
+ || ((availPrimaryInputDevices.getDevice(
+ txDevice, String8(""), AUDIO_FORMAT_DEFAULT) != nullptr) &&
+ (primaryOutput->getPolicyAudioPort()->getModuleVersionMajor() < 3))) {
+ availableOutputDevices = availPrimaryOutputDevices;
+ }
+ } else {
+ ALOGE("%s, STRATEGY_PHONE: Primary output not found", __func__);
}
-
}
// Do not use A2DP devices when in call but use them when not in call
// (e.g for voice mail playback)
@@ -595,8 +598,11 @@
if ((getPhoneState() == AUDIO_MODE_IN_CALL) &&
(availableOutputDevices.getDevice(AUDIO_DEVICE_OUT_TELEPHONY_TX,
String8(""), AUDIO_FORMAT_DEFAULT)) == nullptr) {
- LOG_ALWAYS_FATAL_IF(availablePrimaryDevices.isEmpty(), "Primary devices not found");
- availableDevices = availablePrimaryDevices;
+ if (!availablePrimaryDevices.isEmpty()) {
+ availableDevices = availablePrimaryDevices;
+ } else {
+ ALOGE("%s, AUDIO_SOURCE_VOICE_COMMUNICATION: Primary devices not found", __func__);
+ }
}
if (audio_is_bluetooth_out_sco_device(commDeviceType)) {
@@ -650,8 +656,11 @@
case AUDIO_SOURCE_HOTWORD:
// We should not use primary output criteria for Hotword but rather limit
// to devices attached to the same HW module as the build in mic
- LOG_ALWAYS_FATAL_IF(availablePrimaryDevices.isEmpty(), "Primary devices not found");
- availableDevices = availablePrimaryDevices;
+ if (!availablePrimaryDevices.isEmpty()) {
+ availableDevices = availablePrimaryDevices;
+ } else {
+ ALOGE("%s, AUDIO_SOURCE_HOTWORD: Primary devices not found", __func__);
+ }
if (audio_is_bluetooth_out_sco_device(commDeviceType)) {
device = availableDevices.getDevice(
AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET, String8(""), AUDIO_FORMAT_DEFAULT);
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 63c0ba5..a72598e 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -6621,7 +6621,7 @@
if (status == NO_ERROR) {
const String8& address = String8(device->address().c_str());
- if (!address.isEmpty()) {
+ if (!address.empty()) {
char *param = audio_device_address_to_parameter(device->type(), address);
mpClientInterface->setParameters(input, String8(param));
free(param);
@@ -7698,8 +7698,10 @@
const auto musicVolumeSrc = toVolumeSource(AUDIO_STREAM_MUSIC, false);
const auto alarmVolumeSrc = toVolumeSource(AUDIO_STREAM_ALARM, false);
const auto a11yVolumeSrc = toVolumeSource(AUDIO_STREAM_ACCESSIBILITY, false);
-
- if (volumeSource == a11yVolumeSrc
+ // Verify that the current volume source is not the ringer volume to prevent recursively
+ // calling to compute volume. This could happen in cases where a11y and ringer sounds belong
+ // to the same volume group.
+ if (volumeSource != ringVolumeSrc && volumeSource == a11yVolumeSrc
&& (AUDIO_MODE_RINGTONE == mEngine->getPhoneState()) &&
mOutputs.isActive(ringVolumeSrc, 0)) {
auto &ringCurves = getVolumeCurves(AUDIO_STREAM_RING);
@@ -7762,8 +7764,12 @@
// when the phone is ringing we must consider that music could have been paused just before
// by the music application and behave as if music was active if the last music track was
// just stopped
- if (isStreamActive(AUDIO_STREAM_MUSIC, SONIFICATION_HEADSET_MUSIC_DELAY) ||
- mLimitRingtoneVolume) {
+ // Verify that the current volume source is not the music volume to prevent recursively
+ // calling to compute volume. This could happen in cases where music and
+ // (alarm, ring, notification, system, etc.) sounds belong to the same volume group.
+ if (volumeSource != musicVolumeSrc &&
+ (isStreamActive(AUDIO_STREAM_MUSIC, SONIFICATION_HEADSET_MUSIC_DELAY)
+ || mLimitRingtoneVolume)) {
volumeDb += SONIFICATION_HEADSET_VOLUME_FACTOR_DB;
DeviceTypeSet musicDevice =
mEngine->getOutputDevicesForAttributes(attributes_initializer(AUDIO_USAGE_MEDIA),
@@ -8363,7 +8369,7 @@
sp<DeviceDescriptor> device = devices.getDeviceForOpening();
const audio_devices_t deviceType = device->type();
const String8 &address = String8(device->address().c_str());
- if (!address.isEmpty()) {
+ if (!address.empty()) {
char *param = audio_device_address_to_parameter(deviceType, address.c_str());
mpClientInterface->setParameters(output, String8(param));
free(param);
diff --git a/services/camera/libcameraservice/aidl/AidlCameraDeviceUser.cpp b/services/camera/libcameraservice/aidl/AidlCameraDeviceUser.cpp
index 402f8a2..954cb8b 100644
--- a/services/camera/libcameraservice/aidl/AidlCameraDeviceUser.cpp
+++ b/services/camera/libcameraservice/aidl/AidlCameraDeviceUser.cpp
@@ -119,7 +119,7 @@
in_isRepeating, &submitInfo);
if (!ret.isOk()) {
ALOGE("%s: Failed submitRequestList to cameraservice: %s",
- __FUNCTION__, ret.toString8().string());
+ __FUNCTION__, ret.toString8().c_str());
return fromUStatus(ret);
}
mRequestId = submitInfo.mRequestId;
@@ -158,7 +158,7 @@
int32_t newStreamId;
UStatus ret = mDeviceRemote->createStream(outputConfig, &newStreamId);
if (!ret.isOk()) {
- ALOGE("%s: Failed to create stream: %s", __FUNCTION__, ret.toString8().string());
+ ALOGE("%s: Failed to create stream: %s", __FUNCTION__, ret.toString8().c_str());
}
*_aidl_return = newStreamId;
return fromUStatus(ret);
@@ -170,7 +170,7 @@
UStatus ret = mDeviceRemote->createDefaultRequest(convertFromAidl(in_templateId),
&metadata);
if (!ret.isOk()) {
- ALOGE("%s: Failed to create default request: %s", __FUNCTION__, ret.toString8().string());
+ ALOGE("%s: Failed to create default request: %s", __FUNCTION__, ret.toString8().c_str());
return fromUStatus(ret);
}
@@ -202,7 +202,7 @@
UStatus ret = mDeviceRemote->updateOutputConfiguration(in_streamId, outputConfig);
if (!ret.isOk()) {
ALOGE("%s: Failed to update output config for stream id: %d: %s",
- __FUNCTION__, in_streamId, ret.toString8().string());
+ __FUNCTION__, in_streamId, ret.toString8().c_str());
}
return fromUStatus(ret);
}
diff --git a/services/camera/libcameraservice/aidl/AidlCameraService.cpp b/services/camera/libcameraservice/aidl/AidlCameraService.cpp
index a62f6de..8cd7d1f 100644
--- a/services/camera/libcameraservice/aidl/AidlCameraService.cpp
+++ b/services/camera/libcameraservice/aidl/AidlCameraService.cpp
@@ -103,7 +103,7 @@
return fromSStatus(SStatus::ILLEGAL_ARGUMENT);
default:
ALOGE("Get camera characteristics from camera service failed: %s",
- ret.toString8().string());
+ ret.toString8().c_str());
return fromUStatus(ret);
}
}
@@ -313,7 +313,7 @@
}
vendorTagSections.resize(numSections);
for (size_t s = 0; s < numSections; s++) {
- vendorTagSections[s].sectionName = (*sectionNames)[s].string();
+ vendorTagSections[s].sectionName = (*sectionNames)[s].c_str();
vendorTagSections[s].tags = tagsBySection[s];
}
SProviderIdAndVendorTagSections & prvdrIdAndVendorTagSection =
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index 597b9aa..082ac8c 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -3041,7 +3041,6 @@
mAutoframingOverride(ANDROID_CONTROL_AUTOFRAMING_OFF),
mComposerOutput(false),
mCameraMute(ANDROID_SENSOR_TEST_PATTERN_MODE_OFF),
- mCameraMuteChanged(false),
mSettingsOverride(ANDROID_CONTROL_SETTINGS_OVERRIDE_OFF),
mRepeatingLastFrameNumber(
hardware::camera2::ICameraDeviceUser::NO_IN_FLIGHT_REPEATING_FRAMES),
@@ -4239,7 +4238,6 @@
Mutex::Autolock l(mTriggerMutex);
if (muteMode != mCameraMute) {
mCameraMute = muteMode;
- mCameraMuteChanged = true;
}
return OK;
}
diff --git a/services/camera/libcameraservice/device3/Camera3Device.h b/services/camera/libcameraservice/device3/Camera3Device.h
index a1e25fd..0229446 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.h
+++ b/services/camera/libcameraservice/device3/Camera3Device.h
@@ -1157,7 +1157,6 @@
camera_metadata_enum_android_control_autoframing_t mAutoframingOverride;
bool mComposerOutput;
int32_t mCameraMute; // 0 = no mute, otherwise the TEST_PATTERN_MODE to use
- bool mCameraMuteChanged;
int32_t mSettingsOverride; // -1 = use original, otherwise
// the settings override to use.
diff --git a/services/camera/libcameraservice/device3/StatusTracker.cpp b/services/camera/libcameraservice/device3/StatusTracker.cpp
index ea1f2c1..bd78e0a 100644
--- a/services/camera/libcameraservice/device3/StatusTracker.cpp
+++ b/services/camera/libcameraservice/device3/StatusTracker.cpp
@@ -172,6 +172,7 @@
}
}
+ bool waitForIdleFence = false;
// After new pending states appear, or timeout, check if we're idle. Even
// with timeout, need to check to account for fences that may still be
// clearing out
@@ -196,6 +197,7 @@
ssize_t idx = mStates.indexOfKey(newState.id);
// Ignore notices for unknown components
if (idx >= 0) {
+ bool validFence = newState.fence != Fence::NO_FENCE;
// Update single component state
mStates.replaceValueAt(idx, newState.state);
mIdleFence = Fence::merge(String8("idleFence"),
@@ -204,6 +206,8 @@
ComponentState newState = getDeviceStateLocked();
if (newState != prevState) {
mStateTransitions.add(newState);
+ } else if (validFence && !waitForIdleFence) {
+ waitForIdleFence = true;
}
prevState = newState;
}
@@ -227,6 +231,13 @@
}
mStateTransitions.clear();
+ if (waitForIdleFence) {
+ auto ret = mIdleFence->wait(kWaitDuration);
+ if (ret == NO_ERROR) {
+ mComponentsChanged = true;
+ }
+ }
+
return true;
}
diff --git a/services/mediaresourcemanager/ResourceObserverService.cpp b/services/mediaresourcemanager/ResourceObserverService.cpp
index 33525fd..6c5cecf 100644
--- a/services/mediaresourcemanager/ResourceObserverService.cpp
+++ b/services/mediaresourcemanager/ResourceObserverService.cpp
@@ -138,7 +138,7 @@
String8 enabledEventsStr;
for (auto &event : sEvents) {
if (((uint64_t)observable.eventFilter & (uint64_t)event) != 0) {
- if (!enabledEventsStr.isEmpty()) {
+ if (!enabledEventsStr.empty()) {
enabledEventsStr.append("|");
}
enabledEventsStr.append(toString(event).c_str());