Merge "codec2: do not count padding into allocation's capacity." am: 86f2d536ae am: a7c2d14224 am: e211cc3927 am: f234b7c6c3
Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/1732496
Change-Id: I42dac8a69c3c5bc8ef84ddde4d8770a422f0d2e6
diff --git a/cmds/screenrecord/screenrecord.cpp b/cmds/screenrecord/screenrecord.cpp
index e6e3473..cd8fe97 100644
--- a/cmds/screenrecord/screenrecord.cpp
+++ b/cmds/screenrecord/screenrecord.cpp
@@ -1067,7 +1067,7 @@
std::optional<PhysicalDisplayId> displayId = SurfaceComposerClient::getInternalDisplayId();
if (!displayId) {
- fprintf(stderr, "Failed to get token for internal display\n");
+ fprintf(stderr, "Failed to get ID for internal display\n");
return 1;
}
@@ -1168,17 +1168,14 @@
}
break;
case 'd':
- gPhysicalDisplayId = PhysicalDisplayId(atoll(optarg));
- if (gPhysicalDisplayId.value == 0) {
- fprintf(stderr, "Please specify a valid physical display id\n");
- return 2;
- } else if (SurfaceComposerClient::
- getPhysicalDisplayToken(gPhysicalDisplayId) == nullptr) {
- fprintf(stderr, "Invalid physical display id: %s\n",
- to_string(gPhysicalDisplayId).c_str());
- return 2;
+ if (const auto id = android::DisplayId::fromValue<PhysicalDisplayId>(atoll(optarg));
+ id && SurfaceComposerClient::getPhysicalDisplayToken(*id)) {
+ gPhysicalDisplayId = *id;
+ break;
}
- break;
+
+ fprintf(stderr, "Invalid physical display ID\n");
+ return 2;
default:
if (ic != '?') {
fprintf(stderr, "getopt_long returned unexpected value 0x%x\n", ic);
diff --git a/drm/mediadrm/plugins/TEST_MAPPING b/drm/mediadrm/plugins/TEST_MAPPING
index 7bd1568..87becb6 100644
--- a/drm/mediadrm/plugins/TEST_MAPPING
+++ b/drm/mediadrm/plugins/TEST_MAPPING
@@ -11,6 +11,9 @@
},
{
"include-filter": "android.media.cts.MediaDrmMetricsTest"
+ },
+ {
+ "include-filter": "android.media.cts.NativeMediaDrmClearkeyTest"
}
]
}
diff --git a/drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp b/drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp
index 6a374f9..0cd9375 100644
--- a/drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp
+++ b/drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp
@@ -221,7 +221,6 @@
if (requestString.find(kOfflineLicense) != std::string::npos) {
std::string emptyResponse;
std::string keySetIdString(keySetId.begin(), keySetId.end());
- Mutex::Autolock lock(mFileHandleLock);
if (!mFileHandle.StoreLicense(keySetIdString,
DeviceFiles::kLicenseStateReleasing,
emptyResponse)) {
@@ -337,7 +336,6 @@
}
*keySetId = kKeySetIdPrefix + ByteArrayToHexString(
reinterpret_cast<const uint8_t*>(randomData.data()), randomData.size());
- Mutex::Autolock lock(mFileHandleLock);
if (mFileHandle.LicenseExists(*keySetId)) {
// collision, regenerate
ALOGV("Retry generating KeySetId");
@@ -395,7 +393,6 @@
if (status == Status::OK) {
if (isOfflineLicense) {
if (isRelease) {
- Mutex::Autolock lock(mFileHandleLock);
mFileHandle.DeleteLicense(keySetId);
mSessionLibrary->destroySession(session);
} else {
@@ -404,7 +401,6 @@
return Void();
}
- Mutex::Autolock lock(mFileHandleLock);
bool ok = mFileHandle.StoreLicense(
keySetId,
DeviceFiles::kLicenseStateActive,
@@ -459,7 +455,6 @@
DeviceFiles::LicenseState licenseState;
std::string offlineLicense;
Status status = Status::OK;
- Mutex::Autolock lock(mFileHandleLock);
if (!mFileHandle.RetrieveLicense(std::string(keySetId.begin(), keySetId.end()),
&licenseState, &offlineLicense)) {
ALOGE("Failed to restore offline license");
@@ -769,8 +764,6 @@
}
Return<void> DrmPlugin::getOfflineLicenseKeySetIds(getOfflineLicenseKeySetIds_cb _hidl_cb) {
- Mutex::Autolock lock(mFileHandleLock);
-
std::vector<std::string> licenseNames = mFileHandle.ListLicenses();
std::vector<KeySetId> keySetIds;
if (mMockError != Status_V1_2::OK) {
@@ -791,7 +784,6 @@
return toStatus_1_0(mMockError);
}
std::string licenseName(keySetId.begin(), keySetId.end());
- Mutex::Autolock lock(mFileHandleLock);
if (mFileHandle.DeleteLicense(licenseName)) {
return Status::OK;
}
@@ -800,8 +792,6 @@
Return<void> DrmPlugin::getOfflineLicenseState(const KeySetId& keySetId,
getOfflineLicenseState_cb _hidl_cb) {
- Mutex::Autolock lock(mFileHandleLock);
-
std::string licenseName(keySetId.begin(), keySetId.end());
DeviceFiles::LicenseState state;
std::string license;
diff --git a/drm/mediadrm/plugins/clearkey/hidl/MemoryFileSystem.cpp b/drm/mediadrm/plugins/clearkey/hidl/MemoryFileSystem.cpp
index e61db3f..56910be 100644
--- a/drm/mediadrm/plugins/clearkey/hidl/MemoryFileSystem.cpp
+++ b/drm/mediadrm/plugins/clearkey/hidl/MemoryFileSystem.cpp
@@ -24,13 +24,11 @@
}
bool MemoryFileSystem::FileExists(const std::string& fileName) const {
- std::lock_guard<std::mutex> lock(mMemoryFileSystemLock);
auto result = mMemoryFileSystem.find(fileName);
return result != mMemoryFileSystem.end();
}
ssize_t MemoryFileSystem::GetFileSize(const std::string& fileName) const {
- std::lock_guard<std::mutex> lock(mMemoryFileSystemLock);
auto result = mMemoryFileSystem.find(fileName);
if (result != mMemoryFileSystem.end()) {
return static_cast<ssize_t>(result->second.getFileSize());
@@ -42,7 +40,6 @@
std::vector<std::string> MemoryFileSystem::ListFiles() const {
std::vector<std::string> list;
- std::lock_guard<std::mutex> lock(mMemoryFileSystemLock);
for (const auto& filename : mMemoryFileSystem) {
list.push_back(filename.first);
}
@@ -51,7 +48,6 @@
size_t MemoryFileSystem::Read(const std::string& path, std::string* buffer) {
std::string key = GetFileName(path);
- std::lock_guard<std::mutex> lock(mMemoryFileSystemLock);
auto result = mMemoryFileSystem.find(key);
if (result != mMemoryFileSystem.end()) {
std::string serializedHashFile = result->second.getContent();
@@ -65,7 +61,6 @@
size_t MemoryFileSystem::Write(const std::string& path, const MemoryFile& memoryFile) {
std::string key = GetFileName(path);
- std::lock_guard<std::mutex> lock(mMemoryFileSystemLock);
auto result = mMemoryFileSystem.find(key);
if (result != mMemoryFileSystem.end()) {
mMemoryFileSystem.erase(key);
@@ -75,7 +70,6 @@
}
bool MemoryFileSystem::RemoveFile(const std::string& fileName) {
- std::lock_guard<std::mutex> lock(mMemoryFileSystemLock);
auto result = mMemoryFileSystem.find(fileName);
if (result != mMemoryFileSystem.end()) {
mMemoryFileSystem.erase(result);
@@ -87,7 +81,6 @@
}
bool MemoryFileSystem::RemoveAllFiles() {
- std::lock_guard<std::mutex> lock(mMemoryFileSystemLock);
mMemoryFileSystem.clear();
return mMemoryFileSystem.empty();
}
diff --git a/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h b/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h
index 5d6e3da..cb5c9fe 100644
--- a/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h
+++ b/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h
@@ -432,8 +432,7 @@
mMockError = Status_V1_2::OK;
}
- DeviceFiles mFileHandle GUARDED_BY(mFileHandleLock);
- Mutex mFileHandleLock;
+ DeviceFiles mFileHandle;
Mutex mSecureStopLock;
CLEARKEY_DISALLOW_COPY_AND_ASSIGN_AND_NEW(DrmPlugin);
diff --git a/drm/mediadrm/plugins/clearkey/hidl/include/MemoryFileSystem.h b/drm/mediadrm/plugins/clearkey/hidl/include/MemoryFileSystem.h
index a90d818..1d98860 100644
--- a/drm/mediadrm/plugins/clearkey/hidl/include/MemoryFileSystem.h
+++ b/drm/mediadrm/plugins/clearkey/hidl/include/MemoryFileSystem.h
@@ -5,9 +5,7 @@
#ifndef CLEARKEY_MEMORY_FILE_SYSTEM_H_
#define CLEARKEY_MEMORY_FILE_SYSTEM_H_
-#include <android-base/thread_annotations.h>
#include <map>
-#include <mutex>
#include <string>
#include "ClearKeyTypes.h"
@@ -51,12 +49,10 @@
size_t Write(const std::string& pathName, const MemoryFile& memoryFile);
private:
- mutable std::mutex mMemoryFileSystemLock;
-
// License file name is made up of a unique keySetId, therefore,
// the filename can be used as the key to locate licenses in the
// memory file system.
- std::map<std::string, MemoryFile> mMemoryFileSystem GUARDED_BY(mMemoryFileSystemLock);
+ std::map<std::string, MemoryFile> mMemoryFileSystem;
std::string GetFileName(const std::string& path);
diff --git a/media/codec2/components/gav1/C2SoftGav1Dec.cpp b/media/codec2/components/gav1/C2SoftGav1Dec.cpp
index 2fa4f25..ff59490 100644
--- a/media/codec2/components/gav1/C2SoftGav1Dec.cpp
+++ b/media/codec2/components/gav1/C2SoftGav1Dec.cpp
@@ -26,6 +26,11 @@
#include <media/stagefright/foundation/MediaDefs.h>
namespace android {
+namespace {
+
+constexpr uint8_t NEUTRAL_UV_VALUE = 128;
+
+} // namespace
// codecname set and passed in as a compile flag from Android.bp
constexpr char COMPONENT_NAME[] = CODECNAME;
@@ -51,8 +56,8 @@
DefineParam(mSize, C2_PARAMKEY_PICTURE_SIZE)
.withDefault(new C2StreamPictureSizeInfo::output(0u, 320, 240))
.withFields({
- C2F(mSize, width).inRange(2, 2048, 2),
- C2F(mSize, height).inRange(2, 2048, 2),
+ C2F(mSize, width).inRange(2, 4096, 2),
+ C2F(mSize, height).inRange(2, 4096, 2),
})
.withSetter(SizeSetter)
.build());
@@ -464,7 +469,8 @@
const uint8_t *srcY, const uint8_t *srcU, const uint8_t *srcV,
size_t srcYStride, size_t srcUStride, size_t srcVStride,
size_t dstYStride, size_t dstUVStride,
- uint32_t width, uint32_t height) {
+ uint32_t width, uint32_t height,
+ bool isMonochrome) {
for (size_t i = 0; i < height; ++i) {
memcpy(dstY, srcY, width);
@@ -472,6 +478,17 @@
dstY += dstYStride;
}
+ if (isMonochrome) {
+ // Fill with neutral U/V values.
+ for (size_t i = 0; i < height / 2; ++i) {
+ memset(dstV, NEUTRAL_UV_VALUE, width / 2);
+ memset(dstU, NEUTRAL_UV_VALUE, width / 2);
+ dstV += dstUVStride;
+ dstU += dstUVStride;
+ }
+ return;
+ }
+
for (size_t i = 0; i < height / 2; ++i) {
memcpy(dstV, srcV, width / 2);
srcV += srcVStride;
@@ -557,7 +574,7 @@
const uint16_t *srcY, const uint16_t *srcU, const uint16_t *srcV,
size_t srcYStride, size_t srcUStride, size_t srcVStride,
size_t dstYStride, size_t dstUVStride,
- size_t width, size_t height) {
+ size_t width, size_t height, bool isMonochrome) {
for (size_t y = 0; y < height; ++y) {
for (size_t x = 0; x < width; ++x) {
@@ -568,6 +585,17 @@
dstY += dstYStride;
}
+ if (isMonochrome) {
+ // Fill with neutral U/V values.
+ for (size_t y = 0; y < (height + 1) / 2; ++y) {
+ memset(dstV, NEUTRAL_UV_VALUE, (width + 1) / 2);
+ memset(dstU, NEUTRAL_UV_VALUE, (width + 1) / 2);
+ dstV += dstUVStride;
+ dstU += dstUVStride;
+ }
+ return;
+ }
+
for (size_t y = 0; y < (height + 1) / 2; ++y) {
for (size_t x = 0; x < (width + 1) / 2; ++x) {
dstU[x] = (uint8_t)(srcU[x] >> 2);
@@ -623,8 +651,10 @@
}
}
- // TODO(vigneshv): Add support for monochrome videos since AV1 supports it.
- CHECK(buffer->image_format == libgav1::kImageFormatYuv420);
+ CHECK(buffer->image_format == libgav1::kImageFormatYuv420 ||
+ buffer->image_format == libgav1::kImageFormatMonochrome400);
+ const bool isMonochrome =
+ buffer->image_format == libgav1::kImageFormatMonochrome400;
std::shared_ptr<C2GraphicBlock> block;
uint32_t format = HAL_PIXEL_FORMAT_YV12;
@@ -636,6 +666,13 @@
if (defaultColorAspects->primaries == C2Color::PRIMARIES_BT2020 &&
defaultColorAspects->matrix == C2Color::MATRIX_BT2020 &&
defaultColorAspects->transfer == C2Color::TRANSFER_ST2084) {
+ if (buffer->image_format != libgav1::kImageFormatYuv420) {
+ ALOGE("Only YUV420 output is supported when targeting RGBA_1010102");
+ mSignalledError = true;
+ work->result = C2_OMITTED;
+ work->workletsProcessed = 1u;
+ return false;
+ }
format = HAL_PIXEL_FORMAT_RGBA_1010102;
}
}
@@ -682,21 +719,18 @@
(uint32_t *)dstY, srcY, srcU, srcV, srcYStride / 2, srcUStride / 2,
srcVStride / 2, dstYStride / sizeof(uint32_t), mWidth, mHeight);
} else {
- convertYUV420Planar16ToYUV420Planar(dstY, dstU, dstV,
- srcY, srcU, srcV,
- srcYStride / 2, srcUStride / 2, srcVStride / 2,
- dstYStride, dstUVStride,
- mWidth, mHeight);
+ convertYUV420Planar16ToYUV420Planar(
+ dstY, dstU, dstV, srcY, srcU, srcV, srcYStride / 2, srcUStride / 2,
+ srcVStride / 2, dstYStride, dstUVStride, mWidth, mHeight,
+ isMonochrome);
}
} else {
const uint8_t *srcY = (const uint8_t *)buffer->plane[0];
const uint8_t *srcU = (const uint8_t *)buffer->plane[1];
const uint8_t *srcV = (const uint8_t *)buffer->plane[2];
- copyOutputBufferToYV12Frame(dstY, dstU, dstV,
- srcY, srcU, srcV,
- srcYStride, srcUStride, srcVStride,
- dstYStride, dstUVStride,
- mWidth, mHeight);
+ copyOutputBufferToYV12Frame(
+ dstY, dstU, dstV, srcY, srcU, srcV, srcYStride, srcUStride, srcVStride,
+ dstYStride, dstUVStride, mWidth, mHeight, isMonochrome);
}
finishWork(buffer->user_private_data, work, std::move(block));
block = nullptr;
diff --git a/media/libaaudio/src/Android.bp b/media/libaaudio/src/Android.bp
index 33a5c7f..cb08b1c 100644
--- a/media/libaaudio/src/Android.bp
+++ b/media/libaaudio/src/Android.bp
@@ -7,6 +7,65 @@
default_applicable_licenses: ["frameworks_av_license"],
}
+tidy_errors = [
+ // https://clang.llvm.org/extra/clang-tidy/checks/list.html
+ // For many categories, the checks are too many to specify individually.
+ // Feel free to disable as needed - as warnings are generally ignored,
+ // we treat warnings as errors.
+ "android-*",
+ "bugprone-*",
+ "cert-*",
+ "clang-analyzer-security*",
+ "google-*",
+ "misc-*",
+ //"modernize-*", // explicitly list the modernize as they can be subjective.
+ "modernize-avoid-bind",
+ //"modernize-avoid-c-arrays", // std::array<> can be verbose
+ "modernize-concat-nested-namespaces",
+ //"modernize-deprecated-headers", // C headers still ok even if there is C++ equivalent.
+ "modernize-deprecated-ios-base-aliases",
+ "modernize-loop-convert",
+ "modernize-make-shared",
+ "modernize-make-unique",
+ "modernize-pass-by-value",
+ "modernize-raw-string-literal",
+ "modernize-redundant-void-arg",
+ "modernize-replace-auto-ptr",
+ "modernize-replace-random-shuffle",
+ "modernize-return-braced-init-list",
+ "modernize-shrink-to-fit",
+ "modernize-unary-static-assert",
+ // "modernize-use-auto", // found in AAudioAudio.cpp
+ "modernize-use-bool-literals",
+ "modernize-use-default-member-init",
+ "modernize-use-emplace",
+ "modernize-use-equals-default",
+ "modernize-use-equals-delete",
+ // "modernize-use-nodiscard", // found in aidl generated files
+ "modernize-use-noexcept",
+ "modernize-use-nullptr",
+ // "modernize-use-override", // found in aidl generated files
+ // "modernize-use-trailing-return-type", // not necessarily more readable
+ "modernize-use-transparent-functors",
+ "modernize-use-uncaught-exceptions",
+ // "modernize-use-using", // found typedef in several files
+ "performance-*",
+
+ // Remove some pedantic stylistic requirements.
+ "-android-cloexec-dup", // found in SharedMemoryParcelable.cpp
+ "-bugprone-macro-parentheses", // found in SharedMemoryParcelable.h
+ "-bugprone-narrowing-conversions", // found in several interface from size_t to int32_t
+
+ "-google-readability-casting", // C++ casts not always necessary and may be verbose
+ "-google-readability-todo", // do not require TODO(info)
+ "-google-build-using-namespace", // Reenable and fix later.
+ "-google-global-names-in-headers", // found in several files
+
+ "-misc-non-private-member-variables-in-classes", // found in aidl generated files
+
+ "-performance-no-int-to-ptr", // found in SharedMemoryParcelable.h
+]
+
cc_library {
name: "libaaudio",
@@ -52,7 +111,7 @@
"libcutils",
"libutils",
"libbinder",
- "libpermission",
+ "framework-permission-aidl-cpp",
],
sanitize: {
@@ -64,6 +123,13 @@
symbol_file: "libaaudio.map.txt",
versions: ["28"],
},
+
+ tidy: true,
+ tidy_checks: tidy_errors,
+ tidy_checks_as_errors: tidy_errors,
+ tidy_flags: [
+ "-format-style=file",
+ ]
}
cc_library {
@@ -156,6 +222,13 @@
integer_overflow: true,
misc_undefined: ["bounds"],
},
+
+ tidy: true,
+ tidy_checks: tidy_errors,
+ tidy_checks_as_errors: tidy_errors,
+ tidy_flags: [
+ "-format-style=file",
+ ]
}
aidl_interface {
@@ -172,19 +245,14 @@
"binding/aidl/aaudio/IAAudioService.aidl",
],
imports: [
- "audio_common-aidl",
+ "audioclient-types-aidl",
"shared-file-region-aidl",
- "framework-permission-aidl"
+ "framework-permission-aidl",
],
backend:
{
- cpp: {
- enabled: true,
- },
java: {
- // TODO: need to have audio_common-aidl available in Java to enable
- // this.
- enabled: false,
+ sdk_version: "module_current",
},
},
}
diff --git a/media/libaaudio/src/binding/AAudioBinderClient.cpp b/media/libaaudio/src/binding/AAudioBinderClient.cpp
index fa5a2da..135bac3 100644
--- a/media/libaaudio/src/binding/AAudioBinderClient.cpp
+++ b/media/libaaudio/src/binding/AAudioBinderClient.cpp
@@ -36,13 +36,10 @@
using android::IServiceManager;
using android::defaultServiceManager;
using android::interface_cast;
-using android::IInterface;
using android::Mutex;
using android::ProcessState;
using android::sp;
using android::status_t;
-using android::wp;
-using android::binder::Status;
using namespace aaudio;
@@ -93,7 +90,7 @@
ALOGE("%s() - linkToDeath() returned %d", __func__, status);
}
aaudioService = interface_cast<IAAudioService>(binder);
- mAdapter.reset(new Adapter(aaudioService, mAAudioClient));
+ mAdapter = std::make_shared<Adapter>(aaudioService, mAAudioClient);
needToRegister = true;
// Make sure callbacks can be received by mAAudioClient
ProcessState::self()->startThreadPool();
diff --git a/media/libaaudio/src/binding/AAudioBinderClient.h b/media/libaaudio/src/binding/AAudioBinderClient.h
index 6a7b639..557ced5 100644
--- a/media/libaaudio/src/binding/AAudioBinderClient.h
+++ b/media/libaaudio/src/binding/AAudioBinderClient.h
@@ -108,7 +108,7 @@
return AAUDIO_ERROR_UNAVAILABLE;
}
- void onStreamChange(aaudio_handle_t handle, int32_t opcode, int32_t value) {
+ void onStreamChange(aaudio_handle_t /*handle*/, int32_t /*opcode*/, int32_t /*value*/) {
// TODO This is just a stub so we can have a client Binder to pass to the service.
// TODO Implemented in a later CL.
ALOGW("onStreamChange called!");
@@ -116,7 +116,7 @@
class AAudioClient : public android::IBinder::DeathRecipient, public BnAAudioClient {
public:
- AAudioClient(android::wp<AAudioBinderClient> aaudioBinderClient)
+ explicit AAudioClient(const android::wp<AAudioBinderClient>& aaudioBinderClient)
: mBinderClient(aaudioBinderClient) {
}
@@ -150,10 +150,10 @@
class Adapter : public AAudioBinderAdapter {
public:
Adapter(const android::sp<IAAudioService>& delegate,
- const android::sp<AAudioClient>& aaudioClient)
+ android::sp<AAudioClient> aaudioClient)
: AAudioBinderAdapter(delegate.get()),
mDelegate(delegate),
- mAAudioClient(aaudioClient) {}
+ mAAudioClient(std::move(aaudioClient)) {}
virtual ~Adapter() {
if (mDelegate != nullptr) {
diff --git a/media/libaaudio/src/binding/AAudioServiceInterface.h b/media/libaaudio/src/binding/AAudioServiceInterface.h
index 5d11512..bf94774 100644
--- a/media/libaaudio/src/binding/AAudioServiceInterface.h
+++ b/media/libaaudio/src/binding/AAudioServiceInterface.h
@@ -37,7 +37,7 @@
class AAudioServiceInterface {
public:
- AAudioServiceInterface() {};
+ AAudioServiceInterface() = default;
virtual ~AAudioServiceInterface() = default;
virtual void registerClient(const android::sp<IAAudioClient>& client) = 0;
diff --git a/media/libaaudio/src/binding/AAudioStreamConfiguration.cpp b/media/libaaudio/src/binding/AAudioStreamConfiguration.cpp
index 2d501ef..f28e0d6 100644
--- a/media/libaaudio/src/binding/AAudioStreamConfiguration.cpp
+++ b/media/libaaudio/src/binding/AAudioStreamConfiguration.cpp
@@ -27,7 +27,7 @@
using namespace aaudio;
-using android::media::audio::common::AudioFormat;
+using android::media::AudioFormatSys;
AAudioStreamConfiguration::AAudioStreamConfiguration(const StreamParameters& parcelable) {
setSamplesPerFrame(parcelable.samplesPerFrame);
@@ -69,7 +69,7 @@
static_assert(sizeof(aaudio_sharing_mode_t) == sizeof(result.sharingMode));
result.sharingMode = getSharingMode();
static_assert(sizeof(audio_format_t) == sizeof(result.audioFormat));
- result.audioFormat = static_cast<AudioFormat>(getFormat());
+ result.audioFormat = static_cast<AudioFormatSys>(getFormat());
static_assert(sizeof(aaudio_direction_t) == sizeof(result.direction));
result.direction = getDirection();
static_assert(sizeof(audio_usage_t) == sizeof(result.usage));
diff --git a/media/libaaudio/src/binding/AAudioStreamRequest.cpp b/media/libaaudio/src/binding/AAudioStreamRequest.cpp
index 8d90034..a4cc2bd 100644
--- a/media/libaaudio/src/binding/AAudioStreamRequest.cpp
+++ b/media/libaaudio/src/binding/AAudioStreamRequest.cpp
@@ -30,7 +30,7 @@
using namespace aaudio;
AAudioStreamRequest::AAudioStreamRequest(const StreamRequest& parcelable) :
- mConfiguration(std::move(parcelable.params)),
+ mConfiguration(parcelable.params),
mAttributionSource(parcelable.attributionSource),
mSharingModeMatchRequired(parcelable.sharingModeMatchRequired),
mInService(parcelable.inService) {
@@ -38,7 +38,7 @@
StreamRequest AAudioStreamRequest::parcelable() const {
StreamRequest result;
- result.params = std::move(mConfiguration).parcelable();
+ result.params = mConfiguration.parcelable();
result.attributionSource = mAttributionSource;
result.sharingModeMatchRequired = mSharingModeMatchRequired;
result.inService = mInService;
diff --git a/media/libaaudio/src/binding/AudioEndpointParcelable.cpp b/media/libaaudio/src/binding/AudioEndpointParcelable.cpp
index aa4ac27..dea3e4a 100644
--- a/media/libaaudio/src/binding/AudioEndpointParcelable.cpp
+++ b/media/libaaudio/src/binding/AudioEndpointParcelable.cpp
@@ -29,17 +29,15 @@
#include "binding/AudioEndpointParcelable.h"
using android::base::unique_fd;
-using android::media::SharedFileRegion;
-using android::NO_ERROR;
using android::status_t;
using namespace aaudio;
AudioEndpointParcelable::AudioEndpointParcelable(Endpoint&& parcelable)
- : mUpMessageQueueParcelable(std::move(parcelable.upMessageQueueParcelable)),
- mDownMessageQueueParcelable(std::move(parcelable.downMessageQueueParcelable)),
- mUpDataQueueParcelable(std::move(parcelable.upDataQueueParcelable)),
- mDownDataQueueParcelable(std::move(parcelable.downDataQueueParcelable)),
+ : mUpMessageQueueParcelable(parcelable.upMessageQueueParcelable),
+ mDownMessageQueueParcelable(parcelable.downMessageQueueParcelable),
+ mUpDataQueueParcelable(parcelable.upDataQueueParcelable),
+ mDownDataQueueParcelable(parcelable.downDataQueueParcelable),
mNumSharedMemories(parcelable.sharedMemories.size()) {
for (size_t i = 0; i < parcelable.sharedMemories.size() && i < MAX_SHARED_MEMORIES; ++i) {
// Re-construct.
@@ -56,10 +54,10 @@
Endpoint AudioEndpointParcelable::parcelable()&& {
Endpoint result;
- result.upMessageQueueParcelable = std::move(mUpMessageQueueParcelable).parcelable();
- result.downMessageQueueParcelable = std::move(mDownMessageQueueParcelable).parcelable();
- result.upDataQueueParcelable = std::move(mUpDataQueueParcelable).parcelable();
- result.downDataQueueParcelable = std::move(mDownDataQueueParcelable).parcelable();
+ result.upMessageQueueParcelable = mUpMessageQueueParcelable.parcelable();
+ result.downMessageQueueParcelable = mDownMessageQueueParcelable.parcelable();
+ result.upDataQueueParcelable = mUpDataQueueParcelable.parcelable();
+ result.downDataQueueParcelable = mDownDataQueueParcelable.parcelable();
result.sharedMemories.reserve(std::min(mNumSharedMemories, MAX_SHARED_MEMORIES));
for (size_t i = 0; i < mNumSharedMemories && i < MAX_SHARED_MEMORIES; ++i) {
result.sharedMemories.emplace_back(std::move(mSharedMemories[i]).parcelable());
diff --git a/media/libaaudio/src/binding/AudioEndpointParcelable.h b/media/libaaudio/src/binding/AudioEndpointParcelable.h
index 5237a1a..544aa92 100644
--- a/media/libaaudio/src/binding/AudioEndpointParcelable.h
+++ b/media/libaaudio/src/binding/AudioEndpointParcelable.h
@@ -43,7 +43,7 @@
// Ctor/assignment from a parcelable representation.
// Since the parcelable object owns unique FDs (for shared memory blocks), move semantics are
// provided to avoid the need to dupe.
- AudioEndpointParcelable(Endpoint&& parcelable);
+ explicit AudioEndpointParcelable(Endpoint&& parcelable);
AudioEndpointParcelable& operator=(Endpoint&& parcelable);
/**
diff --git a/media/libaaudio/src/binding/RingBufferParcelable.cpp b/media/libaaudio/src/binding/RingBufferParcelable.cpp
index a4b3cec..fa7ca72 100644
--- a/media/libaaudio/src/binding/RingBufferParcelable.cpp
+++ b/media/libaaudio/src/binding/RingBufferParcelable.cpp
@@ -30,9 +30,9 @@
using namespace aaudio;
RingBufferParcelable::RingBufferParcelable(const RingBuffer& parcelable)
- : mReadCounterParcelable(std::move(parcelable.readCounterParcelable)),
- mWriteCounterParcelable(std::move(parcelable.writeCounterParcelable)),
- mDataParcelable(std::move(parcelable.dataParcelable)),
+ : mReadCounterParcelable(parcelable.readCounterParcelable),
+ mWriteCounterParcelable(parcelable.writeCounterParcelable),
+ mDataParcelable(parcelable.dataParcelable),
mBytesPerFrame(parcelable.bytesPerFrame),
mFramesPerBurst(parcelable.framesPerBurst),
mCapacityInFrames(parcelable.capacityInFrames),
@@ -42,9 +42,9 @@
RingBuffer RingBufferParcelable::parcelable() const {
RingBuffer result;
- result.readCounterParcelable = std::move(mReadCounterParcelable).parcelable();
- result.writeCounterParcelable = std::move(mWriteCounterParcelable).parcelable();
- result.dataParcelable = std::move(mDataParcelable).parcelable();
+ result.readCounterParcelable = mReadCounterParcelable.parcelable();
+ result.writeCounterParcelable = mWriteCounterParcelable.parcelable();
+ result.dataParcelable = mDataParcelable.parcelable();
result.bytesPerFrame = mBytesPerFrame;
result.framesPerBurst = mFramesPerBurst;
result.capacityInFrames = mCapacityInFrames;
diff --git a/media/libaaudio/src/binding/SharedMemoryParcelable.cpp b/media/libaaudio/src/binding/SharedMemoryParcelable.cpp
index eef238f..3a49655 100644
--- a/media/libaaudio/src/binding/SharedMemoryParcelable.cpp
+++ b/media/libaaudio/src/binding/SharedMemoryParcelable.cpp
@@ -32,7 +32,6 @@
#include "binding/SharedMemoryParcelable.h"
using android::base::unique_fd;
-using android::NO_ERROR;
using android::status_t;
using android::media::SharedFileRegion;
@@ -78,7 +77,7 @@
}
aaudio_result_t SharedMemoryParcelable::resolveSharedMemory(const unique_fd& fd) {
- mResolvedAddress = (uint8_t *) mmap(0, mSizeInBytes, PROT_READ | PROT_WRITE,
+ mResolvedAddress = (uint8_t *) mmap(nullptr, mSizeInBytes, PROT_READ | PROT_WRITE,
MAP_SHARED, fd.get(), 0);
if (mResolvedAddress == MMAP_UNRESOLVED_ADDRESS) {
ALOGE("mmap() failed for fd = %d, nBytes = %" PRId64 ", errno = %s",
diff --git a/media/libaaudio/src/binding/SharedRegionParcelable.cpp b/media/libaaudio/src/binding/SharedRegionParcelable.cpp
index 56b99c0..6fa109b 100644
--- a/media/libaaudio/src/binding/SharedRegionParcelable.cpp
+++ b/media/libaaudio/src/binding/SharedRegionParcelable.cpp
@@ -29,10 +29,7 @@
#include "binding/SharedMemoryParcelable.h"
#include "binding/SharedRegionParcelable.h"
-using android::NO_ERROR;
using android::status_t;
-using android::Parcel;
-using android::Parcelable;
using namespace aaudio;
diff --git a/media/libaaudio/src/binding/aidl/aaudio/StreamParameters.aidl b/media/libaaudio/src/binding/aidl/aaudio/StreamParameters.aidl
index b7c4f70..d1ba9b3 100644
--- a/media/libaaudio/src/binding/aidl/aaudio/StreamParameters.aidl
+++ b/media/libaaudio/src/binding/aidl/aaudio/StreamParameters.aidl
@@ -16,14 +16,14 @@
package aaudio;
-import android.media.audio.common.AudioFormat;
+import android.media.AudioFormatSys;
parcelable StreamParameters {
int samplesPerFrame; // = AAUDIO_UNSPECIFIED;
int sampleRate; // = AAUDIO_UNSPECIFIED;
int deviceId; // = AAUDIO_UNSPECIFIED;
int /* aaudio_sharing_mode_t */ sharingMode; // = AAUDIO_SHARING_MODE_SHARED;
- AudioFormat audioFormat; // = AUDIO_FORMAT_DEFAULT;
+ AudioFormatSys audioFormat; // = AUDIO_FORMAT_DEFAULT;
int /* aaudio_direction_t */ direction; // = AAUDIO_DIRECTION_OUTPUT;
int /* aaudio_usage_t */ usage; // = AAUDIO_UNSPECIFIED;
int /* aaudio_content_type_t */ contentType; // = AAUDIO_UNSPECIFIED;
diff --git a/media/libaaudio/src/client/AudioEndpoint.cpp b/media/libaaudio/src/client/AudioEndpoint.cpp
index ebc9f2b..24888de 100644
--- a/media/libaaudio/src/client/AudioEndpoint.cpp
+++ b/media/libaaudio/src/client/AudioEndpoint.cpp
@@ -31,13 +31,6 @@
#define RIDICULOUSLY_LARGE_BUFFER_CAPACITY (256 * 1024)
#define RIDICULOUSLY_LARGE_FRAME_SIZE 4096
-AudioEndpoint::AudioEndpoint()
- : mFreeRunning(false)
- , mDataReadCounter(0)
- , mDataWriteCounter(0)
-{
-}
-
// TODO Consider moving to a method in RingBufferDescriptor
static aaudio_result_t AudioEndpoint_validateQueueDescriptor(const char *type,
const RingBufferDescriptor *descriptor) {
diff --git a/media/libaaudio/src/client/AudioEndpoint.h b/media/libaaudio/src/client/AudioEndpoint.h
index 4c8d60f..b3dbc20 100644
--- a/media/libaaudio/src/client/AudioEndpoint.h
+++ b/media/libaaudio/src/client/AudioEndpoint.h
@@ -34,7 +34,7 @@
class AudioEndpoint {
public:
- AudioEndpoint();
+ AudioEndpoint() = default;
/**
* Configure based on the EndPointDescriptor_t.
@@ -95,9 +95,9 @@
private:
std::unique_ptr<android::FifoBufferIndirect> mUpCommandQueue;
std::unique_ptr<android::FifoBufferIndirect> mDataQueue;
- bool mFreeRunning;
- android::fifo_counter_t mDataReadCounter; // only used if free-running
- android::fifo_counter_t mDataWriteCounter; // only used if free-running
+ bool mFreeRunning{false};
+ android::fifo_counter_t mDataReadCounter{0}; // only used if free-running
+ android::fifo_counter_t mDataWriteCounter{0}; // only used if free-running
};
} // namespace aaudio
diff --git a/media/libaaudio/src/client/AudioStreamInternal.cpp b/media/libaaudio/src/client/AudioStreamInternal.cpp
index cf2abe8..e584425 100644
--- a/media/libaaudio/src/client/AudioStreamInternal.cpp
+++ b/media/libaaudio/src/client/AudioStreamInternal.cpp
@@ -49,8 +49,6 @@
// This is needed to make sense of the logs more easily.
#define LOG_TAG (mInService ? "AudioStreamInternal_Service" : "AudioStreamInternal_Client")
-using android::Mutex;
-using android::WrappingBuffer;
using android::content::AttributionSourceState;
using namespace aaudio;
@@ -329,10 +327,10 @@
{
AudioStreamInternal *stream = (AudioStreamInternal *)context;
//LOGD("oboe_callback_thread, stream = %p", stream);
- if (stream != NULL) {
+ if (stream != nullptr) {
return stream->callbackLoop();
} else {
- return NULL;
+ return nullptr;
}
}
@@ -421,7 +419,7 @@
if (isDataCallbackSet()
&& (isActive() || getState() == AAUDIO_STREAM_STATE_DISCONNECTED)) {
mCallbackEnabled.store(false);
- aaudio_result_t result = joinThread_l(NULL); // may temporarily unlock mStreamLock
+ aaudio_result_t result = joinThread_l(nullptr); // may temporarily unlock mStreamLock
if (result == AAUDIO_ERROR_INVALID_HANDLE) {
ALOGD("%s() INVALID_HANDLE, stream was probably stolen", __func__);
result = AAUDIO_OK;
@@ -508,7 +506,7 @@
return result;
}
-aaudio_result_t AudioStreamInternal::getTimestamp(clockid_t clockId,
+aaudio_result_t AudioStreamInternal::getTimestamp(clockid_t /*clockId*/,
int64_t *framePosition,
int64_t *timeNanoseconds) {
// Generated in server and passed to client. Return latest.
diff --git a/media/libaaudio/src/client/AudioStreamInternal.h b/media/libaaudio/src/client/AudioStreamInternal.h
index fbe4c13..eab1382 100644
--- a/media/libaaudio/src/client/AudioStreamInternal.h
+++ b/media/libaaudio/src/client/AudioStreamInternal.h
@@ -116,7 +116,7 @@
virtual void prepareBuffersForStart() {}
- virtual void advanceClientToMatchServerPosition(int32_t serverMargin = 0) = 0;
+ virtual void advanceClientToMatchServerPosition(int32_t serverMargin) = 0;
virtual void onFlushFromServer() {}
diff --git a/media/libaaudio/src/client/AudioStreamInternalCapture.cpp b/media/libaaudio/src/client/AudioStreamInternalCapture.cpp
index 2da5406..1efccb1 100644
--- a/media/libaaudio/src/client/AudioStreamInternalCapture.cpp
+++ b/media/libaaudio/src/client/AudioStreamInternalCapture.cpp
@@ -46,8 +46,6 @@
}
-AudioStreamInternalCapture::~AudioStreamInternalCapture() {}
-
void AudioStreamInternalCapture::advanceClientToMatchServerPosition(int32_t serverMargin) {
int64_t readCounter = mAudioEndpoint->getDataReadCounter();
int64_t writeCounter = mAudioEndpoint->getDataWriteCounter() + serverMargin;
@@ -109,7 +107,7 @@
if (mNeedCatchUp.isRequested()) {
// Catch an MMAP pointer that is already advancing.
// This will avoid initial underruns caused by a slow cold start.
- advanceClientToMatchServerPosition();
+ advanceClientToMatchServerPosition(0 /*serverMargin*/);
mNeedCatchUp.acknowledge();
}
@@ -228,7 +226,7 @@
void *AudioStreamInternalCapture::callbackLoop() {
aaudio_result_t result = AAUDIO_OK;
aaudio_data_callback_result_t callbackResult = AAUDIO_CALLBACK_RESULT_CONTINUE;
- if (!isDataCallbackSet()) return NULL;
+ if (!isDataCallbackSet()) return nullptr;
// result might be a frame count
while (mCallbackEnabled.load() && isActive() && (result >= 0)) {
@@ -260,5 +258,5 @@
ALOGD("callbackLoop() exiting, result = %d, isActive() = %d",
result, (int) isActive());
- return NULL;
+ return nullptr;
}
diff --git a/media/libaaudio/src/client/AudioStreamInternalCapture.h b/media/libaaudio/src/client/AudioStreamInternalCapture.h
index 251a7f2..87017de 100644
--- a/media/libaaudio/src/client/AudioStreamInternalCapture.h
+++ b/media/libaaudio/src/client/AudioStreamInternalCapture.h
@@ -28,8 +28,9 @@
class AudioStreamInternalCapture : public AudioStreamInternal {
public:
- AudioStreamInternalCapture(AAudioServiceInterface &serviceInterface, bool inService = false);
- virtual ~AudioStreamInternalCapture();
+ explicit AudioStreamInternalCapture(AAudioServiceInterface &serviceInterface,
+ bool inService = false);
+ virtual ~AudioStreamInternalCapture() = default;
aaudio_result_t read(void *buffer,
int32_t numFrames,
@@ -45,7 +46,7 @@
}
protected:
- void advanceClientToMatchServerPosition(int32_t serverOffset = 0) override;
+ void advanceClientToMatchServerPosition(int32_t serverOffset) override;
/**
* Low level data processing that will not block. It will just read or write as much as it can.
diff --git a/media/libaaudio/src/client/AudioStreamInternalPlay.cpp b/media/libaaudio/src/client/AudioStreamInternalPlay.cpp
index 71bde90..5921799 100644
--- a/media/libaaudio/src/client/AudioStreamInternalPlay.cpp
+++ b/media/libaaudio/src/client/AudioStreamInternalPlay.cpp
@@ -44,8 +44,6 @@
}
-AudioStreamInternalPlay::~AudioStreamInternalPlay() {}
-
constexpr int kRampMSec = 10; // time to apply a change in volume
aaudio_result_t AudioStreamInternalPlay::open(const AudioStreamBuilder &builder) {
@@ -115,7 +113,7 @@
}
void AudioStreamInternalPlay::onFlushFromServer() {
- advanceClientToMatchServerPosition();
+ advanceClientToMatchServerPosition(0 /*serverMargin*/);
}
// Write the data, block if needed and timeoutMillis > 0
@@ -281,7 +279,7 @@
ALOGD("%s() entering >>>>>>>>>>>>>>>", __func__);
aaudio_result_t result = AAUDIO_OK;
aaudio_data_callback_result_t callbackResult = AAUDIO_CALLBACK_RESULT_CONTINUE;
- if (!isDataCallbackSet()) return NULL;
+ if (!isDataCallbackSet()) return nullptr;
int64_t timeoutNanos = calculateReasonableTimeout(mCallbackFrames);
// result might be a frame count
@@ -309,7 +307,7 @@
ALOGD("%s() exiting, result = %d, isActive() = %d <<<<<<<<<<<<<<",
__func__, result, (int) isActive());
- return NULL;
+ return nullptr;
}
//------------------------------------------------------------------------------
diff --git a/media/libaaudio/src/client/AudioStreamInternalPlay.h b/media/libaaudio/src/client/AudioStreamInternalPlay.h
index 03c957d..e761807 100644
--- a/media/libaaudio/src/client/AudioStreamInternalPlay.h
+++ b/media/libaaudio/src/client/AudioStreamInternalPlay.h
@@ -30,8 +30,9 @@
class AudioStreamInternalPlay : public AudioStreamInternal {
public:
- AudioStreamInternalPlay(AAudioServiceInterface &serviceInterface, bool inService = false);
- virtual ~AudioStreamInternalPlay();
+ explicit AudioStreamInternalPlay(AAudioServiceInterface &serviceInterface,
+ bool inService = false);
+ virtual ~AudioStreamInternalPlay() = default;
aaudio_result_t open(const AudioStreamBuilder &builder) override;
@@ -66,7 +67,7 @@
void prepareBuffersForStart() override;
- void advanceClientToMatchServerPosition(int32_t serverMargin = 0) override;
+ void advanceClientToMatchServerPosition(int32_t serverMargin) override;
void onFlushFromServer() override;
diff --git a/media/libaaudio/src/client/IsochronousClockModel.cpp b/media/libaaudio/src/client/IsochronousClockModel.cpp
index f0dcd44..6921271 100644
--- a/media/libaaudio/src/client/IsochronousClockModel.cpp
+++ b/media/libaaudio/src/client/IsochronousClockModel.cpp
@@ -43,14 +43,7 @@
// and dumped to the log when the stream is stopped.
IsochronousClockModel::IsochronousClockModel()
- : mMarkerFramePosition(0)
- , mMarkerNanoTime(0)
- , mSampleRate(48000)
- , mFramesPerBurst(48)
- , mBurstPeriodNanos(0) // this will be updated before use
- , mMaxMeasuredLatenessNanos(0)
- , mLatenessForDriftNanos(kInitialLatenessForDriftNanos)
- , mState(STATE_STOPPED)
+ : mLatenessForDriftNanos(kInitialLatenessForDriftNanos)
{
if ((AAudioProperty_getLogMask() & AAUDIO_LOG_CLOCK_MODEL_HISTOGRAM) != 0) {
mHistogramMicros = std::make_unique<Histogram>(kHistogramBinCount,
diff --git a/media/libaaudio/src/client/IsochronousClockModel.h b/media/libaaudio/src/client/IsochronousClockModel.h
index 6280013..3007237 100644
--- a/media/libaaudio/src/client/IsochronousClockModel.h
+++ b/media/libaaudio/src/client/IsochronousClockModel.h
@@ -149,16 +149,16 @@
static constexpr int32_t kHistogramBinWidthMicros = 50;
static constexpr int32_t kHistogramBinCount = 128;
- int64_t mMarkerFramePosition; // Estimated HW position.
- int64_t mMarkerNanoTime; // Estimated HW time.
- int32_t mSampleRate;
- int32_t mFramesPerBurst; // number of frames transferred at one time.
- int32_t mBurstPeriodNanos; // Time between HW bursts.
+ int64_t mMarkerFramePosition{0}; // Estimated HW position.
+ int64_t mMarkerNanoTime{0}; // Estimated HW time.
+ int32_t mSampleRate{48000};
+ int32_t mFramesPerBurst{48}; // number of frames transferred at one time.
+ int32_t mBurstPeriodNanos{0}; // Time between HW bursts.
// Includes mBurstPeriodNanos because we sample randomly over time.
- int32_t mMaxMeasuredLatenessNanos;
+ int32_t mMaxMeasuredLatenessNanos{0};
// Threshold for lateness that triggers a drift later in time.
int32_t mLatenessForDriftNanos;
- clock_model_state_t mState; // State machine handles startup sequence.
+ clock_model_state_t mState{STATE_STOPPED}; // State machine handles startup sequence.
int32_t mTimestampCount = 0; // For logging.
diff --git a/media/libaaudio/src/core/AAudioStreamParameters.cpp b/media/libaaudio/src/core/AAudioStreamParameters.cpp
index acfac24..4d84474 100644
--- a/media/libaaudio/src/core/AAudioStreamParameters.cpp
+++ b/media/libaaudio/src/core/AAudioStreamParameters.cpp
@@ -30,9 +30,6 @@
// HDMI supports up to 32 channels at 1536000 Hz.
#define SAMPLE_RATE_HZ_MAX 1600000
-AAudioStreamParameters::AAudioStreamParameters() {}
-AAudioStreamParameters::~AAudioStreamParameters() {}
-
void AAudioStreamParameters::copyFrom(const AAudioStreamParameters &other) {
mSamplesPerFrame = other.mSamplesPerFrame;
mSampleRate = other.mSampleRate;
diff --git a/media/libaaudio/src/core/AAudioStreamParameters.h b/media/libaaudio/src/core/AAudioStreamParameters.h
index 5737052..0349ffc 100644
--- a/media/libaaudio/src/core/AAudioStreamParameters.h
+++ b/media/libaaudio/src/core/AAudioStreamParameters.h
@@ -26,8 +26,8 @@
class AAudioStreamParameters {
public:
- AAudioStreamParameters();
- virtual ~AAudioStreamParameters();
+ AAudioStreamParameters() = default;
+ virtual ~AAudioStreamParameters() = default;
int32_t getDeviceId() const {
return mDeviceId;
@@ -141,7 +141,7 @@
}
// TODO b/182392769: reexamine if Identity can be used
- void setOpPackageName(const std::optional<std::string> opPackageName) {
+ void setOpPackageName(const std::optional<std::string>& opPackageName) {
mOpPackageName = opPackageName;
}
@@ -149,7 +149,7 @@
return mAttributionTag;
}
- void setAttributionTag(const std::optional<std::string> attributionTag) {
+ void setAttributionTag(const std::optional<std::string>& attributionTag) {
mAttributionTag = attributionTag;
}
diff --git a/media/libaaudio/src/core/AudioGlobal.h b/media/libaaudio/src/core/AudioGlobal.h
index 1e88d15..6c22744 100644
--- a/media/libaaudio/src/core/AudioGlobal.h
+++ b/media/libaaudio/src/core/AudioGlobal.h
@@ -31,7 +31,8 @@
const char* AudioGlobal_convertResultToText(aaudio_result_t returnCode);
const char* AudioGlobal_convertSharingModeToText(aaudio_sharing_mode_t mode);
const char* AudioGlobal_convertStreamStateToText(aaudio_stream_state_t state);
-}
+
+} // namespace aaudio
#endif // AAUDIO_AUDIOGLOBAL_H
diff --git a/media/libaaudio/src/core/AudioStream.h b/media/libaaudio/src/core/AudioStream.h
index 2b45ed3..0068508 100644
--- a/media/libaaudio/src/core/AudioStream.h
+++ b/media/libaaudio/src/core/AudioStream.h
@@ -425,7 +425,7 @@
// PlayerBase allows the system to control the stream volume.
class MyPlayerBase : public android::PlayerBase {
public:
- MyPlayerBase() {};
+ MyPlayerBase() = default;
virtual ~MyPlayerBase() = default;
@@ -554,7 +554,7 @@
* @param numFrames
* @return original pointer or the conversion buffer
*/
- virtual const void * maybeConvertDeviceData(const void *audioData, int32_t numFrames) {
+ virtual const void * maybeConvertDeviceData(const void *audioData, int32_t /*numFrames*/) {
return audioData;
}
diff --git a/media/libaaudio/src/core/AudioStreamBuilder.cpp b/media/libaaudio/src/core/AudioStreamBuilder.cpp
index e015592..a3e42e9 100644
--- a/media/libaaudio/src/core/AudioStreamBuilder.cpp
+++ b/media/libaaudio/src/core/AudioStreamBuilder.cpp
@@ -53,16 +53,10 @@
/*
* AudioStreamBuilder
*/
-AudioStreamBuilder::AudioStreamBuilder() {
-}
-
-AudioStreamBuilder::~AudioStreamBuilder() {
-}
-
static aaudio_result_t builder_createStream(aaudio_direction_t direction,
- aaudio_sharing_mode_t sharingMode,
- bool tryMMap,
- android::sp<AudioStream> &stream) {
+ aaudio_sharing_mode_t /*sharingMode*/,
+ bool tryMMap,
+ android::sp<AudioStream> &stream) {
aaudio_result_t result = AAUDIO_OK;
switch (direction) {
diff --git a/media/libaaudio/src/core/AudioStreamBuilder.h b/media/libaaudio/src/core/AudioStreamBuilder.h
index 9f93341..f91c25a 100644
--- a/media/libaaudio/src/core/AudioStreamBuilder.h
+++ b/media/libaaudio/src/core/AudioStreamBuilder.h
@@ -31,9 +31,9 @@
*/
class AudioStreamBuilder : public AAudioStreamParameters {
public:
- AudioStreamBuilder();
+ AudioStreamBuilder() = default;
- ~AudioStreamBuilder();
+ ~AudioStreamBuilder() = default;
bool isSharingModeMatchRequired() const {
return mSharingModeMatchRequired;
diff --git a/media/libaaudio/src/fifo/FifoBuffer.h b/media/libaaudio/src/fifo/FifoBuffer.h
index 37548f0..7b0aca1 100644
--- a/media/libaaudio/src/fifo/FifoBuffer.h
+++ b/media/libaaudio/src/fifo/FifoBuffer.h
@@ -38,7 +38,7 @@
class FifoBuffer {
public:
- FifoBuffer(int32_t bytesPerFrame);
+ explicit FifoBuffer(int32_t bytesPerFrame);
virtual ~FifoBuffer() = default;
@@ -162,6 +162,6 @@
uint8_t *mExternalStorage = nullptr;
};
-} // android
+} // namespace android
#endif //FIFO_FIFO_BUFFER_H
diff --git a/media/libaaudio/src/fifo/FifoController.h b/media/libaaudio/src/fifo/FifoController.h
index 057a94e..e15d444 100644
--- a/media/libaaudio/src/fifo/FifoController.h
+++ b/media/libaaudio/src/fifo/FifoController.h
@@ -36,7 +36,7 @@
, mWriteCounter(0)
{}
- virtual ~FifoController() {}
+ virtual ~FifoController() = default;
// TODO review use of memory barriers, probably incorrect
virtual fifo_counter_t getReadCounter() override {
@@ -57,6 +57,6 @@
std::atomic<fifo_counter_t> mWriteCounter;
};
-} // android
+} // namespace android
#endif //FIFO_FIFO_CONTROLLER_H
diff --git a/media/libaaudio/src/fifo/FifoControllerBase.cpp b/media/libaaudio/src/fifo/FifoControllerBase.cpp
index 1dece0e..ad6d041 100644
--- a/media/libaaudio/src/fifo/FifoControllerBase.cpp
+++ b/media/libaaudio/src/fifo/FifoControllerBase.cpp
@@ -29,9 +29,6 @@
{
}
-FifoControllerBase::~FifoControllerBase() {
-}
-
fifo_frames_t FifoControllerBase::getFullFramesAvailable() {
fifo_frames_t temp = 0;
__builtin_sub_overflow(getWriteCounter(), getReadCounter(), &temp);
diff --git a/media/libaaudio/src/fifo/FifoControllerBase.h b/media/libaaudio/src/fifo/FifoControllerBase.h
index 1edb8a3..2a6173b 100644
--- a/media/libaaudio/src/fifo/FifoControllerBase.h
+++ b/media/libaaudio/src/fifo/FifoControllerBase.h
@@ -43,7 +43,7 @@
*/
FifoControllerBase(fifo_frames_t capacity, fifo_frames_t threshold);
- virtual ~FifoControllerBase();
+ virtual ~FifoControllerBase() = default;
// Abstract methods to be implemented in subclasses.
/**
@@ -123,6 +123,6 @@
fifo_frames_t mThreshold;
};
-} // android
+} // namespace android
#endif // FIFO_FIFO_CONTROLLER_BASE_H
diff --git a/media/libaaudio/src/fifo/FifoControllerIndirect.h b/media/libaaudio/src/fifo/FifoControllerIndirect.h
index ec48e57..a59225a 100644
--- a/media/libaaudio/src/fifo/FifoControllerIndirect.h
+++ b/media/libaaudio/src/fifo/FifoControllerIndirect.h
@@ -44,7 +44,7 @@
setReadCounter(0);
setWriteCounter(0);
}
- virtual ~FifoControllerIndirect() {};
+ virtual ~FifoControllerIndirect() = default;
// TODO review use of memory barriers, probably incorrect
virtual fifo_counter_t getReadCounter() override {
@@ -68,6 +68,6 @@
std::atomic<fifo_counter_t> * mWriteCounterAddress;
};
-} // android
+} // namespace android
#endif //FIFO_FIFO_CONTROLLER_INDIRECT_H
diff --git a/media/libaaudio/src/flowgraph/AudioProcessorBase.cpp b/media/libaaudio/src/flowgraph/AudioProcessorBase.cpp
index 5667fdb..d8ffd00 100644
--- a/media/libaaudio/src/flowgraph/AudioProcessorBase.cpp
+++ b/media/libaaudio/src/flowgraph/AudioProcessorBase.cpp
@@ -34,8 +34,7 @@
int32_t samplesPerFrame,
int32_t framesPerBlock)
: AudioPort(parent, samplesPerFrame)
- , mFramesPerBlock(framesPerBlock)
- , mSampleBlock(NULL) {
+ , mFramesPerBlock(framesPerBlock) {
int32_t numFloats = framesPerBlock * getSamplesPerFrame();
mSampleBlock = new float[numFloats]{0.0f};
}
@@ -61,13 +60,13 @@
/***************************************************************************/
int32_t AudioFloatInputPort::pullData(int64_t framePosition, int32_t numFrames) {
- return (mConnected == NULL)
+ return (mConnected == nullptr)
? std::min(getFramesPerBlock(), numFrames)
: mConnected->pullData(framePosition, numFrames);
}
float *AudioFloatInputPort::getBlock() {
- if (mConnected == NULL) {
+ if (mConnected == nullptr) {
return AudioFloatBlockPort::getBlock(); // loaded using setValue()
} else {
return mConnected->getBlock();
diff --git a/media/libaaudio/src/flowgraph/MonoToMultiConverter.cpp b/media/libaaudio/src/flowgraph/MonoToMultiConverter.cpp
index 78aad52..c6fcac6 100644
--- a/media/libaaudio/src/flowgraph/MonoToMultiConverter.cpp
+++ b/media/libaaudio/src/flowgraph/MonoToMultiConverter.cpp
@@ -26,8 +26,6 @@
, output(*this, channelCount) {
}
-MonoToMultiConverter::~MonoToMultiConverter() { }
-
int32_t MonoToMultiConverter::onProcess(int64_t framePosition, int32_t numFrames) {
int32_t framesToProcess = input.pullData(framePosition, numFrames);
diff --git a/media/libaaudio/src/flowgraph/MonoToMultiConverter.h b/media/libaaudio/src/flowgraph/MonoToMultiConverter.h
index 34d53c7..5058ae0 100644
--- a/media/libaaudio/src/flowgraph/MonoToMultiConverter.h
+++ b/media/libaaudio/src/flowgraph/MonoToMultiConverter.h
@@ -29,7 +29,7 @@
public:
explicit MonoToMultiConverter(int32_t channelCount);
- virtual ~MonoToMultiConverter();
+ virtual ~MonoToMultiConverter() = default;
int32_t onProcess(int64_t framePosition, int32_t numFrames) override;
diff --git a/media/libaaudio/src/flowgraph/SourceFloat.cpp b/media/libaaudio/src/flowgraph/SourceFloat.cpp
index 4bb674f..5b3a51e 100644
--- a/media/libaaudio/src/flowgraph/SourceFloat.cpp
+++ b/media/libaaudio/src/flowgraph/SourceFloat.cpp
@@ -25,7 +25,7 @@
: AudioSource(channelCount) {
}
-int32_t SourceFloat::onProcess(int64_t framePosition, int32_t numFrames) {
+int32_t SourceFloat::onProcess(int64_t /*framePosition*/, int32_t numFrames) {
float *outputBuffer = output.getBlock();
int32_t channelCount = output.getSamplesPerFrame();
diff --git a/media/libaaudio/src/flowgraph/SourceI16.cpp b/media/libaaudio/src/flowgraph/SourceI16.cpp
index c3fcec2..a645cc2 100644
--- a/media/libaaudio/src/flowgraph/SourceI16.cpp
+++ b/media/libaaudio/src/flowgraph/SourceI16.cpp
@@ -30,7 +30,7 @@
: AudioSource(channelCount) {
}
-int32_t SourceI16::onProcess(int64_t framePosition, int32_t numFrames) {
+int32_t SourceI16::onProcess(int64_t /*framePosition*/, int32_t numFrames) {
float *floatData = output.getBlock();
int32_t channelCount = output.getSamplesPerFrame();
diff --git a/media/libaaudio/src/flowgraph/SourceI24.cpp b/media/libaaudio/src/flowgraph/SourceI24.cpp
index 097954e..50fb98e 100644
--- a/media/libaaudio/src/flowgraph/SourceI24.cpp
+++ b/media/libaaudio/src/flowgraph/SourceI24.cpp
@@ -32,7 +32,7 @@
: AudioSource(channelCount) {
}
-int32_t SourceI24::onProcess(int64_t framePosition, int32_t numFrames) {
+int32_t SourceI24::onProcess(int64_t /*framePosition*/, int32_t numFrames) {
float *floatData = output.getBlock();
int32_t channelCount = output.getSamplesPerFrame();
diff --git a/media/libaaudio/src/flowgraph/SourceI32.cpp b/media/libaaudio/src/flowgraph/SourceI32.cpp
index e8177ad..95bfd8f 100644
--- a/media/libaaudio/src/flowgraph/SourceI32.cpp
+++ b/media/libaaudio/src/flowgraph/SourceI32.cpp
@@ -30,7 +30,7 @@
: AudioSource(channelCount) {
}
-int32_t SourceI32::onProcess(int64_t framePosition, int32_t numFrames) {
+int32_t SourceI32::onProcess(int64_t /*framePosition*/, int32_t numFrames) {
float *floatData = output.getBlock();
int32_t channelCount = output.getSamplesPerFrame();
diff --git a/media/libaaudio/src/legacy/AudioStreamLegacy.cpp b/media/libaaudio/src/legacy/AudioStreamLegacy.cpp
index 60eb73a..b6bd0e1 100644
--- a/media/libaaudio/src/legacy/AudioStreamLegacy.cpp
+++ b/media/libaaudio/src/legacy/AudioStreamLegacy.cpp
@@ -37,9 +37,6 @@
: AudioStream() {
}
-AudioStreamLegacy::~AudioStreamLegacy() {
-}
-
// Called from AudioTrack.cpp or AudioRecord.cpp
static void AudioStreamLegacy_callback(int event, void* userData, void *info) {
AudioStreamLegacy *streamLegacy = (AudioStreamLegacy *) userData;
diff --git a/media/libaaudio/src/legacy/AudioStreamLegacy.h b/media/libaaudio/src/legacy/AudioStreamLegacy.h
index 88ef270..d9ba990 100644
--- a/media/libaaudio/src/legacy/AudioStreamLegacy.h
+++ b/media/libaaudio/src/legacy/AudioStreamLegacy.h
@@ -60,7 +60,7 @@
public:
AudioStreamLegacy();
- virtual ~AudioStreamLegacy();
+ virtual ~AudioStreamLegacy() = default;
aaudio_legacy_callback_t getLegacyCallback();
diff --git a/media/libaaudio/src/legacy/AudioStreamRecord.cpp b/media/libaaudio/src/legacy/AudioStreamRecord.cpp
index dc66742..20b909a 100644
--- a/media/libaaudio/src/legacy/AudioStreamRecord.cpp
+++ b/media/libaaudio/src/legacy/AudioStreamRecord.cpp
@@ -505,7 +505,7 @@
return (aaudio_result_t) framesRead;
}
-aaudio_result_t AudioStreamRecord::setBufferSize(int32_t requestedFrames)
+aaudio_result_t AudioStreamRecord::setBufferSize(int32_t /*requestedFrames*/)
{
return getBufferSize();
}
diff --git a/media/libaaudio/src/legacy/AudioStreamTrack.cpp b/media/libaaudio/src/legacy/AudioStreamTrack.cpp
index 1d412c0..62f583c 100644
--- a/media/libaaudio/src/legacy/AudioStreamTrack.cpp
+++ b/media/libaaudio/src/legacy/AudioStreamTrack.cpp
@@ -162,11 +162,11 @@
callback,
callbackData,
notificationFrames,
- 0, // DEFAULT sharedBuffer*/,
+ nullptr, // DEFAULT sharedBuffer*/,
false, // DEFAULT threadCanCallJava
sessionId,
streamTransferType,
- NULL, // DEFAULT audio_offload_info_t
+ nullptr, // DEFAULT audio_offload_info_t
AttributionSourceState(), // DEFAULT uid and pid
&attributes,
// WARNING - If doNotReconnect set true then audio stops after plugging and unplugging
diff --git a/media/libaaudio/src/utility/AAudioUtilities.h b/media/libaaudio/src/utility/AAudioUtilities.h
index 82eb77d..ee8cfd2 100644
--- a/media/libaaudio/src/utility/AAudioUtilities.h
+++ b/media/libaaudio/src/utility/AAudioUtilities.h
@@ -198,7 +198,7 @@
* @return true if f() eventually returns true.
*/
static inline bool AAudio_tryUntilTrue(
- std::function<bool()> f, int times, int sleepMs) {
+ const std::function<bool()>& f, int times, int sleepMs) {
static const useconds_t US_PER_MS = 1000;
sleepMs = std::max(sleepMs, 0);
@@ -270,9 +270,7 @@
class Timestamp {
public:
- Timestamp()
- : mPosition(0)
- , mNanoseconds(0) {}
+ Timestamp() = default;
Timestamp(int64_t position, int64_t nanoseconds)
: mPosition(position)
, mNanoseconds(nanoseconds) {}
@@ -283,8 +281,8 @@
private:
// These cannot be const because we need to implement the copy assignment operator.
- int64_t mPosition;
- int64_t mNanoseconds;
+ int64_t mPosition{0};
+ int64_t mNanoseconds{0};
};
diff --git a/media/libaaudio/src/utility/FixedBlockAdapter.h b/media/libaaudio/src/utility/FixedBlockAdapter.h
index 4dc7e68..290e473 100644
--- a/media/libaaudio/src/utility/FixedBlockAdapter.h
+++ b/media/libaaudio/src/utility/FixedBlockAdapter.h
@@ -35,7 +35,7 @@
class FixedBlockAdapter
{
public:
- FixedBlockAdapter(FixedBlockProcessor &fixedBlockProcessor)
+ explicit FixedBlockAdapter(FixedBlockProcessor &fixedBlockProcessor)
: mFixedBlockProcessor(fixedBlockProcessor) {}
virtual ~FixedBlockAdapter() = default;
diff --git a/media/libaaudio/src/utility/FixedBlockReader.h b/media/libaaudio/src/utility/FixedBlockReader.h
index 128dd52..dc82416 100644
--- a/media/libaaudio/src/utility/FixedBlockReader.h
+++ b/media/libaaudio/src/utility/FixedBlockReader.h
@@ -30,7 +30,7 @@
class FixedBlockReader : public FixedBlockAdapter
{
public:
- FixedBlockReader(FixedBlockProcessor &fixedBlockProcessor);
+ explicit FixedBlockReader(FixedBlockProcessor &fixedBlockProcessor);
virtual ~FixedBlockReader() = default;
diff --git a/media/libaaudio/src/utility/FixedBlockWriter.h b/media/libaaudio/src/utility/FixedBlockWriter.h
index f1d917c..3e89b5d 100644
--- a/media/libaaudio/src/utility/FixedBlockWriter.h
+++ b/media/libaaudio/src/utility/FixedBlockWriter.h
@@ -28,7 +28,7 @@
class FixedBlockWriter : public FixedBlockAdapter
{
public:
- FixedBlockWriter(FixedBlockProcessor &fixedBlockProcessor);
+ explicit FixedBlockWriter(FixedBlockProcessor &fixedBlockProcessor);
virtual ~FixedBlockWriter() = default;
diff --git a/media/libaaudio/src/utility/MonotonicCounter.h b/media/libaaudio/src/utility/MonotonicCounter.h
index 63add4e..313ccbd 100644
--- a/media/libaaudio/src/utility/MonotonicCounter.h
+++ b/media/libaaudio/src/utility/MonotonicCounter.h
@@ -30,8 +30,8 @@
class MonotonicCounter {
public:
- MonotonicCounter() {};
- virtual ~MonotonicCounter() {};
+ MonotonicCounter() = default;
+ virtual ~MonotonicCounter() = default;
/**
* @return current value of the counter
diff --git a/media/libaudioclient/AidlConversion.cpp b/media/libaudioclient/AidlConversion.cpp
index 321e7f9..0e98e5d 100644
--- a/media/libaudioclient/AidlConversion.cpp
+++ b/media/libaudioclient/AidlConversion.cpp
@@ -273,18 +273,14 @@
enumToMask_index<int32_t, media::AudioPortConfigType>);
}
-ConversionResult<audio_channel_mask_t> aidl2legacy_int32_t_audio_channel_mask_t(int32_t aidl) {
- // TODO(ytai): should we convert bit-by-bit?
- // One problem here is that the representation is both opaque and is different based on the
- // context (input vs. output). Can determine based on type and role, as per useInChannelMask().
+ConversionResult<audio_channel_mask_t> aidl2legacy_AudioChannelMask_audio_channel_mask_t(
+ media::AudioChannelMask aidl) {
return convertReinterpret<audio_channel_mask_t>(aidl);
}
-ConversionResult<int32_t> legacy2aidl_audio_channel_mask_t_int32_t(audio_channel_mask_t legacy) {
- // TODO(ytai): should we convert bit-by-bit?
- // One problem here is that the representation is both opaque and is different based on the
- // context (input vs. output). Can determine based on type and role, as per useInChannelMask().
- return convertReinterpret<int32_t>(legacy);
+ConversionResult<media::AudioChannelMask> legacy2aidl_audio_channel_mask_t_AudioChannelMask(
+ audio_channel_mask_t legacy) {
+ return convertReinterpret<media::AudioChannelMask>(legacy);
}
ConversionResult<audio_io_config_event> aidl2legacy_AudioIoConfigEvent_audio_io_config_event(
@@ -394,17 +390,17 @@
}
ConversionResult<audio_format_t> aidl2legacy_AudioFormat_audio_format_t(
- media::audio::common::AudioFormat aidl) {
- // This relies on AudioFormat being kept in sync with audio_format_t.
- static_assert(sizeof(media::audio::common::AudioFormat) == sizeof(audio_format_t));
+ media::AudioFormatSys aidl) {
+ // This relies on AudioFormatSys being kept in sync with audio_format_t.
+ static_assert(sizeof(media::AudioFormatSys) == sizeof(audio_format_t));
return static_cast<audio_format_t>(aidl);
}
-ConversionResult<media::audio::common::AudioFormat> legacy2aidl_audio_format_t_AudioFormat(
+ConversionResult<media::AudioFormatSys> legacy2aidl_audio_format_t_AudioFormat(
audio_format_t legacy) {
- // This relies on AudioFormat being kept in sync with audio_format_t.
- static_assert(sizeof(media::audio::common::AudioFormat) == sizeof(audio_format_t));
- return static_cast<media::audio::common::AudioFormat>(legacy);
+ // This relies on AudioFormatSys being kept in sync with audio_format_t.
+ static_assert(sizeof(media::AudioFormatSys) == sizeof(audio_format_t));
+ return static_cast<media::AudioFormatSys>(legacy);
}
ConversionResult<audio_gain_mode_t> aidl2legacy_AudioGainMode_audio_gain_mode_t(media::AudioGainMode aidl) {
@@ -465,7 +461,7 @@
legacy.index = VALUE_OR_RETURN(convertIntegral<int>(aidl.index));
legacy.mode = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_gain_mode_t_mask(aidl.mode));
legacy.channel_mask =
- VALUE_OR_RETURN(aidl2legacy_int32_t_audio_channel_mask_t(aidl.channelMask));
+ VALUE_OR_RETURN(aidl2legacy_AudioChannelMask_audio_channel_mask_t(aidl.channelMask));
const bool isInput = VALUE_OR_RETURN(direction(role, type)) == Direction::INPUT;
const bool isJoint = bitmaskIsSet(aidl.mode, media::AudioGainMode::JOINT);
size_t numValues = isJoint ? 1
@@ -487,7 +483,7 @@
aidl.index = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.index));
aidl.mode = VALUE_OR_RETURN(legacy2aidl_audio_gain_mode_t_int32_t_mask(legacy.mode));
aidl.channelMask =
- VALUE_OR_RETURN(legacy2aidl_audio_channel_mask_t_int32_t(legacy.channel_mask));
+ VALUE_OR_RETURN(legacy2aidl_audio_channel_mask_t_AudioChannelMask(legacy.channel_mask));
const bool isInput = VALUE_OR_RETURN(direction(role, type)) == Direction::INPUT;
const bool isJoint = (legacy.mode & AUDIO_GAIN_MODE_JOINT) != 0;
size_t numValues = isJoint ? 1
@@ -1054,7 +1050,8 @@
}
if (bitmaskIsSet(aidl.configMask, media::AudioPortConfigType::CHANNEL_MASK)) {
legacy.channel_mask =
- VALUE_OR_RETURN(aidl2legacy_int32_t_audio_channel_mask_t(aidl.channelMask));
+ VALUE_OR_RETURN(
+ aidl2legacy_AudioChannelMask_audio_channel_mask_t(aidl.channelMask));
}
if (bitmaskIsSet(aidl.configMask, media::AudioPortConfigType::FORMAT)) {
legacy.format = VALUE_OR_RETURN(aidl2legacy_AudioFormat_audio_format_t(aidl.format));
@@ -1083,7 +1080,8 @@
}
if (legacy.config_mask & AUDIO_PORT_CONFIG_CHANNEL_MASK) {
aidl.channelMask =
- VALUE_OR_RETURN(legacy2aidl_audio_channel_mask_t_int32_t(legacy.channel_mask));
+ VALUE_OR_RETURN(
+ legacy2aidl_audio_channel_mask_t_AudioChannelMask(legacy.channel_mask));
}
if (legacy.config_mask & AUDIO_PORT_CONFIG_FORMAT) {
aidl.format = VALUE_OR_RETURN(legacy2aidl_audio_format_t_AudioFormat(legacy.format));
@@ -1154,7 +1152,7 @@
legacy->mSamplingRate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.samplingRate));
legacy->mFormat = VALUE_OR_RETURN(aidl2legacy_AudioFormat_audio_format_t(aidl.format));
legacy->mChannelMask =
- VALUE_OR_RETURN(aidl2legacy_int32_t_audio_channel_mask_t(aidl.channelMask));
+ VALUE_OR_RETURN(aidl2legacy_AudioChannelMask_audio_channel_mask_t(aidl.channelMask));
legacy->mFrameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCount));
legacy->mFrameCountHAL = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCountHAL));
legacy->mLatency = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.latency));
@@ -1170,7 +1168,7 @@
aidl.samplingRate = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy->mSamplingRate));
aidl.format = VALUE_OR_RETURN(legacy2aidl_audio_format_t_AudioFormat(legacy->mFormat));
aidl.channelMask = VALUE_OR_RETURN(
- legacy2aidl_audio_channel_mask_t_int32_t(legacy->mChannelMask));
+ legacy2aidl_audio_channel_mask_t_AudioChannelMask(legacy->mChannelMask));
aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(legacy->mFrameCount));
aidl.frameCountHAL = VALUE_OR_RETURN(convertIntegral<int64_t>(legacy->mFrameCountHAL));
aidl.latency = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy->mLatency));
@@ -1503,7 +1501,7 @@
aidl.version = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.version));
aidl.config.sampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.sample_rate));
aidl.config.channelMask = VALUE_OR_RETURN(
- legacy2aidl_audio_channel_mask_t_int32_t(legacy.channel_mask));
+ legacy2aidl_audio_channel_mask_t_AudioChannelMask(legacy.channel_mask));
aidl.config.format = VALUE_OR_RETURN(legacy2aidl_audio_format_t_AudioFormat(legacy.format));
aidl.streamType = VALUE_OR_RETURN(
legacy2aidl_audio_stream_type_t_AudioStreamType(legacy.stream_type));
@@ -1535,7 +1533,7 @@
audio_config_t legacy;
legacy.sample_rate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.sampleRate));
legacy.channel_mask = VALUE_OR_RETURN(
- aidl2legacy_int32_t_audio_channel_mask_t(aidl.channelMask));
+ aidl2legacy_AudioChannelMask_audio_channel_mask_t(aidl.channelMask));
legacy.format = VALUE_OR_RETURN(aidl2legacy_AudioFormat_audio_format_t(aidl.format));
legacy.offload_info = VALUE_OR_RETURN(
aidl2legacy_AudioOffloadInfo_audio_offload_info_t(aidl.offloadInfo));
@@ -1548,7 +1546,7 @@
media::AudioConfig aidl;
aidl.sampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.sample_rate));
aidl.channelMask = VALUE_OR_RETURN(
- legacy2aidl_audio_channel_mask_t_int32_t(legacy.channel_mask));
+ legacy2aidl_audio_channel_mask_t_AudioChannelMask(legacy.channel_mask));
aidl.format = VALUE_OR_RETURN(legacy2aidl_audio_format_t_AudioFormat(legacy.format));
aidl.offloadInfo = VALUE_OR_RETURN(
legacy2aidl_audio_offload_info_t_AudioOffloadInfo(legacy.offload_info));
@@ -1561,7 +1559,7 @@
audio_config_base_t legacy;
legacy.sample_rate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.sampleRate));
legacy.channel_mask = VALUE_OR_RETURN(
- aidl2legacy_int32_t_audio_channel_mask_t(aidl.channelMask));
+ aidl2legacy_AudioChannelMask_audio_channel_mask_t(aidl.channelMask));
legacy.format = VALUE_OR_RETURN(aidl2legacy_AudioFormat_audio_format_t(aidl.format));
return legacy;
}
@@ -1571,7 +1569,7 @@
media::AudioConfigBase aidl;
aidl.sampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.sample_rate));
aidl.channelMask = VALUE_OR_RETURN(
- legacy2aidl_audio_channel_mask_t_int32_t(legacy.channel_mask));
+ legacy2aidl_audio_channel_mask_t_AudioChannelMask(legacy.channel_mask));
aidl.format = VALUE_OR_RETURN(legacy2aidl_audio_format_t_AudioFormat(legacy.format));
return aidl;
}
@@ -1916,7 +1914,7 @@
}
RETURN_IF_ERROR(
convertRange(aidl.channelMasks.begin(), aidl.channelMasks.end(), legacy.channel_masks,
- aidl2legacy_int32_t_audio_channel_mask_t));
+ aidl2legacy_AudioChannelMask_audio_channel_mask_t));
legacy.num_channel_masks = aidl.channelMasks.size();
legacy.encapsulation_type = VALUE_OR_RETURN(
@@ -1943,7 +1941,7 @@
RETURN_IF_ERROR(
convertRange(legacy.channel_masks, legacy.channel_masks + legacy.num_channel_masks,
std::back_inserter(aidl.channelMasks),
- legacy2aidl_audio_channel_mask_t_int32_t));
+ legacy2aidl_audio_channel_mask_t_AudioChannelMask));
aidl.encapsulationType = VALUE_OR_RETURN(
legacy2aidl_audio_encapsulation_type_t_AudioEncapsulationType(
@@ -1956,7 +1954,7 @@
audio_gain legacy;
legacy.mode = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_gain_mode_t_mask(aidl.mode));
legacy.channel_mask = VALUE_OR_RETURN(
- aidl2legacy_int32_t_audio_channel_mask_t(aidl.channelMask));
+ aidl2legacy_AudioChannelMask_audio_channel_mask_t(aidl.channelMask));
legacy.min_value = VALUE_OR_RETURN(convertIntegral<int>(aidl.minValue));
legacy.max_value = VALUE_OR_RETURN(convertIntegral<int>(aidl.maxValue));
legacy.default_value = VALUE_OR_RETURN(convertIntegral<int>(aidl.defaultValue));
@@ -1971,7 +1969,7 @@
media::AudioGain aidl;
aidl.mode = VALUE_OR_RETURN(legacy2aidl_audio_gain_mode_t_int32_t_mask(legacy.mode));
aidl.channelMask = VALUE_OR_RETURN(
- legacy2aidl_audio_channel_mask_t_int32_t(legacy.channel_mask));
+ legacy2aidl_audio_channel_mask_t_AudioChannelMask(legacy.channel_mask));
aidl.minValue = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.min_value));
aidl.maxValue = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.max_value));
aidl.defaultValue = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.default_value));
diff --git a/media/libaudioclient/Android.bp b/media/libaudioclient/Android.bp
index 9c307ff..4652a18 100644
--- a/media/libaudioclient/Android.bp
+++ b/media/libaudioclient/Android.bp
@@ -302,6 +302,7 @@
local_include_dir: "aidl",
srcs: [
"aidl/android/media/AudioAttributesInternal.aidl",
+ "aidl/android/media/AudioChannelMask.aidl",
"aidl/android/media/AudioClient.aidl",
"aidl/android/media/AudioConfig.aidl",
"aidl/android/media/AudioConfigBase.aidl",
@@ -311,6 +312,7 @@
"aidl/android/media/AudioEncapsulationMode.aidl",
"aidl/android/media/AudioEncapsulationMetadataType.aidl",
"aidl/android/media/AudioEncapsulationType.aidl",
+ "aidl/android/media/AudioFormatSys.aidl",
"aidl/android/media/AudioFlag.aidl",
"aidl/android/media/AudioGain.aidl",
"aidl/android/media/AudioGainConfig.aidl",
@@ -353,7 +355,7 @@
"aidl/android/media/TrackSecondaryOutputInfo.aidl",
],
imports: [
- "audio_common-aidl",
+ "android.media.audio.common.types",
"framework-permission-aidl",
],
backend: {
@@ -364,6 +366,9 @@
"com.android.media",
],
},
+ java: {
+ sdk_version: "module_current",
+ },
},
}
aidl_interface {
@@ -391,7 +396,6 @@
"aidl/android/media/SoundTriggerSession.aidl",
],
imports: [
- "audio_common-aidl",
"audioclient-types-aidl",
],
backend: {
@@ -402,6 +406,9 @@
"com.android.media",
],
},
+ java: {
+ sdk_version: "module_current",
+ },
},
}
@@ -431,7 +438,6 @@
"aidl/android/media/IAudioTrackCallback.aidl",
],
imports: [
- "audio_common-aidl",
"audioclient-types-aidl",
"av-types-aidl",
"effect-aidl",
@@ -447,6 +453,9 @@
"com.android.media",
],
},
+ java: {
+ sdk_version: "module_current",
+ },
},
}
@@ -465,7 +474,6 @@
"aidl/android/media/IAudioPolicyServiceClient.aidl",
],
imports: [
- "audio_common-aidl",
"audioclient-types-aidl",
"audiopolicy-types-aidl",
"capture_state_listener-aidl",
@@ -481,5 +489,8 @@
"com.android.media",
],
},
+ java: {
+ sdk_version: "module_current",
+ },
},
}
diff --git a/media/libaudioclient/AudioSystem.cpp b/media/libaudioclient/AudioSystem.cpp
index 88e752b..640f547 100644
--- a/media/libaudioclient/AudioSystem.cpp
+++ b/media/libaudioclient/AudioSystem.cpp
@@ -1865,7 +1865,7 @@
media::Int numSurroundFormatsAidl;
numSurroundFormatsAidl.value =
VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(*numSurroundFormats));
- std::vector<media::audio::common::AudioFormat> surroundFormatsAidl;
+ std::vector<media::AudioFormatSys> surroundFormatsAidl;
std::vector<bool> surroundFormatsEnabledAidl;
RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
aps->getSurroundFormats(&numSurroundFormatsAidl, &surroundFormatsAidl,
@@ -1892,7 +1892,7 @@
media::Int numSurroundFormatsAidl;
numSurroundFormatsAidl.value =
VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(*numSurroundFormats));
- std::vector<media::audio::common::AudioFormat> surroundFormatsAidl;
+ std::vector<media::AudioFormatSys> surroundFormatsAidl;
RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
aps->getReportedSurroundFormats(&numSurroundFormatsAidl, &surroundFormatsAidl)));
@@ -1908,7 +1908,7 @@
const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
if (aps == 0) return PERMISSION_DENIED;
- media::audio::common::AudioFormat audioFormatAidl = VALUE_OR_RETURN_STATUS(
+ media::AudioFormatSys audioFormatAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_format_t_AudioFormat(audioFormat));
return statusTFromBinderStatus(
aps->setSurroundFormatEnabled(audioFormatAidl, enabled));
@@ -1962,7 +1962,7 @@
& aps = AudioSystem::get_audio_policy_service();
if (aps == 0) return PERMISSION_DENIED;
- std::vector<media::audio::common::AudioFormat> formatsAidl;
+ std::vector<media::AudioFormatSys> formatsAidl;
RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
aps->getHwOffloadEncodingFormatsSupportedForA2DP(&formatsAidl)));
*formats = VALUE_OR_RETURN_STATUS(
diff --git a/media/libaudioclient/IAudioFlinger.cpp b/media/libaudioclient/IAudioFlinger.cpp
index 0564cdf..f89de97 100644
--- a/media/libaudioclient/IAudioFlinger.cpp
+++ b/media/libaudioclient/IAudioFlinger.cpp
@@ -238,7 +238,7 @@
audio_format_t AudioFlingerClientAdapter::format(audio_io_handle_t output) const {
auto result = [&]() -> ConversionResult<audio_format_t> {
int32_t outputAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(output));
- media::audio::common::AudioFormat aidlRet;
+ media::AudioFormatSys aidlRet;
RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->format(outputAidl, &aidlRet)));
return aidl2legacy_AudioFormat_audio_format_t(aidlRet);
}();
@@ -406,10 +406,10 @@
audio_channel_mask_t channelMask) const {
auto result = [&]() -> ConversionResult<size_t> {
int32_t sampleRateAidl = VALUE_OR_RETURN(convertIntegral<int32_t>(sampleRate));
- media::audio::common::AudioFormat formatAidl = VALUE_OR_RETURN(
+ media::AudioFormatSys formatAidl = VALUE_OR_RETURN(
legacy2aidl_audio_format_t_AudioFormat(format));
- int32_t channelMaskAidl = VALUE_OR_RETURN(
- legacy2aidl_audio_channel_mask_t_int32_t(channelMask));
+ media::AudioChannelMask channelMaskAidl = VALUE_OR_RETURN(
+ legacy2aidl_audio_channel_mask_t_AudioChannelMask(channelMask));
int64_t aidlRet;
RETURN_IF_ERROR(statusTFromBinderStatus(
mDelegate->getInputBufferSize(sampleRateAidl, formatAidl, channelMaskAidl,
@@ -798,7 +798,7 @@
}
Status AudioFlingerServerAdapter::format(int32_t output,
- media::audio::common::AudioFormat* _aidl_return) {
+ media::AudioFormatSys* _aidl_return) {
audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER(
aidl2legacy_int32_t_audio_io_handle_t(output));
*_aidl_return = VALUE_OR_RETURN_BINDER(
@@ -926,13 +926,14 @@
}
Status AudioFlingerServerAdapter::getInputBufferSize(int32_t sampleRate,
- media::audio::common::AudioFormat format,
- int32_t channelMask, int64_t* _aidl_return) {
+ media::AudioFormatSys format,
+ media::AudioChannelMask channelMask,
+ int64_t* _aidl_return) {
uint32_t sampleRateLegacy = VALUE_OR_RETURN_BINDER(convertIntegral<uint32_t>(sampleRate));
audio_format_t formatLegacy = VALUE_OR_RETURN_BINDER(
aidl2legacy_AudioFormat_audio_format_t(format));
audio_channel_mask_t channelMaskLegacy = VALUE_OR_RETURN_BINDER(
- aidl2legacy_int32_t_audio_channel_mask_t(channelMask));
+ aidl2legacy_AudioChannelMask_audio_channel_mask_t(channelMask));
size_t size = mDelegate->getInputBufferSize(sampleRateLegacy, formatLegacy, channelMaskLegacy);
*_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<int64_t>(size));
return Status::ok();
diff --git a/media/libaudioclient/aidl/android/media/AudioChannelMask.aidl b/media/libaudioclient/aidl/android/media/AudioChannelMask.aidl
new file mode 100644
index 0000000..1e7e6e5
--- /dev/null
+++ b/media/libaudioclient/aidl/android/media/AudioChannelMask.aidl
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media;
+
+/**
+ * AudioChannelMask is an opaque type and its internal layout should not be
+ * assumed as it may change in the future.
+ *
+ * This is a temporary implementation to provide a distinct type (instead of
+ * 'int') in all the places that need a channel mask. Later the enum will be
+ * replaced with a type which is more extensible by vendors.
+ *
+ * The actual value range of this enum is the same as of
+ * the 'audio_channel_mask_t' enum.
+ *
+ * {@hide}
+ */
+@Backing(type="int")
+enum AudioChannelMask {
+ /**
+ * Framework use only, do not constitute a valid channel mask.
+ */
+ INVALID = 0xC0000000,
+
+ NONE = 0,
+ /**
+ * Since the current code never uses the values of the SAIDL enum
+ * directly--it uses the values of the C enum and coerces the type--
+ * we don't specify any other values here.
+ */
+}
diff --git a/media/libaudioclient/aidl/android/media/AudioConfig.aidl b/media/libaudioclient/aidl/android/media/AudioConfig.aidl
index 8dc97d3..dc4e9e4 100644
--- a/media/libaudioclient/aidl/android/media/AudioConfig.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioConfig.aidl
@@ -16,20 +16,17 @@
package android.media;
+import android.media.AudioChannelMask;
+import android.media.AudioFormatSys;
import android.media.AudioOffloadInfo;
-import android.media.audio.common.AudioFormat;
/**
* {@hide}
*/
parcelable AudioConfig {
int sampleRate;
- /**
- * Interpreted as audio_channel_mask_t.
- * TODO(ytai): Create a designated type.
- */
- int channelMask;
- AudioFormat format;
+ AudioChannelMask channelMask;
+ AudioFormatSys format;
AudioOffloadInfo offloadInfo;
long frameCount;
}
diff --git a/media/libaudioclient/aidl/android/media/AudioConfigBase.aidl b/media/libaudioclient/aidl/android/media/AudioConfigBase.aidl
index 8353c0d..59fbee6 100644
--- a/media/libaudioclient/aidl/android/media/AudioConfigBase.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioConfigBase.aidl
@@ -16,14 +16,14 @@
package android.media;
-import android.media.audio.common.AudioFormat;
+import android.media.AudioChannelMask;
+import android.media.AudioFormatSys;
/**
* {@hide}
*/
parcelable AudioConfigBase {
int sampleRate;
- /** Interpreted as audio_channel_mask_t. */
- int channelMask;
- AudioFormat format;
+ AudioChannelMask channelMask;
+ AudioFormatSys format;
}
diff --git a/media/libaudioclient/aidl/android/media/AudioFormatSys.aidl b/media/libaudioclient/aidl/android/media/AudioFormatSys.aidl
new file mode 100644
index 0000000..95a3753
--- /dev/null
+++ b/media/libaudioclient/aidl/android/media/AudioFormatSys.aidl
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media;
+
+/**
+ * Audio format is a 32-bit word that consists of:
+ * main format field (upper 8 bits)
+ * sub format field (lower 24 bits).
+ *
+ * The main format indicates the main codec type. The sub format field indicates
+ * options and parameters for each format. The sub format is mainly used for
+ * record to indicate for instance the requested bitrate or profile. It can
+ * also be used for certain formats to give informations not present in the
+ * encoded audio stream (e.g. octet alignement for AMR).
+ *
+ * This type corresponds to enums in system/audio.h, whereas 'AudioFormat.aidl'
+ * located in frameworks/base/media/java/android/media is the type used by SDK.
+ * Both types are in the 'android.media' package.
+ *
+ * {@hide}
+ */
+@Backing(type="int")
+enum AudioFormatSys {
+ /**
+ * Framework use only, do not constitute valid formats.
+ */
+ MAIN_MASK = 0xFF000000,
+ SUB_MASK = 0x00FFFFFF,
+ INVALID = 0xFFFFFFFF,
+ PCM = 0x00000000,
+
+ DEFAULT = 0,
+
+ PCM_16_BIT = 0x1,
+ PCM_8_BIT = 0x2,
+ PCM_32_BIT = 0x3,
+ PCM_8_24_BIT = 0x4,
+ PCM_FLOAT = 0x5,
+ PCM_24_BIT_PACKED = 0x6,
+ MP3 = 0x01000000,
+ AMR_NB = 0x02000000,
+ AMR_WB = 0x03000000,
+ AAC = 0x04000000,
+ AAC_MAIN = 0x04000001,
+ AAC_LC = 0x04000002,
+ AAC_SSR = 0x04000004,
+ AAC_LTP = 0x04000008,
+ AAC_HE_V1 = 0x04000010,
+ AAC_SCALABLE = 0x04000020,
+ AAC_ERLC = 0x04000040,
+ AAC_LD = 0x04000080,
+ AAC_HE_V2 = 0x040000100,
+ AAC_ELD = 0x040000200,
+ AAC_XHE = 0x040000300,
+ /**
+ * Deprecated, Use AAC_HE_V1.
+ */
+ HE_AAC_V1 = 0x05000000,
+ /**
+ * Deprecated, Use AAC_HE_V2.
+ */
+ HE_AAC_V2 = 0x06000000,
+ VORBIS = 0x07000000,
+ OPUS = 0x08000000,
+ AC3 = 0x09000000,
+ E_AC3 = 0x0A000000,
+ E_AC3_JOC = 0x0A000001,
+ DTS = 0x0B000000,
+ DTS_HD = 0x0C000000,
+ IEC61937 = 0x0D000000,
+ DOLBY_TRUEHD = 0x0E000000,
+ EVRC = 0x10000000,
+ EVRCB = 0x11000000,
+ EVRCWB = 0x12000000,
+ EVRCNW = 0x13000000,
+ AAC_ADIF = 0x14000000,
+ WMA = 0x15000000,
+ WMA_PRO = 0x16000000,
+ AMR_WB_PLUS = 0x17000000,
+ MP2 = 0x18000000,
+ QCELP = 0x19000000,
+ DSD = 0x1A000000,
+ FLAC = 0x1B000000,
+ ALAC = 0x1C000000,
+ APE = 0x1D000000,
+ AAC_ADTS = 0x1E000000,
+ AAC_ADTS_MAIN = 0x1E000001,
+ AAC_ADTS_LC = 0x1E000002,
+ AAC_ADTS_SSR = 0x1E000004,
+ AAC_ADTS_LTP = 0x1E000008,
+ AAC_ADTS_HE_V1 = 0x1E000010,
+ AAC_ADTS_SCALABLE = 0x1E000020,
+ AAC_ADTS_ERLC = 0x1E000040,
+ AAC_ADTS_LD = 0x1E000080,
+ AAC_ADTS_HE_V2 = 0x1E000100,
+ AAC_ADTS_ELD = 0x1E000200,
+ AAC_ADTS_XHE = 0x1E000300,
+ SBC = 0x1F000000,
+ APTX = 0x20000000,
+ APTX_HD = 0x21000000,
+ AC4 = 0x22000000,
+ LDAC = 0x23000000,
+ MAT = 0x24000000,
+ MAT_1_0 = 0x24000001,
+ MAT_2_0 = 0x24000002,
+ MAT_2_1 = 0x24000003,
+ AAC_LATM = 0x25000000,
+ AAC_LATM_LC = 0x25000002,
+ AAC_LATM_HE_V1 = 0x25000010,
+ AAC_LATM_HE_V2 = 0x25000100,
+ CELT = 0x26000000,
+ APTX_ADAPTIVE = 0x27000000,
+ LHDC = 0x28000000,
+ LHDC_LL = 0x29000000,
+ APTX_TWSP = 0x2A000000,
+ LC3 = 0x2B000000,
+ MPEGH = 0x2C000000,
+ MPEGH_BL_L3 = 0x2C000013,
+ MPEGH_BL_L4 = 0x2C000014,
+ MPEGH_LC_L3 = 0x2C000023,
+ MPEGH_LC_L4 = 0x2C000024,
+ IEC60958 = 0x2D000000,
+ DTS_UHD = 0x2E000000,
+ DRA = 0x2F000000,
+ /**
+ * Subformats.
+ */
+ AAC_SUB_MAIN = 0x1,
+ AAC_SUB_LC = 0x2,
+ AAC_SUB_SSR = 0x4,
+ AAC_SUB_LTP = 0x8,
+ AAC_SUB_HE_V1 = 0x10,
+ AAC_SUB_SCALABLE = 0x20,
+ AAC_SUB_ERLC = 0x40,
+ AAC_SUB_LD = 0x80,
+ AAC_SUB_HE_V2 = 0x100,
+ AAC_SUB_ELD = 0x200,
+ AAC_SUB_XHE = 0x300,
+ E_AC3_SUB_JOC = 0x1,
+ MAT_SUB_1_0 = 0x1,
+ MAT_SUB_2_0 = 0x2,
+ MAT_SUB_2_1 = 0x3,
+ MPEGH_SUB_BL_L3 = 0x13,
+ MPEGH_SUB_BL_L4 = 0x14,
+ MPEGH_SUB_LC_L3 = 0x23,
+ MPEGH_SUB_LC_L4 = 0x24,
+}
diff --git a/media/libaudioclient/aidl/android/media/AudioGain.aidl b/media/libaudioclient/aidl/android/media/AudioGain.aidl
index 048b295..58cf1c9 100644
--- a/media/libaudioclient/aidl/android/media/AudioGain.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioGain.aidl
@@ -16,6 +16,8 @@
package android.media;
+import android.media.AudioChannelMask;
+
/**
* {@hide}
*/
@@ -25,8 +27,7 @@
boolean useForVolume;
/** Bitmask, indexed by AudioGainMode. */
int mode;
- /** Interpreted as audio_channel_mask_t. */
- int channelMask;
+ AudioChannelMask channelMask;
int minValue;
int maxValue;
int defaultValue;
diff --git a/media/libaudioclient/aidl/android/media/AudioGainConfig.aidl b/media/libaudioclient/aidl/android/media/AudioGainConfig.aidl
index b93c2dc..67b77a5 100644
--- a/media/libaudioclient/aidl/android/media/AudioGainConfig.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioGainConfig.aidl
@@ -16,6 +16,8 @@
package android.media;
+import android.media.AudioChannelMask;
+
/**
* {@hide}
*/
@@ -28,9 +30,8 @@
/**
* Channels which gain value follows. N/A in joint mode.
- * Interpreted as audio_channel_mask_t.
*/
- int channelMask;
+ AudioChannelMask channelMask;
/**
* Gain values in millibels.
diff --git a/media/libaudioclient/aidl/android/media/AudioIoDescriptor.aidl b/media/libaudioclient/aidl/android/media/AudioIoDescriptor.aidl
index 876ef9b..80dfdcd 100644
--- a/media/libaudioclient/aidl/android/media/AudioIoDescriptor.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioIoDescriptor.aidl
@@ -16,8 +16,9 @@
package android.media;
+import android.media.AudioChannelMask;
+import android.media.AudioFormatSys;
import android.media.AudioPatch;
-import android.media.audio.common.AudioFormat;
/**
* {@hide}
@@ -27,9 +28,8 @@
int ioHandle;
AudioPatch patch;
int samplingRate;
- AudioFormat format;
- /** Interpreted as audio_channel_mask_t. */
- int channelMask;
+ AudioFormatSys format;
+ AudioChannelMask channelMask;
long frameCount;
long frameCountHAL;
/** Only valid for output. */
diff --git a/media/libaudioclient/aidl/android/media/AudioOffloadInfo.aidl b/media/libaudioclient/aidl/android/media/AudioOffloadInfo.aidl
index c86b3f0..693c818 100644
--- a/media/libaudioclient/aidl/android/media/AudioOffloadInfo.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioOffloadInfo.aidl
@@ -20,7 +20,7 @@
import android.media.AudioEncapsulationMode;
import android.media.AudioStreamType;
import android.media.AudioUsage;
-import android.media.audio.common.AudioFormat;
+import android.media.AudioFormatSys;
/**
* {@hide}
diff --git a/media/libaudioclient/aidl/android/media/AudioPortConfig.aidl b/media/libaudioclient/aidl/android/media/AudioPortConfig.aidl
index 2dd30a4..7489792 100644
--- a/media/libaudioclient/aidl/android/media/AudioPortConfig.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioPortConfig.aidl
@@ -16,13 +16,14 @@
package android.media;
+import android.media.AudioChannelMask;
import android.media.AudioGainConfig;
import android.media.AudioIoFlags;
import android.media.AudioPortConfigExt;
import android.media.AudioPortConfigType;
import android.media.AudioPortRole;
import android.media.AudioPortType;
-import android.media.audio.common.AudioFormat;
+import android.media.AudioFormatSys;
/**
* {@hide}
@@ -43,14 +44,12 @@
int sampleRate;
/**
* Channel mask, if applicable.
- * Interpreted as audio_channel_mask_t.
- * TODO: bitmask?
*/
- int channelMask;
+ AudioChannelMask channelMask;
/**
* Format, if applicable.
*/
- AudioFormat format;
+ AudioFormatSys format;
/** Gain to apply, if applicable. */
AudioGainConfig gain;
/** Framework only: HW_AV_SYNC, DIRECT, ... */
diff --git a/media/libaudioclient/aidl/android/media/AudioProfile.aidl b/media/libaudioclient/aidl/android/media/AudioProfile.aidl
index afb288f..0de7ca9 100644
--- a/media/libaudioclient/aidl/android/media/AudioProfile.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioProfile.aidl
@@ -16,8 +16,9 @@
package android.media;
+import android.media.AudioChannelMask;
import android.media.AudioEncapsulationType;
-import android.media.audio.common.AudioFormat;
+import android.media.AudioFormatSys;
/**
* {@hide}
@@ -25,9 +26,8 @@
parcelable AudioProfile {
@utf8InCpp String name;
/** The format for an audio profile should only be set when initialized. */
- AudioFormat format;
- /** Interpreted as audio_channel_mask_t. */
- int[] channelMasks;
+ AudioFormatSys format;
+ AudioChannelMask[] channelMasks;
int[] samplingRates;
boolean isDynamicFormat;
boolean isDynamicChannels;
diff --git a/media/libaudioclient/aidl/android/media/IAudioFlingerService.aidl b/media/libaudioclient/aidl/android/media/IAudioFlingerService.aidl
index d2cae6d..98a3e3b 100644
--- a/media/libaudioclient/aidl/android/media/IAudioFlingerService.aidl
+++ b/media/libaudioclient/aidl/android/media/IAudioFlingerService.aidl
@@ -16,6 +16,7 @@
package android.media;
+import android.media.AudioChannelMask;
import android.media.AudioMode;
import android.media.AudioPatch;
import android.media.AudioPort;
@@ -41,7 +42,7 @@
import android.media.MicrophoneInfoData;
import android.media.RenderPosition;
import android.media.TrackSecondaryOutputInfo;
-import android.media.audio.common.AudioFormat;
+import android.media.AudioFormatSys;
/**
* {@hide}
@@ -62,7 +63,7 @@
*/
int sampleRate(int /* audio_io_handle_t */ ioHandle);
- AudioFormat format(int /* audio_io_handle_t */ output);
+ AudioFormatSys format(int /* audio_io_handle_t */ output);
long frameCount(int /* audio_io_handle_t */ ioHandle);
@@ -115,8 +116,8 @@
// Retrieve the audio recording buffer size in bytes.
// FIXME This API assumes a route, and so should be deprecated.
long getInputBufferSize(int sampleRate,
- AudioFormat format,
- int /* audio_channel_mask_t */ channelMask);
+ AudioFormatSys format,
+ AudioChannelMask channelMask);
OpenOutputResponse openOutput(in OpenOutputRequest request);
int /* audio_io_handle_t */ openDuplicateOutput(int /* audio_io_handle_t */ output1,
diff --git a/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl b/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl
index 65bcd82..184b024 100644
--- a/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl
+++ b/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl
@@ -16,10 +16,9 @@
package android.media;
+import android.media.AudioFormatSys;
import android.content.AttributionSourceState;
-import android.media.audio.common.AudioFormat;
-
import android.media.AudioAttributesEx;
import android.media.AudioAttributesInternal;
import android.media.AudioConfig;
@@ -63,13 +62,13 @@
void setDeviceConnectionState(in AudioDevice device,
in AudioPolicyDeviceState state,
@utf8InCpp String deviceName,
- in AudioFormat encodedFormat);
+ in AudioFormatSys encodedFormat);
AudioPolicyDeviceState getDeviceConnectionState(in AudioDevice device);
void handleDeviceConfigChange(in AudioDevice device,
@utf8InCpp String deviceName,
- in AudioFormat encodedFormat);
+ in AudioFormatSys encodedFormat);
void setPhoneState(AudioMode state, int /* uid_t */ uid);
@@ -279,7 +278,7 @@
* number of elements without actually retrieving them.
*/
void getSurroundFormats(inout Int count,
- out AudioFormat[] formats,
+ out AudioFormatSys[] formats,
out boolean[] formatsEnabled);
/**
@@ -291,11 +290,11 @@
* number of elements without actually retrieving them.
*/
void getReportedSurroundFormats(inout Int count,
- out AudioFormat[] formats);
+ out AudioFormatSys[] formats);
- AudioFormat[] getHwOffloadEncodingFormatsSupportedForA2DP();
+ AudioFormatSys[] getHwOffloadEncodingFormatsSupportedForA2DP();
- void setSurroundFormatEnabled(AudioFormat audioFormat, boolean enabled);
+ void setSurroundFormatEnabled(AudioFormatSys audioFormat, boolean enabled);
void setAssistantUid(int /* uid_t */ uid);
diff --git a/media/libaudioclient/include/media/AidlConversion.h b/media/libaudioclient/include/media/AidlConversion.h
index 4ec69c7..fc8a1e8 100644
--- a/media/libaudioclient/include/media/AidlConversion.h
+++ b/media/libaudioclient/include/media/AidlConversion.h
@@ -96,8 +96,10 @@
ConversionResult<unsigned int> aidl2legacy_int32_t_config_mask(int32_t aidl);
ConversionResult<int32_t> legacy2aidl_config_mask_int32_t(unsigned int legacy);
-ConversionResult<audio_channel_mask_t> aidl2legacy_int32_t_audio_channel_mask_t(int32_t aidl);
-ConversionResult<int32_t> legacy2aidl_audio_channel_mask_t_int32_t(audio_channel_mask_t legacy);
+ConversionResult<audio_channel_mask_t> aidl2legacy_AudioChannelMask_audio_channel_mask_t(
+ media::AudioChannelMask aidl);
+ConversionResult<media::AudioChannelMask> legacy2aidl_audio_channel_mask_t_AudioChannelMask(
+ audio_channel_mask_t legacy);
ConversionResult<pid_t> aidl2legacy_int32_t_pid_t(int32_t aidl);
ConversionResult<int32_t> legacy2aidl_pid_t_int32_t(pid_t legacy);
@@ -132,8 +134,8 @@
audio_port_type_t legacy);
ConversionResult<audio_format_t> aidl2legacy_AudioFormat_audio_format_t(
- media::audio::common::AudioFormat aidl);
-ConversionResult<media::audio::common::AudioFormat> legacy2aidl_audio_format_t_AudioFormat(
+ media::AudioFormatSys aidl);
+ConversionResult<media::AudioFormatSys> legacy2aidl_audio_format_t_AudioFormat(
audio_format_t legacy);
ConversionResult<audio_gain_mode_t>
diff --git a/media/libaudioclient/include/media/IAudioFlinger.h b/media/libaudioclient/include/media/IAudioFlinger.h
index 327b37e..634326e 100644
--- a/media/libaudioclient/include/media/IAudioFlinger.h
+++ b/media/libaudioclient/include/media/IAudioFlinger.h
@@ -562,7 +562,7 @@
Status createRecord(const media::CreateRecordRequest& request,
media::CreateRecordResponse* _aidl_return) override;
Status sampleRate(int32_t ioHandle, int32_t* _aidl_return) override;
- Status format(int32_t output, media::audio::common::AudioFormat* _aidl_return) override;
+ Status format(int32_t output, media::AudioFormatSys* _aidl_return) override;
Status frameCount(int32_t ioHandle, int64_t* _aidl_return) override;
Status latency(int32_t output, int32_t* _aidl_return) override;
Status setMasterVolume(float value) override;
@@ -584,8 +584,8 @@
Status
getParameters(int32_t ioHandle, const std::string& keys, std::string* _aidl_return) override;
Status registerClient(const sp<media::IAudioFlingerClient>& client) override;
- Status getInputBufferSize(int32_t sampleRate, media::audio::common::AudioFormat format,
- int32_t channelMask, int64_t* _aidl_return) override;
+ Status getInputBufferSize(int32_t sampleRate, media::AudioFormatSys format,
+ media::AudioChannelMask channelMask, int64_t* _aidl_return) override;
Status openOutput(const media::OpenOutputRequest& request,
media::OpenOutputResponse* _aidl_return) override;
Status openDuplicateOutput(int32_t output1, int32_t output2, int32_t* _aidl_return) override;
diff --git a/media/libaudiofoundation/AudioGain.cpp b/media/libaudiofoundation/AudioGain.cpp
index 1dee938..5cc2b2f 100644
--- a/media/libaudiofoundation/AudioGain.cpp
+++ b/media/libaudiofoundation/AudioGain.cpp
@@ -142,7 +142,7 @@
parcelable->mode = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_gain_mode_t_int32_t_mask(mGain.mode));
parcelable->channelMask = VALUE_OR_RETURN_STATUS(
- legacy2aidl_audio_channel_mask_t_int32_t(mGain.channel_mask));
+ legacy2aidl_audio_channel_mask_t_AudioChannelMask(mGain.channel_mask));
parcelable->minValue = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(mGain.min_value));
parcelable->maxValue = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(mGain.max_value));
parcelable->defaultValue = VALUE_OR_RETURN_STATUS(
@@ -166,7 +166,7 @@
mGain.mode = VALUE_OR_RETURN_STATUS(
aidl2legacy_int32_t_audio_gain_mode_t_mask(parcelable.mode));
mGain.channel_mask = VALUE_OR_RETURN_STATUS(
- aidl2legacy_int32_t_audio_channel_mask_t(parcelable.channelMask));
+ aidl2legacy_AudioChannelMask_audio_channel_mask_t(parcelable.channelMask));
mGain.min_value = VALUE_OR_RETURN_STATUS(convertIntegral<int>(parcelable.minValue));
mGain.max_value = VALUE_OR_RETURN_STATUS(convertIntegral<int>(parcelable.maxValue));
mGain.default_value = VALUE_OR_RETURN_STATUS(convertIntegral<int>(parcelable.defaultValue));
diff --git a/media/libaudiofoundation/AudioPort.cpp b/media/libaudiofoundation/AudioPort.cpp
index fafabd9..fc67c59 100644
--- a/media/libaudiofoundation/AudioPort.cpp
+++ b/media/libaudiofoundation/AudioPort.cpp
@@ -340,13 +340,13 @@
parcelable->sampleRate = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(mSamplingRate));
parcelable->format = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_format_t_AudioFormat(mFormat));
parcelable->channelMask = VALUE_OR_RETURN_STATUS(
- legacy2aidl_audio_channel_mask_t_int32_t(mChannelMask));
+ legacy2aidl_audio_channel_mask_t_AudioChannelMask(mChannelMask));
parcelable->id = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_port_handle_t_int32_t(mId));
parcelable->gain.index = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(mGain.index));
parcelable->gain.mode = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_gain_mode_t_int32_t_mask(mGain.mode));
parcelable->gain.channelMask = VALUE_OR_RETURN_STATUS(
- legacy2aidl_audio_channel_mask_t_int32_t(mGain.channel_mask));
+ legacy2aidl_audio_channel_mask_t_AudioChannelMask(mGain.channel_mask));
parcelable->gain.rampDurationMs = VALUE_OR_RETURN_STATUS(
convertIntegral<int32_t>(mGain.ramp_duration_ms));
parcelable->gain.values = VALUE_OR_RETURN_STATUS(convertContainer<std::vector<int32_t>>(
@@ -364,13 +364,13 @@
mSamplingRate = VALUE_OR_RETURN_STATUS(convertIntegral<unsigned int>(parcelable.sampleRate));
mFormat = VALUE_OR_RETURN_STATUS(aidl2legacy_AudioFormat_audio_format_t(parcelable.format));
mChannelMask = VALUE_OR_RETURN_STATUS(
- aidl2legacy_int32_t_audio_channel_mask_t(parcelable.channelMask));
+ aidl2legacy_AudioChannelMask_audio_channel_mask_t(parcelable.channelMask));
mId = VALUE_OR_RETURN_STATUS(aidl2legacy_int32_t_audio_port_handle_t(parcelable.id));
mGain.index = VALUE_OR_RETURN_STATUS(convertIntegral<int>(parcelable.gain.index));
mGain.mode = VALUE_OR_RETURN_STATUS(
aidl2legacy_int32_t_audio_gain_mode_t_mask(parcelable.gain.mode));
mGain.channel_mask = VALUE_OR_RETURN_STATUS(
- aidl2legacy_int32_t_audio_channel_mask_t(parcelable.gain.channelMask));
+ aidl2legacy_AudioChannelMask_audio_channel_mask_t(parcelable.gain.channelMask));
mGain.ramp_duration_ms = VALUE_OR_RETURN_STATUS(
convertIntegral<unsigned int>(parcelable.gain.rampDurationMs));
if (parcelable.gain.values.size() > std::size(mGain.values)) {
diff --git a/media/libaudiofoundation/AudioProfile.cpp b/media/libaudiofoundation/AudioProfile.cpp
index 8ac3f73..7243131 100644
--- a/media/libaudiofoundation/AudioProfile.cpp
+++ b/media/libaudiofoundation/AudioProfile.cpp
@@ -165,8 +165,9 @@
parcelable.name = mName;
parcelable.format = VALUE_OR_RETURN(legacy2aidl_audio_format_t_AudioFormat(mFormat));
parcelable.channelMasks = VALUE_OR_RETURN(
- convertContainer<std::vector<int32_t>>(mChannelMasks,
- legacy2aidl_audio_channel_mask_t_int32_t));
+ convertContainer<std::vector<media::AudioChannelMask>>(
+ mChannelMasks,
+ legacy2aidl_audio_channel_mask_t_AudioChannelMask));
parcelable.samplingRates = VALUE_OR_RETURN(
convertContainer<std::vector<int32_t>>(mSamplingRates,
convertIntegral<int32_t, uint32_t>));
@@ -194,7 +195,7 @@
legacy->mFormat = VALUE_OR_RETURN(aidl2legacy_AudioFormat_audio_format_t(parcelable.format));
legacy->mChannelMasks = VALUE_OR_RETURN(
convertContainer<ChannelMaskSet>(parcelable.channelMasks,
- aidl2legacy_int32_t_audio_channel_mask_t));
+ aidl2legacy_AudioChannelMask_audio_channel_mask_t));
legacy->mSamplingRates = VALUE_OR_RETURN(
convertContainer<SampleRateSet>(parcelable.samplingRates,
convertIntegral<uint32_t, int32_t>));
diff --git a/media/libmedia/IMediaPlayer.cpp b/media/libmedia/IMediaPlayer.cpp
index c89c023..c9f361e 100644
--- a/media/libmedia/IMediaPlayer.cpp
+++ b/media/libmedia/IMediaPlayer.cpp
@@ -17,7 +17,6 @@
#include <arpa/inet.h>
#include <stdint.h>
-#include <sys/types.h>
#include <android/IDataSource.h>
#include <binder/IPCThreadState.h>
diff --git a/media/libmedia/tests/codeclist/Android.bp b/media/libmedia/tests/codeclist/Android.bp
index 7dd0caa..57af9a9 100644
--- a/media/libmedia/tests/codeclist/Android.bp
+++ b/media/libmedia/tests/codeclist/Android.bp
@@ -25,7 +25,7 @@
cc_test {
name: "CodecListTest",
- test_suites: ["device-tests"],
+ test_suites: ["device-tests", "mts"],
gtest: true,
srcs: [
@@ -41,7 +41,7 @@
"libstagefright_xmlparser",
"libutils",
],
-
+ compile_multilib: "first",
cflags: [
"-Werror",
"-Wall",
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index f2bcebb..13e7279 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -4691,8 +4691,8 @@
}
const CryptoPlugin::SubSample *subSamples;
size_t numSubSamples;
- const uint8_t *key;
- const uint8_t *iv;
+ const uint8_t *key = NULL;
+ const uint8_t *iv = NULL;
CryptoPlugin::Mode mode = CryptoPlugin::kMode_Unencrypted;
// We allow the simpler queueInputBuffer API to be used even in
@@ -4707,8 +4707,6 @@
subSamples = &ss;
numSubSamples = 1;
- key = NULL;
- iv = NULL;
pattern.mEncryptBlocks = 0;
pattern.mSkipBlocks = 0;
}
diff --git a/media/utils/fuzzers/ServiceUtilitiesFuzz.cpp b/media/utils/fuzzers/ServiceUtilitiesFuzz.cpp
index 6e52512..51e8d7a 100644
--- a/media/utils/fuzzers/ServiceUtilitiesFuzz.cpp
+++ b/media/utils/fuzzers/ServiceUtilitiesFuzz.cpp
@@ -17,7 +17,7 @@
#include <fcntl.h>
#include <functional>
-#include <type_traits>
+#include <type_traits>
#include <android/content/AttributionSourceState.h>
#include "fuzzer/FuzzedDataProvider.h"
diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
index 3298f6b..1ebf76b 100644
--- a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
+++ b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
@@ -99,7 +99,7 @@
const media::AudioDevice& deviceAidl,
media::AudioPolicyDeviceState stateAidl,
const std::string& deviceNameAidl,
- media::audio::common::AudioFormat encodedFormatAidl) {
+ media::AudioFormatSys encodedFormatAidl) {
audio_devices_t device = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_int32_t_audio_devices_t(deviceAidl.type));
audio_policy_dev_state_t state = VALUE_OR_RETURN_BINDER_STATUS(
@@ -149,7 +149,7 @@
Status AudioPolicyService::handleDeviceConfigChange(
const media::AudioDevice& deviceAidl,
const std::string& deviceNameAidl,
- media::audio::common::AudioFormat encodedFormatAidl) {
+ media::AudioFormatSys encodedFormatAidl) {
audio_devices_t device = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_int32_t_audio_devices_t(deviceAidl.type));
audio_format_t encodedFormat = VALUE_OR_RETURN_BINDER_STATUS(
@@ -1819,7 +1819,7 @@
}
Status AudioPolicyService::getSurroundFormats(media::Int* count,
- std::vector<media::audio::common::AudioFormat>* formats,
+ std::vector<media::AudioFormatSys>* formats,
std::vector<bool>* formatsEnabled) {
unsigned int numSurroundFormats = VALUE_OR_RETURN_BINDER_STATUS(
convertIntegral<unsigned int>(count->value));
@@ -1851,7 +1851,7 @@
}
Status AudioPolicyService::getReportedSurroundFormats(
- media::Int* count, std::vector<media::audio::common::AudioFormat>* formats) {
+ media::Int* count, std::vector<media::AudioFormatSys>* formats) {
unsigned int numSurroundFormats = VALUE_OR_RETURN_BINDER_STATUS(
convertIntegral<unsigned int>(count->value));
if (numSurroundFormats > MAX_ITEMS_PER_LIST) {
@@ -1877,7 +1877,7 @@
}
Status AudioPolicyService::getHwOffloadEncodingFormatsSupportedForA2DP(
- std::vector<media::audio::common::AudioFormat>* _aidl_return) {
+ std::vector<media::AudioFormatSys>* _aidl_return) {
std::vector<audio_format_t> formats;
if (mAudioPolicyManager == NULL) {
@@ -1888,14 +1888,14 @@
RETURN_IF_BINDER_ERROR(binderStatusFromStatusT(
mAudioPolicyManager->getHwOffloadEncodingFormatsSupportedForA2DP(&formats)));
*_aidl_return = VALUE_OR_RETURN_BINDER_STATUS(
- convertContainer<std::vector<media::audio::common::AudioFormat>>(
+ convertContainer<std::vector<media::AudioFormatSys>>(
formats,
legacy2aidl_audio_format_t_AudioFormat));
return Status::ok();
}
Status AudioPolicyService::setSurroundFormatEnabled(
- media::audio::common::AudioFormat audioFormatAidl, bool enabled) {
+ media::AudioFormatSys audioFormatAidl, bool enabled) {
audio_format_t audioFormat = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_AudioFormat_audio_format_t(audioFormatAidl));
if (mAudioPolicyManager == NULL) {
diff --git a/services/audiopolicy/service/AudioPolicyService.h b/services/audiopolicy/service/AudioPolicyService.h
index ac9c20f..b583484 100644
--- a/services/audiopolicy/service/AudioPolicyService.h
+++ b/services/audiopolicy/service/AudioPolicyService.h
@@ -70,13 +70,13 @@
const media::AudioDevice& device,
media::AudioPolicyDeviceState state,
const std::string& deviceName,
- media::audio::common::AudioFormat encodedFormat) override;
+ media::AudioFormatSys encodedFormat) override;
binder::Status getDeviceConnectionState(const media::AudioDevice& device,
media::AudioPolicyDeviceState* _aidl_return) override;
binder::Status handleDeviceConfigChange(
const media::AudioDevice& device,
const std::string& deviceName,
- media::audio::common::AudioFormat encodedFormat) override;
+ media::AudioFormatSys encodedFormat) override;
binder::Status setPhoneState(media::AudioMode state, int32_t uid) override;
binder::Status setForceUse(media::AudioPolicyForceUse usage,
media::AudioPolicyForcedConfig config) override;
@@ -189,13 +189,13 @@
binder::Status getStreamVolumeDB(media::AudioStreamType stream, int32_t index, int32_t device,
float* _aidl_return) override;
binder::Status getSurroundFormats(media::Int* count,
- std::vector<media::audio::common::AudioFormat>* formats,
+ std::vector<media::AudioFormatSys>* formats,
std::vector<bool>* formatsEnabled) override;
binder::Status getReportedSurroundFormats(
- media::Int* count, std::vector<media::audio::common::AudioFormat>* formats) override;
+ media::Int* count, std::vector<media::AudioFormatSys>* formats) override;
binder::Status getHwOffloadEncodingFormatsSupportedForA2DP(
- std::vector<media::audio::common::AudioFormat>* _aidl_return) override;
- binder::Status setSurroundFormatEnabled(media::audio::common::AudioFormat audioFormat,
+ std::vector<media::AudioFormatSys>* _aidl_return) override;
+ binder::Status setSurroundFormatEnabled(media::AudioFormatSys audioFormat,
bool enabled) override;
binder::Status setAssistantUid(int32_t uid) override;
binder::Status setA11yServicesUids(const std::vector<int32_t>& uids) override;
diff --git a/services/audiopolicy/tests/Android.bp b/services/audiopolicy/tests/Android.bp
index b296fb0..8fbe8b2 100644
--- a/services/audiopolicy/tests/Android.bp
+++ b/services/audiopolicy/tests/Android.bp
@@ -25,7 +25,7 @@
"libmedia_helper",
"libutils",
"libxml2",
- "libpermission",
+ "framework-permission-aidl-cpp",
"libbinder",
],
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 3deea6b..c380711 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -1861,6 +1861,27 @@
CameraServiceProxyWrapper::logOpen(cameraId, facing, clientPackageName,
effectiveApiLevel, isNdk, openLatencyMs);
+ {
+ Mutex::Autolock lock(mInjectionParametersLock);
+ if (cameraId == mInjectionInternalCamId && mInjectionInitPending) {
+ mInjectionInitPending = false;
+ status_t res = NO_ERROR;
+ auto clientDescriptor = mActiveClientManager.get(mInjectionInternalCamId);
+ if (clientDescriptor != nullptr) {
+ BasicClient* baseClientPtr = clientDescriptor->getValue().get();
+ res = baseClientPtr->injectCamera(mInjectionExternalCamId, mCameraProviderManager);
+ if (res != OK) {
+ mInjectionStatusListener->notifyInjectionError(mInjectionExternalCamId, res);
+ }
+ } else {
+ ALOGE("%s: Internal camera ID = %s 's client does not exist!",
+ __FUNCTION__, mInjectionInternalCamId.string());
+ res = NO_INIT;
+ mInjectionStatusListener->notifyInjectionError(mInjectionExternalCamId, res);
+ }
+ }
+ }
+
return ret;
}
@@ -2521,7 +2542,7 @@
const String16& externalCamId,
const sp<ICameraInjectionCallback>& callback,
/*out*/
- sp<hardware::camera2::ICameraInjectionSession>* cameraInjectionSession) {
+ sp<ICameraInjectionSession>* cameraInjectionSession) {
ATRACE_CALL();
if (!checkCallingPermission(sCameraInjectExternalCameraPermission)) {
@@ -2538,18 +2559,30 @@
__FUNCTION__, String8(packageName).string(),
String8(internalCamId).string(), String8(externalCamId).string());
- binder::Status ret = binder::Status::ok();
- // TODO: Implement the injection camera function.
- // ret = internalInjectCamera(...);
- // if(!ret.isOk()) {
- // mInjectionStatusListener->notifyInjectionError(...);
- // return ret;
- // }
-
+ {
+ Mutex::Autolock lock(mInjectionParametersLock);
+ mInjectionInternalCamId = String8(internalCamId);
+ mInjectionExternalCamId = String8(externalCamId);
+ status_t res = NO_ERROR;
+ auto clientDescriptor = mActiveClientManager.get(mInjectionInternalCamId);
+ // If the client already exists, we can directly connect to the camera device through the
+ // client's injectCamera(), otherwise we need to wait until the client is established
+ // (execute connectHelper()) before injecting the camera to the camera device.
+ if (clientDescriptor != nullptr) {
+ mInjectionInitPending = false;
+ BasicClient* baseClientPtr = clientDescriptor->getValue().get();
+ res = baseClientPtr->injectCamera(mInjectionExternalCamId, mCameraProviderManager);
+ if(res != OK) {
+ mInjectionStatusListener->notifyInjectionError(mInjectionExternalCamId, res);
+ }
+ } else {
+ mInjectionInitPending = true;
+ }
+ }
mInjectionStatusListener->addListener(callback);
*cameraInjectionSession = new CameraInjectionSession(this);
- return ret;
+ return binder::Status::ok();
}
void CameraService::removeByClient(const BasicClient* client) {
@@ -3814,13 +3847,50 @@
}
void CameraService::InjectionStatusListener::notifyInjectionError(
- int errorCode) {
+ String8 injectedCamId, status_t err) {
Mutex::Autolock lock(mListenerLock);
if (mCameraInjectionCallback == nullptr) {
ALOGW("InjectionStatusListener: mCameraInjectionCallback == nullptr");
return;
}
- mCameraInjectionCallback->onInjectionError(errorCode);
+
+ switch (err) {
+ case -ENODEV:
+ mCameraInjectionCallback->onInjectionError(
+ ICameraInjectionCallback::ERROR_INJECTION_SESSION);
+ ALOGE("No camera device with ID \"%s\" currently available!",
+ injectedCamId.string());
+ break;
+ case -EBUSY:
+ mCameraInjectionCallback->onInjectionError(
+ ICameraInjectionCallback::ERROR_INJECTION_SESSION);
+ ALOGE("Higher-priority client using camera, ID \"%s\" currently unavailable!",
+ injectedCamId.string());
+ break;
+ case DEAD_OBJECT:
+ mCameraInjectionCallback->onInjectionError(
+ ICameraInjectionCallback::ERROR_INJECTION_SESSION);
+ ALOGE("Camera ID \"%s\" object is dead!",
+ injectedCamId.string());
+ break;
+ case INVALID_OPERATION:
+ mCameraInjectionCallback->onInjectionError(
+ ICameraInjectionCallback::ERROR_INJECTION_SESSION);
+ ALOGE("Camera ID \"%s\" encountered an operating or internal error!",
+ injectedCamId.string());
+ break;
+ case UNKNOWN_TRANSACTION:
+ mCameraInjectionCallback->onInjectionError(
+ ICameraInjectionCallback::ERROR_INJECTION_UNSUPPORTED);
+ ALOGE("Camera ID \"%s\" method doesn't support!",
+ injectedCamId.string());
+ break;
+ default:
+ mCameraInjectionCallback->onInjectionError(
+ ICameraInjectionCallback::ERROR_INJECTION_INVALID_ERROR);
+ ALOGE("Unexpected error %s (%d) opening camera \"%s\"!",
+ strerror(-err), err, injectedCamId.string());
+ }
}
void CameraService::InjectionStatusListener::binderDied(
@@ -3829,7 +3899,12 @@
ALOGV("InjectionStatusListener: ICameraInjectionCallback has died");
auto parent = mParent.promote();
if (parent != nullptr) {
- parent->stopInjectionImpl();
+ parent->clearInjectionParameters();
+ auto clientDescriptor = parent->mActiveClientManager.get(parent->mInjectionInternalCamId);
+ if (clientDescriptor != nullptr) {
+ BasicClient* baseClientPtr = clientDescriptor->getValue().get();
+ baseClientPtr->stopInjection();
+ }
}
}
@@ -3845,7 +3920,20 @@
return STATUS_ERROR(ICameraInjectionCallback::ERROR_INJECTION_SERVICE,
"Camera service encountered error");
}
- parent->stopInjectionImpl();
+
+ status_t res = NO_ERROR;
+ parent->clearInjectionParameters();
+ auto clientDescriptor = parent->mActiveClientManager.get(parent->mInjectionInternalCamId);
+ if (clientDescriptor != nullptr) {
+ BasicClient* baseClientPtr = clientDescriptor->getValue().get();
+ res = baseClientPtr->stopInjection();
+ if (res != OK) {
+ ALOGE("CameraInjectionSession: Failed to stop the injection camera!"
+ " ret != NO_ERROR: %d", res);
+ return STATUS_ERROR(ICameraInjectionCallback::ERROR_INJECTION_SESSION,
+ "Camera session encountered error");
+ }
+ }
return binder::Status::ok();
}
@@ -4554,10 +4642,14 @@
return mode;
}
-void CameraService::stopInjectionImpl() {
+void CameraService::clearInjectionParameters() {
+ {
+ Mutex::Autolock lock(mInjectionParametersLock);
+ mInjectionInitPending = true;
+ mInjectionInternalCamId = "";
+ }
+ mInjectionExternalCamId = "";
mInjectionStatusListener->removeListener();
-
- // TODO: Implement the stop injection function.
}
}; // namespace android
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index 1fb7104..dc194cc 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -320,6 +320,14 @@
// Set/reset camera mute
virtual status_t setCameraMute(bool enabled) = 0;
+ // The injection camera session to replace the internal camera
+ // session.
+ virtual status_t injectCamera(const String8& injectedCamId,
+ sp<CameraProviderManager> manager) = 0;
+
+ // Stop the injection camera and restore to internal camera session.
+ virtual status_t stopInjection() = 0;
+
protected:
BasicClient(const sp<CameraService>& cameraService,
const sp<IBinder>& remoteCallback,
@@ -1190,7 +1198,7 @@
void addListener(const sp<hardware::camera2::ICameraInjectionCallback>& callback);
void removeListener();
- void notifyInjectionError(int errorCode);
+ void notifyInjectionError(String8 injectedCamId, status_t err);
// IBinder::DeathRecipient implementation
virtual void binderDied(const wp<IBinder>& who);
@@ -1217,7 +1225,15 @@
wp<CameraService> mParent;
};
- void stopInjectionImpl();
+ void clearInjectionParameters();
+
+ // This is the existing camera id being replaced.
+ String8 mInjectionInternalCamId;
+ // This is the external camera Id replacing the internalId.
+ String8 mInjectionExternalCamId;
+ bool mInjectionInitPending = true;
+ // Guard mInjectionInternalCamId and mInjectionInitPending.
+ Mutex mInjectionParametersLock;
};
} // namespace android
diff --git a/services/camera/libcameraservice/api2/CameraOfflineSessionClient.cpp b/services/camera/libcameraservice/api2/CameraOfflineSessionClient.cpp
index ef15f2d..652842b 100644
--- a/services/camera/libcameraservice/api2/CameraOfflineSessionClient.cpp
+++ b/services/camera/libcameraservice/api2/CameraOfflineSessionClient.cpp
@@ -330,5 +330,19 @@
CaptureResultExtras());
}
+status_t CameraOfflineSessionClient::injectCamera(const String8& injectedCamId,
+ sp<CameraProviderManager> manager) {
+ ALOGV("%s: This client doesn't support the injection camera. injectedCamId: %s providerPtr: %p",
+ __FUNCTION__, injectedCamId.string(), manager.get());
+
+ return OK;
+}
+
+status_t CameraOfflineSessionClient::stopInjection() {
+ ALOGV("%s: This client doesn't support the injection camera.", __FUNCTION__);
+
+ return OK;
+}
+
// ----------------------------------------------------------------------------
}; // namespace android
diff --git a/services/camera/libcameraservice/api2/CameraOfflineSessionClient.h b/services/camera/libcameraservice/api2/CameraOfflineSessionClient.h
index b219a4c..b5238b8 100644
--- a/services/camera/libcameraservice/api2/CameraOfflineSessionClient.h
+++ b/services/camera/libcameraservice/api2/CameraOfflineSessionClient.h
@@ -98,6 +98,9 @@
void notifyPrepared(int streamId) override;
void notifyRequestQueueEmpty() override;
void notifyRepeatingRequestError(long lastFrameNumber) override;
+ status_t injectCamera(const String8& injectedCamId,
+ sp<CameraProviderManager> manager) override;
+ status_t stopInjection() override;
private:
mutable Mutex mBinderSerializationLock;
diff --git a/services/camera/libcameraservice/common/Camera2ClientBase.cpp b/services/camera/libcameraservice/common/Camera2ClientBase.cpp
index 13d044a..1147e23 100644
--- a/services/camera/libcameraservice/common/Camera2ClientBase.cpp
+++ b/services/camera/libcameraservice/common/Camera2ClientBase.cpp
@@ -413,6 +413,17 @@
mRemoteCallback.clear();
}
+template <typename TClientBase>
+status_t Camera2ClientBase<TClientBase>::injectCamera(const String8& injectedCamId,
+ sp<CameraProviderManager> manager) {
+ return mDevice->injectCamera(injectedCamId, manager);
+}
+
+template <typename TClientBase>
+status_t Camera2ClientBase<TClientBase>::stopInjection() {
+ return mDevice->stopInjection();
+}
+
template class Camera2ClientBase<CameraService::Client>;
template class Camera2ClientBase<CameraDeviceClientBase>;
diff --git a/services/camera/libcameraservice/common/Camera2ClientBase.h b/services/camera/libcameraservice/common/Camera2ClientBase.h
index 6246f7b..b593bfa 100644
--- a/services/camera/libcameraservice/common/Camera2ClientBase.h
+++ b/services/camera/libcameraservice/common/Camera2ClientBase.h
@@ -114,6 +114,10 @@
mutable Mutex mRemoteCallbackLock;
} mSharedCameraCallbacks;
+ status_t injectCamera(const String8& injectedCamId,
+ sp<CameraProviderManager> manager) override;
+ status_t stopInjection() override;
+
protected:
// The PID provided in the constructor call
diff --git a/services/camera/libcameraservice/common/CameraDeviceBase.h b/services/camera/libcameraservice/common/CameraDeviceBase.h
index 85b0cc2..3c95ed3 100644
--- a/services/camera/libcameraservice/common/CameraDeviceBase.h
+++ b/services/camera/libcameraservice/common/CameraDeviceBase.h
@@ -427,6 +427,18 @@
*/
void setImageDumpMask(int mask) { mImageDumpMask = mask; }
+ /**
+ * The injection camera session to replace the internal camera
+ * session.
+ */
+ virtual status_t injectCamera(const String8& injectedCamId,
+ sp<CameraProviderManager> manager) = 0;
+
+ /**
+ * Stop the injection camera and restore to internal camera session.
+ */
+ virtual status_t stopInjection() = 0;
+
protected:
bool mImageDumpMask = 0;
};