Merge "ACodec: Update max temporal layer count" into qt-dev
diff --git a/apex/ld.config.txt b/apex/ld.config.txt
index 715113d..87af5a1 100644
--- a/apex/ld.config.txt
+++ b/apex/ld.config.txt
@@ -38,7 +38,8 @@
namespace.platform.isolated = true
namespace.platform.search.paths = /system/${LIB}
-namespace.platform.asan.search.paths = /data/asan/system/${LIB}
+namespace.platform.asan.search.paths = /data/asan/system/${LIB}
+namespace.platform.asan.search.paths += /system/${LIB}
# /system/lib/libc.so, etc are symlinks to /apex/com.android.lib/lib/bionic/libc.so, etc.
# Add /apex/... pat to the permitted paths because linker uses realpath(3)
diff --git a/camera/ndk/Android.bp b/camera/ndk/Android.bp
index d96f403..7786856 100644
--- a/camera/ndk/Android.bp
+++ b/camera/ndk/Android.bp
@@ -64,6 +64,10 @@
"-Wextra",
"-Werror",
],
+ // TODO: jchowdhary@, use header_libs instead b/131165718
+ include_dirs: [
+ "system/media/private/camera/include",
+ ],
export_include_dirs: ["include"],
export_shared_lib_headers: [
"libnativewindow",
@@ -123,6 +127,10 @@
"android.hardware.camera.common@1.0-helper",
"libarect",
],
+ // TODO: jchowdhary@, use header_libs instead b/131165718
+ include_dirs: [
+ "system/media/private/camera/include",
+ ],
product_variables: {
pdk: {
enabled: false,
diff --git a/camera/ndk/NdkCameraManager.cpp b/camera/ndk/NdkCameraManager.cpp
index 23d01ef..3d231a8 100644
--- a/camera/ndk/NdkCameraManager.cpp
+++ b/camera/ndk/NdkCameraManager.cpp
@@ -190,3 +190,17 @@
}
return mgr->openCamera(cameraId, callback, device);
}
+
+#ifdef __ANDROID_VNDK__
+EXPORT
+camera_status_t ACameraManager_getTagFromName(ACameraManager *mgr, const char* cameraId,
+ const char *name, /*out*/uint32_t *tag) {
+ ATRACE_CALL();
+ if (mgr == nullptr || cameraId == nullptr || name == nullptr) {
+ ALOGE("%s: invalid argument! mgr %p cameraId %p name %p",
+ __FUNCTION__, mgr, cameraId, name);
+ return ACAMERA_ERROR_INVALID_PARAMETER;
+ }
+ return mgr->getTagFromName(cameraId, name, tag);
+}
+#endif
diff --git a/camera/ndk/include/camera/NdkCameraManager.h b/camera/ndk/include/camera/NdkCameraManager.h
index 5c810bb..2cc8a97 100644
--- a/camera/ndk/include/camera/NdkCameraManager.h
+++ b/camera/ndk/include/camera/NdkCameraManager.h
@@ -374,6 +374,23 @@
ACameraManager* manager,
const ACameraManager_ExtendedAvailabilityCallbacks* callback) __INTRODUCED_IN(29);
+#ifdef __ANDROID_VNDK__
+/**
+ * Retrieve the tag value, given the tag name and camera id.
+ * This method is device specific since some metadata might be defined by device manufacturers
+ * and might only be accessible for specific cameras.
+ * @param manager The {@link ACameraManager} of interest.
+ * @param cameraId The cameraId, which is used to query camera characteristics.
+ * @param name The name of the tag being queried.
+ * @param tag The output tag assigned by this method.
+ *
+ * @return ACAMERA_OK only if the function call was successful.
+ */
+camera_status_t ACameraManager_getTagFromName(ACameraManager *manager, const char* cameraId,
+ const char *name, /*out*/uint32_t *tag)
+ __INTRODUCED_IN(29);
+#endif
+
#endif /* __ANDROID_API__ >= 29 */
__END_DECLS
diff --git a/camera/ndk/include/camera/NdkCameraMetadataTags.h b/camera/ndk/include/camera/NdkCameraMetadataTags.h
index 4563b41..7cd832a 100644
--- a/camera/ndk/include/camera/NdkCameraMetadataTags.h
+++ b/camera/ndk/include/camera/NdkCameraMetadataTags.h
@@ -7511,18 +7511,19 @@
/**
* <p>The camera device supports capturing high-resolution images at >= 20 frames per
- * second, in at least the uncompressed YUV format, when post-processing settings are set
- * to FAST. Additionally, maximum-resolution images can be captured at >= 10 frames
- * per second. Here, 'high resolution' means at least 8 megapixels, or the maximum
- * resolution of the device, whichever is smaller.</p>
+ * second, in at least the uncompressed YUV format, when post-processing settings are
+ * set to FAST. Additionally, all image resolutions less than 24 megapixels can be
+ * captured at >= 10 frames per second. Here, 'high resolution' means at least 8
+ * megapixels, or the maximum resolution of the device, whichever is smaller.</p>
* <p>More specifically, this means that at least one output {@link AIMAGE_FORMAT_YUV_420_888 } size listed in
* {@link ACAMERA_SCALER_AVAILABLE_STREAM_CONFIGURATIONS }
* is larger or equal to the 'high resolution' defined above, and can be captured at at
* least 20 fps. For the largest {@link AIMAGE_FORMAT_YUV_420_888 } size listed in
* {@link ACAMERA_SCALER_AVAILABLE_STREAM_CONFIGURATIONS },
- * camera device can capture this size for at least 10 frames per second. Also the
- * ACAMERA_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES entry lists at least one FPS range where
- * the minimum FPS is >= 1 / minimumFrameDuration for the largest YUV_420_888 size.</p>
+ * camera device can capture this size for at least 10 frames per second if the size is
+ * less than 24 megapixels. Also the ACAMERA_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES entry
+ * lists at least one FPS range where the minimum FPS is >= 1 / minimumFrameDuration
+ * for the largest YUV_420_888 size.</p>
* <p>If the device supports the {@link AIMAGE_FORMAT_RAW10 }, {@link AIMAGE_FORMAT_RAW12 }, {@link AIMAGE_FORMAT_Y8 }, then those can also be
* captured at the same rate as the maximum-size YUV_420_888 resolution is.</p>
* <p>In addition, the ACAMERA_SYNC_MAX_LATENCY field is guaranted to have a value between 0
diff --git a/camera/ndk/ndk_vendor/impl/ACameraManager.cpp b/camera/ndk/ndk_vendor/impl/ACameraManager.cpp
index 575ee9d..70c887a 100644
--- a/camera/ndk/ndk_vendor/impl/ACameraManager.cpp
+++ b/camera/ndk/ndk_vendor/impl/ACameraManager.cpp
@@ -22,6 +22,8 @@
#include "ACameraMetadata.h"
#include "ndk_vendor/impl/ACameraDevice.h"
#include "utils.h"
+#include <CameraMetadata.h>
+#include <camera_metadata_hidden.h>
#include <utils/Vector.h>
#include <cutils/properties.h>
@@ -587,6 +589,26 @@
return ACAMERA_OK;
}
+camera_status_t
+ACameraManager::getTagFromName(const char *cameraId, const char *name, uint32_t *tag) {
+ sp<ACameraMetadata> rawChars;
+ camera_status_t ret = getCameraCharacteristics(cameraId, &rawChars);
+ if (ret != ACAMERA_OK) {
+ ALOGE("%s, Cannot retrieve camera characteristics for camera id %s", __FUNCTION__,
+ cameraId);
+ return ACAMERA_ERROR_METADATA_NOT_FOUND;
+ }
+ const CameraMetadata& metadata = rawChars->getInternalData();
+ const camera_metadata_t *rawMetadata = metadata.getAndLock();
+ metadata_vendor_id_t vendorTagId = get_camera_metadata_vendor_id(rawMetadata);
+ metadata.unlock(rawMetadata);
+ sp<VendorTagDescriptorCache> vtCache = VendorTagDescriptorCache::getGlobalVendorTagCache();
+ sp<VendorTagDescriptor> vTags = nullptr;
+ vtCache->getVendorTagDescriptor(vendorTagId, &vTags);
+ status_t status= metadata.getTagFromName(name, vTags.get(), tag);
+ return status == OK ? ACAMERA_OK : ACAMERA_ERROR_METADATA_NOT_FOUND;
+}
+
ACameraManager::~ACameraManager() {
}
diff --git a/camera/ndk/ndk_vendor/impl/ACameraManager.h b/camera/ndk/ndk_vendor/impl/ACameraManager.h
index df69353..2c62d44 100644
--- a/camera/ndk/ndk_vendor/impl/ACameraManager.h
+++ b/camera/ndk/ndk_vendor/impl/ACameraManager.h
@@ -204,6 +204,7 @@
camera_status_t openCamera(const char* cameraId,
ACameraDevice_StateCallbacks* callback,
/*out*/ACameraDevice** device);
+ camera_status_t getTagFromName(const char *cameraId, const char *name, uint32_t *tag);
private:
enum {
diff --git a/camera/ndk/ndk_vendor/tests/AImageReaderVendorTest.cpp b/camera/ndk/ndk_vendor/tests/AImageReaderVendorTest.cpp
index 7368775..37de30a 100644
--- a/camera/ndk/ndk_vendor/tests/AImageReaderVendorTest.cpp
+++ b/camera/ndk/ndk_vendor/tests/AImageReaderVendorTest.cpp
@@ -799,6 +799,15 @@
bool isBC = isCapabilitySupported(staticMetadata,
ACAMERA_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE);
+ uint32_t namedTag = 0;
+ // Test that ACameraMetadata_getTagFromName works as expected for public tag
+ // names
+ camera_status_t status = ACameraManager_getTagFromName(mCameraManager, cameraId,
+ "android.control.aeMode", &namedTag);
+
+ ASSERT_EQ(status, ACAMERA_OK);
+ ASSERT_EQ(namedTag, ACAMERA_CONTROL_AE_MODE);
+
ACameraMetadata_free(staticMetadata);
if (!isBC) {
diff --git a/media/codec2/sfplugin/CCodecBufferChannel.cpp b/media/codec2/sfplugin/CCodecBufferChannel.cpp
index 90265de..715e78b 100644
--- a/media/codec2/sfplugin/CCodecBufferChannel.cpp
+++ b/media/codec2/sfplugin/CCodecBufferChannel.cpp
@@ -533,10 +533,12 @@
feedInputBufferIfAvailable();
if (!c2Buffer) {
if (released) {
- ALOGD("[%s] The app is calling releaseOutputBuffer() with "
- "timestamp or render=true with non-video buffers. Apps should "
- "call releaseOutputBuffer() with render=false for those.",
- mName);
+ std::call_once(mRenderWarningFlag, [this] {
+ ALOGW("[%s] The app is calling releaseOutputBuffer() with "
+ "timestamp or render=true with non-video buffers. Apps should "
+ "call releaseOutputBuffer() with render=false for those.",
+ mName);
+ });
}
return INVALID_OPERATION;
}
diff --git a/media/codec2/sfplugin/CCodecBufferChannel.h b/media/codec2/sfplugin/CCodecBufferChannel.h
index bc997e6..9aec82d 100644
--- a/media/codec2/sfplugin/CCodecBufferChannel.h
+++ b/media/codec2/sfplugin/CCodecBufferChannel.h
@@ -305,6 +305,7 @@
Mutexed<ReorderStash> mReorderStash;
std::atomic_bool mInputMetEos;
+ std::once_flag mRenderWarningFlag;
inline bool hasCryptoOrDescrambler() {
return mCrypto != nullptr || mDescrambler != nullptr;
diff --git a/media/codec2/vndk/C2Store.cpp b/media/codec2/vndk/C2Store.cpp
index e075849..10c4dcc 100644
--- a/media/codec2/vndk/C2Store.cpp
+++ b/media/codec2/vndk/C2Store.cpp
@@ -661,24 +661,27 @@
ALOGV("in %s", __func__);
ALOGV("loading dll");
mLibHandle = dlopen(libPath.c_str(), RTLD_NOW|RTLD_NODELETE);
- if (mLibHandle == nullptr) {
- // could be access/symbol or simply not being there
- ALOGD("could not dlopen %s: %s", libPath.c_str(), dlerror());
- mInit = C2_CORRUPTED;
- } else {
- createFactory =
- (C2ComponentFactory::CreateCodec2FactoryFunc)dlsym(mLibHandle, "CreateCodec2Factory");
- destroyFactory =
- (C2ComponentFactory::DestroyCodec2FactoryFunc)dlsym(mLibHandle, "DestroyCodec2Factory");
+ LOG_ALWAYS_FATAL_IF(mLibHandle == nullptr,
+ "could not dlopen %s: %s", libPath.c_str(), dlerror());
- mComponentFactory = createFactory();
- if (mComponentFactory == nullptr) {
- ALOGD("could not create factory in %s", libPath.c_str());
- mInit = C2_NO_MEMORY;
- } else {
- mInit = C2_OK;
- }
+ createFactory =
+ (C2ComponentFactory::CreateCodec2FactoryFunc)dlsym(mLibHandle, "CreateCodec2Factory");
+ LOG_ALWAYS_FATAL_IF(createFactory == nullptr,
+ "createFactory is null in %s", libPath.c_str());
+
+ destroyFactory =
+ (C2ComponentFactory::DestroyCodec2FactoryFunc)dlsym(mLibHandle, "DestroyCodec2Factory");
+ LOG_ALWAYS_FATAL_IF(destroyFactory == nullptr,
+ "destroyFactory is null in %s", libPath.c_str());
+
+ mComponentFactory = createFactory();
+ if (mComponentFactory == nullptr) {
+ ALOGD("could not create factory in %s", libPath.c_str());
+ mInit = C2_NO_MEMORY;
+ } else {
+ mInit = C2_OK;
}
+
if (mInit != C2_OK) {
return mInit;
}
diff --git a/media/extractors/flac/FLACExtractor.cpp b/media/extractors/flac/FLACExtractor.cpp
index 8854631..5329bd1 100644
--- a/media/extractors/flac/FLACExtractor.cpp
+++ b/media/extractors/flac/FLACExtractor.cpp
@@ -531,23 +531,9 @@
return NO_INIT;
}
// check sample rate
- switch (getSampleRate()) {
- case 8000:
- case 11025:
- case 12000:
- case 16000:
- case 22050:
- case 24000:
- case 32000:
- case 44100:
- case 48000:
- case 88200:
- case 96000:
- case 176400:
- case 192000:
- break;
- default:
- // Note: internally we support arbitrary sample rates from 8kHz to 192kHz.
+ // Note: flac supports arbitrary sample rates up to 655350 Hz, but Android
+ // supports sample rates from 8kHz to 192kHz, so use that as the limit.
+ if (getSampleRate() < 8000 || getSampleRate() > 192000) {
ALOGE("unsupported sample rate %u", getSampleRate());
return NO_INIT;
}
diff --git a/media/extractors/mpeg2/ExtractorBundle.cpp b/media/extractors/mpeg2/ExtractorBundle.cpp
index 946a2a9..a7c756b 100644
--- a/media/extractors/mpeg2/ExtractorBundle.cpp
+++ b/media/extractors/mpeg2/ExtractorBundle.cpp
@@ -29,6 +29,8 @@
static const char *extensions[] = {
"m2p",
+ "m2ts",
+ "mts",
"ts",
NULL
};
diff --git a/media/extractors/mpeg2/MPEG2TSExtractor.cpp b/media/extractors/mpeg2/MPEG2TSExtractor.cpp
index 49dd0b4..50ce657 100644
--- a/media/extractors/mpeg2/MPEG2TSExtractor.cpp
+++ b/media/extractors/mpeg2/MPEG2TSExtractor.cpp
@@ -238,6 +238,12 @@
mParser(new ATSParser),
mLastSyncEvent(0),
mOffset(0) {
+ char header;
+ if (source->readAt(0, &header, 1) == 1 && header == 0x47) {
+ mHeaderSkip = 0;
+ } else {
+ mHeaderSkip = 4;
+ }
init();
}
@@ -460,7 +466,7 @@
Mutex::Autolock autoLock(mLock);
uint8_t packet[kTSPacketSize];
- ssize_t n = mDataSource->readAt(mOffset, packet, kTSPacketSize);
+ ssize_t n = mDataSource->readAt(mOffset + mHeaderSkip, packet, kTSPacketSize);
if (n < (ssize_t)kTSPacketSize) {
if (n >= 0) {
@@ -470,7 +476,7 @@
}
ATSParser::SyncEvent event(mOffset);
- mOffset += n;
+ mOffset += mHeaderSkip + n;
status_t err = mParser->feedTSPacket(packet, kTSPacketSize, &event);
if (event.hasReturnedData()) {
if (isInit) {
@@ -539,15 +545,15 @@
break;
}
- ssize_t n = mDataSource->readAt(offset, packet, kTSPacketSize);
+ ssize_t n = mDataSource->readAt(offset+mHeaderSkip, packet, kTSPacketSize);
if (n < 0) {
return n;
} else if (n < (ssize_t)kTSPacketSize) {
break;
}
- offset += kTSPacketSize;
- bytesRead += kTSPacketSize;
+ offset += kTSPacketSize + mHeaderSkip;
+ bytesRead += kTSPacketSize + mHeaderSkip;
err = parser->feedTSPacket(packet, kTSPacketSize, &ev);
if (err != OK) {
return err;
@@ -791,7 +797,17 @@
char header;
if (source->readAt(kTSPacketSize * i, &header, 1) != 1
|| header != 0x47) {
- return false;
+ // not ts file, check if m2ts file
+ for (int j = 0; j < 5; ++j) {
+ char headers[5];
+ if (source->readAt((kTSPacketSize + 4) * j, &headers, 5) != 5
+ || headers[4] != 0x47) {
+ // not m2ts file too, return
+ return false;
+ }
+ }
+ ALOGV("this is m2ts file\n");
+ break;
}
}
diff --git a/media/extractors/mpeg2/MPEG2TSExtractor.h b/media/extractors/mpeg2/MPEG2TSExtractor.h
index 2537d3b..dcd1e7b 100644
--- a/media/extractors/mpeg2/MPEG2TSExtractor.h
+++ b/media/extractors/mpeg2/MPEG2TSExtractor.h
@@ -102,6 +102,7 @@
status_t estimateDurationsFromTimesUsAtEnd();
+ size_t mHeaderSkip;
DISALLOW_EVIL_CONSTRUCTORS(MPEG2TSExtractor);
};
diff --git a/media/extractors/ogg/OggExtractor.cpp b/media/extractors/ogg/OggExtractor.cpp
index b63ae6b..72b94bb 100644
--- a/media/extractors/ogg/OggExtractor.cpp
+++ b/media/extractors/ogg/OggExtractor.cpp
@@ -323,6 +323,7 @@
mFirstDataOffset(-1),
mHapticChannelCount(0) {
mCurrentPage.mNumSegments = 0;
+ mCurrentPage.mFlags = 0;
vorbis_info_init(&mVi);
vorbis_comment_init(&mVc);
@@ -414,19 +415,18 @@
ALOGV("prevPageOffset at %lld, pageOffset at %lld",
(long long)prevPageOffset, (long long)pageOffset);
-
+ uint8_t flag = 0;
for (;;) {
Page prevPage;
ssize_t n = readPage(prevPageOffset, &prevPage);
if (n <= 0) {
- return (status_t)n;
+ return (flag & 0x4) ? OK : (status_t)n;
}
-
+ flag = prevPage.mFlags;
prevPageOffset += n;
-
+ *granulePos = prevPage.mGranulePosition;
if (prevPageOffset == pageOffset) {
- *granulePos = prevPage.mGranulePosition;
return OK;
}
}
@@ -688,7 +688,7 @@
TRESPASS();
}
- uint32_t numSamples = frameSizeUs * numFrames * kOpusSampleRate / 1000000;
+ uint32_t numSamples = (uint32_t)((uint64_t)frameSizeUs * numFrames * kOpusSampleRate) / 1000000;
return numSamples;
}
@@ -868,6 +868,7 @@
CHECK_EQ(mNextLaceIndex, mCurrentPage.mNumSegments);
mOffset += mCurrentPageSize;
+ uint8_t flag = mCurrentPage.mFlags;
ssize_t n = readPage(mOffset, &mCurrentPage);
if (n <= 0) {
@@ -878,6 +879,7 @@
ALOGV("readPage returned %zd", n);
+ if (flag & 0x04) return AMEDIA_ERROR_END_OF_STREAM;
return (media_status_t) n;
}
diff --git a/media/img_utils/src/DngUtils.cpp b/media/img_utils/src/DngUtils.cpp
index 9304f53..7914030 100644
--- a/media/img_utils/src/DngUtils.cpp
+++ b/media/img_utils/src/DngUtils.cpp
@@ -173,8 +173,8 @@
status_t err = addGainMap(/*top*/redTop,
/*left*/redLeft,
- /*bottom*/activeAreaHeight - 1,
- /*right*/activeAreaWidth - 1,
+ /*bottom*/activeAreaHeight,
+ /*right*/activeAreaWidth,
/*plane*/0,
/*planes*/1,
/*rowPitch*/2,
@@ -191,8 +191,8 @@
err = addGainMap(/*top*/greenEvenTop,
/*left*/greenEvenLeft,
- /*bottom*/activeAreaHeight - 1,
- /*right*/activeAreaWidth - 1,
+ /*bottom*/activeAreaHeight,
+ /*right*/activeAreaWidth,
/*plane*/0,
/*planes*/1,
/*rowPitch*/2,
@@ -209,8 +209,8 @@
err = addGainMap(/*top*/greenOddTop,
/*left*/greenOddLeft,
- /*bottom*/activeAreaHeight - 1,
- /*right*/activeAreaWidth - 1,
+ /*bottom*/activeAreaHeight,
+ /*right*/activeAreaWidth,
/*plane*/0,
/*planes*/1,
/*rowPitch*/2,
@@ -227,8 +227,8 @@
err = addGainMap(/*top*/blueTop,
/*left*/blueLeft,
- /*bottom*/activeAreaHeight - 1,
- /*right*/activeAreaWidth - 1,
+ /*bottom*/activeAreaHeight,
+ /*right*/activeAreaWidth,
/*plane*/0,
/*planes*/1,
/*rowPitch*/2,
@@ -265,8 +265,8 @@
status_t err = addGainMap(/*top*/0,
/*left*/0,
- /*bottom*/activeAreaHeight - 1,
- /*right*/activeAreaWidth - 1,
+ /*bottom*/activeAreaHeight,
+ /*right*/activeAreaWidth,
/*plane*/0,
/*planes*/1,
/*rowPitch*/1,
@@ -364,8 +364,8 @@
return BAD_VALUE;
}
- double normalizedOCX = opticalCenterX / static_cast<double>(activeArrayWidth - 1);
- double normalizedOCY = opticalCenterY / static_cast<double>(activeArrayHeight - 1);
+ double normalizedOCX = opticalCenterX / static_cast<double>(activeArrayWidth);
+ double normalizedOCY = opticalCenterY / static_cast<double>(activeArrayHeight);
normalizedOCX = CLAMP(normalizedOCX, 0, 1);
normalizedOCY = CLAMP(normalizedOCY, 0, 1);
diff --git a/media/libaaudio/src/client/AudioStreamInternal.cpp b/media/libaaudio/src/client/AudioStreamInternal.cpp
index db98d58..c7e8088 100644
--- a/media/libaaudio/src/client/AudioStreamInternal.cpp
+++ b/media/libaaudio/src/client/AudioStreamInternal.cpp
@@ -76,6 +76,7 @@
aaudio_result_t result = AAUDIO_OK;
int32_t capacity;
int32_t framesPerBurst;
+ int32_t framesPerHardwareBurst;
AAudioStreamRequest request;
AAudioStreamConfiguration configurationOutput;
@@ -90,6 +91,9 @@
return result;
}
+ const int32_t burstMinMicros = AAudioProperty_getHardwareBurstMinMicros();
+ int32_t burstMicros = 0;
+
// We have to do volume scaling. So we prefer FLOAT format.
if (getFormat() == AUDIO_FORMAT_DEFAULT) {
setFormat(AUDIO_FORMAT_PCM_FLOAT);
@@ -173,8 +177,22 @@
goto error;
}
- // Validate result from server.
- framesPerBurst = mEndpointDescriptor.dataQueueDescriptor.framesPerBurst;
+ framesPerHardwareBurst = mEndpointDescriptor.dataQueueDescriptor.framesPerBurst;
+
+ // Scale up the burst size to meet the minimum equivalent in microseconds.
+ // This is to avoid waking the CPU too often when the HW burst is very small
+ // or at high sample rates.
+ framesPerBurst = framesPerHardwareBurst;
+ do {
+ if (burstMicros > 0) { // skip first loop
+ framesPerBurst *= 2;
+ }
+ burstMicros = framesPerBurst * static_cast<int64_t>(1000000) / getSampleRate();
+ } while (burstMicros < burstMinMicros);
+ ALOGD("%s() original HW burst = %d, minMicros = %d => SW burst = %d\n",
+ __func__, framesPerHardwareBurst, burstMinMicros, framesPerBurst);
+
+ // Validate final burst size.
if (framesPerBurst < MIN_FRAMES_PER_BURST || framesPerBurst > MAX_FRAMES_PER_BURST) {
ALOGE("%s - framesPerBurst out of range = %d", __func__, framesPerBurst);
result = AAUDIO_ERROR_OUT_OF_RANGE;
@@ -190,7 +208,7 @@
}
mClockModel.setSampleRate(getSampleRate());
- mClockModel.setFramesPerBurst(mFramesPerBurst);
+ mClockModel.setFramesPerBurst(framesPerHardwareBurst);
if (isDataCallbackSet()) {
mCallbackFrames = builder.getFramesPerDataCallback();
diff --git a/media/libaudioclient/Android.bp b/media/libaudioclient/Android.bp
index e9b6fb1..03bd6ce 100644
--- a/media/libaudioclient/Android.bp
+++ b/media/libaudioclient/Android.bp
@@ -59,6 +59,7 @@
"IEffectClient.cpp",
"ToneGenerator.cpp",
"PlayerBase.cpp",
+ "RecordingActivityTracker.cpp",
"TrackPlayerBase.cpp",
],
shared_libs: [
diff --git a/media/libaudioclient/AudioRecord.cpp b/media/libaudioclient/AudioRecord.cpp
index f07be46..0cce5bc 100644
--- a/media/libaudioclient/AudioRecord.cpp
+++ b/media/libaudioclient/AudioRecord.cpp
@@ -22,7 +22,11 @@
#include <android-base/macros.h>
#include <sys/resource.h>
+#include <audiomanager/AudioManager.h>
+#include <audiomanager/IAudioManager.h>
+#include <binder/Binder.h>
#include <binder/IPCThreadState.h>
+#include <binder/IServiceManager.h>
#include <media/AudioRecord.h>
#include <utils/Log.h>
#include <private/media/AudioTrackShared.h>
@@ -219,6 +223,8 @@
inputSource, sampleRate, format, channelMask, frameCount, notificationFrames,
sessionId, transferType, flags, String8(mOpPackageName).string(), uid, pid);
+ mTracker.reset(new RecordingActivityTracker());
+
mSelectedDeviceId = selectedDeviceId;
mSelectedMicDirection = selectedMicDirection;
mSelectedMicFieldDimension = microphoneFieldDimension;
@@ -396,6 +402,7 @@
// This is legacy behavior. This is not done in stop() to avoid a race condition
// where the last marker event is issued twice.
mMarkerReached = false;
+ // mActive is checked by restoreRecord_l
mActive = true;
status_t status = NO_ERROR;
@@ -416,7 +423,9 @@
if (status != NO_ERROR) {
mActive = false;
ALOGE("%s(%d): status %d", __func__, mPortId, status);
+ mMediaMetrics.markError(status, __FUNCTION__);
} else {
+ mTracker->recordingStarted();
sp<AudioRecordThread> t = mAudioRecordThread;
if (t != 0) {
t->resume();
@@ -429,10 +438,6 @@
// we've successfully started, log that time
mMediaMetrics.logStart(systemTime());
}
-
- if (status != NO_ERROR) {
- mMediaMetrics.markError(status, __FUNCTION__);
- }
return status;
}
@@ -447,6 +452,7 @@
mActive = false;
mProxy->interrupt();
mAudioRecord->stop();
+ mTracker->recordingStopped();
// Note: legacy handling - stop does not clear record marker and
// periodic update position; we update those on start().
@@ -711,6 +717,7 @@
}
}
input.opPackageName = opPackageName;
+ input.riid = mTracker->getRiid();
input.flags = mFlags;
// The notification frame count is the period between callbacks, as suggested by the client
diff --git a/media/libaudioclient/AudioSystem.cpp b/media/libaudioclient/AudioSystem.cpp
index de82d2b..47e2c28 100644
--- a/media/libaudioclient/AudioSystem.cpp
+++ b/media/libaudioclient/AudioSystem.cpp
@@ -428,6 +428,7 @@
audio_unique_id_t AudioSystem::newAudioUniqueId(audio_unique_id_use_t use)
{
+ // Must not use AF as IDs will re-roll on audioserver restart, b/130369529.
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
if (af == 0) return AUDIO_UNIQUE_ID_ALLOCATE;
return af->newAudioUniqueId(use);
@@ -924,6 +925,7 @@
status_t AudioSystem::getInputForAttr(const audio_attributes_t *attr,
audio_io_handle_t *input,
+ audio_unique_id_t riid,
audio_session_t session,
pid_t pid,
uid_t uid,
@@ -936,7 +938,7 @@
const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
if (aps == 0) return NO_INIT;
return aps->getInputForAttr(
- attr, input, session, pid, uid, opPackageName,
+ attr, input, riid, session, pid, uid, opPackageName,
config, flags, selectedDeviceId, portId);
}
diff --git a/media/libaudioclient/IAudioPolicyService.cpp b/media/libaudioclient/IAudioPolicyService.cpp
index 4a8bb52..9b4221c 100644
--- a/media/libaudioclient/IAudioPolicyService.cpp
+++ b/media/libaudioclient/IAudioPolicyService.cpp
@@ -305,6 +305,7 @@
virtual status_t getInputForAttr(const audio_attributes_t *attr,
audio_io_handle_t *input,
+ audio_unique_id_t riid,
audio_session_t session,
pid_t pid,
uid_t uid,
@@ -334,6 +335,7 @@
}
data.write(attr, sizeof(audio_attributes_t));
data.writeInt32(*input);
+ data.writeInt32(riid);
data.writeInt32(session);
data.writeInt32(pid);
data.writeInt32(uid);
@@ -1511,6 +1513,7 @@
data.read(&attr, sizeof(audio_attributes_t));
sanetizeAudioAttributes(&attr);
audio_io_handle_t input = (audio_io_handle_t)data.readInt32();
+ audio_unique_id_t riid = (audio_unique_id_t)data.readInt32();
audio_session_t session = (audio_session_t)data.readInt32();
pid_t pid = (pid_t)data.readInt32();
uid_t uid = (uid_t)data.readInt32();
@@ -1521,7 +1524,7 @@
audio_input_flags_t flags = (audio_input_flags_t) data.readInt32();
audio_port_handle_t selectedDeviceId = (audio_port_handle_t) data.readInt32();
audio_port_handle_t portId = (audio_port_handle_t)data.readInt32();
- status_t status = getInputForAttr(&attr, &input, session, pid, uid,
+ status_t status = getInputForAttr(&attr, &input, riid, session, pid, uid,
opPackageName, &config,
flags, &selectedDeviceId, &portId);
reply->writeInt32(status);
diff --git a/media/libaudioclient/IAudioPolicyServiceClient.cpp b/media/libaudioclient/IAudioPolicyServiceClient.cpp
index 52d8ccd..0f9580c 100644
--- a/media/libaudioclient/IAudioPolicyServiceClient.cpp
+++ b/media/libaudioclient/IAudioPolicyServiceClient.cpp
@@ -50,6 +50,7 @@
}
inline void readRecordClientInfoFromParcel(const Parcel& data, record_client_info_t *clientInfo) {
+ clientInfo->riid = (audio_unique_id_t) data.readInt32();
clientInfo->uid = (uid_t) data.readUint32();
clientInfo->session = (audio_session_t) data.readInt32();
clientInfo->source = (audio_source_t) data.readInt32();
@@ -58,6 +59,7 @@
}
inline void writeRecordClientInfoToParcel(Parcel& data, const record_client_info_t *clientInfo) {
+ data.writeInt32((int32_t) clientInfo->riid);
data.writeUint32((uint32_t) clientInfo->uid);
data.writeInt32((int32_t) clientInfo->session);
data.writeInt32((int32_t) clientInfo->source);
diff --git a/media/libaudioclient/RecordingActivityTracker.cpp b/media/libaudioclient/RecordingActivityTracker.cpp
new file mode 100644
index 0000000..bd10895
--- /dev/null
+++ b/media/libaudioclient/RecordingActivityTracker.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2019 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 <audiomanager/AudioManager.h>
+#include <audiomanager/IAudioManager.h>
+#include <binder/Binder.h>
+#include <binder/IServiceManager.h>
+#include <media/RecordingActivityTracker.h>
+
+namespace android {
+
+RecordingActivityTracker::RecordingActivityTracker()
+ : mRIId(RECORD_RIID_INVALID), mToken(new BBinder())
+{
+ // use checkService() to avoid blocking if audio service is not up yet
+ sp<IBinder> binder = defaultServiceManager()->checkService(String16("audio"));
+ if (binder != 0) {
+ mAudioManager = interface_cast<IAudioManager>(binder);
+ } else {
+ ALOGE("RecordingActivityTracker(): binding to audio service failed, service up?");
+ }
+}
+
+RecordingActivityTracker::~RecordingActivityTracker()
+{
+}
+
+audio_unique_id_t RecordingActivityTracker::getRiid()
+{
+ if (mRIId == RECORD_RIID_INVALID && mAudioManager) {
+ mRIId = mAudioManager->trackRecorder(mToken);
+ }
+ return mRIId;
+}
+
+void RecordingActivityTracker::recordingStarted()
+{
+ if (getRiid() != RECORD_RIID_INVALID && mAudioManager) {
+ mAudioManager->recorderEvent(mRIId, RECORDER_STATE_STARTED);
+ }
+}
+
+void RecordingActivityTracker::recordingStopped()
+{
+ if (getRiid() != RECORD_RIID_INVALID && mAudioManager) {
+ mAudioManager->recorderEvent(mRIId, RECORDER_STATE_STOPPED);
+ }
+}
+
+} // namespace android
diff --git a/media/libaudioclient/include/media/AudioPolicy.h b/media/libaudioclient/include/media/AudioPolicy.h
index 4b94c12..a40e019 100644
--- a/media/libaudioclient/include/media/AudioPolicy.h
+++ b/media/libaudioclient/include/media/AudioPolicy.h
@@ -119,11 +119,11 @@
};
-// definitions for audio recording configuration updates
-// which update type is reported
-#define RECORD_CONFIG_EVENT_NONE -1
-#define RECORD_CONFIG_EVENT_START 1
-#define RECORD_CONFIG_EVENT_STOP 0
+// definitions for audio recording configuration updates;
+// keep in sync with AudioManager.java for values used from native code
+#define RECORD_CONFIG_EVENT_START 0
+#define RECORD_CONFIG_EVENT_STOP 1
+#define RECORD_CONFIG_EVENT_UPDATE 2
static inline bool is_mix_loopback_render(uint32_t routeFlags) {
return (routeFlags & MIX_ROUTE_FLAG_LOOP_BACK_AND_RENDER)
diff --git a/media/libaudioclient/include/media/AudioRecord.h b/media/libaudioclient/include/media/AudioRecord.h
index 9c81bb7..a3c0fe4 100644
--- a/media/libaudioclient/include/media/AudioRecord.h
+++ b/media/libaudioclient/include/media/AudioRecord.h
@@ -17,6 +17,9 @@
#ifndef ANDROID_AUDIORECORD_H
#define ANDROID_AUDIORECORD_H
+#include <memory>
+#include <vector>
+
#include <binder/IMemory.h>
#include <cutils/sched_policy.h>
#include <media/AudioSystem.h>
@@ -24,9 +27,9 @@
#include <media/MediaAnalyticsItem.h>
#include <media/Modulo.h>
#include <media/MicrophoneInfo.h>
+#include <media/RecordingActivityTracker.h>
#include <utils/RefBase.h>
#include <utils/threads.h>
-#include <vector>
#include "android/media/IAudioRecord.h"
@@ -618,6 +621,8 @@
sp<AudioRecordThread> mAudioRecordThread;
mutable Mutex mLock;
+ std::unique_ptr<RecordingActivityTracker> mTracker;
+
// Current client state: false = stopped, true = active. Protected by mLock. If more states
// are added, consider changing this to enum State { ... } mState as in AudioTrack.
bool mActive;
diff --git a/media/libaudioclient/include/media/AudioSystem.h b/media/libaudioclient/include/media/AudioSystem.h
index d180bbc..d3035da 100644
--- a/media/libaudioclient/include/media/AudioSystem.h
+++ b/media/libaudioclient/include/media/AudioSystem.h
@@ -242,6 +242,7 @@
// or release it with releaseInput().
static status_t getInputForAttr(const audio_attributes_t *attr,
audio_io_handle_t *input,
+ audio_unique_id_t riid,
audio_session_t session,
pid_t pid,
uid_t uid,
diff --git a/media/libaudioclient/include/media/IAudioFlinger.h b/media/libaudioclient/include/media/IAudioFlinger.h
index dcc18b6..8ec8931 100644
--- a/media/libaudioclient/include/media/IAudioFlinger.h
+++ b/media/libaudioclient/include/media/IAudioFlinger.h
@@ -205,6 +205,9 @@
return DEAD_OBJECT;
}
opPackageName = parcel->readString16();
+ if (parcel->read(&riid, sizeof(audio_unique_id_t)) != NO_ERROR) {
+ return DEAD_OBJECT;
+ }
/* input/output arguments*/
(void)parcel->read(&flags, sizeof(audio_input_flags_t));
@@ -221,6 +224,7 @@
(void)parcel->write(&config, sizeof(audio_config_base_t));
(void)clientInfo.writeToParcel(parcel);
(void)parcel->writeString16(opPackageName);
+ (void)parcel->write(&riid, sizeof(audio_unique_id_t));
/* input/output arguments*/
(void)parcel->write(&flags, sizeof(audio_input_flags_t));
@@ -236,6 +240,7 @@
audio_config_base_t config;
AudioClient clientInfo;
String16 opPackageName;
+ audio_unique_id_t riid;
/* input/output */
audio_input_flags_t flags;
diff --git a/media/libaudioclient/include/media/IAudioPolicyService.h b/media/libaudioclient/include/media/IAudioPolicyService.h
index 11983d5..b639044 100644
--- a/media/libaudioclient/include/media/IAudioPolicyService.h
+++ b/media/libaudioclient/include/media/IAudioPolicyService.h
@@ -73,6 +73,7 @@
virtual void releaseOutput(audio_port_handle_t portId) = 0;
virtual status_t getInputForAttr(const audio_attributes_t *attr,
audio_io_handle_t *input,
+ audio_unique_id_t riid,
audio_session_t session,
pid_t pid,
uid_t uid,
diff --git a/media/libaudioclient/include/media/IAudioPolicyServiceClient.h b/media/libaudioclient/include/media/IAudioPolicyServiceClient.h
index 79008c3..47b31ee 100644
--- a/media/libaudioclient/include/media/IAudioPolicyServiceClient.h
+++ b/media/libaudioclient/include/media/IAudioPolicyServiceClient.h
@@ -31,6 +31,7 @@
// ----------------------------------------------------------------------------
struct record_client_info {
+ audio_unique_id_t riid;
uid_t uid;
audio_session_t session;
audio_source_t source;
diff --git a/media/libaudioclient/include/media/RecordingActivityTracker.h b/media/libaudioclient/include/media/RecordingActivityTracker.h
new file mode 100644
index 0000000..9891a70
--- /dev/null
+++ b/media/libaudioclient/include/media/RecordingActivityTracker.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#ifndef __ANDROID_RECORDING_ACTIVITY_TRACKER_H__
+#define __ANDROID_RECORDING_ACTIVITY_TRACKER_H__
+
+#include <utils/StrongPointer.h>
+
+namespace android {
+
+class IAudioManager;
+class IBinder;
+
+class RecordingActivityTracker
+{
+public:
+ RecordingActivityTracker();
+ ~RecordingActivityTracker();
+ audio_unique_id_t getRiid();
+ void recordingStarted();
+ void recordingStopped();
+
+private:
+ sp<IAudioManager> mAudioManager;
+ audio_unique_id_t mRIId;
+ sp<IBinder> mToken;
+};
+
+} // namespace android
+
+#endif // __ANDROID_RECORDING_ACTIVITY_TRACKER_H__
diff --git a/media/libstagefright/MediaExtractorFactory.cpp b/media/libstagefright/MediaExtractorFactory.cpp
index a309ee4..d97591f 100644
--- a/media/libstagefright/MediaExtractorFactory.cpp
+++ b/media/libstagefright/MediaExtractorFactory.cpp
@@ -19,6 +19,7 @@
#include <utils/Log.h>
#include <android/dlext.h>
+#include <android-base/logging.h>
#include <binder/IPCThreadState.h>
#include <binder/PermissionCache.h>
#include <binder/IServiceManager.h>
@@ -244,20 +245,17 @@
void *libHandle = android_dlopen_ext(
libPath.string(),
RTLD_NOW | RTLD_LOCAL, dlextinfo);
- if (libHandle) {
- GetExtractorDef getDef =
- (GetExtractorDef) dlsym(libHandle, "GETEXTRACTORDEF");
- if (getDef) {
- ALOGV("registering sniffer for %s", libPath.string());
- RegisterExtractor(
- new ExtractorPlugin(getDef(), libHandle, libPath), pluginList);
- } else {
- ALOGW("%s does not contain sniffer", libPath.string());
- dlclose(libHandle);
- }
- } else {
- ALOGW("couldn't dlopen(%s) %s", libPath.string(), strerror(errno));
- }
+ CHECK(libHandle != nullptr)
+ << "couldn't dlopen(" << libPath.string() << ") " << strerror(errno);
+
+ GetExtractorDef getDef =
+ (GetExtractorDef) dlsym(libHandle, "GETEXTRACTORDEF");
+ CHECK(getDef != nullptr)
+ << libPath.string() << " does not contain sniffer";
+
+ ALOGV("registering sniffer for %s", libPath.string());
+ RegisterExtractor(
+ new ExtractorPlugin(getDef(), libHandle, libPath), pluginList);
}
closedir(libDir);
} else {
diff --git a/media/libstagefright/Utils.cpp b/media/libstagefright/Utils.cpp
index 537e4c0..3de934f 100644
--- a/media/libstagefright/Utils.cpp
+++ b/media/libstagefright/Utils.cpp
@@ -1101,7 +1101,9 @@
} else if (meta->findData(kKeyHVCC, &type, &data, &size)) {
const uint8_t *ptr = (const uint8_t *)data;
- if (size < 23 || ptr[0] != 1) { // configurationVersion == 1
+ if (size < 23 || (ptr[0] != 1 && ptr[0] != 0)) {
+ // configurationVersion == 1 or 0
+ // 1 is what the standard dictates, but some old muxers may have used 0.
ALOGE("b/23680780");
return BAD_VALUE;
}
diff --git a/media/libstagefright/VideoFrameSchedulerBase.cpp b/media/libstagefright/VideoFrameSchedulerBase.cpp
index 77107ff..0d1517b 100644
--- a/media/libstagefright/VideoFrameSchedulerBase.cpp
+++ b/media/libstagefright/VideoFrameSchedulerBase.cpp
@@ -115,6 +115,10 @@
#endif
+// If overflow happens, the value is already incorrect, and no mater what value we get is OK.
+// And this part of calculation is not important, so it's OK to simply disable overflow check
+// instead of using double which makes code more complicated.
+__attribute__((no_sanitize("integer")))
bool VideoFrameSchedulerBase::PLL::fit(
nsecs_t phase, nsecs_t period, size_t numSamplesToUse,
int64_t *a, int64_t *b, int64_t *err) {
diff --git a/media/libstagefright/rtsp/MyHandler.h b/media/libstagefright/rtsp/MyHandler.h
index b4515e4..48bc8ce 100644
--- a/media/libstagefright/rtsp/MyHandler.h
+++ b/media/libstagefright/rtsp/MyHandler.h
@@ -75,6 +75,8 @@
// a new sequence.
static int32_t kMaxAllowedStaleAccessUnits = 20;
+static int64_t kTearDownTimeoutUs = 3000000ll;
+
namespace android {
static bool GetAttribute(const char *s, const char *key, AString *value) {
@@ -930,6 +932,14 @@
request.append("\r\n");
mConn->sendRequest(request.c_str(), reply);
+
+ // If the response of teardown hasn't been received in 3 seconds,
+ // post 'tear' message to avoid ANR.
+ if (!msg->findInt32("reconnect", &reconnect) || !reconnect) {
+ sp<AMessage> teardown = reply->dup();
+ teardown->setInt32("result", -ECONNABORTED);
+ teardown->post(kTearDownTimeoutUs);
+ }
break;
}
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 55db699..0f03b7e 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -46,6 +46,7 @@
#include <cutils/properties.h>
#include <system/audio.h>
+#include <audiomanager/AudioManager.h>
#include "AudioFlinger.h"
#include "NBAIO_Tee.h"
@@ -312,6 +313,7 @@
"%s does not support secondary outputs, ignoring them", __func__);
} else {
ret = AudioSystem::getInputForAttr(attr, &io,
+ RECORD_RIID_INVALID,
actualSessionId,
client.clientPid,
client.clientUid,
@@ -1889,6 +1891,7 @@
portId = AUDIO_PORT_HANDLE_NONE;
}
lStatus = AudioSystem::getInputForAttr(&input.attr, &output.inputId,
+ input.riid,
sessionId,
// FIXME compare to AudioTrack
clientPid,
diff --git a/services/audioflinger/PlaybackTracks.h b/services/audioflinger/PlaybackTracks.h
index 4fd72a7..56be433 100644
--- a/services/audioflinger/PlaybackTracks.h
+++ b/services/audioflinger/PlaybackTracks.h
@@ -22,11 +22,16 @@
// Checks and monitors OP_PLAY_AUDIO
class OpPlayAudioMonitor : public RefBase {
public:
- OpPlayAudioMonitor(uid_t uid, audio_usage_t usage, int id, audio_stream_type_t streamType);
~OpPlayAudioMonitor() override;
bool hasOpPlayAudio() const;
+ static sp<OpPlayAudioMonitor> createIfNeeded(
+ uid_t uid, audio_usage_t usage, int id, audio_stream_type_t streamType);
+
private:
+ OpPlayAudioMonitor(uid_t uid, audio_usage_t usage, int id);
+ void onFirstRef() override;
+
AppOpsManager mAppOpsManager;
class PlayAudioOpCallback : public BnAppOpsCallback {
@@ -209,7 +214,9 @@
int fastIndex() const { return mFastIndex; }
- bool isPlaybackRestricted() const { return !mOpPlayAudioMonitor->hasOpPlayAudio(); }
+ bool isPlaybackRestricted() const {
+ // The monitor is only created for tracks that can be silenced.
+ return mOpPlayAudioMonitor ? !mOpPlayAudioMonitor->hasOpPlayAudio() : false; }
protected:
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 711a6dd..fd29f31 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -59,6 +59,7 @@
#include <media/nbaio/SourceAudioBufferProvider.h>
#include <mediautils/BatteryNotifier.h>
+#include <audiomanager/AudioManager.h>
#include <powermanager/PowerManager.h>
#include <media/audiohal/EffectsFactoryHalInterface.h>
@@ -8561,6 +8562,7 @@
config.format = mFormat;
audio_port_handle_t deviceId = mDeviceId;
ret = AudioSystem::getInputForAttr(&mAttr, &io,
+ RECORD_RIID_INVALID,
mSessionId,
client.clientPid,
client.clientUid,
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 2ff80c6..8d59431 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -381,26 +381,28 @@
// ----------------------------------------------------------------------------
// AppOp for audio playback
// -------------------------------
-AudioFlinger::PlaybackThread::OpPlayAudioMonitor::OpPlayAudioMonitor(uid_t uid, audio_usage_t usage,
- int id, audio_stream_type_t streamType)
- : mHasOpPlayAudio(true), mUid(uid), mUsage((int32_t) usage), mId(id)
+
+// static
+sp<AudioFlinger::PlaybackThread::OpPlayAudioMonitor>
+AudioFlinger::PlaybackThread::OpPlayAudioMonitor::createIfNeeded(
+ uid_t uid, audio_usage_t usage, int id, audio_stream_type_t streamType)
{
if (isAudioServerOrRootUid(uid)) {
- ALOGD("OpPlayAudio: not muting track:%d usage:%d root or audioserver", mId, usage);
- return;
+ ALOGD("OpPlayAudio: not muting track:%d usage:%d root or audioserver", id, usage);
+ return nullptr;
}
// stream type has been filtered by audio policy to indicate whether it can be muted
if (streamType == AUDIO_STREAM_ENFORCED_AUDIBLE) {
- ALOGD("OpPlayAudio: not muting track:%d usage:%d ENFORCED_AUDIBLE", mId, usage);
- return;
+ ALOGD("OpPlayAudio: not muting track:%d usage:%d ENFORCED_AUDIBLE", id, usage);
+ return nullptr;
}
- PermissionController permissionController;
- permissionController.getPackagesForUid(uid, mPackages);
- checkPlayAudioForUsage();
- if (!mPackages.isEmpty()) {
- mOpCallback = new PlayAudioOpCallback(this);
- mAppOpsManager.startWatchingMode(AppOpsManager::OP_PLAY_AUDIO, mPackages[0], mOpCallback);
- }
+ return new OpPlayAudioMonitor(uid, usage, id);
+}
+
+AudioFlinger::PlaybackThread::OpPlayAudioMonitor::OpPlayAudioMonitor(
+ uid_t uid, audio_usage_t usage, int id)
+ : mHasOpPlayAudio(true), mUid(uid), mUsage((int32_t) usage), mId(id)
+{
}
AudioFlinger::PlaybackThread::OpPlayAudioMonitor::~OpPlayAudioMonitor()
@@ -411,6 +413,17 @@
mOpCallback.clear();
}
+void AudioFlinger::PlaybackThread::OpPlayAudioMonitor::onFirstRef()
+{
+ PermissionController permissionController;
+ permissionController.getPackagesForUid(mUid, mPackages);
+ checkPlayAudioForUsage();
+ if (!mPackages.isEmpty()) {
+ mOpCallback = new PlayAudioOpCallback(this);
+ mAppOpsManager.startWatchingMode(AppOpsManager::OP_PLAY_AUDIO, mPackages[0], mOpCallback);
+ }
+}
+
bool AudioFlinger::PlaybackThread::OpPlayAudioMonitor::hasOpPlayAudio() const {
return mHasOpPlayAudio.load();
}
@@ -492,7 +505,7 @@
mPresentationCompleteFrames(0),
mFrameMap(16 /* sink-frame-to-track-frame map memory */),
mVolumeHandler(new media::VolumeHandler(sampleRate)),
- mOpPlayAudioMonitor(new OpPlayAudioMonitor(uid, attr.usage, id(), streamType)),
+ mOpPlayAudioMonitor(OpPlayAudioMonitor::createIfNeeded(uid, attr.usage, id(), streamType)),
// mSinkTimestamp
mFastIndex(-1),
mCachedVolume(1.0),
diff --git a/services/audiopolicy/Android.bp b/services/audiopolicy/Android.bp
new file mode 100644
index 0000000..a42b89f
--- /dev/null
+++ b/services/audiopolicy/Android.bp
@@ -0,0 +1,5 @@
+cc_library_headers {
+ name: "libaudiopolicymanager_interface_headers",
+ host_supported: true,
+ export_include_dirs: ["."],
+}
diff --git a/services/audiopolicy/Android.mk b/services/audiopolicy/Android.mk
deleted file mode 100644
index 3badda1..0000000
--- a/services/audiopolicy/Android.mk
+++ /dev/null
@@ -1,136 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- service/AudioPolicyService.cpp \
- service/AudioPolicyEffects.cpp \
- service/AudioPolicyInterfaceImpl.cpp \
- service/AudioPolicyClientImpl.cpp
-
-LOCAL_C_INCLUDES := \
- frameworks/av/services/audioflinger \
- $(call include-path-for, audio-utils) \
-
-LOCAL_HEADER_LIBRARIES := \
- libaudiopolicycommon \
- libaudiopolicyengine_interface_headers \
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils \
- libutils \
- liblog \
- libbinder \
- libaudioclient \
- libhardware_legacy \
- libaudiopolicymanager \
- libmedia_helper \
- libmediametrics \
- libmediautils \
- libeffectsconfig \
- libsensorprivacy
-
-LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := \
- libsensorprivacy
-
-LOCAL_STATIC_LIBRARIES := \
- libaudiopolicycomponents
-
-LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
-
-LOCAL_MODULE:= libaudiopolicyservice
-
-LOCAL_CFLAGS += -fvisibility=hidden
-LOCAL_CFLAGS += -Wall -Werror
-
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= managerdefault/AudioPolicyManager.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils \
- libutils \
- liblog \
- libaudiopolicy \
- libsoundtrigger
-
-ifeq ($(USE_CONFIGURABLE_AUDIO_POLICY), 1)
-
-ifneq ($(USE_XML_AUDIO_POLICY_CONF), 1)
-$(error Configurable policy does not support legacy conf file)
-endif #ifneq ($(USE_XML_AUDIO_POLICY_CONF), 1)
-
-LOCAL_C_INCLUDES += frameworks/av/services/audiopolicy/engineconfigurable/include
-LOCAL_C_INCLUDES += frameworks/av/include
-
-LOCAL_SHARED_LIBRARIES += libaudiopolicyengineconfigurable
-
-else
-
-LOCAL_SHARED_LIBRARIES += libaudiopolicyenginedefault
-
-endif # ifeq ($(USE_CONFIGURABLE_AUDIO_POLICY), 1)
-
-LOCAL_C_INCLUDES += \
- $(call include-path-for, audio-utils) \
-
-LOCAL_HEADER_LIBRARIES := \
- libaudiopolicycommon \
- libaudiopolicyengine_interface_headers
-
-LOCAL_STATIC_LIBRARIES := \
- libaudiopolicycomponents
-
-LOCAL_SHARED_LIBRARIES += libmedia_helper
-LOCAL_SHARED_LIBRARIES += libmediametrics
-
-LOCAL_SHARED_LIBRARIES += libbinder libhidlbase libxml2
-
-ifeq ($(USE_XML_AUDIO_POLICY_CONF), 1)
-LOCAL_CFLAGS += -DUSE_XML_AUDIO_POLICY_CONF
-endif #ifeq ($(USE_XML_AUDIO_POLICY_CONF), 1)
-
-LOCAL_CFLAGS += -Wall -Werror
-
-LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
-
-LOCAL_MODULE:= libaudiopolicymanagerdefault
-
-include $(BUILD_SHARED_LIBRARY)
-
-ifneq ($(USE_CUSTOM_AUDIO_POLICY), 1)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- manager/AudioPolicyFactory.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libaudiopolicymanagerdefault
-
-LOCAL_STATIC_LIBRARIES := \
- libaudiopolicycomponents
-
-LOCAL_C_INCLUDES += \
- $(call include-path-for, audio-utils) \
-
-LOCAL_HEADER_LIBRARIES := \
- libaudiopolicycommon \
- libaudiopolicyengine_interface_headers
-
-LOCAL_CFLAGS := -Wall -Werror
-
-LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
-
-LOCAL_MODULE:= libaudiopolicymanager
-
-include $(BUILD_SHARED_LIBRARY)
-
-endif
-
-#######################################################################
-# Recursive call sub-folder Android.mk
-#
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/services/audiopolicy/AudioPolicyInterface.h b/services/audiopolicy/AudioPolicyInterface.h
index 4b56a46..49937f0 100644
--- a/services/audiopolicy/AudioPolicyInterface.h
+++ b/services/audiopolicy/AudioPolicyInterface.h
@@ -124,6 +124,7 @@
// request an input appropriate for record from the supplied device with supplied parameters.
virtual status_t getInputForAttr(const audio_attributes_t *attr,
audio_io_handle_t *input,
+ audio_unique_id_t riid,
audio_session_t session,
uid_t uid,
const audio_config_base_t *config,
diff --git a/services/audiopolicy/common/managerdefinitions/Android.bp b/services/audiopolicy/common/managerdefinitions/Android.bp
index c9037a1..f02f3cf 100644
--- a/services/audiopolicy/common/managerdefinitions/Android.bp
+++ b/services/audiopolicy/common/managerdefinitions/Android.bp
@@ -34,6 +34,7 @@
],
header_libs: [
"libaudiopolicycommon",
+ "libaudiopolicymanager_interface_headers",
],
export_header_lib_headers: ["libaudiopolicycommon"],
diff --git a/services/audiopolicy/common/managerdefinitions/include/ClientDescriptor.h b/services/audiopolicy/common/managerdefinitions/include/ClientDescriptor.h
index 4bb225d..0d05a63 100644
--- a/services/audiopolicy/common/managerdefinitions/include/ClientDescriptor.h
+++ b/services/audiopolicy/common/managerdefinitions/include/ClientDescriptor.h
@@ -22,6 +22,7 @@
#include <sys/types.h>
#include <system/audio.h>
+#include <audiomanager/AudioManager.h>
#include <media/AudioProductStrategy.h>
#include <utils/Errors.h>
#include <utils/KeyedVector.h>
@@ -146,20 +147,23 @@
class RecordClientDescriptor: public ClientDescriptor
{
public:
- RecordClientDescriptor(audio_port_handle_t portId, uid_t uid, audio_session_t sessionId,
- audio_attributes_t attributes, audio_config_base_t config,
- audio_port_handle_t preferredDeviceId,
+ RecordClientDescriptor(audio_port_handle_t portId, audio_unique_id_t riid, uid_t uid,
+ audio_session_t sessionId, audio_attributes_t attributes,
+ audio_config_base_t config, audio_port_handle_t preferredDeviceId,
audio_source_t source, audio_input_flags_t flags, bool isSoundTrigger) :
ClientDescriptor(portId, uid, sessionId, attributes, config, preferredDeviceId),
- mSource(source), mFlags(flags), mIsSoundTrigger(isSoundTrigger), mAppState(APP_STATE_IDLE) {}
+ mRIId(riid), mSource(source), mFlags(flags), mIsSoundTrigger(isSoundTrigger),
+ mAppState(APP_STATE_IDLE) {}
~RecordClientDescriptor() override = default;
using ClientDescriptor::dump;
void dump(String8 *dst, int spaces, int index) const override;
+ audio_unique_id_t riid() const { return mRIId; }
audio_source_t source() const { return mSource; }
audio_input_flags_t flags() const { return mFlags; }
bool isSoundTrigger() const { return mIsSoundTrigger; }
+ bool isLowLevel() const { return mRIId == RECORD_RIID_INVALID; }
void setAppState(app_state_t appState) { mAppState = appState; }
app_state_t appState() { return mAppState; }
bool isSilenced() const { return mAppState == APP_STATE_IDLE; }
@@ -167,6 +171,7 @@
EffectDescriptorCollection getEnabledEffects() const { return mEnabledEffects; }
private:
+ const audio_unique_id_t mRIId;
const audio_source_t mSource;
const audio_input_flags_t mFlags;
const bool mIsSoundTrigger;
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp
index 58683be..a096e8f 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp
@@ -17,6 +17,7 @@
#define LOG_TAG "APM::AudioInputDescriptor"
//#define LOG_NDEBUG 0
+#include <audiomanager/AudioManager.h>
#include <media/AudioPolicy.h>
#include <policy.h>
#include <AudioPolicyInterface.h>
@@ -179,7 +180,9 @@
mPatchHandle = handle;
for (const auto &client : getClientIterable()) {
if (client->active()) {
- updateClientRecordingConfiguration(RECORD_CONFIG_EVENT_START, client);
+ updateClientRecordingConfiguration(
+ client->isLowLevel() ? RECORD_CONFIG_EVENT_START : RECORD_CONFIG_EVENT_UPDATE,
+ client);
}
}
}
@@ -342,15 +345,19 @@
void AudioInputDescriptor::updateClientRecordingConfiguration(
int event, const sp<RecordClientDescriptor>& client)
{
+ ALOGV("%s riid %d uid %d port %d session %d event %d",
+ __func__, client->riid(), client->uid(), client->portId(), client->session(), event);
// do not send callback if starting and no device is selected yet to avoid
// double callbacks from startInput() before and after the device is selected
- if (event == RECORD_CONFIG_EVENT_START
- && mPatchHandle == AUDIO_PATCH_HANDLE_NONE) {
+ // "start" and "stop" events for "high level" clients (AudioRecord) are sent by the client side
+ if ((event == RECORD_CONFIG_EVENT_START && mPatchHandle == AUDIO_PATCH_HANDLE_NONE)
+ || (!client->isLowLevel()
+ && (event == RECORD_CONFIG_EVENT_START || event == RECORD_CONFIG_EVENT_STOP))) {
return;
}
const audio_config_base_t sessionConfig = client->config();
- const record_client_info_t recordClientInfo{client->uid(), client->session(),
+ const record_client_info_t recordClientInfo{client->riid(), client->uid(), client->session(),
client->source(), client->portId(),
client->isSilenced()};
const audio_config_base_t config = getConfig();
@@ -429,7 +436,7 @@
checkSuspendEffects();
for (const auto& client : updatedClients) {
- updateClientRecordingConfiguration(RECORD_CONFIG_EVENT_START, client);
+ updateClientRecordingConfiguration(RECORD_CONFIG_EVENT_UPDATE, client);
}
}
@@ -462,7 +469,7 @@
checkSuspendEffects();
for (const auto& client : updatedClients) {
- updateClientRecordingConfiguration(RECORD_CONFIG_EVENT_START, client);
+ updateClientRecordingConfiguration(RECORD_CONFIG_EVENT_UPDATE, client);
}
}
diff --git a/services/audiopolicy/engine/Android.mk b/services/audiopolicy/engine/Android.mk
deleted file mode 100644
index dcce8e3..0000000
--- a/services/audiopolicy/engine/Android.mk
+++ /dev/null
@@ -1,9 +0,0 @@
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-#######################################################################
-# Recursive call sub-folder Android.mk
-#
-include $(call all-makefiles-under,$(LOCAL_PATH))
-
diff --git a/services/audiopolicy/engineconfigurable/Android.bp b/services/audiopolicy/engineconfigurable/Android.bp
new file mode 100644
index 0000000..c27dc88
--- /dev/null
+++ b/services/audiopolicy/engineconfigurable/Android.bp
@@ -0,0 +1,44 @@
+cc_library_headers {
+ name: "libaudiopolicyengineconfigurable_interface_headers",
+ host_supported: true,
+ export_include_dirs: ["interface"],
+}
+
+cc_library_shared {
+ name: "libaudiopolicyengineconfigurable",
+ export_include_dirs: ["include"],
+ srcs: [
+ "src/Engine.cpp",
+ "src/EngineInstance.cpp",
+ "src/Stream.cpp",
+ "src/InputSource.cpp",
+ ],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wextra",
+ ],
+ local_include_dirs: ["include"],
+ header_libs: [
+ "libbase_headers",
+ "libaudiopolicycommon",
+ "libaudiopolicyengine_interface_headers",
+ "libaudiopolicyengineconfigurable_interface_headers",
+ ],
+ static_libs: [
+ "libaudiopolicycomponents",
+ "libaudiopolicyengine_common",
+ "libaudiopolicyengine_config",
+ "libaudiopolicyengineconfigurable_pfwwrapper",
+
+ ],
+ shared_libs: [
+ "liblog",
+ "libcutils",
+ "libutils",
+ "libmedia_helper",
+ "libaudiopolicy",
+ "libparameter",
+ "libxml2",
+ ],
+}
diff --git a/services/audiopolicy/engineconfigurable/Android.mk b/services/audiopolicy/engineconfigurable/Android.mk
deleted file mode 100644
index 84a4422..0000000
--- a/services/audiopolicy/engineconfigurable/Android.mk
+++ /dev/null
@@ -1,67 +0,0 @@
-ifeq ($(USE_CONFIGURABLE_AUDIO_POLICY), 1)
-
-LOCAL_PATH := $(call my-dir)
-
-# Component build
-#######################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- src/Engine.cpp \
- src/EngineInstance.cpp \
- src/Stream.cpp \
- src/InputSource.cpp \
-
-audio_policy_engine_includes_common := \
- frameworks/av/services/audiopolicy/engineconfigurable/include \
- frameworks/av/services/audiopolicy/engineconfigurable/interface
-
-LOCAL_CFLAGS += \
- -Wall \
- -Werror \
- -Wextra \
-
-LOCAL_EXPORT_C_INCLUDE_DIRS := \
- $(audio_policy_engine_includes_common)
-
-LOCAL_C_INCLUDES := \
- $(audio_policy_engine_includes_common) \
- $(TARGET_OUT_HEADERS)/hw \
- $(call include-path-for, frameworks-av) \
- $(call include-path-for, audio-utils)
-
-LOCAL_HEADER_LIBRARIES := \
- libaudiopolicycommon \
- libaudiopolicyengine_interface_headers
-
-LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
-
-LOCAL_MODULE := libaudiopolicyengineconfigurable
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_STATIC_LIBRARIES := \
- libaudiopolicypfwwrapper \
- libaudiopolicycomponents \
- libaudiopolicyengine_common \
- libaudiopolicyengine_config \
-
-LOCAL_SHARED_LIBRARIES := \
- liblog \
- libutils \
- liblog \
- libcutils \
- libaudioutils \
- libparameter \
- libmedia_helper \
- libaudiopolicy \
- libxml2
-
-include $(BUILD_SHARED_LIBRARY)
-
-#######################################################################
-# Recursive call sub-folder Android.mk
-#
-include $(call all-makefiles-under,$(LOCAL_PATH))
-
-endif
diff --git a/services/audiopolicy/engineconfigurable/config/Android.mk b/services/audiopolicy/engineconfigurable/config/Android.mk
deleted file mode 100644
index dcce8e3..0000000
--- a/services/audiopolicy/engineconfigurable/config/Android.mk
+++ /dev/null
@@ -1,9 +0,0 @@
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-#######################################################################
-# Recursive call sub-folder Android.mk
-#
-include $(call all-makefiles-under,$(LOCAL_PATH))
-
diff --git a/services/audiopolicy/engineconfigurable/config/example/Android.mk b/services/audiopolicy/engineconfigurable/config/example/Android.mk
index 37271b5..a0f1a90 100644
--- a/services/audiopolicy/engineconfigurable/config/example/Android.mk
+++ b/services/audiopolicy/engineconfigurable/config/example/Android.mk
@@ -1,5 +1,7 @@
LOCAL_PATH := $(call my-dir)
+ifdef BUILD_AUDIO_POLICY_EXAMPLE_CONFIGURATION
+
TOOLS := frameworks/av/services/audiopolicy/engineconfigurable/tools
PROVISION_CRITERION_TYPES := $(TOOLS)/provision_criterion_types_from_android_headers.mk
@@ -137,9 +139,7 @@
LOCAL_MODULE := audio_policy_engine_criterion_types.xml
LOCAL_MODULE_CLASS := ETC
LOCAL_VENDOR_MODULE := true
-LOCAL_ADDITIONAL_DEPENDENCIES := \
- $(TARGET_OUT_VENDOR_ETC)/audio_policy_configuration.xml
-
+LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_VENDOR_ETC)/primary_audio_policy_configuration.xml
ANDROID_AUDIO_BASE_HEADER_FILE := system/media/audio/include/system/audio-base.h
AUDIO_POLICY_CONFIGURATION_FILE := $(TARGET_OUT_VENDOR_ETC)/audio_policy_configuration.xml
CRITERION_TYPES_FILE := $(LOCAL_PATH)/common/$(LOCAL_MODULE).in
@@ -147,3 +147,5 @@
include $(PROVISION_CRITERION_TYPES)
endif #ifeq ($(BUILD_AUDIO_POLICY_EXAMPLE_CONFIGURATION),$(filter $(BUILD_AUDIO_POLICY_EXAMPLE_CONFIGURATION),phone_configurable automotive_configurable caremu_configurable))
+
+endif #ifdef BUILD_AUDIO_POLICY_EXAMPLE_CONFIGURATION
diff --git a/services/audiopolicy/engineconfigurable/config/example/phone/audio_policy_engine_configuration.xml b/services/audiopolicy/engineconfigurable/config/example/phone/audio_policy_engine_configuration.xml
index 4ca33b4..3faf9b9 100644
--- a/services/audiopolicy/engineconfigurable/config/example/phone/audio_policy_engine_configuration.xml
+++ b/services/audiopolicy/engineconfigurable/config/example/phone/audio_policy_engine_configuration.xml
@@ -17,6 +17,8 @@
<configuration version="1.0" xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="audio_policy_engine_product_strategies.xml"/>
+ <xi:include href="audio_policy_engine_criterion_types.xml"/>
+ <xi:include href="audio_policy_engine_criteria.xml"/>
<xi:include href="audio_policy_engine_stream_volumes.xml"/>
<xi:include href="audio_policy_engine_default_stream_volumes.xml"/>
diff --git a/services/audiopolicy/engineconfigurable/parameter-framework/Android.mk b/services/audiopolicy/engineconfigurable/parameter-framework/Android.mk
deleted file mode 100644
index c402fd5..0000000
--- a/services/audiopolicy/engineconfigurable/parameter-framework/Android.mk
+++ /dev/null
@@ -1,7 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-#######################################################################
-# Recursive call sub-folder Android.mk
-#######################################################################
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/services/audiopolicy/engineconfigurable/parameter-framework/examples/Android.mk b/services/audiopolicy/engineconfigurable/parameter-framework/examples/Android.mk
index 782fe83..19f93b3 100644
--- a/services/audiopolicy/engineconfigurable/parameter-framework/examples/Android.mk
+++ b/services/audiopolicy/engineconfigurable/parameter-framework/examples/Android.mk
@@ -9,6 +9,8 @@
LOCAL_PATH := $(call my-dir)
+ifdef BUILD_AUDIO_POLICY_EXAMPLE_CONFIGURATION
+
ifeq ($(BUILD_AUDIO_POLICY_EXAMPLE_CONFIGURATION),$(filter $(BUILD_AUDIO_POLICY_EXAMPLE_CONFIGURATION),phone_configurable automotive_configurable caremu_configurable no-output_configurable no-input_configurable))
PFW_CORE := external/parameter-framework
@@ -38,14 +40,17 @@
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE_RELATIVE_PATH := parameter-framework
LOCAL_SRC_FILES := $(LOCAL_MODULE).in
+LOCAL_REQUIRED_MODULES := \
+ PolicySubsystem.xml \
+ PolicyClass.xml
# external/parameter-framework prevents from using debug interface
AUDIO_PATTERN = @TUNING_ALLOWED@
-#ifeq ($(TARGET_BUILD_VARIANT),user)
+ifeq ($(TARGET_BUILD_VARIANT),user)
AUDIO_VALUE = false
-#else
-#AUDIO_VALUE = true
-#endif
+else
+AUDIO_VALUE = true
+endif
LOCAL_POST_INSTALL_CMD := $(hide) sed -i -e 's|$(AUDIO_PATTERN)|$(AUDIO_VALUE)|g' $(TARGET_OUT_VENDOR_ETC)/$(LOCAL_MODULE_RELATIVE_PATH)/$(LOCAL_MODULE)
@@ -60,9 +65,7 @@
LOCAL_VENDOR_MODULE := true
LOCAL_REQUIRED_MODULES := \
PolicySubsystem-CommonTypes.xml \
- ProductStrategies.xml \
- PolicySubsystem-Volume.xml \
- libpolicy-subsystem \
+ ProductStrategies.xml
LOCAL_MODULE_RELATIVE_PATH := parameter-framework/Structure/Policy
LOCAL_SRC_FILES := common/Structure/$(LOCAL_MODULE)
@@ -92,7 +95,7 @@
LOCAL_MODULE_CLASS := ETC
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE_RELATIVE_PATH := parameter-framework/Structure/Policy
-LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_VENDOR_ETC)/audio_policy_engine_configuration.xml
+
AUDIO_POLICY_ENGINE_CONFIGURATION_FILE := \
$(TARGET_OUT_VENDOR_ETC)/audio_policy_engine_configuration.xml
STRATEGIES_STRUCTURE_FILE := $(LOCAL_PATH)/common/Structure/$(LOCAL_MODULE).in
@@ -105,18 +108,30 @@
ifeq ($(BUILD_AUDIO_POLICY_EXAMPLE_CONFIGURATION),$(filter $(BUILD_AUDIO_POLICY_EXAMPLE_CONFIGURATION),no-output_configurable no-input_configurable))
include $(CLEAR_VARS)
-LOCAL_MODULE := PolicySubsystem-no-strategy.xml
-LOCAL_MODULE_STEM := PolicySubsystem.xml
+LOCAL_MODULE := PolicySubsystem.xml
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := ETC
LOCAL_VENDOR_MODULE := true
-LOCAL_REQUIRED_MODULES := \
- PolicySubsystem-CommonTypes.xml \
- PolicySubsystem-Volume.xml \
- libpolicy-subsystem \
+LOCAL_REQUIRED_MODULES := PolicySubsystem-CommonTypes.xml
LOCAL_MODULE_RELATIVE_PATH := parameter-framework/Structure/Policy
-LOCAL_SRC_FILES := common/Structure/$(LOCAL_MODULE_STEM)
+LOCAL_SRC_FILES := common/Structure/$(LOCAL_MODULE)
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := ParameterFrameworkConfigurationPolicy-no-strategy.xml
+LOCAL_MODULE_STEM := ParameterFrameworkConfigurationPolicy.xml
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := ETC
+LOCAL_VENDOR_MODULE := true
+LOCAL_MODULE_RELATIVE_PATH := parameter-framework
+LOCAL_SRC_FILES := $(LOCAL_MODULE).in
+LOCAL_REQUIRED_MODULES := \
+ PolicySubsystem.xml \
+ PolicyClass.xml
+AUDIO_VALUE = false
+LOCAL_POST_INSTALL_CMD := $(hide) sed -i -e 's|$(AUDIO_PATTERN)|$(AUDIO_VALUE)|g' $(TARGET_OUT_VENDOR_ETC)/$(LOCAL_MODULE_RELATIVE_PATH)/$(LOCAL_MODULE)
+
include $(BUILD_PREBUILT)
endif # ifeq ($(BUILD_AUDIO_POLICY_EXAMPLE_CONFIGURATION),$(filter $(BUILD_AUDIO_POLICY_EXAMPLE_CONFIGURATION),no-output_configurable no-input_configurable))
@@ -130,12 +145,6 @@
LOCAL_MODULE_CLASS := ETC
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE_RELATIVE_PATH := parameter-framework/Settings/Policy
-LOCAL_REQUIRED_MODULES := \
- audio_policy_engine_criteria.xml \
- audio_policy_engine_criterion_types.xml \
- PolicySubsystem-no-strategy.xml \
- PolicyClass.xml \
- ParameterFrameworkConfigurationPolicy.xml
PFW_TOPLEVEL_FILE := $(TARGET_OUT_VENDOR_ETC)/parameter-framework/ParameterFrameworkConfigurationPolicy.xml
PFW_CRITERION_TYPES_FILE := $(TARGET_OUT_VENDOR_ETC)/audio_policy_engine_criterion_types.xml
@@ -143,9 +152,10 @@
PFW_EDD_FILES := \
$(LOCAL_PATH)/SettingsNoOutput/device_for_strategies.pfw \
$(LOCAL_PATH)/Settings/device_for_input_source.pfw \
- $(LOCAL_PATH)/Settings/volumes.pfw
-
+ $(LOCAL_PATH)/Settings/volumes.pfw
+LOCAL_REQUIRED_MODULES := libpolicy-subsystem
include $(BUILD_PFW_SETTINGS)
+
endif # ifeq ($(BUILD_AUDIO_POLICY_EXAMPLE_CONFIGURATION),no-output_configurable)
######### Policy PFW Settings - No Input #########
ifeq ($(BUILD_AUDIO_POLICY_EXAMPLE_CONFIGURATION),no-input_configurable)
@@ -156,12 +166,6 @@
LOCAL_MODULE_CLASS := ETC
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE_RELATIVE_PATH := parameter-framework/Settings/Policy
-LOCAL_REQUIRED_MODULES := \
- audio_policy_engine_criteria.xml \
- audio_policy_engine_criterion_types.xml \
- PolicySubsystem-no-strategy.xml \
- PolicyClass.xml \
- ParameterFrameworkConfigurationPolicy.xml
PFW_TOPLEVEL_FILE := $(TARGET_OUT_VENDOR_ETC)/parameter-framework/ParameterFrameworkConfigurationPolicy.xml
PFW_CRITERION_TYPES_FILE := $(TARGET_OUT_VENDOR_ETC)/audio_policy_engine_criterion_types.xml
@@ -169,7 +173,7 @@
PFW_EDD_FILES := \
$(LOCAL_PATH)/SettingsNoInput/device_for_input_source.pfw \
$(LOCAL_PATH)/Settings/volumes.pfw
-
+LOCAL_REQUIRED_MODULES := libpolicy-subsystem
include $(BUILD_PFW_SETTINGS)
endif #ifeq ($(BUILD_AUDIO_POLICY_EXAMPLE_CONFIGURATION),no-input_configurable)
@@ -179,4 +183,5 @@
include $(call all-makefiles-under,$(LOCAL_PATH))
+endif #ifdef BUILD_AUDIO_POLICY_EXAMPLE_CONFIGURATION
diff --git a/services/audiopolicy/engineconfigurable/parameter-framework/examples/Car/Android.mk b/services/audiopolicy/engineconfigurable/parameter-framework/examples/Car/Android.mk
index 20ca8e2..7304ec2 100644
--- a/services/audiopolicy/engineconfigurable/parameter-framework/examples/Car/Android.mk
+++ b/services/audiopolicy/engineconfigurable/parameter-framework/examples/Car/Android.mk
@@ -30,27 +30,16 @@
LOCAL_MODULE_CLASS := ETC
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE_RELATIVE_PATH := parameter-framework/Settings/Policy
+LOCAL_REQUIRED_MODULES := libpolicy-subsystem
PFW_EDD_FILES := \
- $(LOCAL_PATH)/Settings/device_for_product_strategies.pfw \
- $(LOCAL_PATH)/../Settings/device_for_input_source.pfw \
- $(LOCAL_PATH)/../Settings/volumes.pfw
-
-LOCAL_ADDITIONAL_DEPENDENCIES := \
- $(PFW_EDD_FILES)
-
-LOCAL_REQUIRED_MODULES := \
- PolicySubsystem.xml \
- PolicyClass.xml \
- audio_policy_engine_criteria.xml \
- audio_policy_engine_criterion_types.xml \
- ParameterFrameworkConfigurationPolicy.xml
+ $(LOCAL_PATH)/Settings/device_for_product_strategies.pfw \
+ $(LOCAL_PATH)/../Settings/device_for_input_source.pfw \
+ $(LOCAL_PATH)/../Settings/volumes.pfw
PFW_CRITERION_TYPES_FILE := $(TARGET_OUT_VENDOR_ETC)/audio_policy_engine_criterion_types.xml
PFW_CRITERIA_FILE := $(TARGET_OUT_VENDOR_ETC)/audio_policy_engine_criteria.xml
-
PFW_TOPLEVEL_FILE := $(TARGET_OUT_VENDOR_ETC)/parameter-framework/ParameterFrameworkConfigurationPolicy.xml
-
PFW_SCHEMAS_DIR := $(PFW_DEFAULT_SCHEMAS_DIR)
include $(BUILD_PFW_SETTINGS)
diff --git a/services/audiopolicy/engineconfigurable/parameter-framework/examples/CarEmu/Android.mk b/services/audiopolicy/engineconfigurable/parameter-framework/examples/CarEmu/Android.mk
index 8fa8f0a..f5eb7d1 100644
--- a/services/audiopolicy/engineconfigurable/parameter-framework/examples/CarEmu/Android.mk
+++ b/services/audiopolicy/engineconfigurable/parameter-framework/examples/CarEmu/Android.mk
@@ -30,27 +30,15 @@
LOCAL_MODULE_CLASS := ETC
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE_RELATIVE_PATH := parameter-framework/Settings/Policy
+LOCAL_REQUIRED_MODULES := libpolicy-subsystem
PFW_EDD_FILES := \
- $(LOCAL_PATH)/Settings/device_for_product_strategies.pfw \
- $(LOCAL_PATH)/../Settings/device_for_input_source.pfw \
- $(LOCAL_PATH)/../Settings/volumes.pfw
-
-LOCAL_ADDITIONAL_DEPENDENCIES := \
- $(PFW_EDD_FILES)
-
-LOCAL_REQUIRED_MODULES := \
- PolicySubsystem.xml \
- PolicyClass.xml \
- audio_policy_engine_criteria.xml \
- audio_policy_engine_criterion_types.xml \
- ParameterFrameworkConfigurationPolicy.xml
-
+ $(LOCAL_PATH)/Settings/device_for_product_strategies.pfw \
+ $(LOCAL_PATH)/../Settings/device_for_input_source.pfw \
+ $(LOCAL_PATH)/../Settings/volumes.pfw
PFW_CRITERION_TYPES_FILE := $(TARGET_OUT_VENDOR_ETC)/audio_policy_engine_criterion_types.xml
PFW_CRITERIA_FILE := $(TARGET_OUT_VENDOR_ETC)/audio_policy_engine_criteria.xml
-
PFW_TOPLEVEL_FILE := $(TARGET_OUT_VENDOR_ETC)/parameter-framework/ParameterFrameworkConfigurationPolicy.xml
-
PFW_SCHEMAS_DIR := $(PFW_DEFAULT_SCHEMAS_DIR)
include $(BUILD_PFW_SETTINGS)
diff --git a/services/audiopolicy/engineconfigurable/parameter-framework/examples/ParameterFrameworkConfigurationPolicy.xml.in b/services/audiopolicy/engineconfigurable/parameter-framework/examples/ParameterFrameworkConfigurationPolicy.xml.in
index f80a07f..1be67dd 100644
--- a/services/audiopolicy/engineconfigurable/parameter-framework/examples/ParameterFrameworkConfigurationPolicy.xml.in
+++ b/services/audiopolicy/engineconfigurable/parameter-framework/examples/ParameterFrameworkConfigurationPolicy.xml.in
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<ParameterFrameworkConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- SystemClassName="Policy" ServerPort="/dev/socket/audioserver/policy_debug"
+ SystemClassName="Policy" ServerPort="unix:///dev/socket/audioserver/policy_debug"
TuningAllowed="@TUNING_ALLOWED@">
<SubsystemPlugins>
diff --git a/services/audiopolicy/engineconfigurable/parameter-framework/examples/Phone/Android.mk b/services/audiopolicy/engineconfigurable/parameter-framework/examples/Phone/Android.mk
index d1845b8..0b20781 100644
--- a/services/audiopolicy/engineconfigurable/parameter-framework/examples/Phone/Android.mk
+++ b/services/audiopolicy/engineconfigurable/parameter-framework/examples/Phone/Android.mk
@@ -29,6 +29,7 @@
LOCAL_MODULE_CLASS := ETC
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE_RELATIVE_PATH := parameter-framework/Settings/Policy
+LOCAL_REQUIRED_MODULES := libpolicy-subsystem
PFW_EDD_FILES := \
$(LOCAL_PATH)/../Settings/device_for_input_source.pfw \
@@ -43,22 +44,9 @@
$(LOCAL_PATH)/Settings/device_for_product_strategy_transmitted_through_speaker.pfw \
$(LOCAL_PATH)/Settings/device_for_product_strategy_rerouting.pfw \
$(LOCAL_PATH)/Settings/device_for_product_strategy_patch.pfw
-
-LOCAL_ADDITIONAL_DEPENDENCIES := \
- $(PFW_EDD_FILES)
-
-LOCAL_REQUIRED_MODULES := \
- PolicySubsystem.xml \
- PolicyClass.xml \
- audio_policy_engine_criteria.xml \
- audio_policy_engine_criterion_types.xml \
- ParameterFrameworkConfigurationPolicy.xml
-
PFW_CRITERION_TYPES_FILE := $(TARGET_OUT_VENDOR_ETC)/audio_policy_engine_criterion_types.xml
PFW_CRITERIA_FILE := $(TARGET_OUT_VENDOR_ETC)/audio_policy_engine_criteria.xml
-
PFW_TOPLEVEL_FILE := $(TARGET_OUT_VENDOR_ETC)/parameter-framework/ParameterFrameworkConfigurationPolicy.xml
-
PFW_SCHEMAS_DIR := $(PFW_DEFAULT_SCHEMAS_DIR)
include $(BUILD_PFW_SETTINGS)
diff --git a/services/audiopolicy/engineconfigurable/parameter-framework/examples/common/Structure/PolicySubsystem-CommonTypes.xml b/services/audiopolicy/engineconfigurable/parameter-framework/examples/common/Structure/PolicySubsystem-CommonTypes.xml
index 56c5ed3..d17c021 100644
--- a/services/audiopolicy/engineconfigurable/parameter-framework/examples/common/Structure/PolicySubsystem-CommonTypes.xml
+++ b/services/audiopolicy/engineconfigurable/parameter-framework/examples/common/Structure/PolicySubsystem-CommonTypes.xml
@@ -74,6 +74,8 @@
<BitParameter Name="proxy" Size="1" Pos="21"/>
<BitParameter Name="usb_headset" Size="1" Pos="22"/>
<BitParameter Name="bluetooth_ble" Size="1" Pos="23"/>
+ <BitParameter Name="hdmi_arc" Size="1" Pos="24"/>
+ <BitParameter Name="echo_reference" Size="1" Pos="25"/>
<BitParameter Name="stub" Size="1" Pos="30"/>
</BitParameterBlock>
</ComponentType>
@@ -128,8 +130,10 @@
<BitParameter Name="voice_communication" Size="1" Pos="7"/>
<BitParameter Name="remote_submix" Size="1" Pos="8"/>
<BitParameter Name="unprocessed" Size="1" Pos="9"/>
- <BitParameter Name="fm_tuner" Size="1" Pos="10"/>
- <BitParameter Name="hotword" Size="1" Pos="11"/>
+ <BitParameter Name="voice_performance" Size="1" Pos="10"/>
+ <BitParameter Name="echo_reference" Size="1" Pos="11"/>
+ <BitParameter Name="fm_tuner" Size="1" Pos="12"/>
+ <BitParameter Name="hotword" Size="1" Pos="13"/>
</BitParameterBlock>
</ComponentType>
diff --git a/services/audiopolicy/engineconfigurable/parameter-framework/plugin/Android.bp b/services/audiopolicy/engineconfigurable/parameter-framework/plugin/Android.bp
new file mode 100644
index 0000000..2685c6d
--- /dev/null
+++ b/services/audiopolicy/engineconfigurable/parameter-framework/plugin/Android.bp
@@ -0,0 +1,36 @@
+cc_library_shared {
+ name: "libpolicy-subsystem",
+ srcs: [
+ "PolicySubsystemBuilder.cpp",
+ "PolicySubsystem.cpp",
+ "InputSource.cpp",
+ "Stream.cpp",
+ "ProductStrategy.cpp",
+ ],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wextra",
+ "-fvisibility-inlines-hidden",
+ "-fvisibility=hidden",
+ ],
+ header_libs: [
+ "libbase_headers",
+ "libaudiopolicycommon",
+ "libaudioclient_headers",
+ "libaudiopolicyengine_interface_headers",
+ "libaudiopolicyengineconfigurable_interface_headers",
+ ],
+ static_libs: [
+ "libaudiopolicycomponents",
+ "libaudiopolicyengine_common",
+ "libpfw_utility",
+ ],
+ shared_libs: [
+ "libaudiopolicyengineconfigurable",
+ "liblog",
+ "libutils",
+ "libmedia_helper",
+ "libparameter"
+ ],
+}
diff --git a/services/audiopolicy/engineconfigurable/parameter-framework/plugin/Android.mk b/services/audiopolicy/engineconfigurable/parameter-framework/plugin/Android.mk
deleted file mode 100644
index 4706d7d..0000000
--- a/services/audiopolicy/engineconfigurable/parameter-framework/plugin/Android.mk
+++ /dev/null
@@ -1,48 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-ifneq ($(USE_CUSTOM_PARAMETER_FRAMEWORK), true)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := \
- PolicySubsystemBuilder.cpp \
- PolicySubsystem.cpp \
- InputSource.cpp \
- Stream.cpp \
- ProductStrategy.cpp
-
-LOCAL_CFLAGS += \
- -Wall \
- -Werror \
- -Wextra \
- -fvisibility-inlines-hidden \
- -fvisibility=hidden
-
-LOCAL_C_INCLUDES := \
- frameworks/av/services/audiopolicy/engineconfigurable/include \
- frameworks/av/services/audiopolicy/engineconfigurable/interface
-
-LOCAL_SHARED_LIBRARIES := \
- libaudiopolicyengineconfigurable \
- libparameter \
- libmedia_helper \
- liblog \
-
-LOCAL_HEADER_LIBRARIES := \
- libaudiopolicycommon \
- libaudioclient_headers \
- libbase_headers
-
-LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
-
-LOCAL_STATIC_LIBRARIES := \
- libpfw_utility \
- libaudiopolicycomponents
-
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := libpolicy-subsystem
-
-include $(BUILD_SHARED_LIBRARY)
-
-endif # ifneq ($(USE_CUSTOM_PARAMETER_FRAMEWORK), true)
diff --git a/services/audiopolicy/engineconfigurable/tools/buildPolicyCriterionTypes.py b/services/audiopolicy/engineconfigurable/tools/buildPolicyCriterionTypes.py
index 0fb70a6..a63c858 100755
--- a/services/audiopolicy/engineconfigurable/tools/buildPolicyCriterionTypes.py
+++ b/services/audiopolicy/engineconfigurable/tools/buildPolicyCriterionTypes.py
@@ -101,8 +101,16 @@
for criterion_name, values_list in addressCriteria.items():
for criterion_type in criterion_types_root.findall('criterion_type'):
if criterion_type.get('name') == criterion_name:
- values_node = ET.SubElement(criterion_type, "values")
index = 0
+ existing_values_node = criterion_type.find("values")
+ if existing_values_node is not None:
+ for existing_value in existing_values_node.findall('value'):
+ if existing_value.get('numerical') == str(1 << index):
+ index += 1
+ values_node = existing_values_node
+ else:
+ values_node = ET.SubElement(criterion_type, "values")
+
for value in values_list:
value_node = ET.SubElement(values_node, "value", literal=value)
value_node.set('numerical', str(1 << index))
@@ -240,4 +248,4 @@
# If this file is directly executed
if __name__ == "__main__":
- exit(main())
+ sys.exit(main())
diff --git a/services/audiopolicy/engineconfigurable/tools/buildStrategiesStructureFile.py b/services/audiopolicy/engineconfigurable/tools/buildStrategiesStructureFile.py
index ee70b26..af40602 100755
--- a/services/audiopolicy/engineconfigurable/tools/buildStrategiesStructureFile.py
+++ b/services/audiopolicy/engineconfigurable/tools/buildStrategiesStructureFile.py
@@ -136,4 +136,4 @@
# If this file is directly executed
if __name__ == "__main__":
- exit(main())
+ sys.exit(main())
diff --git a/services/audiopolicy/engineconfigurable/tools/build_audio_pfw_settings.mk b/services/audiopolicy/engineconfigurable/tools/build_audio_pfw_settings.mk
index 2b86469..ac60ef7 100644
--- a/services/audiopolicy/engineconfigurable/tools/build_audio_pfw_settings.mk
+++ b/services/audiopolicy/engineconfigurable/tools/build_audio_pfw_settings.mk
@@ -1,10 +1,13 @@
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_TAGS := optional
+LOCAL_ADDITIONAL_DEPENDENCIES += \
+ $(HOST_OUT_EXECUTABLES)/domainGeneratorPolicy.py \
+ $(PFW_TOPLEVEL_FILE) $(PFW_CRITERIA_FILE) $(PFW_CRITERION_TYPES_FILE)
include $(BUILD_SYSTEM)/base_rules.mk
$(LOCAL_BUILT_MODULE): MY_CRITERION_TYPES_FILE := $(PFW_CRITERION_TYPES_FILE)
-$(LOCAL_BUILT_MODULE): MY_TOOL := domainGeneratorPolicy.py
+$(LOCAL_BUILT_MODULE): MY_TOOL := $(HOST_OUT_EXECUTABLES)/domainGeneratorPolicy.py
$(LOCAL_BUILT_MODULE): MY_TOPLEVEL_FILE := $(PFW_TOPLEVEL_FILE)
$(LOCAL_BUILT_MODULE): MY_CRITERIA_FILE := $(PFW_CRITERIA_FILE)
$(LOCAL_BUILT_MODULE): MY_TUNING_FILE := $(PFW_TUNING_FILE)
@@ -12,7 +15,7 @@
$(LOCAL_BUILT_MODULE): MY_DOMAIN_FILES := $(PFW_DOMAIN_FILES)
$(LOCAL_BUILT_MODULE): MY_SCHEMAS_DIR := $(PFW_SCHEMAS_DIR)
$(LOCAL_BUILT_MODULE): MY_CRITERION_TYPES_FILE := $(PFW_CRITERION_TYPES_FILE)
-$(LOCAL_BUILT_MODULE): $(LOCAL_REQUIRED_MODULES) $(LOCAL_ADDITIONAL_DEPENDENCIES) domainGeneratorPolicy.py
+$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES)
"$(MY_TOOL)" --validate \
--toplevel-config "$(MY_TOPLEVEL_FILE)" \
diff --git a/services/audiopolicy/engineconfigurable/tools/domainGeneratorPolicy.py b/services/audiopolicy/engineconfigurable/tools/domainGeneratorPolicy.py
index 7929402..4dec9a2 100755
--- a/services/audiopolicy/engineconfigurable/tools/domainGeneratorPolicy.py
+++ b/services/audiopolicy/engineconfigurable/tools/domainGeneratorPolicy.py
@@ -129,7 +129,7 @@
criterion_values = []
values_node = criterion_types.find('values')
- if values_node:
+ if values_node is not None:
for value in values_node.findall('value'):
criterion_values.append(value.get('literal'))
@@ -265,4 +265,4 @@
# If this file is directly executed
if __name__ == "__main__":
- exit(main())
+ sys.exit(main())
diff --git a/services/audiopolicy/engineconfigurable/tools/provision_criterion_types_from_android_headers.mk b/services/audiopolicy/engineconfigurable/tools/provision_criterion_types_from_android_headers.mk
index eebdfd6..dab5a0f 100644
--- a/services/audiopolicy/engineconfigurable/tools/provision_criterion_types_from_android_headers.mk
+++ b/services/audiopolicy/engineconfigurable/tools/provision_criterion_types_from_android_headers.mk
@@ -1,15 +1,17 @@
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_TAGS := optional
+LOCAL_ADDITIONAL_DEPENDENCIES += \
+ $(HOST_OUT_EXECUTABLES)/buildPolicyCriterionTypes.py \
+ $(CRITERION_TYPES_FILE) $(AUDIO_POLICY_CONFIGURATION_FILE) \
+ $(ANDROID_AUDIO_BASE_HEADER_FILE)
include $(BUILD_SYSTEM)/base_rules.mk
$(LOCAL_BUILT_MODULE): MY_CRITERION_TYPES_FILE := $(CRITERION_TYPES_FILE)
$(LOCAL_BUILT_MODULE): MY_ANDROID_AUDIO_BASE_HEADER_FILE := $(ANDROID_AUDIO_BASE_HEADER_FILE)
$(LOCAL_BUILT_MODULE): MY_AUDIO_POLICY_CONFIGURATION_FILE := $(AUDIO_POLICY_CONFIGURATION_FILE)
-$(LOCAL_BUILT_MODULE): MY_CRITERION_TOOL := $(HOST_OUT)/bin/buildPolicyCriterionTypes.py
-$(LOCAL_BUILT_MODULE): $(LOCAL_REQUIRED_MODULES) $(LOCAL_ADDITIONAL_DEPENDENCIES) \
- $(CRITERION_TYPES_FILE) \
- $(ANDROID_AUDIO_BASE_HEADER_FILE)
+$(LOCAL_BUILT_MODULE): MY_CRITERION_TOOL := $(HOST_OUT_EXECUTABLES)/buildPolicyCriterionTypes.py
+$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES)
"$(MY_CRITERION_TOOL)" \
--androidaudiobaseheader "$(MY_ANDROID_AUDIO_BASE_HEADER_FILE)" \
diff --git a/services/audiopolicy/engineconfigurable/tools/provision_strategies_structure.mk b/services/audiopolicy/engineconfigurable/tools/provision_strategies_structure.mk
index 72c938c..f2b1a19 100644
--- a/services/audiopolicy/engineconfigurable/tools/provision_strategies_structure.mk
+++ b/services/audiopolicy/engineconfigurable/tools/provision_strategies_structure.mk
@@ -1,15 +1,15 @@
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_TAGS := optional
+LOCAL_ADDITIONAL_DEPENDENCIES += \
+ $(HOST_OUT_EXECUTABLES)/buildStrategiesStructureFile.py \
+ $(STRATEGIES_STRUCTURE_FILE) $(AUDIO_POLICY_ENGINE_CONFIGURATION_FILE)
include $(BUILD_SYSTEM)/base_rules.mk
$(LOCAL_BUILT_MODULE): MY_STRATEGIES_STRUCTURE_FILE := $(STRATEGIES_STRUCTURE_FILE)
$(LOCAL_BUILT_MODULE): MY_AUDIO_POLICY_ENGINE_CONFIGURATION_FILE := $(AUDIO_POLICY_ENGINE_CONFIGURATION_FILE)
-$(LOCAL_BUILT_MODULE): MY_PROVISION_TOOL := $(HOST_OUT)/bin/buildStrategiesStructureFile.py
-$(LOCAL_BUILT_MODULE): $(LOCAL_REQUIRED_MODULES) $(LOCAL_ADDITIONAL_DEPENDENCIES) \
- buildStrategiesStructureFile.py \
- $(STRATEGIES_STRUCTURE_FILE) \
- $(AUDIO_POLICY_ENGINE_CONFIGURATION_FILE)
+$(LOCAL_BUILT_MODULE): MY_PROVISION_TOOL := $(HOST_OUT_EXECUTABLES)/buildStrategiesStructureFile.py
+$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES)
"$(MY_PROVISION_TOOL)" \
--audiopolicyengineconfigurationfile "$(MY_AUDIO_POLICY_ENGINE_CONFIGURATION_FILE)" \
diff --git a/services/audiopolicy/engineconfigurable/wrapper/Android.bp b/services/audiopolicy/engineconfigurable/wrapper/Android.bp
new file mode 100644
index 0000000..6f59487
--- /dev/null
+++ b/services/audiopolicy/engineconfigurable/wrapper/Android.bp
@@ -0,0 +1,21 @@
+cc_library {
+ name: "libaudiopolicyengineconfigurable_pfwwrapper",
+ export_include_dirs: ["include"],
+ srcs: ["ParameterManagerWrapper.cpp"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wextra",
+ ],
+ header_libs: [
+ "libbase_headers",
+ "libaudiopolicycommon",
+ ],
+ static_libs: ["libaudiopolicycomponents"],
+ shared_libs: [
+ "liblog",
+ "libutils",
+ "libmedia_helper",
+ "libparameter",
+ ],
+}
diff --git a/services/audiopolicy/engineconfigurable/wrapper/Android.mk b/services/audiopolicy/engineconfigurable/wrapper/Android.mk
deleted file mode 100644
index c7d8d34..0000000
--- a/services/audiopolicy/engineconfigurable/wrapper/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-##################################################################
-# WRAPPER LIBRARY
-##################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/include \
- frameworks/av/services/audiopolicy/engineconfigurable/include \
- frameworks/av/services/audiopolicy/engineconfigurable/interface \
- external/libxml2/include \
- external/icu/icu4c/source/common
-
-LOCAL_SRC_FILES:= \
- ParameterManagerWrapper.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libparameter \
- libmedia_helper \
- libxml2
-
-LOCAL_HEADER_LIBRARIES := \
- libaudiopolicycommon
-
-LOCAL_STATIC_LIBRARIES := \
- libaudiopolicycomponents
-
-LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
-
-LOCAL_MODULE:= libaudiopolicypfwwrapper
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
-
-LOCAL_MODULE_TAGS := optional
-LOCAL_CFLAGS := -Wall -Werror -Wextra
-
-include $(BUILD_STATIC_LIBRARY)
-
diff --git a/services/audiopolicy/enginedefault/config/Android.mk b/services/audiopolicy/enginedefault/config/Android.mk
deleted file mode 100644
index dcce8e3..0000000
--- a/services/audiopolicy/enginedefault/config/Android.mk
+++ /dev/null
@@ -1,9 +0,0 @@
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-#######################################################################
-# Recursive call sub-folder Android.mk
-#
-include $(call all-makefiles-under,$(LOCAL_PATH))
-
diff --git a/services/audiopolicy/manager/Android.mk b/services/audiopolicy/manager/Android.mk
new file mode 100644
index 0000000..d6ca2f2
--- /dev/null
+++ b/services/audiopolicy/manager/Android.mk
@@ -0,0 +1,32 @@
+LOCAL_PATH:= $(call my-dir)
+
+ifneq ($(USE_CUSTOM_AUDIO_POLICY), 1)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ AudioPolicyFactory.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+ libaudiopolicymanagerdefault
+
+LOCAL_STATIC_LIBRARIES := \
+ libaudiopolicycomponents
+
+LOCAL_C_INCLUDES += \
+ $(call include-path-for, audio-utils)
+
+LOCAL_HEADER_LIBRARIES := \
+ libaudiopolicycommon \
+ libaudiopolicyengine_interface_headers \
+ libaudiopolicymanager_interface_headers
+
+LOCAL_CFLAGS := -Wall -Werror
+
+LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
+
+LOCAL_MODULE:= libaudiopolicymanager
+
+include $(BUILD_SHARED_LIBRARY)
+
+endif #ifneq ($(USE_CUSTOM_AUDIO_POLICY), 1)
diff --git a/services/audiopolicy/manager/AudioPolicyFactory.cpp b/services/audiopolicy/manager/AudioPolicyFactory.cpp
index 3efa1b0..7aff6a9 100644
--- a/services/audiopolicy/manager/AudioPolicyFactory.cpp
+++ b/services/audiopolicy/manager/AudioPolicyFactory.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "managerdefault/AudioPolicyManager.h"
+#include <AudioPolicyManager.h>
namespace android {
diff --git a/services/audiopolicy/managerdefault/Android.mk b/services/audiopolicy/managerdefault/Android.mk
new file mode 100644
index 0000000..684fc9f
--- /dev/null
+++ b/services/audiopolicy/managerdefault/Android.mk
@@ -0,0 +1,56 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= AudioPolicyManager.cpp
+
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils \
+ libutils \
+ liblog \
+ libaudiopolicy \
+ libsoundtrigger
+
+ifeq ($(USE_CONFIGURABLE_AUDIO_POLICY), 1)
+
+ifneq ($(USE_XML_AUDIO_POLICY_CONF), 1)
+$(error Configurable policy does not support legacy conf file)
+endif #ifneq ($(USE_XML_AUDIO_POLICY_CONF), 1)
+
+LOCAL_SHARED_LIBRARIES += libaudiopolicyengineconfigurable
+
+else
+
+LOCAL_SHARED_LIBRARIES += libaudiopolicyenginedefault
+
+endif # ifeq ($(USE_CONFIGURABLE_AUDIO_POLICY), 1)
+
+LOCAL_C_INCLUDES += \
+ $(call include-path-for, audio-utils)
+
+LOCAL_HEADER_LIBRARIES := \
+ libaudiopolicycommon \
+ libaudiopolicyengine_interface_headers \
+ libaudiopolicymanager_interface_headers
+
+LOCAL_STATIC_LIBRARIES := \
+ libaudiopolicycomponents
+
+LOCAL_SHARED_LIBRARIES += libmedia_helper
+LOCAL_SHARED_LIBRARIES += libmediametrics
+
+LOCAL_SHARED_LIBRARIES += libbinder libhidlbase libxml2
+
+ifeq ($(USE_XML_AUDIO_POLICY_CONF), 1)
+LOCAL_CFLAGS += -DUSE_XML_AUDIO_POLICY_CONF
+endif #ifeq ($(USE_XML_AUDIO_POLICY_CONF), 1)
+
+LOCAL_CFLAGS += -Wall -Werror
+
+LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
+
+LOCAL_MODULE:= libaudiopolicymanagerdefault
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 7011ef7..c0ca440 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -1884,6 +1884,7 @@
status_t AudioPolicyManager::getInputForAttr(const audio_attributes_t *attr,
audio_io_handle_t *input,
+ audio_unique_id_t riid,
audio_session_t session,
uid_t uid,
const audio_config_base_t *config,
@@ -2027,7 +2028,7 @@
mSoundTriggerSessions.indexOfKey(session) > 0;
*portId = AudioPort::getNextUniqueId();
- clientDesc = new RecordClientDescriptor(*portId, uid, session, attributes, *config,
+ clientDesc = new RecordClientDescriptor(*portId, riid, uid, session, attributes, *config,
requestedDeviceId, attributes.source, flags,
isSoundTrigger);
inputDesc = mInputs.valueFor(*input);
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index 8ca06e7..612bd8f 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -128,6 +128,7 @@
virtual void releaseOutput(audio_port_handle_t portId);
virtual status_t getInputForAttr(const audio_attributes_t *attr,
audio_io_handle_t *input,
+ audio_unique_id_t riid,
audio_session_t session,
uid_t uid,
const audio_config_base_t *config,
diff --git a/services/audiopolicy/service/Android.mk b/services/audiopolicy/service/Android.mk
new file mode 100644
index 0000000..c4f4c56
--- /dev/null
+++ b/services/audiopolicy/service/Android.mk
@@ -0,0 +1,49 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ AudioPolicyService.cpp \
+ AudioPolicyEffects.cpp \
+ AudioPolicyInterfaceImpl.cpp \
+ AudioPolicyClientImpl.cpp
+
+LOCAL_C_INCLUDES := \
+ frameworks/av/services/audioflinger \
+ $(call include-path-for, audio-utils)
+
+LOCAL_HEADER_LIBRARIES := \
+ libaudiopolicycommon \
+ libaudiopolicyengine_interface_headers \
+ libaudiopolicymanager_interface_headers
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils \
+ libutils \
+ liblog \
+ libbinder \
+ libaudioclient \
+ libaudioutils \
+ libhardware_legacy \
+ libaudiopolicymanager \
+ libmedia_helper \
+ libmediametrics \
+ libmediautils \
+ libeffectsconfig \
+ libsensorprivacy
+
+LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := \
+ libsensorprivacy
+
+LOCAL_STATIC_LIBRARIES := \
+ libaudiopolicycomponents
+
+LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
+
+LOCAL_MODULE:= libaudiopolicyservice
+
+LOCAL_CFLAGS += -fvisibility=hidden
+LOCAL_CFLAGS += -Wall -Werror
+
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
index 2e47eb6..06e68a9 100644
--- a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
+++ b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
@@ -334,6 +334,7 @@
status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr,
audio_io_handle_t *input,
+ audio_unique_id_t riid,
audio_session_t session,
pid_t pid,
uid_t uid,
@@ -403,7 +404,7 @@
{
AutoCallerClear acc;
// the audio_in_acoustics_t parameter is ignored by get_input()
- status = mAudioPolicyManager->getInputForAttr(attr, input, session, uid,
+ status = mAudioPolicyManager->getInputForAttr(attr, input, riid, session, uid,
config,
flags, selectedDeviceId,
&inputType, portId);
diff --git a/services/audiopolicy/service/AudioPolicyService.h b/services/audiopolicy/service/AudioPolicyService.h
index 6c19912..58256f7 100644
--- a/services/audiopolicy/service/AudioPolicyService.h
+++ b/services/audiopolicy/service/AudioPolicyService.h
@@ -33,7 +33,7 @@
#include <media/AudioPolicy.h>
#include <mediautils/ServiceUtilities.h>
#include "AudioPolicyEffects.h"
-#include "managerdefault/AudioPolicyManager.h"
+#include <AudioPolicyInterface.h>
#include <android/hardware/BnSensorPrivacyListener.h>
#include <unordered_map>
@@ -91,6 +91,7 @@
virtual void releaseOutput(audio_port_handle_t portId);
virtual status_t getInputForAttr(const audio_attributes_t *attr,
audio_io_handle_t *input,
+ audio_unique_id_t riid,
audio_session_t session,
pid_t pid,
uid_t uid,
diff --git a/services/audiopolicy/tests/Android.mk b/services/audiopolicy/tests/Android.mk
index 97be44c..ab9f78b 100644
--- a/services/audiopolicy/tests/Android.mk
+++ b/services/audiopolicy/tests/Android.mk
@@ -18,7 +18,8 @@
LOCAL_HEADER_LIBRARIES := \
libaudiopolicycommon \
- libaudiopolicyengine_interface_headers
+ libaudiopolicyengine_interface_headers \
+ libaudiopolicymanager_interface_headers
LOCAL_SRC_FILES := \
audiopolicymanager_tests.cpp \
diff --git a/services/camera/libcameraservice/utils/LatencyHistogram.cpp b/services/camera/libcameraservice/utils/LatencyHistogram.cpp
index 538bb6e..e2bdc43 100644
--- a/services/camera/libcameraservice/utils/LatencyHistogram.cpp
+++ b/services/camera/libcameraservice/utils/LatencyHistogram.cpp
@@ -46,7 +46,7 @@
}
void CameraLatencyHistogram::reset() {
- mBins.clear();
+ memset(mBins.data(), 0, mBins.size() * sizeof(int64_t));
mTotalCount = 0;
}
diff --git a/services/oboeservice/AAudioServiceEndpointMMAP.cpp b/services/oboeservice/AAudioServiceEndpointMMAP.cpp
index 447f32c..b05baa4 100644
--- a/services/oboeservice/AAudioServiceEndpointMMAP.cpp
+++ b/services/oboeservice/AAudioServiceEndpointMMAP.cpp
@@ -77,9 +77,6 @@
audio_config_base_t config;
audio_port_handle_t deviceId;
- int32_t burstMinMicros = AAudioProperty_getHardwareBurstMinMicros();
- int32_t burstMicros = 0;
-
copyFrom(request.getConstantConfiguration());
aaudio_direction_t direction = getDirection();
@@ -235,24 +232,12 @@
setFormat(config.format);
setSampleRate(config.sample_rate);
- // Scale up the burst size to meet the minimum equivalent in microseconds.
- // This is to avoid waking the CPU too often when the HW burst is very small
- // or at high sample rates.
- do {
- if (burstMicros > 0) { // skip first loop
- mFramesPerBurst *= 2;
- }
- burstMicros = mFramesPerBurst * static_cast<int64_t>(1000000) / getSampleRate();
- } while (burstMicros < burstMinMicros);
+ ALOGD("%s() actual rate = %d, channels = %d"
+ ", deviceId = %d, capacity = %d\n",
+ __func__, getSampleRate(), getSamplesPerFrame(), deviceId, getBufferCapacity());
- ALOGD("%s() original burst = %d, minMicros = %d => burst = %d\n",
- __func__, mMmapBufferinfo.burst_size_frames, burstMinMicros, mFramesPerBurst);
-
- ALOGD("%s() actual rate = %d, channels = %d, deviceId = %d\n",
- __func__, getSampleRate(), getSamplesPerFrame(), deviceId);
-
- ALOGD("%s() format = 0x%08x, frame size = %d",
- __func__, getFormat(), calculateBytesPerFrame());
+ ALOGD("%s() format = 0x%08x, frame size = %d, burst size = %d",
+ __func__, getFormat(), calculateBytesPerFrame(), mFramesPerBurst);
return result;