Merge "Simplify some code in NuPlayerRenderer"
diff --git a/camera/OWNERS b/camera/OWNERS
index d6b95da..47d1d19 100644
--- a/camera/OWNERS
+++ b/camera/OWNERS
@@ -2,7 +2,7 @@
etalvala@google.com
jchowdhary@google.com
shuzhenwang@google.com
-yinchiayeh@google.com
+ruchamk@google.com
# backup owner
cychen@google.com
zhijunhe@google.com
diff --git a/drm/mediadrm/plugins/TEST_MAPPING b/drm/mediadrm/plugins/TEST_MAPPING
index 87becb6..fd4ef95 100644
--- a/drm/mediadrm/plugins/TEST_MAPPING
+++ b/drm/mediadrm/plugins/TEST_MAPPING
@@ -1,19 +1,19 @@
{
"presubmit": [
{
- "name": "CtsMediaTestCases",
+ "name": "CtsMediaDrmTestCases",
"options" : [
{
"include-annotation": "android.platform.test.annotations.Presubmit"
},
{
- "include-filter": "android.media.cts.MediaDrmClearkeyTest"
+ "include-filter": "android.mediadrm.cts.MediaDrmClearkeyTest"
},
{
- "include-filter": "android.media.cts.MediaDrmMetricsTest"
+ "include-filter": "android.mediadrm.cts.MediaDrmMetricsTest"
},
{
- "include-filter": "android.media.cts.NativeMediaDrmClearkeyTest"
+ "include-filter": "android.mediadrm.cts.NativeMediaDrmClearkeyTest"
}
]
}
diff --git a/media/codec2/components/aac/C2SoftAacDec.cpp b/media/codec2/components/aac/C2SoftAacDec.cpp
index 342d771..57cdcd0 100644
--- a/media/codec2/components/aac/C2SoftAacDec.cpp
+++ b/media/codec2/components/aac/C2SoftAacDec.cpp
@@ -287,6 +287,7 @@
mOutputDelayRingBufferWritePos = 0;
mOutputDelayRingBufferReadPos = 0;
mOutputDelayRingBufferFilled = 0;
+ mOutputDelayRingBuffer.reset();
mBuffersInfo.clear();
status_t status = UNKNOWN_ERROR;
@@ -308,10 +309,7 @@
aacDecoder_Close(mAACDecoder);
mAACDecoder = nullptr;
}
- if (mOutputDelayRingBuffer) {
- delete[] mOutputDelayRingBuffer;
- mOutputDelayRingBuffer = nullptr;
- }
+ mOutputDelayRingBuffer.reset();
}
status_t C2SoftAacDec::initDecoder() {
@@ -327,7 +325,7 @@
mOutputDelayCompensated = 0;
mOutputDelayRingBufferSize = 2048 * MAX_CHANNEL_COUNT * kNumDelayBlocksMax;
- mOutputDelayRingBuffer = new short[mOutputDelayRingBufferSize];
+ mOutputDelayRingBuffer.reset(new short[mOutputDelayRingBufferSize]);
mOutputDelayRingBufferWritePos = 0;
mOutputDelayRingBufferReadPos = 0;
mOutputDelayRingBufferFilled = 0;
diff --git a/media/codec2/components/aac/C2SoftAacDec.h b/media/codec2/components/aac/C2SoftAacDec.h
index 986187c..a03fc70 100644
--- a/media/codec2/components/aac/C2SoftAacDec.h
+++ b/media/codec2/components/aac/C2SoftAacDec.h
@@ -93,7 +93,7 @@
bool mEndOfOutput;
int32_t mOutputDelayCompensated;
int32_t mOutputDelayRingBufferSize;
- short *mOutputDelayRingBuffer;
+ std::unique_ptr<short[]> mOutputDelayRingBuffer;
int32_t mOutputDelayRingBufferWritePos;
int32_t mOutputDelayRingBufferReadPos;
int32_t mOutputDelayRingBufferFilled;
diff --git a/media/codec2/components/mpeg4_h263/C2SoftMpeg4Dec.cpp b/media/codec2/components/mpeg4_h263/C2SoftMpeg4Dec.cpp
index 60d6b44..81f4679 100644
--- a/media/codec2/components/mpeg4_h263/C2SoftMpeg4Dec.cpp
+++ b/media/codec2/components/mpeg4_h263/C2SoftMpeg4Dec.cpp
@@ -228,7 +228,6 @@
const std::shared_ptr<IntfImpl> &intfImpl)
: SimpleC2Component(std::make_shared<SimpleInterface<IntfImpl>>(name, id, intfImpl)),
mIntf(intfImpl),
- mDecHandle(nullptr),
mOutputBuffer{},
mInitialized(false) {
}
@@ -243,13 +242,9 @@
}
c2_status_t C2SoftMpeg4Dec::onStop() {
- if (mDecHandle) {
- if (mInitialized) {
- PVCleanUpVideoDecoder(mDecHandle);
- mInitialized = false;
- }
- delete mDecHandle;
- mDecHandle = nullptr;
+ if (mInitialized) {
+ PVCleanUpVideoDecoder(&mVideoDecControls);
+ mInitialized = false;
}
for (int32_t i = 0; i < kNumOutputBuffers; ++i) {
if (mOutputBuffer[i]) {
@@ -279,7 +274,7 @@
c2_status_t C2SoftMpeg4Dec::onFlush_sm() {
if (mInitialized) {
- if (PV_TRUE != PVResetVideoDecoder(mDecHandle)) {
+ if (PV_TRUE != PVResetVideoDecoder(&mVideoDecControls)) {
return C2_CORRUPTED;
}
}
@@ -294,14 +289,8 @@
#else
mIsMpeg4 = false;
#endif
- if (!mDecHandle) {
- mDecHandle = new tagvideoDecControls;
- }
- if (!mDecHandle) {
- ALOGE("mDecHandle is null");
- return NO_MEMORY;
- }
- memset(mDecHandle, 0, sizeof(tagvideoDecControls));
+
+ memset(&mVideoDecControls, 0, sizeof(tagvideoDecControls));
/* TODO: bring these values to 352 and 288. It cannot be done as of now
* because, h263 doesn't seem to allow port reconfiguration. In OMX, the
@@ -357,10 +346,6 @@
}
c2_status_t C2SoftMpeg4Dec::ensureDecoderState(const std::shared_ptr<C2BlockPool> &pool) {
- if (!mDecHandle) {
- ALOGE("not supposed to be here, invalid decoder context");
- return C2_CORRUPTED;
- }
mOutputBufferSize = align(mIntf->getMaxWidth(), 16) * align(mIntf->getMaxHeight(), 16) * 3 / 2;
for (int32_t i = 0; i < kNumOutputBuffers; ++i) {
@@ -391,10 +376,10 @@
bool C2SoftMpeg4Dec::handleResChange(const std::unique_ptr<C2Work> &work) {
uint32_t disp_width, disp_height;
- PVGetVideoDimensions(mDecHandle, (int32 *)&disp_width, (int32 *)&disp_height);
+ PVGetVideoDimensions(&mVideoDecControls, (int32 *)&disp_width, (int32 *)&disp_height);
uint32_t buf_width, buf_height;
- PVGetBufferDimensions(mDecHandle, (int32 *)&buf_width, (int32 *)&buf_height);
+ PVGetBufferDimensions(&mVideoDecControls, (int32 *)&buf_width, (int32 *)&buf_height);
CHECK_LE(disp_width, buf_width);
CHECK_LE(disp_height, buf_height);
@@ -415,13 +400,14 @@
}
if (!mIsMpeg4) {
- PVCleanUpVideoDecoder(mDecHandle);
+ PVCleanUpVideoDecoder(&mVideoDecControls);
uint8_t *vol_data[1]{};
int32_t vol_size = 0;
if (!PVInitVideoDecoder(
- mDecHandle, vol_data, &vol_size, 1, mIntf->getMaxWidth(), mIntf->getMaxHeight(), H263_MODE)) {
+ &mVideoDecControls, vol_data, &vol_size, 1, mIntf->getMaxWidth(),
+ mIntf->getMaxHeight(), H263_MODE)) {
ALOGE("Error in PVInitVideoDecoder H263_MODE while resChanged was set to true");
mSignalledError = true;
work->result = C2_CORRUPTED;
@@ -511,7 +497,7 @@
uint32_t *start_code = (uint32_t *)bitstream;
bool volHeader = *start_code == 0xB0010000;
if (volHeader) {
- PVCleanUpVideoDecoder(mDecHandle);
+ PVCleanUpVideoDecoder(&mVideoDecControls);
mInitialized = false;
}
@@ -526,7 +512,7 @@
}
MP4DecodingMode mode = (mIsMpeg4) ? MPEG4_MODE : H263_MODE;
if (!PVInitVideoDecoder(
- mDecHandle, vol_data, &vol_size, 1,
+ &mVideoDecControls, vol_data, &vol_size, 1,
mIntf->getMaxWidth(), mIntf->getMaxHeight(), mode)) {
ALOGE("PVInitVideoDecoder failed. Unsupported content?");
mSignalledError = true;
@@ -534,7 +520,7 @@
return;
}
mInitialized = true;
- MP4DecodingMode actualMode = PVGetDecBitstreamMode(mDecHandle);
+ MP4DecodingMode actualMode = PVGetDecBitstreamMode(&mVideoDecControls);
if (mode != actualMode) {
ALOGE("Decoded mode not same as actual mode of the decoder");
mSignalledError = true;
@@ -542,7 +528,7 @@
return;
}
- PVSetPostProcType(mDecHandle, 0);
+ PVSetPostProcType(&mVideoDecControls, 0);
if (handleResChange(work)) {
ALOGI("Setting width and height");
C2StreamPictureSizeInfo::output size(0u, mWidth, mHeight);
@@ -579,7 +565,7 @@
return;
}
- uint32_t yFrameSize = sizeof(uint8) * mDecHandle->size;
+ uint32_t yFrameSize = sizeof(uint8) * mVideoDecControls.size;
if (mOutputBufferSize < yFrameSize * 3 / 2){
ALOGE("Too small output buffer: %zu bytes", mOutputBufferSize);
mSignalledError = true;
@@ -588,7 +574,7 @@
}
if (!mFramesConfigured) {
- PVSetReferenceYUV(mDecHandle,mOutputBuffer[1]);
+ PVSetReferenceYUV(&mVideoDecControls,mOutputBuffer[1]);
mFramesConfigured = true;
}
@@ -599,7 +585,7 @@
uint8_t *bitstreamTmp = bitstream;
uint32_t timestamp = workIndex;
if (PVDecodeVopHeader(
- mDecHandle, &bitstreamTmp, ×tamp, &tmpInSize,
+ &mVideoDecControls, &bitstreamTmp, ×tamp, &tmpInSize,
&header_info, &useExtTimestamp,
mOutputBuffer[mNumSamplesOutput & 1]) != PV_TRUE) {
ALOGE("failed to decode vop header.");
@@ -631,7 +617,7 @@
continue;
}
- if (PVDecodeVopBody(mDecHandle, &tmpInSize) != PV_TRUE) {
+ if (PVDecodeVopBody(&mVideoDecControls, &tmpInSize) != PV_TRUE) {
ALOGE("failed to decode video frame.");
mSignalledError = true;
work->result = C2_CORRUPTED;
diff --git a/media/codec2/components/mpeg4_h263/C2SoftMpeg4Dec.h b/media/codec2/components/mpeg4_h263/C2SoftMpeg4Dec.h
index 716a095..fed04c9 100644
--- a/media/codec2/components/mpeg4_h263/C2SoftMpeg4Dec.h
+++ b/media/codec2/components/mpeg4_h263/C2SoftMpeg4Dec.h
@@ -19,8 +19,8 @@
#include <SimpleC2Component.h>
+#include <mp4dec_api.h>
-struct tagvideoDecControls;
namespace android {
@@ -54,7 +54,7 @@
bool handleResChange(const std::unique_ptr<C2Work> &work);
std::shared_ptr<IntfImpl> mIntf;
- tagvideoDecControls *mDecHandle;
+ tagvideoDecControls mVideoDecControls;
std::shared_ptr<C2GraphicBlock> mOutBlock;
uint8_t *mOutputBuffer[kNumOutputBuffers];
size_t mOutputBufferSize;
diff --git a/media/codec2/components/vpx/C2SoftVpxDec.cpp b/media/codec2/components/vpx/C2SoftVpxDec.cpp
index 2953d90..45e2ca8 100644
--- a/media/codec2/components/vpx/C2SoftVpxDec.cpp
+++ b/media/codec2/components/vpx/C2SoftVpxDec.cpp
@@ -149,8 +149,16 @@
#else
addParameter(
DefineParam(mProfileLevel, C2_PARAMKEY_PROFILE_LEVEL)
- .withConstValue(new C2StreamProfileLevelInfo::input(0u,
- C2Config::PROFILE_UNUSED, C2Config::LEVEL_UNUSED))
+ .withDefault(new C2StreamProfileLevelInfo::input(0u,
+ C2Config::PROFILE_VP8_0, C2Config::LEVEL_UNUSED))
+ .withFields({
+ C2F(mProfileLevel, profile).equalTo(
+ PROFILE_VP8_0
+ ),
+ C2F(mProfileLevel, level).equalTo(
+ LEVEL_UNUSED),
+ })
+ .withSetter(ProfileLevelSetter, mSize)
.build());
#endif
diff --git a/media/codec2/components/vpx/C2SoftVpxEnc.h b/media/codec2/components/vpx/C2SoftVpxEnc.h
index c98b802..926b2e9 100644
--- a/media/codec2/components/vpx/C2SoftVpxEnc.h
+++ b/media/codec2/components/vpx/C2SoftVpxEnc.h
@@ -324,21 +324,35 @@
.withConstValue(new C2StreamIntraRefreshTuning::output(
0u, C2Config::INTRA_REFRESH_DISABLED, 0.))
.build());
-
+#ifdef VP9
addParameter(
- DefineParam(mProfileLevel, C2_PARAMKEY_PROFILE_LEVEL)
- .withDefault(new C2StreamProfileLevelInfo::output(
- 0u, PROFILE_VP9_0, LEVEL_VP9_4_1))
- .withFields({
- C2F(mProfileLevel, profile).equalTo(
- PROFILE_VP9_0
- ),
- C2F(mProfileLevel, level).equalTo(
- LEVEL_VP9_4_1),
- })
- .withSetter(ProfileLevelSetter)
- .build());
-
+ DefineParam(mProfileLevel, C2_PARAMKEY_PROFILE_LEVEL)
+ .withDefault(new C2StreamProfileLevelInfo::output(
+ 0u, PROFILE_VP9_0, LEVEL_VP9_4_1))
+ .withFields({
+ C2F(mProfileLevel, profile).equalTo(
+ PROFILE_VP9_0
+ ),
+ C2F(mProfileLevel, level).equalTo(
+ LEVEL_VP9_4_1),
+ })
+ .withSetter(ProfileLevelSetter)
+ .build());
+#else
+ addParameter(
+ DefineParam(mProfileLevel, C2_PARAMKEY_PROFILE_LEVEL)
+ .withDefault(new C2StreamProfileLevelInfo::output(
+ 0u, PROFILE_VP8_0, LEVEL_UNUSED))
+ .withFields({
+ C2F(mProfileLevel, profile).equalTo(
+ PROFILE_VP8_0
+ ),
+ C2F(mProfileLevel, level).equalTo(
+ LEVEL_UNUSED),
+ })
+ .withSetter(ProfileLevelSetter)
+ .build());
+#endif
addParameter(
DefineParam(mRequestSync, C2_PARAMKEY_REQUEST_SYNC_FRAME)
.withDefault(new C2StreamRequestSyncFrameTuning::output(0u, C2_FALSE))
diff --git a/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioEncTest.cpp b/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioEncTest.cpp
index c487fa3..1dc037a 100644
--- a/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioEncTest.cpp
+++ b/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioEncTest.cpp
@@ -81,6 +81,7 @@
mEos = false;
mCsd = false;
mFramesReceived = 0;
+ mEncoderFrameSize = 0;
mWorkResult = C2_OK;
mOutputSize = 0u;
getInputMaxBufSize();
@@ -146,6 +147,7 @@
uint32_t mFramesReceived;
int32_t mInputMaxBufSize;
uint64_t mOutputSize;
+ uint32_t mEncoderFrameSize;
std::list<uint64_t> mFlushedIndices;
C2BlockPool::local_id_t mBlockPoolId;
@@ -304,20 +306,21 @@
c2_status_t c2err = mComponent->query({}, {C2StreamAudioFrameSizeInfo::input::PARAM_TYPE},
C2_DONT_BLOCK, &queried);
size_t offset = sizeof(C2Param);
- uint32_t maxInputSize = 0;
if (c2err == C2_OK && queried.size()) {
C2Param* param = queried[0].get();
- maxInputSize = *(uint32_t*)((uint8_t*)param + offset);
+ mEncoderFrameSize = *(uint32_t*)((uint8_t*)param + offset);
+ if (mEncoderFrameSize) {
+ *samplesPerFrame = mEncoderFrameSize;
+ return C2_OK;
+ }
}
- if (0 == maxInputSize) {
- c2err = mComponent->query({}, {C2StreamMaxBufferSizeInfo::input::PARAM_TYPE}, C2_DONT_BLOCK,
- &queried);
- if (c2err != C2_OK || queried.size() == 0) return c2err;
+ c2err = mComponent->query({}, {C2StreamMaxBufferSizeInfo::input::PARAM_TYPE}, C2_DONT_BLOCK,
+ &queried);
+ if (c2err != C2_OK || queried.size() == 0) return c2err;
- C2Param* param = queried[0].get();
- maxInputSize = *(uint32_t*)((uint8_t*)param + offset);
- }
+ C2Param* param = queried[0].get();
+ uint32_t maxInputSize = *(uint32_t*)((uint8_t*)param + offset);
*samplesPerFrame = std::min((maxInputSize / (nChannels * 2)), kMaxSamplesPerFrame);
return C2_OK;
@@ -450,10 +453,13 @@
ALOGV("EncodeTest");
if (mDisableTest) GTEST_SKIP() << "Test is disabled";
bool signalEOS = std::get<2>(GetParam());
- // Ratio w.r.t to mInputMaxBufSize
- int32_t inputMaxBufRatio = std::get<3>(GetParam());
- mSamplesPerFrame = ((mInputMaxBufSize / inputMaxBufRatio) / (mNumChannels * 2));
-
+ // Set samples per frame based on inputMaxBufRatio if component does not
+ // advertise supported frame size
+ if (!mEncoderFrameSize) {
+ // Ratio w.r.t to mInputMaxBufSize
+ int32_t inputMaxBufRatio = std::get<3>(GetParam());
+ mSamplesPerFrame = ((mInputMaxBufSize / inputMaxBufRatio) / (mNumChannels * 2));
+ }
ALOGV("signalEOS %d mInputMaxBufSize %d mSamplesPerFrame %d", signalEOS, mInputMaxBufSize,
mSamplesPerFrame);
diff --git a/media/codec2/vndk/C2PlatformStorePluginLoader.cpp b/media/codec2/vndk/C2PlatformStorePluginLoader.cpp
index bee028a..2a888a8 100644
--- a/media/codec2/vndk/C2PlatformStorePluginLoader.cpp
+++ b/media/codec2/vndk/C2PlatformStorePluginLoader.cpp
@@ -59,13 +59,14 @@
c2_status_t C2PlatformStorePluginLoader::createBlockPool(
::C2Allocator::id_t allocatorId, ::C2BlockPool::local_id_t blockPoolId,
- std::shared_ptr<C2BlockPool>* pool) {
+ std::shared_ptr<C2BlockPool>* pool,
+ std::function<void(C2BlockPool *)> deleter) {
if (mCreateBlockPool == nullptr) {
ALOGD("Handle or CreateBlockPool symbol is null");
return C2_NOT_FOUND;
}
- std::shared_ptr<::C2BlockPool> ptr(mCreateBlockPool(allocatorId, blockPoolId));
+ std::shared_ptr<::C2BlockPool> ptr(mCreateBlockPool(allocatorId, blockPoolId), deleter);
if (ptr) {
*pool = ptr;
return C2_OK;
@@ -75,14 +76,16 @@
}
c2_status_t C2PlatformStorePluginLoader::createAllocator(
- ::C2Allocator::id_t allocatorId, std::shared_ptr<C2Allocator>* const allocator) {
+ ::C2Allocator::id_t allocatorId,
+ std::shared_ptr<C2Allocator>* const allocator,
+ std::function<void(C2Allocator *)> deleter) {
if (mCreateAllocator == nullptr) {
ALOGD("Handle or CreateAllocator symbol is null");
return C2_NOT_FOUND;
}
c2_status_t res = C2_CORRUPTED;
- allocator->reset(mCreateAllocator(allocatorId, &res));
+ allocator->reset(mCreateAllocator(allocatorId, &res), deleter);
if (res != C2_OK) {
ALOGD("Failed to CreateAllocator by id: %u, res: %d", allocatorId, res);
allocator->reset();
diff --git a/media/codec2/vndk/C2Store.cpp b/media/codec2/vndk/C2Store.cpp
index c07c09e..1660c38 100644
--- a/media/codec2/vndk/C2Store.cpp
+++ b/media/codec2/vndk/C2Store.cpp
@@ -443,6 +443,7 @@
public:
_C2BlockPoolCache() : mBlockPoolSeqId(C2BlockPool::PLATFORM_START + 1) {}
+private:
c2_status_t _createBlockPool(
C2PlatformAllocatorStore::id_t allocatorId,
std::vector<std::shared_ptr<const C2Component>> components,
@@ -456,14 +457,19 @@
if (allocatorId == C2AllocatorStore::DEFAULT_LINEAR) {
allocatorId = GetPreferredLinearAllocatorId(GetCodec2PoolMask());
}
+ auto deleter = [this, poolId](C2BlockPool *pool) {
+ std::unique_lock lock(mMutex);
+ mBlockPools.erase(poolId);
+ mComponents.erase(poolId);
+ delete pool;
+ };
switch(allocatorId) {
case C2PlatformAllocatorStore::ION: /* also ::DMABUFHEAP */
res = allocatorStore->fetchAllocator(
C2PlatformAllocatorStore::ION, &allocator);
if (res == C2_OK) {
- std::shared_ptr<C2BlockPool> ptr =
- std::make_shared<C2PooledBlockPool>(
- allocator, poolId);
+ std::shared_ptr<C2BlockPool> ptr(
+ new C2PooledBlockPool(allocator, poolId), deleter);
*pool = ptr;
mBlockPools[poolId] = ptr;
mComponents[poolId].insert(
@@ -475,9 +481,8 @@
res = allocatorStore->fetchAllocator(
C2PlatformAllocatorStore::BLOB, &allocator);
if (res == C2_OK) {
- std::shared_ptr<C2BlockPool> ptr =
- std::make_shared<C2PooledBlockPool>(
- allocator, poolId);
+ std::shared_ptr<C2BlockPool> ptr(
+ new C2PooledBlockPool(allocator, poolId), deleter);
*pool = ptr;
mBlockPools[poolId] = ptr;
mComponents[poolId].insert(
@@ -490,8 +495,8 @@
res = allocatorStore->fetchAllocator(
C2AllocatorStore::DEFAULT_GRAPHIC, &allocator);
if (res == C2_OK) {
- std::shared_ptr<C2BlockPool> ptr =
- std::make_shared<C2PooledBlockPool>(allocator, poolId);
+ std::shared_ptr<C2BlockPool> ptr(
+ new C2PooledBlockPool(allocator, poolId), deleter);
*pool = ptr;
mBlockPools[poolId] = ptr;
mComponents[poolId].insert(
@@ -503,9 +508,8 @@
res = allocatorStore->fetchAllocator(
C2PlatformAllocatorStore::BUFFERQUEUE, &allocator);
if (res == C2_OK) {
- std::shared_ptr<C2BlockPool> ptr =
- std::make_shared<C2BufferQueueBlockPool>(
- allocator, poolId);
+ std::shared_ptr<C2BlockPool> ptr(
+ new C2BufferQueueBlockPool(allocator, poolId), deleter);
*pool = ptr;
mBlockPools[poolId] = ptr;
mComponents[poolId].insert(
@@ -517,7 +521,7 @@
// Try to create block pool from platform store plugins.
std::shared_ptr<C2BlockPool> ptr;
res = C2PlatformStorePluginLoader::GetInstance()->createBlockPool(
- allocatorId, poolId, &ptr);
+ allocatorId, poolId, &ptr, deleter);
if (res == C2_OK) {
*pool = ptr;
mBlockPools[poolId] = ptr;
@@ -530,17 +534,20 @@
return res;
}
+public:
c2_status_t createBlockPool(
C2PlatformAllocatorStore::id_t allocatorId,
std::vector<std::shared_ptr<const C2Component>> components,
std::shared_ptr<C2BlockPool> *pool) {
+ std::unique_lock lock(mMutex);
return _createBlockPool(allocatorId, components, mBlockPoolSeqId++, pool);
}
- bool getBlockPool(
+ c2_status_t getBlockPool(
C2BlockPool::local_id_t blockPoolId,
std::shared_ptr<const C2Component> component,
std::shared_ptr<C2BlockPool> *pool) {
+ std::unique_lock lock(mMutex);
// TODO: use one iterator for multiple blockpool type scalability.
std::shared_ptr<C2BlockPool> ptr;
auto it = mBlockPools.find(blockPoolId);
@@ -558,14 +565,22 @@
});
if (found != mComponents[blockPoolId].end()) {
*pool = ptr;
- return true;
+ return C2_OK;
}
}
}
- return false;
+ // TODO: remove this. this is temporary
+ if (blockPoolId == C2BlockPool::PLATFORM_START) {
+ return _createBlockPool(
+ C2PlatformAllocatorStore::BUFFERQUEUE, {component}, blockPoolId, pool);
+ }
+ return C2_NOT_FOUND;
}
private:
+ // Deleter needs to hold this mutex, and there is a small chance that deleter
+ // is invoked while the mutex is held.
+ std::recursive_mutex mMutex;
C2BlockPool::local_id_t mBlockPoolSeqId;
std::map<C2BlockPool::local_id_t, std::weak_ptr<C2BlockPool>> mBlockPools;
@@ -574,7 +589,6 @@
static std::unique_ptr<_C2BlockPoolCache> sBlockPoolCache =
std::make_unique<_C2BlockPoolCache>();
-static std::mutex sBlockPoolCacheMutex;
} // anynymous namespace
@@ -582,15 +596,12 @@
C2BlockPool::local_id_t id, std::shared_ptr<const C2Component> component,
std::shared_ptr<C2BlockPool> *pool) {
pool->reset();
- std::lock_guard<std::mutex> lock(sBlockPoolCacheMutex);
std::shared_ptr<C2AllocatorStore> allocatorStore = GetCodec2PlatformAllocatorStore();
std::shared_ptr<C2Allocator> allocator;
c2_status_t res = C2_NOT_FOUND;
if (id >= C2BlockPool::PLATFORM_START) {
- if (sBlockPoolCache->getBlockPool(id, component, pool)) {
- return C2_OK;
- }
+ return sBlockPoolCache->getBlockPool(id, component, pool);
}
switch (id) {
@@ -606,11 +617,6 @@
*pool = std::make_shared<C2BasicGraphicBlockPool>(allocator);
}
break;
- // TODO: remove this. this is temporary
- case C2BlockPool::PLATFORM_START:
- res = sBlockPoolCache->_createBlockPool(
- C2PlatformAllocatorStore::BUFFERQUEUE, {component}, id, pool);
- break;
default:
break;
}
@@ -623,7 +629,6 @@
std::shared_ptr<C2BlockPool> *pool) {
pool->reset();
- std::lock_guard<std::mutex> lock(sBlockPoolCacheMutex);
return sBlockPoolCache->createBlockPool(allocatorId, components, pool);
}
@@ -633,7 +638,6 @@
std::shared_ptr<C2BlockPool> *pool) {
pool->reset();
- std::lock_guard<std::mutex> lock(sBlockPoolCacheMutex);
return sBlockPoolCache->createBlockPool(allocatorId, {component}, pool);
}
diff --git a/media/codec2/vndk/include/C2PlatformStorePluginLoader.h b/media/codec2/vndk/include/C2PlatformStorePluginLoader.h
index 4c10643..73d1b5e 100644
--- a/media/codec2/vndk/include/C2PlatformStorePluginLoader.h
+++ b/media/codec2/vndk/include/C2PlatformStorePluginLoader.h
@@ -61,9 +61,11 @@
* \retval C2_NOT_FOUND the extension symbol was not found.
* \retval C2_BAD_INDEX the input allocatorId is not defined in platform store extension.
*/
- c2_status_t createBlockPool(::C2Allocator::id_t allocatorId,
- ::C2BlockPool::local_id_t blockPoolId,
- std::shared_ptr<C2BlockPool>* pool);
+ c2_status_t createBlockPool(
+ ::C2Allocator::id_t allocatorId,
+ ::C2BlockPool::local_id_t blockPoolId,
+ std::shared_ptr<C2BlockPool>* pool,
+ std::function<void(C2BlockPool *)> deleter = std::default_delete<C2BlockPool>());
/**
* Creates allocator from platform store extension.
@@ -81,8 +83,10 @@
* \retval C2_BAD_INDEX the input allocatorId is not defined in platform store extension.
* \retval C2_NO_MEMORY not enough memory to create the allocator
*/
- c2_status_t createAllocator(::C2Allocator::id_t allocatorId,
- std::shared_ptr<C2Allocator>* const allocator);
+ c2_status_t createAllocator(
+ ::C2Allocator::id_t allocatorId,
+ std::shared_ptr<C2Allocator>* const allocator,
+ std::function<void(C2Allocator *)> deleter = std::default_delete<C2Allocator>());
private:
explicit C2PlatformStorePluginLoader(const char *libPath);
diff --git a/media/extractors/mp4/MPEG4Extractor.cpp b/media/extractors/mp4/MPEG4Extractor.cpp
index fbcd554..252a497 100644
--- a/media/extractors/mp4/MPEG4Extractor.cpp
+++ b/media/extractors/mp4/MPEG4Extractor.cpp
@@ -157,6 +157,7 @@
MediaBufferHelper *mBuffer;
+ size_t mSrcBufferSize;
uint8_t *mSrcBuffer;
bool mIsHeif;
@@ -5083,6 +5084,7 @@
mNALLengthSize(0),
mStarted(false),
mBuffer(NULL),
+ mSrcBufferSize(0),
mSrcBuffer(NULL),
mItemTable(itemTable),
mElstShiftStartTicks(elstShiftStartTicks),
@@ -5264,6 +5266,7 @@
// file probably specified a bad max size
return AMEDIA_ERROR_MALFORMED;
}
+ mSrcBufferSize = max_size;
mStarted = true;
@@ -5280,6 +5283,7 @@
mBuffer = NULL;
}
+ mSrcBufferSize = 0;
delete[] mSrcBuffer;
mSrcBuffer = NULL;
@@ -6467,6 +6471,10 @@
// Whole NAL units are returned but each fragment is prefixed by
// the start code (0x00 00 00 01).
ssize_t num_bytes_read = 0;
+ if (mSrcBufferSize < size) {
+ // We are trying to read a sample larger than the expected max sample size.
+ return AMEDIA_ERROR_MALFORMED;
+ }
num_bytes_read = mDataSource->readAt(offset, mSrcBuffer, size);
if (num_bytes_read < (ssize_t)size) {
diff --git a/media/extractors/tests/Android.bp b/media/extractors/tests/Android.bp
index 5d97d9a..23c74f7 100644
--- a/media/extractors/tests/Android.bp
+++ b/media/extractors/tests/Android.bp
@@ -45,14 +45,11 @@
"libdatasource",
"libwatchdog",
- "libstagefright",
"libstagefright_id3",
"libstagefright_flacdec",
"libstagefright_esds",
"libstagefright_mpeg2support",
- "libstagefright_mpeg2extractor",
"libstagefright_foundation_colorutils_ndk",
- "libstagefright_foundation",
"libstagefright_metadatautils",
"libmedia_midiiowrapper",
@@ -74,6 +71,8 @@
"libcutils",
"libmediandk",
"libmedia",
+ "libstagefright",
+ "libstagefright_foundation",
"libcrypto",
"libhidlmemory",
"libhidlbase",
diff --git a/media/libaaudio/tests/Android.bp b/media/libaaudio/tests/Android.bp
index 98e9727..ea00a5a 100644
--- a/media/libaaudio/tests/Android.bp
+++ b/media/libaaudio/tests/Android.bp
@@ -48,7 +48,7 @@
shared_libs: ["libaaudio_internal"],
}
-cc_test {
+cc_binary {
name: "test_timestamps",
defaults: ["libaaudio_tests_defaults"],
srcs: ["test_timestamps.cpp"],
@@ -60,121 +60,71 @@
name: "test_open_params",
defaults: ["libaaudio_tests_defaults"],
srcs: ["test_open_params.cpp"],
- shared_libs: [
- "libaaudio",
- "libbinder",
- "libcutils",
- "libutils",
- ],
+ shared_libs: ["libaaudio"],
}
-cc_test {
+cc_binary {
name: "test_no_close",
defaults: ["libaaudio_tests_defaults"],
srcs: ["test_no_close.cpp"],
- shared_libs: [
- "libaaudio",
- "libbinder",
- "libcutils",
- "libutils",
- ],
+ shared_libs: ["libaaudio"],
}
-cc_test {
+cc_binary {
name: "test_aaudio_recovery",
defaults: ["libaaudio_tests_defaults"],
srcs: ["test_recovery.cpp"],
- shared_libs: [
- "libaaudio",
- "libbinder",
- "libcutils",
- "libutils",
- ],
+ shared_libs: ["libaaudio"],
}
-cc_test {
+cc_binary {
name: "test_n_streams",
defaults: ["libaaudio_tests_defaults"],
srcs: ["test_n_streams.cpp"],
- shared_libs: [
- "libaaudio",
- "libbinder",
- "libcutils",
- "libutils",
- ],
+ shared_libs: ["libaaudio"],
}
-cc_test {
+cc_binary {
name: "test_bad_disconnect",
defaults: ["libaaudio_tests_defaults"],
srcs: ["test_bad_disconnect.cpp"],
- shared_libs: [
- "libaaudio",
- "libbinder",
- "libcutils",
- "libutils",
- ],
+ shared_libs: ["libaaudio"],
}
cc_test {
name: "test_various",
defaults: ["libaaudio_tests_defaults"],
srcs: ["test_various.cpp"],
- shared_libs: [
- "libaaudio",
- "libbinder",
- "libcutils",
- "libutils",
- ],
+ shared_libs: ["libaaudio"],
}
cc_test {
name: "test_session_id",
defaults: ["libaaudio_tests_defaults"],
srcs: ["test_session_id.cpp"],
- shared_libs: [
- "libaaudio",
- "libbinder",
- "libcutils",
- "libutils",
- ],
+ shared_libs: ["libaaudio"],
}
-cc_test {
+cc_binary {
name: "test_aaudio_monkey",
defaults: ["libaaudio_tests_defaults"],
srcs: ["test_aaudio_monkey.cpp"],
header_libs: ["libaaudio_example_utils"],
- shared_libs: [
- "libaaudio",
- "libbinder",
- "libcutils",
- "libutils",
- ],
+ shared_libs: ["libaaudio"],
}
cc_test {
name: "test_attributes",
defaults: ["libaaudio_tests_defaults"],
srcs: ["test_attributes.cpp"],
- shared_libs: [
- "libaaudio",
- "libbinder",
- "libcutils",
- "libutils",
- ],
+ shared_libs: ["libaaudio"],
}
cc_test {
name: "test_interference",
defaults: ["libaaudio_tests_defaults"],
srcs: ["test_interference.cpp"],
- shared_libs: [
- "libaaudio",
- "libbinder",
- "libcutils",
- "libutils",
- ],
+ shared_libs: ["libaaudio"],
}
cc_test {
@@ -196,28 +146,18 @@
],
}
-cc_test {
+cc_binary {
name: "test_return_stop",
defaults: ["libaaudio_tests_defaults"],
srcs: ["test_return_stop.cpp"],
- shared_libs: [
- "libaaudio",
- "libbinder",
- "libcutils",
- "libutils",
- ],
+ shared_libs: ["libaaudio"],
}
cc_test {
name: "test_callback_race",
defaults: ["libaaudio_tests_defaults"],
srcs: ["test_callback_race.cpp"],
- shared_libs: [
- "libaaudio",
- "libbinder",
- "libcutils",
- "libutils",
- ],
+ shared_libs: ["libaaudio"],
}
cc_test {
@@ -238,7 +178,7 @@
],
}
-cc_test {
+cc_binary {
name: "test_steal_exclusive",
defaults: ["libaaudio_tests_defaults"],
srcs: ["test_steal_exclusive.cpp"],
@@ -251,15 +191,9 @@
],
}
-
-cc_test {
+cc_binary {
name: "test_disconnect_race",
defaults: ["libaaudio_tests_defaults"],
srcs: ["test_disconnect_race.cpp"],
- shared_libs: [
- "libaaudio",
- "libbinder",
- "libcutils",
- "libutils",
- ],
+ shared_libs: ["libaaudio"],
}
diff --git a/media/libaudioclient/AidlConversion.cpp b/media/libaudioclient/AidlConversion.cpp
index 80b9820..3d65a54 100644
--- a/media/libaudioclient/AidlConversion.cpp
+++ b/media/libaudioclient/AidlConversion.cpp
@@ -35,8 +35,14 @@
using base::unexpected;
using media::audio::common::AudioChannelLayout;
+using media::audio::common::AudioConfig;
+using media::audio::common::AudioConfigBase;
+using media::audio::common::AudioEncapsulationMode;
using media::audio::common::AudioFormatDescription;
using media::audio::common::AudioFormatType;
+using media::audio::common::AudioOffloadInfo;
+using media::audio::common::AudioStreamType;
+using media::audio::common::AudioUsage;
using media::audio::common::PcmType;
namespace {
@@ -1494,79 +1500,81 @@
}
ConversionResult<audio_stream_type_t> aidl2legacy_AudioStreamType_audio_stream_type_t(
- media::AudioStreamType aidl) {
+ AudioStreamType aidl) {
switch (aidl) {
- case media::AudioStreamType::DEFAULT:
+ case AudioStreamType::INVALID:
+ break; // return error
+ case AudioStreamType::DEFAULT:
return AUDIO_STREAM_DEFAULT;
- case media::AudioStreamType::VOICE_CALL:
+ case AudioStreamType::VOICE_CALL:
return AUDIO_STREAM_VOICE_CALL;
- case media::AudioStreamType::SYSTEM:
+ case AudioStreamType::SYSTEM:
return AUDIO_STREAM_SYSTEM;
- case media::AudioStreamType::RING:
+ case AudioStreamType::RING:
return AUDIO_STREAM_RING;
- case media::AudioStreamType::MUSIC:
+ case AudioStreamType::MUSIC:
return AUDIO_STREAM_MUSIC;
- case media::AudioStreamType::ALARM:
+ case AudioStreamType::ALARM:
return AUDIO_STREAM_ALARM;
- case media::AudioStreamType::NOTIFICATION:
+ case AudioStreamType::NOTIFICATION:
return AUDIO_STREAM_NOTIFICATION;
- case media::AudioStreamType::BLUETOOTH_SCO:
+ case AudioStreamType::BLUETOOTH_SCO:
return AUDIO_STREAM_BLUETOOTH_SCO;
- case media::AudioStreamType::ENFORCED_AUDIBLE:
+ case AudioStreamType::ENFORCED_AUDIBLE:
return AUDIO_STREAM_ENFORCED_AUDIBLE;
- case media::AudioStreamType::DTMF:
+ case AudioStreamType::DTMF:
return AUDIO_STREAM_DTMF;
- case media::AudioStreamType::TTS:
+ case AudioStreamType::TTS:
return AUDIO_STREAM_TTS;
- case media::AudioStreamType::ACCESSIBILITY:
+ case AudioStreamType::ACCESSIBILITY:
return AUDIO_STREAM_ACCESSIBILITY;
- case media::AudioStreamType::ASSISTANT:
+ case AudioStreamType::ASSISTANT:
return AUDIO_STREAM_ASSISTANT;
- case media::AudioStreamType::REROUTING:
+ case AudioStreamType::SYS_RESERVED_REROUTING:
return AUDIO_STREAM_REROUTING;
- case media::AudioStreamType::PATCH:
+ case AudioStreamType::SYS_RESERVED_PATCH:
return AUDIO_STREAM_PATCH;
- case media::AudioStreamType::CALL_ASSISTANT:
+ case AudioStreamType::CALL_ASSISTANT:
return AUDIO_STREAM_CALL_ASSISTANT;
}
return unexpected(BAD_VALUE);
}
-ConversionResult<media::AudioStreamType> legacy2aidl_audio_stream_type_t_AudioStreamType(
+ConversionResult<AudioStreamType> legacy2aidl_audio_stream_type_t_AudioStreamType(
audio_stream_type_t legacy) {
switch (legacy) {
case AUDIO_STREAM_DEFAULT:
- return media::AudioStreamType::DEFAULT;
+ return AudioStreamType::DEFAULT;
case AUDIO_STREAM_VOICE_CALL:
- return media::AudioStreamType::VOICE_CALL;
+ return AudioStreamType::VOICE_CALL;
case AUDIO_STREAM_SYSTEM:
- return media::AudioStreamType::SYSTEM;
+ return AudioStreamType::SYSTEM;
case AUDIO_STREAM_RING:
- return media::AudioStreamType::RING;
+ return AudioStreamType::RING;
case AUDIO_STREAM_MUSIC:
- return media::AudioStreamType::MUSIC;
+ return AudioStreamType::MUSIC;
case AUDIO_STREAM_ALARM:
- return media::AudioStreamType::ALARM;
+ return AudioStreamType::ALARM;
case AUDIO_STREAM_NOTIFICATION:
- return media::AudioStreamType::NOTIFICATION;
+ return AudioStreamType::NOTIFICATION;
case AUDIO_STREAM_BLUETOOTH_SCO:
- return media::AudioStreamType::BLUETOOTH_SCO;
+ return AudioStreamType::BLUETOOTH_SCO;
case AUDIO_STREAM_ENFORCED_AUDIBLE:
- return media::AudioStreamType::ENFORCED_AUDIBLE;
+ return AudioStreamType::ENFORCED_AUDIBLE;
case AUDIO_STREAM_DTMF:
- return media::AudioStreamType::DTMF;
+ return AudioStreamType::DTMF;
case AUDIO_STREAM_TTS:
- return media::AudioStreamType::TTS;
+ return AudioStreamType::TTS;
case AUDIO_STREAM_ACCESSIBILITY:
- return media::AudioStreamType::ACCESSIBILITY;
+ return AudioStreamType::ACCESSIBILITY;
case AUDIO_STREAM_ASSISTANT:
- return media::AudioStreamType::ASSISTANT;
+ return AudioStreamType::ASSISTANT;
case AUDIO_STREAM_REROUTING:
- return media::AudioStreamType::REROUTING;
+ return AudioStreamType::SYS_RESERVED_REROUTING;
case AUDIO_STREAM_PATCH:
- return media::AudioStreamType::PATCH;
+ return AudioStreamType::SYS_RESERVED_PATCH;
case AUDIO_STREAM_CALL_ASSISTANT:
- return media::AudioStreamType::CALL_ASSISTANT;
+ return AudioStreamType::CALL_ASSISTANT;
}
return unexpected(BAD_VALUE);
}
@@ -1998,103 +2006,105 @@
}
ConversionResult<audio_usage_t>
-aidl2legacy_AudioUsage_audio_usage_t(media::AudioUsage aidl) {
+aidl2legacy_AudioUsage_audio_usage_t(AudioUsage aidl) {
switch (aidl) {
- case media::AudioUsage::UNKNOWN:
+ case AudioUsage::INVALID:
+ break; // return error
+ case AudioUsage::UNKNOWN:
return AUDIO_USAGE_UNKNOWN;
- case media::AudioUsage::MEDIA:
+ case AudioUsage::MEDIA:
return AUDIO_USAGE_MEDIA;
- case media::AudioUsage::VOICE_COMMUNICATION:
+ case AudioUsage::VOICE_COMMUNICATION:
return AUDIO_USAGE_VOICE_COMMUNICATION;
- case media::AudioUsage::VOICE_COMMUNICATION_SIGNALLING:
+ case AudioUsage::VOICE_COMMUNICATION_SIGNALLING:
return AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING;
- case media::AudioUsage::ALARM:
+ case AudioUsage::ALARM:
return AUDIO_USAGE_ALARM;
- case media::AudioUsage::NOTIFICATION:
+ case AudioUsage::NOTIFICATION:
return AUDIO_USAGE_NOTIFICATION;
- case media::AudioUsage::NOTIFICATION_TELEPHONY_RINGTONE:
+ case AudioUsage::NOTIFICATION_TELEPHONY_RINGTONE:
return AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE;
- case media::AudioUsage::NOTIFICATION_COMMUNICATION_REQUEST:
+ case AudioUsage::SYS_RESERVED_NOTIFICATION_COMMUNICATION_REQUEST:
return AUDIO_USAGE_NOTIFICATION_COMMUNICATION_REQUEST;
- case media::AudioUsage::NOTIFICATION_COMMUNICATION_INSTANT:
+ case AudioUsage::SYS_RESERVED_NOTIFICATION_COMMUNICATION_INSTANT:
return AUDIO_USAGE_NOTIFICATION_COMMUNICATION_INSTANT;
- case media::AudioUsage::NOTIFICATION_COMMUNICATION_DELAYED:
+ case AudioUsage::SYS_RESERVED_NOTIFICATION_COMMUNICATION_DELAYED:
return AUDIO_USAGE_NOTIFICATION_COMMUNICATION_DELAYED;
- case media::AudioUsage::NOTIFICATION_EVENT:
+ case AudioUsage::NOTIFICATION_EVENT:
return AUDIO_USAGE_NOTIFICATION_EVENT;
- case media::AudioUsage::ASSISTANCE_ACCESSIBILITY:
+ case AudioUsage::ASSISTANCE_ACCESSIBILITY:
return AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY;
- case media::AudioUsage::ASSISTANCE_NAVIGATION_GUIDANCE:
+ case AudioUsage::ASSISTANCE_NAVIGATION_GUIDANCE:
return AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE;
- case media::AudioUsage::ASSISTANCE_SONIFICATION:
+ case AudioUsage::ASSISTANCE_SONIFICATION:
return AUDIO_USAGE_ASSISTANCE_SONIFICATION;
- case media::AudioUsage::GAME:
+ case AudioUsage::GAME:
return AUDIO_USAGE_GAME;
- case media::AudioUsage::VIRTUAL_SOURCE:
+ case AudioUsage::VIRTUAL_SOURCE:
return AUDIO_USAGE_VIRTUAL_SOURCE;
- case media::AudioUsage::ASSISTANT:
+ case AudioUsage::ASSISTANT:
return AUDIO_USAGE_ASSISTANT;
- case media::AudioUsage::CALL_ASSISTANT:
+ case AudioUsage::CALL_ASSISTANT:
return AUDIO_USAGE_CALL_ASSISTANT;
- case media::AudioUsage::EMERGENCY:
+ case AudioUsage::EMERGENCY:
return AUDIO_USAGE_EMERGENCY;
- case media::AudioUsage::SAFETY:
+ case AudioUsage::SAFETY:
return AUDIO_USAGE_SAFETY;
- case media::AudioUsage::VEHICLE_STATUS:
+ case AudioUsage::VEHICLE_STATUS:
return AUDIO_USAGE_VEHICLE_STATUS;
- case media::AudioUsage::ANNOUNCEMENT:
+ case AudioUsage::ANNOUNCEMENT:
return AUDIO_USAGE_ANNOUNCEMENT;
}
return unexpected(BAD_VALUE);
}
-ConversionResult<media::AudioUsage>
+ConversionResult<AudioUsage>
legacy2aidl_audio_usage_t_AudioUsage(audio_usage_t legacy) {
switch (legacy) {
case AUDIO_USAGE_UNKNOWN:
- return media::AudioUsage::UNKNOWN;
+ return AudioUsage::UNKNOWN;
case AUDIO_USAGE_MEDIA:
- return media::AudioUsage::MEDIA;
+ return AudioUsage::MEDIA;
case AUDIO_USAGE_VOICE_COMMUNICATION:
- return media::AudioUsage::VOICE_COMMUNICATION;
+ return AudioUsage::VOICE_COMMUNICATION;
case AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING:
- return media::AudioUsage::VOICE_COMMUNICATION_SIGNALLING;
+ return AudioUsage::VOICE_COMMUNICATION_SIGNALLING;
case AUDIO_USAGE_ALARM:
- return media::AudioUsage::ALARM;
+ return AudioUsage::ALARM;
case AUDIO_USAGE_NOTIFICATION:
- return media::AudioUsage::NOTIFICATION;
+ return AudioUsage::NOTIFICATION;
case AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE:
- return media::AudioUsage::NOTIFICATION_TELEPHONY_RINGTONE;
+ return AudioUsage::NOTIFICATION_TELEPHONY_RINGTONE;
case AUDIO_USAGE_NOTIFICATION_COMMUNICATION_REQUEST:
- return media::AudioUsage::NOTIFICATION_COMMUNICATION_REQUEST;
+ return AudioUsage::SYS_RESERVED_NOTIFICATION_COMMUNICATION_REQUEST;
case AUDIO_USAGE_NOTIFICATION_COMMUNICATION_INSTANT:
- return media::AudioUsage::NOTIFICATION_COMMUNICATION_INSTANT;
+ return AudioUsage::SYS_RESERVED_NOTIFICATION_COMMUNICATION_INSTANT;
case AUDIO_USAGE_NOTIFICATION_COMMUNICATION_DELAYED:
- return media::AudioUsage::NOTIFICATION_COMMUNICATION_DELAYED;
+ return AudioUsage::SYS_RESERVED_NOTIFICATION_COMMUNICATION_DELAYED;
case AUDIO_USAGE_NOTIFICATION_EVENT:
- return media::AudioUsage::NOTIFICATION_EVENT;
+ return AudioUsage::NOTIFICATION_EVENT;
case AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY:
- return media::AudioUsage::ASSISTANCE_ACCESSIBILITY;
+ return AudioUsage::ASSISTANCE_ACCESSIBILITY;
case AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
- return media::AudioUsage::ASSISTANCE_NAVIGATION_GUIDANCE;
+ return AudioUsage::ASSISTANCE_NAVIGATION_GUIDANCE;
case AUDIO_USAGE_ASSISTANCE_SONIFICATION:
- return media::AudioUsage::ASSISTANCE_SONIFICATION;
+ return AudioUsage::ASSISTANCE_SONIFICATION;
case AUDIO_USAGE_GAME:
- return media::AudioUsage::GAME;
+ return AudioUsage::GAME;
case AUDIO_USAGE_VIRTUAL_SOURCE:
- return media::AudioUsage::VIRTUAL_SOURCE;
+ return AudioUsage::VIRTUAL_SOURCE;
case AUDIO_USAGE_ASSISTANT:
- return media::AudioUsage::ASSISTANT;
+ return AudioUsage::ASSISTANT;
case AUDIO_USAGE_CALL_ASSISTANT:
- return media::AudioUsage::CALL_ASSISTANT;
+ return AudioUsage::CALL_ASSISTANT;
case AUDIO_USAGE_EMERGENCY:
- return media::AudioUsage::EMERGENCY;
+ return AudioUsage::EMERGENCY;
case AUDIO_USAGE_SAFETY:
- return media::AudioUsage::SAFETY;
+ return AudioUsage::SAFETY;
case AUDIO_USAGE_VEHICLE_STATUS:
- return media::AudioUsage::VEHICLE_STATUS;
+ return AudioUsage::VEHICLE_STATUS;
case AUDIO_USAGE_ANNOUNCEMENT:
- return media::AudioUsage::ANNOUNCEMENT;
+ return AudioUsage::ANNOUNCEMENT;
}
return unexpected(BAD_VALUE);
}
@@ -2219,44 +2229,44 @@
}
ConversionResult<audio_encapsulation_mode_t>
-aidl2legacy_AudioEncapsulationMode_audio_encapsulation_mode_t(media::AudioEncapsulationMode aidl) {
+aidl2legacy_AudioEncapsulationMode_audio_encapsulation_mode_t(AudioEncapsulationMode aidl) {
switch (aidl) {
- case media::AudioEncapsulationMode::NONE:
+ case AudioEncapsulationMode::INVALID:
+ break; // return error
+ case AudioEncapsulationMode::NONE:
return AUDIO_ENCAPSULATION_MODE_NONE;
- case media::AudioEncapsulationMode::ELEMENTARY_STREAM:
+ case AudioEncapsulationMode::ELEMENTARY_STREAM:
return AUDIO_ENCAPSULATION_MODE_ELEMENTARY_STREAM;
- case media::AudioEncapsulationMode::HANDLE:
+ case AudioEncapsulationMode::HANDLE:
return AUDIO_ENCAPSULATION_MODE_HANDLE;
}
return unexpected(BAD_VALUE);
}
-ConversionResult<media::AudioEncapsulationMode>
+ConversionResult<AudioEncapsulationMode>
legacy2aidl_audio_encapsulation_mode_t_AudioEncapsulationMode(audio_encapsulation_mode_t legacy) {
switch (legacy) {
case AUDIO_ENCAPSULATION_MODE_NONE:
- return media::AudioEncapsulationMode::NONE;
+ return AudioEncapsulationMode::NONE;
case AUDIO_ENCAPSULATION_MODE_ELEMENTARY_STREAM:
- return media::AudioEncapsulationMode::ELEMENTARY_STREAM;
+ return AudioEncapsulationMode::ELEMENTARY_STREAM;
case AUDIO_ENCAPSULATION_MODE_HANDLE:
- return media::AudioEncapsulationMode::HANDLE;
+ return AudioEncapsulationMode::HANDLE;
}
return unexpected(BAD_VALUE);
}
ConversionResult<audio_offload_info_t>
-aidl2legacy_AudioOffloadInfo_audio_offload_info_t(const media::AudioOffloadInfo& aidl) {
- audio_offload_info_t legacy;
- legacy.version = VALUE_OR_RETURN(convertIntegral<uint16_t>(aidl.version));
- legacy.size = sizeof(audio_offload_info_t);
- audio_config_base_t config = VALUE_OR_RETURN(
- aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.config, false /*isInput*/));
- legacy.sample_rate = config.sample_rate;
- legacy.channel_mask = config.channel_mask;
- legacy.format = config.format;
+aidl2legacy_AudioOffloadInfo_audio_offload_info_t(const AudioOffloadInfo& aidl) {
+ audio_offload_info_t legacy = AUDIO_INFO_INITIALIZER;
+ audio_config_base_t base = VALUE_OR_RETURN(
+ aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.base, false /*isInput*/));
+ legacy.sample_rate = base.sample_rate;
+ legacy.channel_mask = base.channel_mask;
+ legacy.format = base.format;
legacy.stream_type = VALUE_OR_RETURN(
aidl2legacy_AudioStreamType_audio_stream_type_t(aidl.streamType));
- legacy.bit_rate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.bitRate));
+ legacy.bit_rate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.bitRatePerSecond));
legacy.duration_us = VALUE_OR_RETURN(convertIntegral<int64_t>(aidl.durationUs));
legacy.has_video = aidl.hasVideo;
legacy.is_streaming = aidl.isStreaming;
@@ -2270,22 +2280,20 @@
return legacy;
}
-ConversionResult<media::AudioOffloadInfo>
+ConversionResult<AudioOffloadInfo>
legacy2aidl_audio_offload_info_t_AudioOffloadInfo(const audio_offload_info_t& legacy) {
- media::AudioOffloadInfo aidl;
+ AudioOffloadInfo aidl;
// Version 0.1 fields.
if (legacy.size < offsetof(audio_offload_info_t, usage) + sizeof(audio_offload_info_t::usage)) {
return unexpected(BAD_VALUE);
}
- 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_AudioChannelLayout(
- legacy.channel_mask, false /*isInput*/));
- aidl.config.format = VALUE_OR_RETURN(
- legacy2aidl_audio_format_t_AudioFormatDescription(legacy.format));
+ const audio_config_base_t base = { .sample_rate = legacy.sample_rate,
+ .channel_mask = legacy.channel_mask, .format = legacy.format };
+ aidl.base = VALUE_OR_RETURN(legacy2aidl_audio_config_base_t_AudioConfigBase(
+ base, false /*isInput*/));
aidl.streamType = VALUE_OR_RETURN(
legacy2aidl_audio_stream_type_t_AudioStreamType(legacy.stream_type));
- aidl.bitRate = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.bit_rate));
+ aidl.bitRatePerSecond = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.bit_rate));
aidl.durationUs = VALUE_OR_RETURN(convertIntegral<int64_t>(legacy.duration_us));
aidl.hasVideo = legacy.has_video;
aidl.isStreaming = legacy.is_streaming;
@@ -2309,25 +2317,25 @@
}
ConversionResult<audio_config_t>
-aidl2legacy_AudioConfig_audio_config_t(const media::AudioConfig& aidl, bool isInput) {
- audio_config_t legacy;
- legacy.sample_rate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.sampleRate));
- legacy.channel_mask = VALUE_OR_RETURN(
- aidl2legacy_AudioChannelLayout_audio_channel_mask_t(aidl.channelMask, isInput));
- legacy.format = VALUE_OR_RETURN(aidl2legacy_AudioFormatDescription_audio_format_t(aidl.format));
+aidl2legacy_AudioConfig_audio_config_t(const AudioConfig& aidl, bool isInput) {
+ const audio_config_base_t legacyBase = VALUE_OR_RETURN(
+ aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.base, isInput));
+ audio_config_t legacy = AUDIO_CONFIG_INITIALIZER;
+ legacy.sample_rate = legacyBase.sample_rate;
+ legacy.channel_mask = legacyBase.channel_mask;
+ legacy.format = legacyBase.format;
legacy.offload_info = VALUE_OR_RETURN(
aidl2legacy_AudioOffloadInfo_audio_offload_info_t(aidl.offloadInfo));
legacy.frame_count = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.frameCount));
return legacy;
}
-ConversionResult<media::AudioConfig>
+ConversionResult<AudioConfig>
legacy2aidl_audio_config_t_AudioConfig(const audio_config_t& legacy, bool isInput) {
- media::AudioConfig aidl;
- aidl.sampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.sample_rate));
- aidl.channelMask = VALUE_OR_RETURN(
- legacy2aidl_audio_channel_mask_t_AudioChannelLayout(legacy.channel_mask, isInput));
- aidl.format = VALUE_OR_RETURN(legacy2aidl_audio_format_t_AudioFormatDescription(legacy.format));
+ const audio_config_base_t base = { .sample_rate = legacy.sample_rate,
+ .channel_mask = legacy.channel_mask, .format = legacy.format };
+ AudioConfig aidl;
+ aidl.base = VALUE_OR_RETURN(legacy2aidl_audio_config_base_t_AudioConfigBase(base, isInput));
aidl.offloadInfo = VALUE_OR_RETURN(
legacy2aidl_audio_offload_info_t_AudioOffloadInfo(legacy.offload_info));
aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(legacy.frame_count));
@@ -2335,7 +2343,7 @@
}
ConversionResult<audio_config_base_t>
-aidl2legacy_AudioConfigBase_audio_config_base_t(const media::AudioConfigBase& aidl, bool isInput) {
+aidl2legacy_AudioConfigBase_audio_config_base_t(const AudioConfigBase& aidl, bool isInput) {
audio_config_base_t legacy;
legacy.sample_rate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.sampleRate));
legacy.channel_mask = VALUE_OR_RETURN(
@@ -2344,9 +2352,9 @@
return legacy;
}
-ConversionResult<media::AudioConfigBase>
+ConversionResult<AudioConfigBase>
legacy2aidl_audio_config_base_t_AudioConfigBase(const audio_config_base_t& legacy, bool isInput) {
- media::AudioConfigBase aidl;
+ AudioConfigBase aidl;
aidl.sampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.sample_rate));
aidl.channelMask = VALUE_OR_RETURN(
legacy2aidl_audio_channel_mask_t_AudioChannelLayout(legacy.channel_mask, isInput));
@@ -2496,9 +2504,9 @@
return convertBitmask<uint32_t,
int32_t,
audio_encapsulation_mode_t,
- media::AudioEncapsulationMode>(
+ AudioEncapsulationMode>(
aidl, aidl2legacy_AudioEncapsulationMode_audio_encapsulation_mode_t,
- indexToEnum_index<media::AudioEncapsulationMode>,
+ indexToEnum_index<AudioEncapsulationMode>,
enumToMask_index<uint32_t, audio_encapsulation_mode_t>);
}
@@ -2506,11 +2514,11 @@
legacy2aidl_AudioEncapsulationMode_mask(uint32_t legacy) {
return convertBitmask<int32_t,
uint32_t,
- media::AudioEncapsulationMode,
+ AudioEncapsulationMode,
audio_encapsulation_mode_t>(
legacy, legacy2aidl_audio_encapsulation_mode_t_AudioEncapsulationMode,
indexToEnum_index<audio_encapsulation_mode_t>,
- enumToMask_index<int32_t, media::AudioEncapsulationMode>);
+ enumToMask_index<int32_t, AudioEncapsulationMode>);
}
ConversionResult<uint32_t>
diff --git a/media/libaudioclient/Android.bp b/media/libaudioclient/Android.bp
index 0a26051..5b60a40 100644
--- a/media/libaudioclient/Android.bp
+++ b/media/libaudioclient/Android.bp
@@ -313,14 +313,11 @@
srcs: [
"aidl/android/media/AudioAttributesInternal.aidl",
"aidl/android/media/AudioClient.aidl",
- "aidl/android/media/AudioConfig.aidl",
- "aidl/android/media/AudioConfigBase.aidl",
"aidl/android/media/AudioContentType.aidl",
"aidl/android/media/AudioDevice.aidl",
"aidl/android/media/AudioDeviceDescription.aidl",
"aidl/android/media/AudioDeviceType.aidl",
"aidl/android/media/AudioDualMonoMode.aidl",
- "aidl/android/media/AudioEncapsulationMode.aidl",
"aidl/android/media/AudioEncapsulationMetadataType.aidl",
"aidl/android/media/AudioEncapsulationType.aidl",
"aidl/android/media/AudioFlag.aidl",
@@ -333,7 +330,6 @@
"aidl/android/media/AudioIoFlags.aidl",
"aidl/android/media/AudioMixLatencyClass.aidl",
"aidl/android/media/AudioMode.aidl",
- "aidl/android/media/AudioOffloadInfo.aidl",
"aidl/android/media/AudioOutputFlags.aidl",
"aidl/android/media/AudioPatch.aidl",
"aidl/android/media/AudioPlaybackRate.aidl",
@@ -354,10 +350,8 @@
"aidl/android/media/AudioProfile.aidl",
"aidl/android/media/AudioSourceType.aidl",
"aidl/android/media/AudioStandard.aidl",
- "aidl/android/media/AudioStreamType.aidl",
"aidl/android/media/AudioTimestampInternal.aidl",
"aidl/android/media/AudioUniqueIdUse.aidl",
- "aidl/android/media/AudioUsage.aidl",
"aidl/android/media/AudioUuid.aidl",
"aidl/android/media/AudioVibratorInfo.aidl",
"aidl/android/media/EffectDescriptor.aidl",
diff --git a/media/libaudioclient/AudioEffect.cpp b/media/libaudioclient/AudioEffect.cpp
index 9091599..50a9735 100644
--- a/media/libaudioclient/AudioEffect.cpp
+++ b/media/libaudioclient/AudioEffect.cpp
@@ -666,7 +666,7 @@
media::AudioUuid uuidAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_uuid_t_AudioUuid(uuid));
std::string opPackageNameAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_String16_string(opPackageName));
- media::AudioUsage usageAidl = VALUE_OR_RETURN_STATUS(
+ media::audio::common::AudioUsage usageAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_usage_t_AudioUsage(usage));
int32_t retAidl;
RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
diff --git a/media/libaudioclient/AudioSystem.cpp b/media/libaudioclient/AudioSystem.cpp
index 057befd..e15643a 100644
--- a/media/libaudioclient/AudioSystem.cpp
+++ b/media/libaudioclient/AudioSystem.cpp
@@ -53,7 +53,12 @@
using binder::Status;
using content::AttributionSourceState;
using media::IAudioPolicyService;
+using media::audio::common::AudioConfig;
+using media::audio::common::AudioConfigBase;
using media::audio::common::AudioFormatDescription;
+using media::audio::common::AudioOffloadInfo;
+using media::audio::common::AudioStreamType;
+using media::audio::common::AudioUsage;
// client singleton for AudioFlinger binder interface
Mutex AudioSystem::gLock;
@@ -955,7 +960,7 @@
if (aps == 0) return AUDIO_IO_HANDLE_NONE;
auto result = [&]() -> ConversionResult<audio_io_handle_t> {
- media::AudioStreamType streamAidl = VALUE_OR_RETURN(
+ AudioStreamType streamAidl = VALUE_OR_RETURN(
legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
int32_t outputAidl;
RETURN_IF_ERROR(
@@ -1003,7 +1008,7 @@
media::AudioAttributesInternal attrAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_attributes_t_AudioAttributesInternal(*attr));
int32_t sessionAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_session_t_int32_t(session));
- media::AudioConfig configAidl = VALUE_OR_RETURN_STATUS(
+ AudioConfig configAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_config_t_AudioConfig(*config, false /*isInput*/));
int32_t flagsAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_output_flags_t_int32_t_mask(flags));
@@ -1097,7 +1102,7 @@
int32_t inputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(*input));
int32_t riidAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_unique_id_t_int32_t(riid));
int32_t sessionAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_session_t_int32_t(session));
- media::AudioConfigBase configAidl = VALUE_OR_RETURN_STATUS(
+ AudioConfigBase configAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_config_base_t_AudioConfigBase(*config, true /*isInput*/));
int32_t flagsAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_input_flags_t_int32_t_mask(flags));
int32_t selectedDeviceIdAidl = VALUE_OR_RETURN_STATUS(
@@ -1154,7 +1159,7 @@
const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
if (aps == 0) return PERMISSION_DENIED;
- media::AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
+ AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
int32_t indexMinAidl = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(indexMin));
int32_t indexMaxAidl = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(indexMax));
@@ -1168,7 +1173,7 @@
const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
if (aps == 0) return PERMISSION_DENIED;
- media::AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
+ AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
int32_t indexAidl = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(index));
media::AudioDeviceDescription deviceAidl = VALUE_OR_RETURN_STATUS(
@@ -1183,7 +1188,7 @@
const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
if (aps == 0) return PERMISSION_DENIED;
- media::AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
+ AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
media::AudioDeviceDescription deviceAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_devices_t_AudioDeviceDescription(device));
@@ -1259,7 +1264,7 @@
if (aps == 0) return PRODUCT_STRATEGY_NONE;
auto result = [&]() -> ConversionResult<product_strategy_t> {
- media::AudioStreamType streamAidl = VALUE_OR_RETURN(
+ AudioStreamType streamAidl = VALUE_OR_RETURN(
legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
int32_t resultAidl;
RETURN_IF_ERROR(statusTFromBinderStatus(
@@ -1274,7 +1279,7 @@
if (aps == 0) return DeviceTypeSet{};
auto result = [&]() -> ConversionResult<DeviceTypeSet> {
- media::AudioStreamType streamAidl = VALUE_OR_RETURN(
+ AudioStreamType streamAidl = VALUE_OR_RETURN(
legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
std::vector<media::AudioDeviceDescription> resultAidl;
RETURN_IF_ERROR(statusTFromBinderStatus(
@@ -1373,7 +1378,7 @@
if (aps == 0) return PERMISSION_DENIED;
if (state == NULL) return BAD_VALUE;
- media::AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
+ AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
int32_t inPastMsAidl = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(inPastMs));
RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
@@ -1387,7 +1392,7 @@
if (aps == 0) return PERMISSION_DENIED;
if (state == NULL) return BAD_VALUE;
- media::AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
+ AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
int32_t inPastMsAidl = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(inPastMs));
RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
@@ -1445,9 +1450,9 @@
const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
if (aps == nullptr) return PERMISSION_DENIED;
- std::vector<media::AudioUsage> systemUsagesAidl = VALUE_OR_RETURN_STATUS(
- convertContainer<std::vector<media::AudioUsage>>(systemUsages,
- legacy2aidl_audio_usage_t_AudioUsage));
+ std::vector<AudioUsage> systemUsagesAidl = VALUE_OR_RETURN_STATUS(
+ convertContainer<std::vector<AudioUsage>>(systemUsages,
+ legacy2aidl_audio_usage_t_AudioUsage));
return statusTFromBinderStatus(aps->setSupportedSystemUsages(systemUsagesAidl));
}
@@ -1467,7 +1472,7 @@
if (aps == 0) return AUDIO_OFFLOAD_NOT_SUPPORTED;
auto result = [&]() -> ConversionResult<audio_offload_mode_t> {
- media::AudioOffloadInfo infoAidl = VALUE_OR_RETURN(
+ AudioOffloadInfo infoAidl = VALUE_OR_RETURN(
legacy2aidl_audio_offload_info_t_AudioOffloadInfo(info));
media::AudioOffloadMode retAidl;
RETURN_IF_ERROR(
@@ -1839,7 +1844,7 @@
if (aps == 0) return NAN;
auto result = [&]() -> ConversionResult<float> {
- media::AudioStreamType streamAidl = VALUE_OR_RETURN(
+ AudioStreamType streamAidl = VALUE_OR_RETURN(
legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
int32_t indexAidl = VALUE_OR_RETURN(convertIntegral<int32_t>(index));
media::AudioDeviceDescription deviceAidl = VALUE_OR_RETURN(
@@ -2278,7 +2283,7 @@
std::optional<media::AudioAttributesInternal> attrAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_attributes_t_AudioAttributesInternal(attributes));
- std::optional<media::AudioConfig> configAidl = VALUE_OR_RETURN_STATUS(
+ std::optional<AudioConfig> configAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_config_t_AudioConfig(configuration, false /*isInput*/));
std::vector<media::AudioDevice> devicesAidl = VALUE_OR_RETURN_STATUS(
convertContainer<std::vector<media::AudioDevice>>(devices,
@@ -2464,9 +2469,9 @@
Status AudioSystem::AudioPolicyServiceClient::onRecordingConfigurationUpdate(
int32_t event,
const media::RecordClientInfo& clientInfo,
- const media::AudioConfigBase& clientConfig,
+ const AudioConfigBase& clientConfig,
const std::vector<media::EffectDescriptor>& clientEffects,
- const media::AudioConfigBase& deviceConfig,
+ const AudioConfigBase& deviceConfig,
const std::vector<media::EffectDescriptor>& effects,
int32_t patchHandle,
media::AudioSourceType source) {
diff --git a/media/libaudioclient/AudioTrack.cpp b/media/libaudioclient/AudioTrack.cpp
index 1149790..0f8c17c 100644
--- a/media/libaudioclient/AudioTrack.cpp
+++ b/media/libaudioclient/AudioTrack.cpp
@@ -170,7 +170,7 @@
if (aps == 0) return false;
auto result = [&]() -> ConversionResult<bool> {
- media::AudioConfigBase configAidl = VALUE_OR_RETURN(
+ media::audio::common::AudioConfigBase configAidl = VALUE_OR_RETURN(
legacy2aidl_audio_config_base_t_AudioConfigBase(config, false /*isInput*/));
media::AudioAttributesInternal attributesAidl = VALUE_OR_RETURN(
legacy2aidl_audio_attributes_t_AudioAttributesInternal(attributes));
diff --git a/media/libaudioclient/AudioVolumeGroup.cpp b/media/libaudioclient/AudioVolumeGroup.cpp
index 361f7b8..36696cd 100644
--- a/media/libaudioclient/AudioVolumeGroup.cpp
+++ b/media/libaudioclient/AudioVolumeGroup.cpp
@@ -31,6 +31,8 @@
namespace android {
+using media::audio::common::AudioStreamType;
+
status_t AudioVolumeGroup::readFromParcel(const Parcel *parcel)
{
media::AudioVolumeGroup aidl;
@@ -55,7 +57,7 @@
legacy.getAudioAttributes(),
legacy2aidl_audio_attributes_t_AudioAttributesInternal));
aidl.streams = VALUE_OR_RETURN(
- convertContainer<std::vector<media::AudioStreamType>>(legacy.getStreamTypes(),
+ convertContainer<std::vector<AudioStreamType>>(legacy.getStreamTypes(),
legacy2aidl_audio_stream_type_t_AudioStreamType));
return aidl;
}
diff --git a/media/libaudioclient/IAudioFlinger.cpp b/media/libaudioclient/IAudioFlinger.cpp
index ee64894..c5a7c96 100644
--- a/media/libaudioclient/IAudioFlinger.cpp
+++ b/media/libaudioclient/IAudioFlinger.cpp
@@ -32,6 +32,7 @@
using binder::Status;
using media::audio::common::AudioChannelLayout;
using media::audio::common::AudioFormatDescription;
+using media::audio::common::AudioStreamType;
#define MAX_ITEMS_PER_LIST 1024
@@ -321,14 +322,14 @@
status_t AudioFlingerClientAdapter::setStreamVolume(audio_stream_type_t stream, float value,
audio_io_handle_t output) {
- media::AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
+ AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output));
return statusTFromBinderStatus(mDelegate->setStreamVolume(streamAidl, value, outputAidl));
}
status_t AudioFlingerClientAdapter::setStreamMute(audio_stream_type_t stream, bool muted) {
- media::AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
+ AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
return statusTFromBinderStatus(mDelegate->setStreamMute(streamAidl, muted));
}
@@ -336,7 +337,7 @@
float AudioFlingerClientAdapter::streamVolume(audio_stream_type_t stream,
audio_io_handle_t output) const {
auto result = [&]() -> ConversionResult<float> {
- media::AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
+ AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output));
float aidlRet;
@@ -350,7 +351,7 @@
bool AudioFlingerClientAdapter::streamMute(audio_stream_type_t stream) const {
auto result = [&]() -> ConversionResult<bool> {
- media::AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
+ AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
bool aidlRet;
RETURN_IF_ERROR(statusTFromBinderStatus(
@@ -481,7 +482,7 @@
}
status_t AudioFlingerClientAdapter::invalidateStream(audio_stream_type_t stream) {
- media::AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
+ AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
return statusTFromBinderStatus(mDelegate->invalidateStream(streamAidl));
}
@@ -872,7 +873,7 @@
return Status::fromStatusT(mDelegate->getMasterBalance(_aidl_return));
}
-Status AudioFlingerServerAdapter::setStreamVolume(media::AudioStreamType stream, float value,
+Status AudioFlingerServerAdapter::setStreamVolume(AudioStreamType stream, float value,
int32_t output) {
audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER(
aidl2legacy_AudioStreamType_audio_stream_type_t(stream));
@@ -881,13 +882,13 @@
return Status::fromStatusT(mDelegate->setStreamVolume(streamLegacy, value, outputLegacy));
}
-Status AudioFlingerServerAdapter::setStreamMute(media::AudioStreamType stream, bool muted) {
+Status AudioFlingerServerAdapter::setStreamMute(AudioStreamType stream, bool muted) {
audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER(
aidl2legacy_AudioStreamType_audio_stream_type_t(stream));
return Status::fromStatusT(mDelegate->setStreamMute(streamLegacy, muted));
}
-Status AudioFlingerServerAdapter::streamVolume(media::AudioStreamType stream, int32_t output,
+Status AudioFlingerServerAdapter::streamVolume(AudioStreamType stream, int32_t output,
float* _aidl_return) {
audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER(
aidl2legacy_AudioStreamType_audio_stream_type_t(stream));
@@ -897,7 +898,7 @@
return Status::ok();
}
-Status AudioFlingerServerAdapter::streamMute(media::AudioStreamType stream, bool* _aidl_return) {
+Status AudioFlingerServerAdapter::streamMute(AudioStreamType stream, bool* _aidl_return) {
audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER(
aidl2legacy_AudioStreamType_audio_stream_type_t(stream));
*_aidl_return = mDelegate->streamMute(streamLegacy);
@@ -1008,7 +1009,7 @@
return Status::fromStatusT(mDelegate->closeInput(inputLegacy));
}
-Status AudioFlingerServerAdapter::invalidateStream(media::AudioStreamType stream) {
+Status AudioFlingerServerAdapter::invalidateStream(AudioStreamType stream) {
audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER(
aidl2legacy_AudioStreamType_audio_stream_type_t(stream));
return Status::fromStatusT(mDelegate->invalidateStream(streamLegacy));
diff --git a/media/libaudioclient/aidl/android/media/AudioAttributesEx.aidl b/media/libaudioclient/aidl/android/media/AudioAttributesEx.aidl
index 04a02c7..335866f 100644
--- a/media/libaudioclient/aidl/android/media/AudioAttributesEx.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioAttributesEx.aidl
@@ -17,7 +17,7 @@
package android.media;
import android.media.AudioAttributesInternal;
-import android.media.AudioStreamType;
+import android.media.audio.common.AudioStreamType;
/**
* This is the equivalent of the android::AudioAttributes C++ type.
diff --git a/media/libaudioclient/aidl/android/media/AudioAttributesInternal.aidl b/media/libaudioclient/aidl/android/media/AudioAttributesInternal.aidl
index 699df0a..1e8d65d 100644
--- a/media/libaudioclient/aidl/android/media/AudioAttributesInternal.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioAttributesInternal.aidl
@@ -18,7 +18,7 @@
import android.media.AudioContentType;
import android.media.AudioSourceType;
-import android.media.AudioUsage;
+import android.media.audio.common.AudioUsage;
/**
* The "Internal" suffix of this type name is to disambiguate it from the
diff --git a/media/libaudioclient/aidl/android/media/AudioConfig.aidl b/media/libaudioclient/aidl/android/media/AudioConfig.aidl
deleted file mode 100644
index aea7a34..0000000
--- a/media/libaudioclient/aidl/android/media/AudioConfig.aidl
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2020 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;
-
-import android.media.AudioOffloadInfo;
-import android.media.audio.common.AudioChannelLayout;
-import android.media.audio.common.AudioFormatDescription;
-
-/**
- * {@hide}
- */
-parcelable AudioConfig {
- int sampleRate;
- AudioChannelLayout channelMask;
- AudioFormatDescription format;
- AudioOffloadInfo offloadInfo;
- long frameCount;
-}
diff --git a/media/libaudioclient/aidl/android/media/AudioConfigBase.aidl b/media/libaudioclient/aidl/android/media/AudioConfigBase.aidl
deleted file mode 100644
index 54b1780..0000000
--- a/media/libaudioclient/aidl/android/media/AudioConfigBase.aidl
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2020 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;
-
-import android.media.audio.common.AudioChannelLayout;
-import android.media.audio.common.AudioFormatDescription;
-
-/**
- * {@hide}
- */
-parcelable AudioConfigBase {
- int sampleRate;
- AudioChannelLayout channelMask;
- AudioFormatDescription format;
-}
diff --git a/media/libaudioclient/aidl/android/media/AudioEncapsulationMode.aidl b/media/libaudioclient/aidl/android/media/AudioEncapsulationMode.aidl
deleted file mode 100644
index 9e04e82..0000000
--- a/media/libaudioclient/aidl/android/media/AudioEncapsulationMode.aidl
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2020 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;
-
-/**
- * {@hide}
- */
-@Backing(type="int")
-enum AudioEncapsulationMode {
- NONE = 0,
- ELEMENTARY_STREAM = 1,
- HANDLE = 2,
-}
diff --git a/media/libaudioclient/aidl/android/media/AudioMix.aidl b/media/libaudioclient/aidl/android/media/AudioMix.aidl
index 7473372..6a8980f 100644
--- a/media/libaudioclient/aidl/android/media/AudioMix.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioMix.aidl
@@ -16,12 +16,12 @@
package android.media;
-import android.media.AudioConfig;
import android.media.AudioDevice;
import android.media.AudioMixCallbackFlag;
import android.media.AudioMixMatchCriterion;
import android.media.AudioMixRouteFlag;
import android.media.AudioMixType;
+import android.media.audio.common.AudioConfig;
/**
* {@hide}
diff --git a/media/libaudioclient/aidl/android/media/AudioMixMatchCriterionValue.aidl b/media/libaudioclient/aidl/android/media/AudioMixMatchCriterionValue.aidl
index e26a9e1..498349f 100644
--- a/media/libaudioclient/aidl/android/media/AudioMixMatchCriterionValue.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioMixMatchCriterionValue.aidl
@@ -17,7 +17,7 @@
package android.media;
import android.media.AudioSourceType;
-import android.media.AudioUsage;
+import android.media.audio.common.AudioUsage;
/**
* {@hide}
diff --git a/media/libaudioclient/aidl/android/media/AudioOffloadInfo.aidl b/media/libaudioclient/aidl/android/media/AudioOffloadInfo.aidl
deleted file mode 100644
index f326305..0000000
--- a/media/libaudioclient/aidl/android/media/AudioOffloadInfo.aidl
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2020 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;
-
-import android.media.AudioConfigBase;
-import android.media.AudioEncapsulationMode;
-import android.media.AudioStreamType;
-import android.media.AudioUsage;
-
-/**
- * {@hide}
- */
-parcelable AudioOffloadInfo {
- /** Version of the info structure. Interpreted as a uint16_t version constant. */
- int version;
- /** Audio configuration. */
- AudioConfigBase config;
- /** Stream type. */
- AudioStreamType streamType;
- /** Bit rate in bits per second. */
- int bitRate;
- /** Duration in microseconds, -1 if unknown. */
- long durationUs;
- /** true if stream is tied to a video stream. */
- boolean hasVideo;
- /** true if streaming, false if local playback. */
- boolean isStreaming;
- int bitWidth;
- /** Offload fragment size. */
- int offloadBufferSize;
- AudioUsage usage;
- AudioEncapsulationMode encapsulationMode;
- /** Content id from tuner HAL (0 if none). */
- int contentId;
- /** Sync id from tuner HAL (0 if none). */
- int syncId;
-}
diff --git a/media/libaudioclient/aidl/android/media/AudioPortConfigMixExtUseCase.aidl b/media/libaudioclient/aidl/android/media/AudioPortConfigMixExtUseCase.aidl
index c61f044..8d97740 100644
--- a/media/libaudioclient/aidl/android/media/AudioPortConfigMixExtUseCase.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioPortConfigMixExtUseCase.aidl
@@ -17,7 +17,7 @@
package android.media;
import android.media.AudioSourceType;
-import android.media.AudioStreamType;
+import android.media.audio.common.AudioStreamType;
/**
* {@hide}
diff --git a/media/libaudioclient/aidl/android/media/AudioStreamType.aidl b/media/libaudioclient/aidl/android/media/AudioStreamType.aidl
deleted file mode 100644
index d777882..0000000
--- a/media/libaudioclient/aidl/android/media/AudioStreamType.aidl
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2020 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;
-
-/**
- * {@hide}
- */
-@Backing(type="int")
-enum AudioStreamType {
- DEFAULT = -1,
- VOICE_CALL = 0,
- SYSTEM = 1,
- RING = 2,
- MUSIC = 3,
- ALARM = 4,
- NOTIFICATION = 5,
- BLUETOOTH_SCO = 6,
- ENFORCED_AUDIBLE = 7,
- DTMF = 8,
- TTS = 9,
- ACCESSIBILITY = 10,
- ASSISTANT = 11,
- /** For dynamic policy output mixes. Only used by the audio policy */
- REROUTING = 12,
- /** For audio flinger tracks volume. Only used by the audioflinger */
- PATCH = 13,
- /** stream for corresponding to AUDIO_USAGE_CALL_ASSISTANT */
- CALL_ASSISTANT = 14,
-}
diff --git a/media/libaudioclient/aidl/android/media/AudioUsage.aidl b/media/libaudioclient/aidl/android/media/AudioUsage.aidl
deleted file mode 100644
index 66c5c30..0000000
--- a/media/libaudioclient/aidl/android/media/AudioUsage.aidl
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2020 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;
-
-/**
- * {@hide}
- */
-@Backing(type="int")
-enum AudioUsage {
- UNKNOWN = 0,
- MEDIA = 1,
- VOICE_COMMUNICATION = 2,
- VOICE_COMMUNICATION_SIGNALLING = 3,
- ALARM = 4,
- NOTIFICATION = 5,
- NOTIFICATION_TELEPHONY_RINGTONE = 6,
- NOTIFICATION_COMMUNICATION_REQUEST = 7,
- NOTIFICATION_COMMUNICATION_INSTANT = 8,
- NOTIFICATION_COMMUNICATION_DELAYED = 9,
- NOTIFICATION_EVENT = 10,
- ASSISTANCE_ACCESSIBILITY = 11,
- ASSISTANCE_NAVIGATION_GUIDANCE = 12,
- ASSISTANCE_SONIFICATION = 13,
- GAME = 14,
- VIRTUAL_SOURCE = 15,
- ASSISTANT = 16,
- CALL_ASSISTANT = 17,
- EMERGENCY = 1000,
- SAFETY = 1001,
- VEHICLE_STATUS = 1002,
- ANNOUNCEMENT = 1003,
-}
diff --git a/media/libaudioclient/aidl/android/media/AudioVolumeGroup.aidl b/media/libaudioclient/aidl/android/media/AudioVolumeGroup.aidl
index 3a29a08..b95a1d3 100644
--- a/media/libaudioclient/aidl/android/media/AudioVolumeGroup.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioVolumeGroup.aidl
@@ -17,7 +17,7 @@
package android.media;
import android.media.AudioAttributesInternal;
-import android.media.AudioStreamType;
+import android.media.audio.common.AudioStreamType;
/**
* {@hide}
diff --git a/media/libaudioclient/aidl/android/media/CreateRecordRequest.aidl b/media/libaudioclient/aidl/android/media/CreateRecordRequest.aidl
index 7e3c240..b938a3e 100644
--- a/media/libaudioclient/aidl/android/media/CreateRecordRequest.aidl
+++ b/media/libaudioclient/aidl/android/media/CreateRecordRequest.aidl
@@ -18,7 +18,7 @@
import android.media.AudioAttributesInternal;
import android.media.AudioClient;
-import android.media.AudioConfigBase;
+import android.media.audio.common.AudioConfigBase;
/**
* CreateRecordRequest contains all input arguments sent by AudioRecord to AudioFlinger
diff --git a/media/libaudioclient/aidl/android/media/CreateRecordResponse.aidl b/media/libaudioclient/aidl/android/media/CreateRecordResponse.aidl
index 61195d0..7d159d0 100644
--- a/media/libaudioclient/aidl/android/media/CreateRecordResponse.aidl
+++ b/media/libaudioclient/aidl/android/media/CreateRecordResponse.aidl
@@ -16,9 +16,9 @@
package android.media;
-import android.media.AudioConfigBase;
import android.media.IAudioRecord;
import android.media.SharedFileRegion;
+import android.media.audio.common.AudioConfigBase;
/**
* CreateRecordResponse contains all output arguments returned by AudioFlinger to AudioRecord
diff --git a/media/libaudioclient/aidl/android/media/CreateTrackRequest.aidl b/media/libaudioclient/aidl/android/media/CreateTrackRequest.aidl
index 014b3ca..212221e 100644
--- a/media/libaudioclient/aidl/android/media/CreateTrackRequest.aidl
+++ b/media/libaudioclient/aidl/android/media/CreateTrackRequest.aidl
@@ -18,9 +18,9 @@
import android.media.AudioAttributesInternal;
import android.media.AudioClient;
-import android.media.AudioConfig;
import android.media.IAudioTrackCallback;
import android.media.SharedFileRegion;
+import android.media.audio.common.AudioConfig;
/**
* CreateTrackInput contains all input arguments sent by AudioTrack to AudioFlinger
diff --git a/media/libaudioclient/aidl/android/media/CreateTrackResponse.aidl b/media/libaudioclient/aidl/android/media/CreateTrackResponse.aidl
index 40473fa..da6f454 100644
--- a/media/libaudioclient/aidl/android/media/CreateTrackResponse.aidl
+++ b/media/libaudioclient/aidl/android/media/CreateTrackResponse.aidl
@@ -16,7 +16,7 @@
package android.media;
-import android.media.AudioStreamType;
+import android.media.audio.common.AudioStreamType;
import android.media.IAudioTrack;
/**
diff --git a/media/libaudioclient/aidl/android/media/GetOutputForAttrResponse.aidl b/media/libaudioclient/aidl/android/media/GetOutputForAttrResponse.aidl
index 164fb9d..963877a 100644
--- a/media/libaudioclient/aidl/android/media/GetOutputForAttrResponse.aidl
+++ b/media/libaudioclient/aidl/android/media/GetOutputForAttrResponse.aidl
@@ -16,7 +16,7 @@
package android.media;
-import android.media.AudioStreamType;
+import android.media.audio.common.AudioStreamType;
/**
* {@hide}
diff --git a/media/libaudioclient/aidl/android/media/IAudioFlingerService.aidl b/media/libaudioclient/aidl/android/media/IAudioFlingerService.aidl
index 7b02a9d..758ae07 100644
--- a/media/libaudioclient/aidl/android/media/IAudioFlingerService.aidl
+++ b/media/libaudioclient/aidl/android/media/IAudioFlingerService.aidl
@@ -20,7 +20,6 @@
import android.media.AudioPatch;
import android.media.AudioPort;
import android.media.AudioPortConfig;
-import android.media.AudioStreamType;
import android.media.AudioUniqueIdUse;
import android.media.AudioUuid;
import android.media.AudioVibratorInfo;
@@ -43,6 +42,7 @@
import android.media.TrackSecondaryOutputInfo;
import android.media.audio.common.AudioChannelLayout;
import android.media.audio.common.AudioFormatDescription;
+import android.media.audio.common.AudioStreamType;
/**
* {@hide}
diff --git a/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl b/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl
index 74bfa05..37834c9 100644
--- a/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl
+++ b/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl
@@ -20,13 +20,10 @@
import android.media.AudioAttributesEx;
import android.media.AudioAttributesInternal;
-import android.media.AudioConfig;
-import android.media.AudioConfigBase;
import android.media.AudioDevice;
import android.media.AudioDeviceDescription;
import android.media.AudioMix;
import android.media.AudioMode;
-import android.media.AudioOffloadInfo;
import android.media.AudioOffloadMode;
import android.media.AudioPatch;
import android.media.AudioPolicyDeviceState;
@@ -38,8 +35,6 @@
import android.media.AudioPortType;
import android.media.AudioProductStrategy;
import android.media.AudioSourceType;
-import android.media.AudioStreamType;
-import android.media.AudioUsage;
import android.media.AudioUuid;
import android.media.AudioVolumeGroup;
import android.media.DeviceRole;
@@ -52,7 +47,12 @@
import android.media.INativeSpatializerCallback;
import android.media.Int;
import android.media.SoundTriggerSession;
+import android.media.audio.common.AudioConfig;
+import android.media.audio.common.AudioConfigBase;
import android.media.audio.common.AudioFormatDescription;
+import android.media.audio.common.AudioOffloadInfo;
+import android.media.audio.common.AudioStreamType;
+import android.media.audio.common.AudioUsage;
/**
* IAudioPolicyService interface (see AudioPolicyInterface for method descriptions).
diff --git a/media/libaudioclient/aidl/android/media/IAudioPolicyServiceClient.aidl b/media/libaudioclient/aidl/android/media/IAudioPolicyServiceClient.aidl
index a7782b8..cf66644 100644
--- a/media/libaudioclient/aidl/android/media/IAudioPolicyServiceClient.aidl
+++ b/media/libaudioclient/aidl/android/media/IAudioPolicyServiceClient.aidl
@@ -16,10 +16,10 @@
package android.media;
-import android.media.AudioConfigBase;
import android.media.AudioSourceType;
import android.media.EffectDescriptor;
import android.media.RecordClientInfo;
+import android.media.audio.common.AudioConfigBase;
/**
* {@hide}
diff --git a/media/libaudioclient/aidl/android/media/OpenInputRequest.aidl b/media/libaudioclient/aidl/android/media/OpenInputRequest.aidl
index 2e55526..cd8a325 100644
--- a/media/libaudioclient/aidl/android/media/OpenInputRequest.aidl
+++ b/media/libaudioclient/aidl/android/media/OpenInputRequest.aidl
@@ -16,9 +16,9 @@
package android.media;
-import android.media.AudioConfig;
import android.media.AudioDevice;
import android.media.AudioSourceType;
+import android.media.audio.common.AudioConfig;
/**
* {@hide}
diff --git a/media/libaudioclient/aidl/android/media/OpenInputResponse.aidl b/media/libaudioclient/aidl/android/media/OpenInputResponse.aidl
index b613ba5..b4de404 100644
--- a/media/libaudioclient/aidl/android/media/OpenInputResponse.aidl
+++ b/media/libaudioclient/aidl/android/media/OpenInputResponse.aidl
@@ -16,8 +16,8 @@
package android.media;
-import android.media.AudioConfig;
import android.media.AudioDevice;
+import android.media.audio.common.AudioConfig;
/**
* {@hide}
diff --git a/media/libaudioclient/aidl/android/media/OpenOutputRequest.aidl b/media/libaudioclient/aidl/android/media/OpenOutputRequest.aidl
index 1541948..90e7ea6 100644
--- a/media/libaudioclient/aidl/android/media/OpenOutputRequest.aidl
+++ b/media/libaudioclient/aidl/android/media/OpenOutputRequest.aidl
@@ -16,9 +16,9 @@
package android.media;
-import android.media.AudioConfig;
-import android.media.AudioConfigBase;
import android.media.AudioPort;
+import android.media.audio.common.AudioConfig;
+import android.media.audio.common.AudioConfigBase;
/**
* {@hide}
diff --git a/media/libaudioclient/aidl/android/media/OpenOutputResponse.aidl b/media/libaudioclient/aidl/android/media/OpenOutputResponse.aidl
index a051969..451a0bf 100644
--- a/media/libaudioclient/aidl/android/media/OpenOutputResponse.aidl
+++ b/media/libaudioclient/aidl/android/media/OpenOutputResponse.aidl
@@ -16,7 +16,7 @@
package android.media;
-import android.media.AudioConfig;
+import android.media.audio.common.AudioConfig;
/**
* {@hide}
diff --git a/media/libaudioclient/include/media/AidlConversion.h b/media/libaudioclient/include/media/AidlConversion.h
index 7e87a4e..0a43459 100644
--- a/media/libaudioclient/include/media/AidlConversion.h
+++ b/media/libaudioclient/include/media/AidlConversion.h
@@ -23,11 +23,8 @@
#include <android/media/AudioAttributesInternal.h>
#include <android/media/AudioClient.h>
-#include <android/media/AudioConfig.h>
-#include <android/media/AudioConfigBase.h>
#include <android/media/AudioDeviceDescription.h>
#include <android/media/AudioDualMonoMode.h>
-#include <android/media/AudioEncapsulationMode.h>
#include <android/media/AudioEncapsulationMetadataType.h>
#include <android/media/AudioEncapsulationType.h>
#include <android/media/AudioFlag.h>
@@ -53,7 +50,12 @@
#include <android/media/ExtraAudioDescriptor.h>
#include <android/media/TrackSecondaryOutputInfo.h>
#include <android/media/audio/common/AudioChannelLayout.h>
+#include <android/media/audio/common/AudioConfig.h>
+#include <android/media/audio/common/AudioConfigBase.h>
+#include <android/media/audio/common/AudioOffloadInfo.h>
+#include <android/media/audio/common/AudioEncapsulationMode.h>
#include <android/media/audio/common/AudioFormatDescription.h>
+#include <android/media/audio/common/AudioUsage.h>
#include <android/media/SharedFileRegion.h>
#include <binder/IMemory.h>
@@ -192,9 +194,9 @@
const audio_port_config_device_ext& legacy);
ConversionResult<audio_stream_type_t> aidl2legacy_AudioStreamType_audio_stream_type_t(
- media::AudioStreamType aidl);
-ConversionResult<media::AudioStreamType> legacy2aidl_audio_stream_type_t_AudioStreamType(
- audio_stream_type_t legacy);
+ media::audio::common::AudioStreamType aidl);
+ConversionResult<media::audio::common::AudioStreamType>
+legacy2aidl_audio_stream_type_t_AudioStreamType(audio_stream_type_t legacy);
ConversionResult<audio_source_t> aidl2legacy_AudioSourceType_audio_source_t(
media::AudioSourceType aidl);
@@ -242,8 +244,8 @@
legacy2aidl_audio_content_type_t_AudioContentType(audio_content_type_t legacy);
ConversionResult<audio_usage_t>
-aidl2legacy_AudioUsage_audio_usage_t(media::AudioUsage aidl);
-ConversionResult<media::AudioUsage>
+aidl2legacy_AudioUsage_audio_usage_t(media::audio::common::AudioUsage aidl);
+ConversionResult<media::audio::common::AudioUsage>
legacy2aidl_audio_usage_t_AudioUsage(audio_usage_t legacy);
ConversionResult<audio_flags_mask_t>
@@ -262,23 +264,26 @@
legacy2aidl_audio_attributes_t_AudioAttributesInternal(const audio_attributes_t& legacy);
ConversionResult<audio_encapsulation_mode_t>
-aidl2legacy_AudioEncapsulationMode_audio_encapsulation_mode_t(media::AudioEncapsulationMode aidl);
-ConversionResult<media::AudioEncapsulationMode>
+aidl2legacy_AudioEncapsulationMode_audio_encapsulation_mode_t(
+ media::audio::common::AudioEncapsulationMode aidl);
+ConversionResult<media::audio::common::AudioEncapsulationMode>
legacy2aidl_audio_encapsulation_mode_t_AudioEncapsulationMode(audio_encapsulation_mode_t legacy);
ConversionResult<audio_offload_info_t>
-aidl2legacy_AudioOffloadInfo_audio_offload_info_t(const media::AudioOffloadInfo& aidl);
-ConversionResult<media::AudioOffloadInfo>
+aidl2legacy_AudioOffloadInfo_audio_offload_info_t(
+ const media::audio::common::AudioOffloadInfo& aidl);
+ConversionResult<media::audio::common::AudioOffloadInfo>
legacy2aidl_audio_offload_info_t_AudioOffloadInfo(const audio_offload_info_t& legacy);
ConversionResult<audio_config_t>
-aidl2legacy_AudioConfig_audio_config_t(const media::AudioConfig& aidl, bool isInput);
-ConversionResult<media::AudioConfig>
+aidl2legacy_AudioConfig_audio_config_t(const media::audio::common::AudioConfig& aidl, bool isInput);
+ConversionResult<media::audio::common::AudioConfig>
legacy2aidl_audio_config_t_AudioConfig(const audio_config_t& legacy, bool isInput);
ConversionResult<audio_config_base_t>
-aidl2legacy_AudioConfigBase_audio_config_base_t(const media::AudioConfigBase& aidl, bool isInput);
-ConversionResult<media::AudioConfigBase>
+aidl2legacy_AudioConfigBase_audio_config_base_t(
+ const media::audio::common::AudioConfigBase& aidl, bool isInput);
+ConversionResult<media::audio::common::AudioConfigBase>
legacy2aidl_audio_config_base_t_AudioConfigBase(const audio_config_base_t& legacy, bool isInput);
ConversionResult<sp<IMemory>>
diff --git a/media/libaudioclient/include/media/AudioSystem.h b/media/libaudioclient/include/media/AudioSystem.h
index 50ab42a..dbd1f6b 100644
--- a/media/libaudioclient/include/media/AudioSystem.h
+++ b/media/libaudioclient/include/media/AudioSystem.h
@@ -689,9 +689,9 @@
binder::Status onRecordingConfigurationUpdate(
int32_t event,
const media::RecordClientInfo& clientInfo,
- const media::AudioConfigBase& clientConfig,
+ const media::audio::common::AudioConfigBase& clientConfig,
const std::vector<media::EffectDescriptor>& clientEffects,
- const media::AudioConfigBase& deviceConfig,
+ const media::audio::common::AudioConfigBase& deviceConfig,
const std::vector<media::EffectDescriptor>& effects,
int32_t patchHandle,
media::AudioSourceType source) override;
diff --git a/media/libaudioclient/include/media/IAudioFlinger.h b/media/libaudioclient/include/media/IAudioFlinger.h
index a74661a..6d62b6b 100644
--- a/media/libaudioclient/include/media/IAudioFlinger.h
+++ b/media/libaudioclient/include/media/IAudioFlinger.h
@@ -580,11 +580,12 @@
Status masterMute(bool* _aidl_return) override;
Status setMasterBalance(float balance) override;
Status getMasterBalance(float* _aidl_return) override;
- Status setStreamVolume(media::AudioStreamType stream, float value, int32_t output) override;
- Status setStreamMute(media::AudioStreamType stream, bool muted) override;
- Status
- streamVolume(media::AudioStreamType stream, int32_t output, float* _aidl_return) override;
- Status streamMute(media::AudioStreamType stream, bool* _aidl_return) override;
+ Status setStreamVolume(media::audio::common::AudioStreamType stream,
+ float value, int32_t output) override;
+ Status setStreamMute(media::audio::common::AudioStreamType stream, bool muted) override;
+ Status streamVolume(media::audio::common::AudioStreamType stream,
+ int32_t output, float* _aidl_return) override;
+ Status streamMute(media::audio::common::AudioStreamType stream, bool* _aidl_return) override;
Status setMode(media::AudioMode mode) override;
Status setMicMute(bool state) override;
Status getMicMute(bool* _aidl_return) override;
@@ -606,7 +607,7 @@
Status openInput(const media::OpenInputRequest& request,
media::OpenInputResponse* _aidl_return) override;
Status closeInput(int32_t input) override;
- Status invalidateStream(media::AudioStreamType stream) override;
+ Status invalidateStream(media::audio::common::AudioStreamType stream) override;
Status setVoiceVolume(float volume) override;
Status getRenderPosition(int32_t output, media::RenderPosition* _aidl_return) override;
Status getInputFramesLost(int32_t ioHandle, int32_t* _aidl_return) override;
diff --git a/media/libmediametrics/IMediaMetricsService.cpp b/media/libmediametrics/IMediaMetricsService.cpp
deleted file mode 100644
index b5675e6..0000000
--- a/media/libmediametrics/IMediaMetricsService.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2016 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.
- */
-
-#define LOG_TAG "MediaMetrics"
-
-#include <stdint.h>
-#include <inttypes.h>
-#include <sys/types.h>
-
-#include <binder/Parcel.h>
-#include <binder/IMemory.h>
-#include <binder/IPCThreadState.h>
-
-#include <utils/Errors.h> // for status_t
-#include <utils/List.h>
-#include <utils/Log.h>
-#include <utils/String8.h>
-
-#include <media/MediaMetricsItem.h>
-#include <media/IMediaMetricsService.h>
-
-namespace android {
-
-// TODO: Currently ONE_WAY transactions, make both ONE_WAY and synchronous options.
-
-enum {
- SUBMIT_ITEM = IBinder::FIRST_CALL_TRANSACTION,
- SUBMIT_BUFFER,
-};
-
-class BpMediaMetricsService: public BpInterface<IMediaMetricsService>
-{
-public:
- explicit BpMediaMetricsService(const sp<IBinder>& impl)
- : BpInterface<IMediaMetricsService>(impl)
- {
- }
-
- status_t submit(mediametrics::Item *item) override
- {
- if (item == nullptr) {
- return BAD_VALUE;
- }
- ALOGV("%s: (ONEWAY) item=%s", __func__, item->toString().c_str());
-
- Parcel data;
- data.writeInterfaceToken(IMediaMetricsService::getInterfaceDescriptor());
-
- status_t status = item->writeToParcel(&data);
- if (status != NO_ERROR) { // assume failure logged in item
- return status;
- }
-
- status = remote()->transact(
- SUBMIT_ITEM, data, nullptr /* reply */, IBinder::FLAG_ONEWAY);
- ALOGW_IF(status != NO_ERROR, "%s: bad response from service for submit, status=%d",
- __func__, status);
- return status;
- }
-
- status_t submitBuffer(const char *buffer, size_t length) override
- {
- if (buffer == nullptr || length > INT32_MAX) {
- return BAD_VALUE;
- }
- ALOGV("%s: (ONEWAY) length:%zu", __func__, length);
-
- Parcel data;
- data.writeInterfaceToken(IMediaMetricsService::getInterfaceDescriptor());
-
- status_t status = data.writeInt32(length)
- ?: data.write((uint8_t*)buffer, length);
- if (status != NO_ERROR) {
- return status;
- }
-
- status = remote()->transact(
- SUBMIT_BUFFER, data, nullptr /* reply */, IBinder::FLAG_ONEWAY);
- ALOGW_IF(status != NO_ERROR, "%s: bad response from service for submit, status=%d",
- __func__, status);
- return status;
- }
-};
-
-IMPLEMENT_META_INTERFACE(MediaMetricsService, "android.media.IMediaMetricsService");
-
-// ----------------------------------------------------------------------
-
-status_t BnMediaMetricsService::onTransact(
- uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
-{
- switch (code) {
- case SUBMIT_ITEM: {
- CHECK_INTERFACE(IMediaMetricsService, data, reply);
-
- mediametrics::Item * const item = mediametrics::Item::create();
- status_t status = item->readFromParcel(data);
- if (status != NO_ERROR) { // assume failure logged in item
- return status;
- }
- status = submitInternal(item, true /* release */);
- // assume failure logged by submitInternal
- return NO_ERROR;
- }
- case SUBMIT_BUFFER: {
- CHECK_INTERFACE(IMediaMetricsService, data, reply);
- int32_t length;
- status_t status = data.readInt32(&length);
- if (status != NO_ERROR || length <= 0) {
- return BAD_VALUE;
- }
- const void *ptr = data.readInplace(length);
- if (ptr == nullptr) {
- return BAD_VALUE;
- }
- status = submitBuffer(static_cast<const char *>(ptr), length);
- // assume failure logged by submitBuffer
- return NO_ERROR;
- }
-
- default:
- return BBinder::onTransact(code, data, reply, flags);
- }
-}
-
-// ----------------------------------------------------------------------------
-
-} // namespace android
diff --git a/media/libmediaplayerservice/Android.bp b/media/libmediaplayerservice/Android.bp
index f55678d..37f8103 100644
--- a/media/libmediaplayerservice/Android.bp
+++ b/media/libmediaplayerservice/Android.bp
@@ -65,6 +65,7 @@
"libstagefright_foundation",
"libstagefright_httplive",
"libutils",
+ "packagemanager_aidl-cpp",
],
header_libs: [
@@ -82,6 +83,7 @@
export_shared_lib_headers: [
"libmedia",
"framework-permission-aidl-cpp",
+ "packagemanager_aidl-cpp",
],
include_dirs: [
diff --git a/media/libstagefright/Android.bp b/media/libstagefright/Android.bp
index a052a70..b412c9d 100644
--- a/media/libstagefright/Android.bp
+++ b/media/libstagefright/Android.bp
@@ -340,6 +340,7 @@
"android.hardware.media.omx@1.0",
"framework-permission-aidl-cpp",
"libaudioclient_aidl_conversion",
+ "packagemanager_aidl-cpp",
],
static_libs: [
@@ -371,6 +372,7 @@
"libmedia",
"android.hidl.allocator@1.0",
"framework-permission-aidl-cpp",
+ "packagemanager_aidl-cpp",
],
export_include_dirs: [
diff --git a/media/libstagefright/httplive/fuzzer/Android.bp b/media/libstagefright/httplive/fuzzer/Android.bp
index 58e5af6..14097b0 100644
--- a/media/libstagefright/httplive/fuzzer/Android.bp
+++ b/media/libstagefright/httplive/fuzzer/Android.bp
@@ -14,6 +14,17 @@
* limitations under the License.
*/
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "frameworks_av_media_libstagefright_httplive_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: [
+ "frameworks_av_media_libstagefright_httplive_license",
+ ],
+}
+
cc_fuzz {
name: "httplive_fuzzer",
srcs: [
diff --git a/media/libstagefright/httplive/fuzzer/httplive_fuzzer.cpp b/media/libstagefright/httplive/fuzzer/httplive_fuzzer.cpp
index 348d526..aa777b3 100644
--- a/media/libstagefright/httplive/fuzzer/httplive_fuzzer.cpp
+++ b/media/libstagefright/httplive/fuzzer/httplive_fuzzer.cpp
@@ -229,17 +229,13 @@
void HttpLiveFuzzer::invokeConnectAsync() {
string currentFileName = generateFileName();
- size_t fileUrlLength =
- strlen(currentFileName.c_str()) + strlen(kFileUrlPrefix);
- char *url = new char[fileUrlLength + 1];
- strcpy(url, kFileUrlPrefix);
- strcat(url, currentFileName.c_str());
+ string url = kFileUrlPrefix + currentFileName;
string str_1 = mFDP->ConsumeRandomLengthString(kRandomStringLength);
string str_2 = mFDP->ConsumeRandomLengthString(kRandomStringLength);
KeyedVector<String8, String8> headers;
headers.add(String8(str_1.c_str()), String8(str_2.c_str()));
- mLiveSession->connectAsync(url, &headers);
+ mLiveSession->connectAsync(url.c_str(), &headers);
}
void HttpLiveFuzzer::invokeLiveSession() {
diff --git a/media/libstagefright/rtsp/ARTPConnection.cpp b/media/libstagefright/rtsp/ARTPConnection.cpp
index ffccbb1..0bd342a 100644
--- a/media/libstagefright/rtsp/ARTPConnection.cpp
+++ b/media/libstagefright/rtsp/ARTPConnection.cpp
@@ -508,8 +508,6 @@
if (n != (ssize_t)buffer->size()) {
ALOGW("failed to send RTCP TMMBR (%s).",
n >= 0 ? "connection gone" : strerror(errno));
-
- it = mStreams.erase(it);
continue;
}
}
@@ -560,8 +558,6 @@
if (n != (ssize_t)buffer->size()) {
ALOGW("failed to send RTCP receiver report (%s).",
n >= 0 ? "connection gone" : strerror(errno));
-
- it = mStreams.erase(it);
continue;
}
@@ -621,7 +617,14 @@
} while (nbytes < 0 && errno == EINTR);
if (nbytes <= 0) {
- return -ECONNRESET;
+ ALOGW("failed to recv rtp packet. cause=%s", strerror(errno));
+ // ECONNREFUSED may happen in next recvfrom() calling if one of
+ // outgoing packet can not be delivered to remote by using sendto()
+ if (errno == ECONNREFUSED) {
+ return -ECONNREFUSED;
+ } else {
+ return -ECONNRESET;
+ }
}
buffer->setRange(0, nbytes);
@@ -665,6 +668,10 @@
pRemoteRTCPAddr, sizeSockSt);
} while (n < 0 && errno == EINTR);
+ if (n < 0) {
+ ALOGW("failed to send rtcp packet. cause=%s", strerror(errno));
+ }
+
return n;
}
diff --git a/media/utils/Android.bp b/media/utils/Android.bp
index 73c4e3b..6e29ac8 100644
--- a/media/utils/Android.bp
+++ b/media/utils/Android.bp
@@ -51,6 +51,7 @@
"libpermission",
"android.hardware.graphics.bufferqueue@1.0",
"android.hidl.token@1.0-utils",
+ "packagemanager_aidl-cpp",
],
export_static_lib_headers: [
"libbatterystats_aidl",
@@ -71,6 +72,7 @@
export_shared_lib_headers: [
"libpermission",
+ "packagemanager_aidl-cpp",
],
include_dirs: [
diff --git a/services/audioflinger/Android.bp b/services/audioflinger/Android.bp
index e4f1b47..ea85d04 100644
--- a/services/audioflinger/Android.bp
+++ b/services/audioflinger/Android.bp
@@ -82,6 +82,7 @@
"libmedia_helper",
"libshmemcompat",
"libvibrator",
+ "packagemanager_aidl-cpp",
],
static_libs: [
@@ -98,6 +99,7 @@
export_shared_lib_headers: [
"libpermission",
+ "packagemanager_aidl-cpp",
],
cflags: [
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 8a32b72..33b71c5 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -566,10 +566,12 @@
String8 result;
result.append("Clients:\n");
+ result.append(" pid heap_size\n");
for (size_t i = 0; i < mClients.size(); ++i) {
sp<Client> client = mClients.valueAt(i).promote();
if (client != 0) {
- result.appendFormat(" pid: %d\n", client->pid());
+ result.appendFormat("%6d %12zu\n", client->pid(),
+ client->heap()->getMemoryHeap()->getSize());
}
}
diff --git a/services/audiopolicy/service/Android.bp b/services/audiopolicy/service/Android.bp
index de1bc37..3723a69 100644
--- a/services/audiopolicy/service/Android.bp
+++ b/services/audiopolicy/service/Android.bp
@@ -17,6 +17,7 @@
"AudioPolicyService.cpp",
"CaptureStateNotifier.cpp",
"Spatializer.cpp",
+ "SpatializerPoseController.cpp",
],
include_dirs: [
@@ -25,6 +26,7 @@
shared_libs: [
"libactivitymanager_aidl",
+ "libandroid",
"libaudioclient",
"libaudioclient_aidl_conversion",
"libaudiofoundation",
@@ -36,11 +38,14 @@
"libcutils",
"libeffectsconfig",
"libhardware_legacy",
+ "libheadtracking",
+ "libheadtracking-binding",
"liblog",
"libmedia_helper",
"libmediametrics",
"libmediautils",
"libpermission",
+ "libsensor",
"libsensorprivacy",
"libshmemcompat",
"libutils",
@@ -51,6 +56,7 @@
"audiopolicy-types-aidl-cpp",
"capture_state_listener-aidl-cpp",
"framework-permission-aidl-cpp",
+ "packagemanager_aidl-cpp",
"spatializer-aidl-cpp",
],
@@ -76,6 +82,8 @@
export_shared_lib_headers: [
"libactivitymanager_aidl",
+ "libheadtracking",
+ "libheadtracking-binding",
"libsensorprivacy",
"framework-permission-aidl-cpp",
],
diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
index 3ff927d..9346de3 100644
--- a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
+++ b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
@@ -44,7 +44,12 @@
using binder::Status;
using aidl_utils::binderStatusFromStatusT;
using content::AttributionSourceState;
+using media::audio::common::AudioConfig;
+using media::audio::common::AudioConfigBase;
using media::audio::common::AudioFormatDescription;
+using media::audio::common::AudioOffloadInfo;
+using media::audio::common::AudioStreamType;
+using media::audio::common::AudioUsage;
const std::vector<audio_usage_t>& SYSTEM_USAGES = {
AUDIO_USAGE_CALL_ASSISTANT,
@@ -258,7 +263,7 @@
return Status::ok();
}
-Status AudioPolicyService::getOutput(media::AudioStreamType streamAidl, int32_t* _aidl_return)
+Status AudioPolicyService::getOutput(AudioStreamType streamAidl, int32_t* _aidl_return)
{
audio_stream_type_t stream = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_AudioStreamType_audio_stream_type_t(streamAidl));
@@ -282,7 +287,7 @@
Status AudioPolicyService::getOutputForAttr(const media::AudioAttributesInternal& attrAidl,
int32_t sessionAidl,
const AttributionSourceState& attributionSource,
- const media::AudioConfig& configAidl,
+ const AudioConfig& configAidl,
int32_t flagsAidl,
int32_t selectedDeviceIdAidl,
media::GetOutputForAttrResponse* _aidl_return)
@@ -511,7 +516,7 @@
int32_t riidAidl,
int32_t sessionAidl,
const AttributionSourceState& attributionSource,
- const media::AudioConfigBase& configAidl,
+ const AudioConfigBase& configAidl,
int32_t flagsAidl,
int32_t selectedDeviceIdAidl,
media::GetInputForAttrResponse* _aidl_return) {
@@ -902,7 +907,7 @@
return Status::ok();
}
-Status AudioPolicyService::initStreamVolume(media::AudioStreamType streamAidl,
+Status AudioPolicyService::initStreamVolume(AudioStreamType streamAidl,
int32_t indexMinAidl,
int32_t indexMaxAidl) {
audio_stream_type_t stream = VALUE_OR_RETURN_BINDER_STATUS(
@@ -925,7 +930,7 @@
return binderStatusFromStatusT(NO_ERROR);
}
-Status AudioPolicyService::setStreamVolumeIndex(media::AudioStreamType streamAidl,
+Status AudioPolicyService::setStreamVolumeIndex(AudioStreamType streamAidl,
const media::AudioDeviceDescription& deviceAidl,
int32_t indexAidl) {
audio_stream_type_t stream = VALUE_OR_RETURN_BINDER_STATUS(
@@ -950,7 +955,7 @@
device));
}
-Status AudioPolicyService::getStreamVolumeIndex(media::AudioStreamType streamAidl,
+Status AudioPolicyService::getStreamVolumeIndex(AudioStreamType streamAidl,
const media::AudioDeviceDescription& deviceAidl,
int32_t* _aidl_return) {
audio_stream_type_t stream = VALUE_OR_RETURN_BINDER_STATUS(
@@ -1056,7 +1061,7 @@
return Status::ok();
}
-Status AudioPolicyService::getStrategyForStream(media::AudioStreamType streamAidl,
+Status AudioPolicyService::getStrategyForStream(AudioStreamType streamAidl,
int32_t* _aidl_return) {
audio_stream_type_t stream = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_AudioStreamType_audio_stream_type_t(streamAidl));
@@ -1081,7 +1086,7 @@
//audio policy: use audio_device_t appropriately
Status AudioPolicyService::getDevicesForStream(
- media::AudioStreamType streamAidl,
+ AudioStreamType streamAidl,
std::vector<media::AudioDeviceDescription>* _aidl_return) {
audio_stream_type_t stream = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_AudioStreamType_audio_stream_type_t(streamAidl));
@@ -1204,7 +1209,7 @@
return binderStatusFromStatusT(mAudioPolicyManager->moveEffectsToIo(ids, io));
}
-Status AudioPolicyService::isStreamActive(media::AudioStreamType streamAidl, int32_t inPastMsAidl,
+Status AudioPolicyService::isStreamActive(AudioStreamType streamAidl, int32_t inPastMsAidl,
bool* _aidl_return) {
audio_stream_type_t stream = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_AudioStreamType_audio_stream_type_t(streamAidl));
@@ -1223,7 +1228,7 @@
return Status::ok();
}
-Status AudioPolicyService::isStreamActiveRemotely(media::AudioStreamType streamAidl,
+Status AudioPolicyService::isStreamActiveRemotely(AudioStreamType streamAidl,
int32_t inPastMsAidl,
bool* _aidl_return) {
audio_stream_type_t stream = VALUE_OR_RETURN_BINDER_STATUS(
@@ -1327,7 +1332,7 @@
Status AudioPolicyService::addStreamDefaultEffect(const media::AudioUuid& typeAidl,
const std::string& opPackageNameAidl,
const media::AudioUuid& uuidAidl,
- int32_t priority, media::AudioUsage usageAidl,
+ int32_t priority, AudioUsage usageAidl,
int32_t* _aidl_return) {
effect_uuid_t type = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_AudioUuid_audio_uuid_t(typeAidl));
@@ -1375,7 +1380,7 @@
}
Status AudioPolicyService::setSupportedSystemUsages(
- const std::vector<media::AudioUsage>& systemUsagesAidl) {
+ const std::vector<AudioUsage>& systemUsagesAidl) {
size_t size = systemUsagesAidl.size();
if (size > MAX_ITEMS_PER_LIST) {
size = MAX_ITEMS_PER_LIST;
@@ -1414,7 +1419,7 @@
mAudioPolicyManager->setAllowedCapturePolicy(uid, capturePolicy));
}
-Status AudioPolicyService::getOffloadSupport(const media::AudioOffloadInfo& infoAidl,
+Status AudioPolicyService::getOffloadSupport(const AudioOffloadInfo& infoAidl,
media::AudioOffloadMode* _aidl_return) {
audio_offload_info_t info = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_AudioOffloadInfo_audio_offload_info_t(infoAidl));
@@ -1430,7 +1435,7 @@
}
Status AudioPolicyService::isDirectOutputSupported(
- const media::AudioConfigBase& configAidl,
+ const AudioConfigBase& configAidl,
const media::AudioAttributesInternal& attributesAidl,
bool* _aidl_return) {
audio_config_base_t config = VALUE_OR_RETURN_BINDER_STATUS(
@@ -1810,7 +1815,7 @@
Status AudioPolicyService::getStreamVolumeDB(
- media::AudioStreamType streamAidl, int32_t indexAidl,
+ AudioStreamType streamAidl, int32_t indexAidl,
const media::AudioDeviceDescription& deviceAidl, float* _aidl_return) {
audio_stream_type_t stream = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_AudioStreamType_audio_stream_type_t(streamAidl));
@@ -2227,7 +2232,7 @@
Status AudioPolicyService::canBeSpatialized(
const std::optional<media::AudioAttributesInternal>& attrAidl,
- const std::optional<media::AudioConfig>& configAidl,
+ const std::optional<AudioConfig>& configAidl,
const std::vector<media::AudioDevice>& devicesAidl,
bool* _aidl_return) {
if (mAudioPolicyManager == nullptr) {
diff --git a/services/audiopolicy/service/AudioPolicyService.cpp b/services/audiopolicy/service/AudioPolicyService.cpp
index 86994ed..db64633 100644
--- a/services/audiopolicy/service/AudioPolicyService.cpp
+++ b/services/audiopolicy/service/AudioPolicyService.cpp
@@ -495,14 +495,14 @@
int32_t eventAidl = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(event));
media::RecordClientInfo clientInfoAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_record_client_info_t_RecordClientInfo(*clientInfo));
- media::AudioConfigBase clientConfigAidl = VALUE_OR_RETURN_STATUS(
+ AudioConfigBase clientConfigAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_config_base_t_AudioConfigBase(
*clientConfig, true /*isInput*/));
std::vector<media::EffectDescriptor> clientEffectsAidl = VALUE_OR_RETURN_STATUS(
convertContainer<std::vector<media::EffectDescriptor>>(
clientEffects,
legacy2aidl_effect_descriptor_t_EffectDescriptor));
- media::AudioConfigBase deviceConfigAidl = VALUE_OR_RETURN_STATUS(
+ AudioConfigBase deviceConfigAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_config_base_t_AudioConfigBase(
*deviceConfig, true /*isInput*/));
std::vector<media::EffectDescriptor> effectsAidl = VALUE_OR_RETURN_STATUS(
diff --git a/services/audiopolicy/service/AudioPolicyService.h b/services/audiopolicy/service/AudioPolicyService.h
index 129c757..a6237bc 100644
--- a/services/audiopolicy/service/AudioPolicyService.h
+++ b/services/audiopolicy/service/AudioPolicyService.h
@@ -49,7 +49,11 @@
namespace android {
using content::AttributionSourceState;
+using media::audio::common::AudioConfig;
+using media::audio::common::AudioConfigBase;
using media::audio::common::AudioFormatDescription;
+using media::audio::common::AudioStreamType;
+using media::audio::common::AudioUsage;
// ----------------------------------------------------------------------------
@@ -87,10 +91,10 @@
media::AudioPolicyForcedConfig config) override;
binder::Status getForceUse(media::AudioPolicyForceUse usage,
media::AudioPolicyForcedConfig* _aidl_return) override;
- binder::Status getOutput(media::AudioStreamType stream, int32_t* _aidl_return) override;
+ binder::Status getOutput(AudioStreamType stream, int32_t* _aidl_return) override;
binder::Status getOutputForAttr(const media::AudioAttributesInternal& attr, int32_t session,
const AttributionSourceState &attributionSource,
- const media::AudioConfig& config,
+ const AudioConfig& config,
int32_t flags, int32_t selectedDeviceId,
media::GetOutputForAttrResponse* _aidl_return) override;
binder::Status startOutput(int32_t portId) override;
@@ -99,18 +103,18 @@
binder::Status getInputForAttr(const media::AudioAttributesInternal& attr, int32_t input,
int32_t riid, int32_t session,
const AttributionSourceState &attributionSource,
- const media::AudioConfigBase& config, int32_t flags,
+ const AudioConfigBase& config, int32_t flags,
int32_t selectedDeviceId,
media::GetInputForAttrResponse* _aidl_return) override;
binder::Status startInput(int32_t portId) override;
binder::Status stopInput(int32_t portId) override;
binder::Status releaseInput(int32_t portId) override;
- binder::Status initStreamVolume(media::AudioStreamType stream, int32_t indexMin,
+ binder::Status initStreamVolume(AudioStreamType stream, int32_t indexMin,
int32_t indexMax) override;
- binder::Status setStreamVolumeIndex(media::AudioStreamType stream,
+ binder::Status setStreamVolumeIndex(AudioStreamType stream,
const media::AudioDeviceDescription& device,
int32_t index) override;
- binder::Status getStreamVolumeIndex(media::AudioStreamType stream,
+ binder::Status getStreamVolumeIndex(AudioStreamType stream,
const media::AudioDeviceDescription& device,
int32_t* _aidl_return) override;
binder::Status setVolumeIndexForAttributes(const media::AudioAttributesInternal& attr,
@@ -123,10 +127,10 @@
int32_t* _aidl_return) override;
binder::Status getMinVolumeIndexForAttributes(const media::AudioAttributesInternal& attr,
int32_t* _aidl_return) override;
- binder::Status getStrategyForStream(media::AudioStreamType stream,
+ binder::Status getStrategyForStream(AudioStreamType stream,
int32_t* _aidl_return) override;
binder::Status getDevicesForStream(
- media::AudioStreamType stream,
+ AudioStreamType stream,
std::vector<media::AudioDeviceDescription>* _aidl_return) override;
binder::Status getDevicesForAttributes(const media::AudioAttributesEx& attr,
std::vector<media::AudioDevice>* _aidl_return) override;
@@ -137,9 +141,9 @@
binder::Status unregisterEffect(int32_t id) override;
binder::Status setEffectEnabled(int32_t id, bool enabled) override;
binder::Status moveEffectsToIo(const std::vector<int32_t>& ids, int32_t io) override;
- binder::Status isStreamActive(media::AudioStreamType stream, int32_t inPastMs,
+ binder::Status isStreamActive(AudioStreamType stream, int32_t inPastMs,
bool* _aidl_return) override;
- binder::Status isStreamActiveRemotely(media::AudioStreamType stream, int32_t inPastMs,
+ binder::Status isStreamActiveRemotely(AudioStreamType stream, int32_t inPastMs,
bool* _aidl_return) override;
binder::Status isSourceActive(media::AudioSourceType source, bool* _aidl_return) override;
binder::Status queryDefaultPreProcessing(
@@ -153,15 +157,15 @@
binder::Status addStreamDefaultEffect(const media::AudioUuid& type,
const std::string& opPackageName,
const media::AudioUuid& uuid, int32_t priority,
- media::AudioUsage usage, int32_t* _aidl_return) override;
+ AudioUsage usage, int32_t* _aidl_return) override;
binder::Status removeSourceDefaultEffect(int32_t id) override;
binder::Status removeStreamDefaultEffect(int32_t id) override;
binder::Status setSupportedSystemUsages(
- const std::vector<media::AudioUsage>& systemUsages) override;
+ const std::vector<AudioUsage>& systemUsages) override;
binder::Status setAllowedCapturePolicy(int32_t uid, int32_t capturePolicy) override;
- binder::Status getOffloadSupport(const media::AudioOffloadInfo& info,
+ binder::Status getOffloadSupport(const media::audio::common::AudioOffloadInfo& info,
media::AudioOffloadMode* _aidl_return) override;
- binder::Status isDirectOutputSupported(const media::AudioConfigBase& config,
+ binder::Status isDirectOutputSupported(const AudioConfigBase& config,
const media::AudioAttributesInternal& attributes,
bool* _aidl_return) override;
binder::Status listAudioPorts(media::AudioPortRole role, media::AudioPortType type,
@@ -196,7 +200,7 @@
binder::Status stopAudioSource(int32_t portId) override;
binder::Status setMasterMono(bool mono) override;
binder::Status getMasterMono(bool* _aidl_return) override;
- binder::Status getStreamVolumeDB(media::AudioStreamType stream, int32_t index,
+ binder::Status getStreamVolumeDB(AudioStreamType stream, int32_t index,
const media::AudioDeviceDescription& device,
float* _aidl_return) override;
binder::Status getSurroundFormats(media::Int* count,
@@ -257,7 +261,7 @@
media::GetSpatializerResponse* _aidl_return) override;
binder::Status canBeSpatialized(
const std::optional<media::AudioAttributesInternal>& attr,
- const std::optional<media::AudioConfig>& config,
+ const std::optional<AudioConfig>& config,
const std::vector<media::AudioDevice>& devices,
bool* _aidl_return) override;
diff --git a/services/audiopolicy/service/SpatializerPoseController.cpp b/services/audiopolicy/service/SpatializerPoseController.cpp
new file mode 100644
index 0000000..f0d7f7c
--- /dev/null
+++ b/services/audiopolicy/service/SpatializerPoseController.cpp
@@ -0,0 +1,196 @@
+/*
+ * Copyright 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.
+ */
+#include "SpatializerPoseController.h"
+
+#define LOG_TAG "VirtualizerStageController"
+//#define LOG_NDEBUG 0
+#include <utils/Log.h>
+#include <utils/SystemClock.h>
+
+namespace android {
+
+using media::createHeadTrackingProcessor;
+using media::HeadTrackingMode;
+using media::HeadTrackingProcessor;
+using media::Pose3f;
+using media::SensorPoseProvider;
+using media::Twist3f;
+
+using namespace std::chrono_literals;
+
+namespace {
+
+// This is how fast, in m/s, we allow position to shift during rate-limiting.
+constexpr auto kMaxTranslationalVelocity = 2 ;
+
+// This is how fast, in rad/s, we allow rotation angle to shift during rate-limiting.
+constexpr auto kMaxRotationalVelocity = 4 * M_PI ;
+
+// This should be set to the typical time scale that the translation sensors used drift in. This
+// means, loosely, for how long we can trust the reading to be "accurate enough". This would
+// determine the time constants used for high-pass filtering those readings. If the value is set
+// too high, we may experience drift. If it is set too low, we may experience poses tending toward
+// identity too fast.
+constexpr auto kTranslationalDriftTimeConstant = 20s;
+
+// This should be set to the typical time scale that the rotation sensors used drift in. This
+// means, loosely, for how long we can trust the reading to be "accurate enough". This would
+// determine the time constants used for high-pass filtering those readings. If the value is set
+// too high, we may experience drift. If it is set too low, we may experience poses tending toward
+// identity too fast.
+constexpr auto kRotationalDriftTimeConstant = 20s;
+
+// This is how far into the future we predict the head pose, using linear extrapolation based on
+// twist (velocity). It should be set to a value that matches the characteristic durations of moving
+// one's head. The higher we set this, the more latency we are able to reduce, but setting this too
+// high will result in high prediction errors whenever the head accelerates (changes velocity).
+constexpr auto kPredictionDuration = 10ms;
+
+// After losing this many consecutive samples from either sensor, we would treat the measurement as
+// stale;
+constexpr auto kMaxLostSamples = 4;
+
+// Time units for system clock ticks. This is what the Sensor Framework timestamps represent and
+// what we use for pose filtering.
+using Ticks = std::chrono::nanoseconds;
+
+// How many ticks in a second.
+constexpr auto kTicksPerSecond = Ticks::period::den;
+
+} // namespace
+
+SpatializerPoseController::SpatializerPoseController(Listener* listener,
+ std::chrono::microseconds sensorPeriod,
+ std::chrono::microseconds maxUpdatePeriod)
+ : mListener(listener),
+ mSensorPeriod(sensorPeriod),
+ mPoseProvider(SensorPoseProvider::create("headtracker", this)),
+ mProcessor(createHeadTrackingProcessor(HeadTrackingProcessor::Options{
+ .maxTranslationalVelocity = kMaxTranslationalVelocity / kTicksPerSecond,
+ .maxRotationalVelocity = kMaxRotationalVelocity / kTicksPerSecond,
+ .translationalDriftTimeConstant = Ticks(kTranslationalDriftTimeConstant).count(),
+ .rotationalDriftTimeConstant = Ticks(kRotationalDriftTimeConstant).count(),
+ .freshnessTimeout = Ticks(sensorPeriod * kMaxLostSamples).count(),
+ .predictionDuration = Ticks(kPredictionDuration).count(),
+ })),
+ mThread([this, maxUpdatePeriod] {
+ while (true) {
+ {
+ std::unique_lock lock(mMutex);
+ mCondVar.wait_for(lock, maxUpdatePeriod,
+ [this] { return mShouldExit || mShouldCalculate; });
+ if (mShouldExit) {
+ ALOGV("Exiting thread");
+ return;
+ }
+ calculate_l();
+ if (!mCalculated) {
+ mCalculated = true;
+ mCondVar.notify_all();
+ }
+ mShouldCalculate = false;
+ }
+ }
+ }) {}
+
+SpatializerPoseController::~SpatializerPoseController() {
+ {
+ std::unique_lock lock(mMutex);
+ mShouldExit = true;
+ mCondVar.notify_all();
+ }
+ mThread.join();
+}
+
+void SpatializerPoseController::setHeadSensor(const ASensor* sensor) {
+ std::lock_guard lock(mMutex);
+ // Stop current sensor, if valid.
+ if (mHeadSensor != SensorPoseProvider::INVALID_HANDLE) {
+ mPoseProvider->stopSensor(mHeadSensor);
+ }
+ // Start new sensor, if valid.
+ mHeadSensor = sensor != nullptr ? mPoseProvider->startSensor(sensor, mSensorPeriod)
+ : SensorPoseProvider::INVALID_HANDLE;
+ mProcessor->recenter();
+}
+
+void SpatializerPoseController::setScreenSensor(const ASensor* sensor) {
+ std::lock_guard lock(mMutex);
+ // Stop current sensor, if valid.
+ if (mScreenSensor != SensorPoseProvider::INVALID_HANDLE) {
+ mPoseProvider->stopSensor(mScreenSensor);
+ }
+ // Start new sensor, if valid.
+ mScreenSensor = sensor != nullptr ? mPoseProvider->startSensor(sensor, mSensorPeriod)
+ : SensorPoseProvider::INVALID_HANDLE;
+ mProcessor->recenter();
+}
+
+void SpatializerPoseController::setDesiredMode(HeadTrackingMode mode) {
+ std::lock_guard lock(mMutex);
+ mProcessor->setDesiredMode(mode);
+}
+
+void SpatializerPoseController::setScreenToStagePose(const Pose3f& screenToStage) {
+ std::lock_guard lock(mMutex);
+ mProcessor->setScreenToStagePose(screenToStage);
+}
+
+void SpatializerPoseController::setDisplayOrientation(float physicalToLogicalAngle) {
+ std::lock_guard lock(mMutex);
+ mProcessor->setDisplayOrientation(physicalToLogicalAngle);
+}
+
+void SpatializerPoseController::calculateAsync() {
+ std::lock_guard lock(mMutex);
+ mShouldCalculate = true;
+ mCondVar.notify_all();
+}
+
+void SpatializerPoseController::waitUntilCalculated() {
+ std::unique_lock lock(mMutex);
+ mCondVar.wait(lock, [this] { return mCalculated; });
+}
+
+void SpatializerPoseController::calculate_l() {
+ Pose3f headToStage;
+ HeadTrackingMode mode;
+ mProcessor->calculate(elapsedRealtimeNano());
+ headToStage = mProcessor->getHeadToStagePose();
+ mode = mProcessor->getActualMode();
+ mListener->onHeadToStagePose(headToStage);
+ if (!mActualMode.has_value() || mActualMode.value() != mode) {
+ mActualMode = mode;
+ mListener->onActualModeChange(mode);
+ }
+}
+
+void SpatializerPoseController::recenter() {
+ std::lock_guard lock(mMutex);
+ mProcessor->recenter();
+}
+
+void SpatializerPoseController::onPose(int64_t timestamp, int32_t sensor, const Pose3f& pose,
+ const std::optional<Twist3f>& twist) {
+ std::lock_guard lock(mMutex);
+ if (sensor == mHeadSensor) {
+ mProcessor->setWorldToHeadPose(timestamp, pose, twist.value_or(Twist3f()));
+ } else if (sensor == mScreenSensor) {
+ mProcessor->setWorldToScreenPose(timestamp, pose);
+ }
+}
+
+} // namespace android
diff --git a/services/audiopolicy/service/SpatializerPoseController.h b/services/audiopolicy/service/SpatializerPoseController.h
new file mode 100644
index 0000000..619dc7b
--- /dev/null
+++ b/services/audiopolicy/service/SpatializerPoseController.h
@@ -0,0 +1,137 @@
+/*
+ * 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.
+ */
+#pragma once
+
+#include <chrono>
+#include <condition_variable>
+#include <limits>
+#include <memory>
+#include <mutex>
+#include <thread>
+
+#include <media/HeadTrackingProcessor.h>
+#include <media/SensorPoseProvider.h>
+
+namespace android {
+
+/**
+ * This class encapsulates the logic for pose processing, intended for driving a spatializer effect.
+ * This includes integration with the Sensor sub-system for retrieving sensor data, doing all the
+ * necessary processing, etc.
+ *
+ * Calculations happen on a dedicated thread and published to the client via the Listener interface.
+ * A calculation may be triggered in one of two ways:
+ * - By calling calculateAsync() - calculation will be kicked off in the background.
+ * - By setting a timeout in the ctor, a calculation will be triggered after the timeout elapsed
+ * from the last calculateAsync() call.
+ *
+ * This class is thread-safe. Callbacks are invoked with the lock held, so it is illegal to call
+ * into this module from the callbacks.
+ */
+class SpatializerPoseController : private media::SensorPoseProvider::Listener {
+ public:
+ /**
+ * Listener interface for getting pose and mode updates.
+ * Methods will always be invoked from a designated thread. Calling into the parent class from
+ * within the callbacks is disallowed (will result in a deadlock).
+ */
+ class Listener {
+ public:
+ virtual ~Listener() = default;
+
+ virtual void onHeadToStagePose(const media::Pose3f&) = 0;
+ virtual void onActualModeChange(media::HeadTrackingMode) = 0;
+ };
+
+ /**
+ * Ctor.
+ * sensorPeriod determines how often to receive updates from the sensors (input rate).
+ * maxUpdatePeriod determines how often to produce an output when calculateAsync() isn't
+ * invoked.
+ */
+ SpatializerPoseController(Listener* listener, std::chrono::microseconds sensorPeriod,
+ std::chrono::microseconds maxUpdatePeriod);
+
+ /** Dtor. */
+ ~SpatializerPoseController();
+
+ /**
+ * Set the sensor that is to be used for head-tracking.
+ * nullptr can be used to disable head-tracking.
+ */
+ void setHeadSensor(const ASensor* sensor);
+
+ /**
+ * Set the sensor that is to be used for screen-tracking.
+ * nullptr can be used to disable screen-tracking.
+ */
+ void setScreenSensor(const ASensor* sensor);
+
+ /** Sets the desired head-tracking mode. */
+ void setDesiredMode(media::HeadTrackingMode mode);
+
+ /**
+ * Set the screen-to-stage pose, used in all modes.
+ */
+ void setScreenToStagePose(const media::Pose3f& screenToStage);
+
+ /**
+ * Sets the display orientation.
+ * Orientation is expressed in the angle of rotation from the physical "up" side of the screen
+ * to the logical "up" side of the content displayed the screen. Counterclockwise angles, as
+ * viewed while facing the screen are positive.
+ */
+ void setDisplayOrientation(float physicalToLogicalAngle);
+
+ /**
+ * This causes the current poses for both the head and screen to be considered "center".
+ */
+ void recenter();
+
+ /**
+ * This call triggers the recalculation of the output and the invocation of the relevant
+ * callbacks. This call is async and the callbacks will be triggered shortly after.
+ */
+ void calculateAsync();
+
+ /**
+ * Blocks until calculation and invocation of the respective callbacks has happened at least
+ * once.
+ */
+ void waitUntilCalculated();
+
+ private:
+ mutable std::mutex mMutex;
+ Listener* const mListener;
+ const std::chrono::microseconds mSensorPeriod;
+ std::unique_ptr<media::SensorPoseProvider> mPoseProvider;
+ std::unique_ptr<media::HeadTrackingProcessor> mProcessor;
+ int32_t mHeadSensor = media::SensorPoseProvider::INVALID_HANDLE;
+ int32_t mScreenSensor = media::SensorPoseProvider::INVALID_HANDLE;
+ std::optional<media::HeadTrackingMode> mActualMode;
+ std::thread mThread;
+ std::condition_variable mCondVar;
+ bool mShouldCalculate = true;
+ bool mShouldExit = false;
+ bool mCalculated = false;
+
+ void onPose(int64_t timestamp, int32_t sensor, const media::Pose3f& pose,
+ const std::optional<media::Twist3f>& twist) override;
+
+ void calculate_l();
+};
+
+} // namespace android
diff --git a/services/mediacodec/seccomp_policy/mediaswcodec-arm64.policy b/services/mediacodec/seccomp_policy/mediaswcodec-arm64.policy
index 4c51a9c..7ff858b 100644
--- a/services/mediacodec/seccomp_policy/mediaswcodec-arm64.policy
+++ b/services/mediacodec/seccomp_policy/mediaswcodec-arm64.policy
@@ -79,4 +79,14 @@
getegid: 1
getgroups: 1
+# Android profiler (heapprofd, traced_perf) additions, where not already
+# covered by the rest of the file, or by builtin minijail allow-listing of
+# logging-related syscalls.
+# TODO(b/197184220): this is a targeted addition for a specific investigation,
+# and addresses just the arm64 framework av service policies. In the future, we
+# should make this more general (e.g. a central file that can be @included in
+# other policy files).
+setsockopt: 1
+sendmsg: 1
+
@include /apex/com.android.media.swcodec/etc/seccomp_policy/code_coverage.arm64.policy
diff --git a/services/mediaextractor/seccomp_policy/mediaextractor-arm64.policy b/services/mediaextractor/seccomp_policy/mediaextractor-arm64.policy
index 9bbd53b..e54c918 100644
--- a/services/mediaextractor/seccomp_policy/mediaextractor-arm64.policy
+++ b/services/mediaextractor/seccomp_policy/mediaextractor-arm64.policy
@@ -46,5 +46,16 @@
# Required by Sanitizers
sched_yield: 1
+# Android profiler (heapprofd, traced_perf) additions, where not already
+# covered by the rest of the file, or by builtin minijail allow-listing of
+# logging-related syscalls.
+# TODO(b/197184220): this is a targeted addition for a specific investigation,
+# and addresses just the arm64 framework av service policies. In the future, we
+# should make this more general (e.g. a central file that can be @included in
+# other policy files).
+setsockopt: 1
+sendmsg: 1
+set_tid_address: 1
+
@include /apex/com.android.media/etc/seccomp_policy/crash_dump.arm64.policy
@include /apex/com.android.media/etc/seccomp_policy/code_coverage.arm64.policy
diff --git a/services/mediametrics/Android.bp b/services/mediametrics/Android.bp
index 0351d2d..04fc430 100644
--- a/services/mediametrics/Android.bp
+++ b/services/mediametrics/Android.bp
@@ -172,11 +172,13 @@
"libstatspull",
"libstatssocket",
"libutils",
+ "packagemanager_aidl-cpp",
],
export_shared_lib_headers: [
"libstatspull",
"libstatssocket",
+ "packagemanager_aidl-cpp",
],
static_libs: [
diff --git a/services/tuner/Android.bp b/services/tuner/Android.bp
index b2b1c3b..ec62d4e 100644
--- a/services/tuner/Android.bp
+++ b/services/tuner/Android.bp
@@ -52,6 +52,7 @@
"liblog",
"libmedia",
"libutils",
+ "packagemanager_aidl-cpp",
"tv_tuner_aidl_interface-ndk",
"tv_tuner_resource_manager_aidl_interface-ndk",
],