Merge changes from topic "appops_native_foreground_mode_changes" into udc-dev
* changes:
Correct attribution source for MMAP thread
Listen for foreground AppOps changes
diff --git a/camera/CameraSessionStats.cpp b/camera/CameraSessionStats.cpp
index 26c612a..3954db5 100644
--- a/camera/CameraSessionStats.cpp
+++ b/camera/CameraSessionStats.cpp
@@ -278,7 +278,8 @@
mRequestCount(0),
mResultErrorCount(0),
mDeviceError(false),
- mVideoStabilizationMode(-1) {}
+ mVideoStabilizationMode(-1),
+ mSessionIndex(0) {}
CameraSessionStats::CameraSessionStats(const String16& cameraId,
int facing, int newCameraState, const String16& clientName,
@@ -297,7 +298,8 @@
mRequestCount(0),
mResultErrorCount(0),
mDeviceError(0),
- mVideoStabilizationMode(-1) {}
+ mVideoStabilizationMode(-1),
+ mSessionIndex(0) {}
status_t CameraSessionStats::readFromParcel(const android::Parcel* parcel) {
if (parcel == NULL) {
@@ -409,6 +411,12 @@
return err;
}
+ int32_t sessionIdx;
+ if ((err = parcel->readInt32(&sessionIdx)) != OK) {
+ ALOGE("%s: Failed to read session index from parcel", __FUNCTION__);
+ return err;
+ }
+
mCameraId = id;
mFacing = facing;
mNewCameraState = newCameraState;
@@ -426,6 +434,7 @@
mStreamStats = std::move(streamStats);
mUserTag = userTag;
mVideoStabilizationMode = videoStabilizationMode;
+ mSessionIndex = sessionIdx;
return OK;
}
@@ -523,6 +532,11 @@
return err;
}
+ if ((err = parcel->writeInt32(mSessionIndex)) != OK) {
+ ALOGE("%s: Failed to write session index!", __FUNCTION__);
+ return err;
+ }
+
return OK;
}
diff --git a/camera/include/camera/CameraSessionStats.h b/camera/include/camera/CameraSessionStats.h
index 091a7ff..895449c 100644
--- a/camera/include/camera/CameraSessionStats.h
+++ b/camera/include/camera/CameraSessionStats.h
@@ -158,6 +158,7 @@
std::vector<CameraStreamStats> mStreamStats;
String16 mUserTag;
int mVideoStabilizationMode;
+ int mSessionIndex;
// Constructors
CameraSessionStats();
diff --git a/media/codec2/components/aom/C2SoftAomEnc.cpp b/media/codec2/components/aom/C2SoftAomEnc.cpp
index 59cad9d..e8b0506 100644
--- a/media/codec2/components/aom/C2SoftAomEnc.cpp
+++ b/media/codec2/components/aom/C2SoftAomEnc.cpp
@@ -542,15 +542,15 @@
mCodecConfiguration->kf_max_dist = 3000;
// Encoder determines optimal key frame placement automatically.
mCodecConfiguration->kf_mode = AOM_KF_AUTO;
- // Initial value of the buffer level in ms.
- mCodecConfiguration->rc_buf_initial_sz = 500;
- // Amount of data that the encoder should try to maintain in ms.
- mCodecConfiguration->rc_buf_optimal_sz = 600;
// The amount of data that may be buffered by the decoding
// application in ms.
mCodecConfiguration->rc_buf_sz = 1000;
if (mBitrateControlMode == AOM_CBR) {
+ // Initial value of the buffer level in ms.
+ mCodecConfiguration->rc_buf_initial_sz = 500;
+ // Amount of data that the encoder should try to maintain in ms.
+ mCodecConfiguration->rc_buf_optimal_sz = 600;
// Maximum amount of bits that can be subtracted from the target
// bitrate - expressed as percentage of the target bitrate.
mCodecConfiguration->rc_undershoot_pct = 100;
@@ -563,7 +563,7 @@
mCodecConfiguration->rc_undershoot_pct = 100;
// Maximum amount of bits that can be added to the target
// bitrate - expressed as percentage of the target bitrate.
- mCodecConfiguration->rc_overshoot_pct = 25;
+ mCodecConfiguration->rc_overshoot_pct = 100;
}
if (mIntf->getSyncFramePeriod() >= 0) {
@@ -576,6 +576,12 @@
}
if (mMaxQuantizer > 0) {
mCodecConfiguration->rc_max_quantizer = mMaxQuantizer;
+ } else {
+ if (mBitrateControlMode == AOM_VBR) {
+ // For VBR we are limiting MaxQP to 52 (down 11 steps) to maintain quality
+ // 52 comes from experiments done on libaom standalone app
+ mCodecConfiguration->rc_max_quantizer = 52;
+ }
}
mCodecContext = new aom_codec_ctx_t;
diff --git a/media/codec2/hal/client/client.cpp b/media/codec2/hal/client/client.cpp
index 9359e29..829a179 100644
--- a/media/codec2/hal/client/client.cpp
+++ b/media/codec2/hal/client/client.cpp
@@ -1523,8 +1523,8 @@
uint64_t consumerUsage = kDefaultConsumerUsage;
{
if (surface) {
- int usage = 0;
- status_t err = surface->query(NATIVE_WINDOW_CONSUMER_USAGE_BITS, &usage);
+ uint64_t usage = 0;
+ status_t err = surface->getConsumerUsage(&usage);
if (err != NO_ERROR) {
ALOGD("setOutputSurface -- failed to get consumer usage bits (%d/%s). ignoring",
err, asString(err));
@@ -1537,8 +1537,7 @@
// they do not exist inside of C2 scope. Any buffer usage shall be communicated
// through the sideband channel.
- // do an unsigned conversion as bit-31 may be 1
- consumerUsage = (uint32_t)usage | kDefaultConsumerUsage;
+ consumerUsage = usage | kDefaultConsumerUsage;
}
}
@@ -1562,6 +1561,8 @@
static_cast<uint64_t>(blockPoolId),
bqId == 0 ? nullHgbp : igbp);
+ mOutputBufferQueue->expireOldWaiters();
+
if (!transStatus.isOk()) {
LOG(ERROR) << "setOutputSurface -- transaction failed.";
return C2_TRANSACTION_FAILED;
@@ -1607,6 +1608,7 @@
<< status << ".";
}
}
+ mOutputBufferQueue->expireOldWaiters();
}
c2_status_t Codec2Client::Component::connectToInputSurface(
diff --git a/media/codec2/hal/client/include/codec2/hidl/output.h b/media/codec2/hal/client/include/codec2/hidl/output.h
index 35a0224..2e89c3b 100644
--- a/media/codec2/hal/client/include/codec2/hidl/output.h
+++ b/media/codec2/hal/client/include/codec2/hidl/output.h
@@ -51,6 +51,10 @@
int maxDequeueBufferCount,
std::shared_ptr<V1_2::SurfaceSyncObj> *syncObj);
+ // If there are waiters to allocate from the old surface, wake up and expire
+ // them.
+ void expireOldWaiters();
+
// Stop using the current output surface. Pending buffer opeations will not
// perform anymore.
void stop();
@@ -90,6 +94,8 @@
std::weak_ptr<_C2BlockPoolData> mPoolDatas[BufferQueueDefs::NUM_BUFFER_SLOTS];
std::shared_ptr<C2SurfaceSyncMemory> mSyncMem;
bool mStopped;
+ std::mutex mOldMutex;
+ std::shared_ptr<C2SurfaceSyncMemory> mOldMem;
bool registerBuffer(const C2ConstGraphicBlock& block);
};
diff --git a/media/codec2/hal/client/output.cpp b/media/codec2/hal/client/output.cpp
index ce706cc..4eebd1c 100644
--- a/media/codec2/hal/client/output.cpp
+++ b/media/codec2/hal/client/output.cpp
@@ -217,6 +217,7 @@
sp<GraphicBuffer> buffers[BufferQueueDefs::NUM_BUFFER_SLOTS];
std::weak_ptr<_C2BlockPoolData>
poolDatas[BufferQueueDefs::NUM_BUFFER_SLOTS];
+ std::shared_ptr<C2SurfaceSyncMemory> oldMem;
{
std::scoped_lock<std::mutex> l(mMutex);
bool stopped = mStopped;
@@ -238,7 +239,7 @@
}
return false;
}
- std::shared_ptr<C2SurfaceSyncMemory> oldMem = mSyncMem;
+ oldMem = mSyncMem;
C2SyncVariables *oldSync = mSyncMem ? mSyncMem->mem() : nullptr;
if (oldSync) {
oldSync->lock();
@@ -314,11 +315,26 @@
newSync->unlock();
}
}
+ {
+ std::scoped_lock<std::mutex> l(mOldMutex);
+ mOldMem = oldMem;
+ }
ALOGD("remote graphic buffer migration %zu/%zu",
success, tryNum);
return true;
}
+void OutputBufferQueue::expireOldWaiters() {
+ std::scoped_lock<std::mutex> l(mOldMutex);
+ if (mOldMem) {
+ C2SyncVariables *oldSync = mOldMem->mem();
+ if (oldSync) {
+ oldSync->notifyAll();
+ }
+ mOldMem.reset();
+ }
+}
+
void OutputBufferQueue::stop() {
std::scoped_lock<std::mutex> l(mMutex);
mStopped = true;
diff --git a/media/codec2/hal/plugin/samples/SampleFilterPlugin.cpp b/media/codec2/hal/plugin/samples/SampleFilterPlugin.cpp
index c77eb22..b5383ad 100644
--- a/media/codec2/hal/plugin/samples/SampleFilterPlugin.cpp
+++ b/media/codec2/hal/plugin/samples/SampleFilterPlugin.cpp
@@ -710,10 +710,6 @@
layerSettings.source.buffer.fence = Fence::NO_FENCE;
layerSettings.source.buffer.textureName = textureName;
layerSettings.source.buffer.usePremultipliedAlpha = false;
- layerSettings.source.buffer.isY410BT2020 =
- (layerSettings.sourceDataspace == ui::Dataspace::BT2020_ITU_PQ ||
- layerSettings.sourceDataspace == ui::Dataspace::BT2020_ITU_HLG) &&
- format == HAL_PIXEL_FORMAT_RGBA_1010102;
layerSettings.source.buffer.maxMasteringLuminance =
(hdrStaticInfo && *hdrStaticInfo &&
hdrStaticInfo->mastering.maxLuminance > 0 &&
diff --git a/media/codec2/sfplugin/CCodecBufferChannel.cpp b/media/codec2/sfplugin/CCodecBufferChannel.cpp
index da33b0d..1c86ba9 100644
--- a/media/codec2/sfplugin/CCodecBufferChannel.cpp
+++ b/media/codec2/sfplugin/CCodecBufferChannel.cpp
@@ -1801,8 +1801,6 @@
output->buffers->flushStash();
}
}
- // reset the frames that are being tracked for onFrameRendered callbacks
- mTrackedFrames.clear();
}
void CCodecBufferChannel::onWorkDone(
@@ -2113,7 +2111,10 @@
outBuffer->meta()->setInt32("flags", BUFFER_FLAG_CODEC_CONFIG);
ALOGV("[%s] onWorkDone: csd index = %zu [%p]", mName, index, outBuffer.get());
- output.unlock();
+ // TRICKY: we want popped buffers reported in order, so sending
+ // the callback while holding the lock here. This assumes that
+ // onOutputBufferAvailable() does not block. onOutputBufferAvailable()
+ // callbacks are always sent with the Output lock held.
mCallback->onOutputBufferAvailable(index, outBuffer);
} else {
ALOGD("[%s] onWorkDone: unable to register csd", mName);
@@ -2203,7 +2204,10 @@
case OutputBuffers::DISCARD:
break;
case OutputBuffers::NOTIFY_CLIENT:
- output.unlock();
+ // TRICKY: we want popped buffers reported in order, so sending
+ // the callback while holding the lock here. This assumes that
+ // onOutputBufferAvailable() does not block. onOutputBufferAvailable()
+ // callbacks are always sent with the Output lock held.
mCallback->onOutputBufferAvailable(index, outBuffer);
break;
case OutputBuffers::REALLOCATE:
diff --git a/media/libaudiohal/impl/ConversionHelperAidl.h b/media/libaudiohal/impl/ConversionHelperAidl.h
index db6b6cf..5534d13 100644
--- a/media/libaudiohal/impl/ConversionHelperAidl.h
+++ b/media/libaudiohal/impl/ConversionHelperAidl.h
@@ -20,6 +20,9 @@
#include <string_view>
#include <vector>
+#include <android-base/expected.h>
+#include <error/Result.h>
+#include <media/AudioParameter.h>
#include <utils/String16.h>
#include <utils/Vector.h>
@@ -51,4 +54,24 @@
const std::string mClassName;
};
+// 'action' must accept a value of type 'T' and return 'status_t'.
+// The function returns 'true' if the parameter was found, and the action has succeeded.
+// The function returns 'false' if the parameter was not found.
+// Any errors get propagated, if there are errors it means the parameter was found.
+template<typename T, typename F>
+error::Result<bool> filterOutAndProcessParameter(
+ AudioParameter& parameters, const String8& key, const F& action) {
+ if (parameters.containsKey(key)) {
+ T value;
+ status_t status = parameters.get(key, value);
+ if (status == OK) {
+ parameters.remove(key);
+ status = action(value);
+ if (status == OK) return true;
+ }
+ return base::unexpected(status);
+ }
+ return false;
+}
+
} // namespace android
diff --git a/media/libaudiohal/impl/DeviceHalAidl.cpp b/media/libaudiohal/impl/DeviceHalAidl.cpp
index 865d1d6..3125e311 100644
--- a/media/libaudiohal/impl/DeviceHalAidl.cpp
+++ b/media/libaudiohal/impl/DeviceHalAidl.cpp
@@ -35,6 +35,7 @@
#include "StreamHalAidl.h"
using aidl::android::aidl_utils::statusTFromBinderStatus;
+using aidl::android::media::audio::common::Boolean;
using aidl::android::media::audio::common::AudioChannelLayout;
using aidl::android::media::audio::common::AudioConfig;
using aidl::android::media::audio::common::AudioDevice;
@@ -68,6 +69,9 @@
using aidl::android::hardware::audio::common::RecordTrackMetadata;
using aidl::android::hardware::audio::core::AudioPatch;
using aidl::android::hardware::audio::core::AudioRoute;
+using aidl::android::hardware::audio::core::IBluetooth;
+using aidl::android::hardware::audio::core::IBluetoothA2dp;
+using aidl::android::hardware::audio::core::IBluetoothLe;
using aidl::android::hardware::audio::core::IModule;
using aidl::android::hardware::audio::core::ITelephony;
using aidl::android::hardware::audio::core::ModuleDebug;
@@ -124,7 +128,10 @@
DeviceHalAidl::DeviceHalAidl(const std::string& instance, const std::shared_ptr<IModule>& module)
: ConversionHelperAidl("DeviceHalAidl"),
mInstance(instance), mModule(module),
- mTelephony(retrieveSubInterface<ITelephony>(module, &IModule::getTelephony)) {
+ mTelephony(retrieveSubInterface<ITelephony>(module, &IModule::getTelephony)),
+ mBluetooth(retrieveSubInterface<IBluetooth>(module, &IModule::getBluetooth)),
+ mBluetoothA2dp(retrieveSubInterface<IBluetoothA2dp>(module, &IModule::getBluetoothA2dp)),
+ mBluetoothLe(retrieveSubInterface<IBluetoothLe>(module, &IModule::getBluetoothLe)) {
}
status_t DeviceHalAidl::getAudioPorts(std::vector<media::audio::common::AudioPort> *ports) {
@@ -265,15 +272,32 @@
return statusTFromBinderStatus(mModule->getMasterMute(state));
}
-status_t DeviceHalAidl::setParameters(const String8& kvPairs __unused) {
- TIME_CHECK();
+status_t DeviceHalAidl::setParameters(const String8& kvPairs) {
if (!mModule) return NO_INIT;
- ALOGE("%s not implemented yet", __func__);
+ AudioParameter parameters(kvPairs);
+ ALOGD("%s: parameters: \"%s\"", __func__, parameters.toString().c_str());
+
+ if (status_t status = filterAndUpdateBtA2dpParameters(parameters); status != OK) {
+ ALOGW("%s: filtering or updating BT A2DP parameters failed: %d", __func__, status);
+ }
+ if (status_t status = filterAndUpdateBtHfpParameters(parameters); status != OK) {
+ ALOGW("%s: filtering or updating BT HFP parameters failed: %d", __func__, status);
+ }
+ if (status_t status = filterAndUpdateBtLeParameters(parameters); status != OK) {
+ ALOGW("%s: filtering or updating BT LE parameters failed: %d", __func__, status);
+ }
+ if (status_t status = filterAndUpdateBtScoParameters(parameters); status != OK) {
+ ALOGW("%s: filtering or updating BT SCO parameters failed: %d", __func__, status);
+ }
+
+ ALOGW_IF(parameters.size() != 0, "%s: unknown parameters, ignored: \"%s\"",
+ __func__, parameters.toString().c_str());
return OK;
}
status_t DeviceHalAidl::getParameters(const String8& keys __unused, String8 *values) {
TIME_CHECK();
+ // FIXME(b/278976019): Support keyReconfigA2dpSupported via vendor plugin
values->clear();
if (!mModule) return NO_INIT;
ALOGE("%s not implemented yet", __func__);
@@ -1088,6 +1112,150 @@
return OK;
}
+status_t DeviceHalAidl::filterAndUpdateBtA2dpParameters(AudioParameter ¶meters) {
+ TIME_CHECK();
+ std::optional<bool> a2dpEnabled;
+ (void)VALUE_OR_RETURN_STATUS(filterOutAndProcessParameter<String8>(
+ parameters, String8(AudioParameter::keyBtA2dpSuspended),
+ [&a2dpEnabled](const String8& trueOrFalse) {
+ if (trueOrFalse == AudioParameter::valueTrue) {
+ a2dpEnabled = false; // 'suspended' == true
+ return OK;
+ } else if (trueOrFalse == AudioParameter::valueFalse) {
+ a2dpEnabled = true; // 'suspended' == false
+ return OK;
+ }
+ ALOGE("setParameters: parameter key \"%s\" has invalid value \"%s\"",
+ AudioParameter::keyBtA2dpSuspended, trueOrFalse.c_str());
+ return BAD_VALUE;
+ }));
+ // FIXME(b/278976019): Support keyReconfigA2dp via vendor plugin
+ if (mBluetoothA2dp != nullptr && a2dpEnabled.has_value()) {
+ return statusTFromBinderStatus(mBluetoothA2dp->setEnabled(a2dpEnabled.value()));
+ }
+ return OK;
+}
+
+status_t DeviceHalAidl::filterAndUpdateBtHfpParameters(AudioParameter ¶meters) {
+ TIME_CHECK();
+ IBluetooth::HfpConfig hfpConfig;
+ (void)VALUE_OR_RETURN_STATUS(filterOutAndProcessParameter<String8>(
+ parameters, String8(AudioParameter::keyBtHfpEnable),
+ [&hfpConfig](const String8& trueOrFalse) {
+ if (trueOrFalse == AudioParameter::valueTrue) {
+ hfpConfig.isEnabled = Boolean{ .value = true };
+ return OK;
+ } else if (trueOrFalse == AudioParameter::valueFalse) {
+ hfpConfig.isEnabled = Boolean{ .value = false };
+ return OK;
+ }
+ ALOGE("setParameters: parameter key \"%s\" has invalid value \"%s\"",
+ AudioParameter::keyBtHfpEnable, trueOrFalse.c_str());
+ return BAD_VALUE;
+ }));
+ (void)VALUE_OR_RETURN_STATUS(filterOutAndProcessParameter<int>(
+ parameters, String8(AudioParameter::keyBtHfpSamplingRate),
+ [&hfpConfig](int sampleRate) {
+ return sampleRate > 0 ?
+ hfpConfig.sampleRate = Int{ .value = sampleRate }, OK : BAD_VALUE;
+ }));
+ (void)VALUE_OR_RETURN_STATUS(filterOutAndProcessParameter<int>(
+ parameters, String8(AudioParameter::keyBtHfpVolume),
+ [&hfpConfig](int volume0to15) {
+ if (volume0to15 >= 0 && volume0to15 <= 15) {
+ hfpConfig.volume = Float{ .value = volume0to15 / 15.0f };
+ return OK;
+ }
+ return BAD_VALUE;
+ }));
+ if (mBluetooth != nullptr && hfpConfig != IBluetooth::HfpConfig{}) {
+ IBluetooth::HfpConfig newHfpConfig;
+ return statusTFromBinderStatus(mBluetooth->setHfpConfig(hfpConfig, &newHfpConfig));
+ }
+ return OK;
+}
+
+status_t DeviceHalAidl::filterAndUpdateBtLeParameters(AudioParameter ¶meters) {
+ TIME_CHECK();
+ std::optional<bool> leEnabled;
+ (void)VALUE_OR_RETURN_STATUS(filterOutAndProcessParameter<String8>(
+ parameters, String8(AudioParameter::keyBtLeSuspended),
+ [&leEnabled](const String8& trueOrFalse) {
+ if (trueOrFalse == AudioParameter::valueTrue) {
+ leEnabled = false; // 'suspended' == true
+ return OK;
+ } else if (trueOrFalse == AudioParameter::valueFalse) {
+ leEnabled = true; // 'suspended' == false
+ return OK;
+ }
+ ALOGE("setParameters: parameter key \"%s\" has invalid value \"%s\"",
+ AudioParameter::keyBtLeSuspended, trueOrFalse.c_str());
+ return BAD_VALUE;
+ }));
+ if (mBluetoothLe != nullptr && leEnabled.has_value()) {
+ return statusTFromBinderStatus(mBluetoothLe->setEnabled(leEnabled.value()));
+ }
+ return OK;
+}
+
+status_t DeviceHalAidl::filterAndUpdateBtScoParameters(AudioParameter ¶meters) {
+ TIME_CHECK();
+ IBluetooth::ScoConfig scoConfig;
+ (void)VALUE_OR_RETURN_STATUS(filterOutAndProcessParameter<String8>(
+ parameters, String8(AudioParameter::keyBtSco),
+ [&scoConfig](const String8& onOrOff) {
+ if (onOrOff == AudioParameter::valueOn) {
+ scoConfig.isEnabled = Boolean{ .value = true };
+ return OK;
+ } else if (onOrOff == AudioParameter::valueOff) {
+ scoConfig.isEnabled = Boolean{ .value = false };
+ return OK;
+ }
+ ALOGE("setParameters: parameter key \"%s\" has invalid value \"%s\"",
+ AudioParameter::keyBtSco, onOrOff.c_str());
+ return BAD_VALUE;
+ }));
+ (void)VALUE_OR_RETURN_STATUS(filterOutAndProcessParameter<String8>(
+ parameters, String8(AudioParameter::keyBtScoHeadsetName),
+ [&scoConfig](const String8& name) {
+ scoConfig.debugName = name;
+ return OK;
+ }));
+ (void)VALUE_OR_RETURN_STATUS(filterOutAndProcessParameter<String8>(
+ parameters, String8(AudioParameter::keyBtNrec),
+ [&scoConfig](const String8& onOrOff) {
+ if (onOrOff == AudioParameter::valueOn) {
+ scoConfig.isNrecEnabled = Boolean{ .value = true };
+ return OK;
+ } else if (onOrOff == AudioParameter::valueOff) {
+ scoConfig.isNrecEnabled = Boolean{ .value = false };
+ return OK;
+ }
+ ALOGE("setParameters: parameter key \"%s\" has invalid value \"%s\"",
+ AudioParameter::keyBtNrec, onOrOff.c_str());
+ return BAD_VALUE;
+ }));
+ (void)VALUE_OR_RETURN_STATUS(filterOutAndProcessParameter<String8>(
+ parameters, String8(AudioParameter::keyBtScoWb),
+ [&scoConfig](const String8& onOrOff) {
+ if (onOrOff == AudioParameter::valueOn) {
+ scoConfig.mode = IBluetooth::ScoConfig::Mode::SCO_WB;
+ return OK;
+ } else if (onOrOff == AudioParameter::valueOff) {
+ scoConfig.mode = IBluetooth::ScoConfig::Mode::SCO;
+ return OK;
+ }
+ ALOGE("setParameters: parameter key \"%s\" has invalid value \"%s\"",
+ AudioParameter::keyBtScoWb, onOrOff.c_str());
+ return BAD_VALUE;
+ }));
+ if (mBluetooth != nullptr && scoConfig != IBluetooth::ScoConfig{}) {
+ IBluetooth::ScoConfig newScoConfig;
+ return statusTFromBinderStatus(mBluetooth->setScoConfig(scoConfig, &newScoConfig));
+ }
+ return OK;
+}
+
status_t DeviceHalAidl::findOrCreatePatch(
const AudioPatch& requestedPatch, AudioPatch* patch, bool* created) {
std::set<int32_t> sourcePortConfigIds(requestedPatch.sourcePortConfigIds.begin(),
diff --git a/media/libaudiohal/impl/DeviceHalAidl.h b/media/libaudiohal/impl/DeviceHalAidl.h
index 5c9950b..37d800b 100644
--- a/media/libaudiohal/impl/DeviceHalAidl.h
+++ b/media/libaudiohal/impl/DeviceHalAidl.h
@@ -214,6 +214,10 @@
status_t createOrUpdatePortConfig(
const ::aidl::android::media::audio::common::AudioPortConfig& requestedPortConfig,
PortConfigs::iterator* result, bool *created);
+ status_t filterAndUpdateBtA2dpParameters(AudioParameter ¶meters);
+ status_t filterAndUpdateBtHfpParameters(AudioParameter ¶meters);
+ status_t filterAndUpdateBtLeParameters(AudioParameter ¶meters);
+ status_t filterAndUpdateBtScoParameters(AudioParameter ¶meters);
status_t findOrCreatePatch(
const std::set<int32_t>& sourcePortConfigIds,
const std::set<int32_t>& sinkPortConfigIds,
@@ -288,6 +292,9 @@
const std::string mInstance;
const std::shared_ptr<::aidl::android::hardware::audio::core::IModule> mModule;
const std::shared_ptr<::aidl::android::hardware::audio::core::ITelephony> mTelephony;
+ const std::shared_ptr<::aidl::android::hardware::audio::core::IBluetooth> mBluetooth;
+ const std::shared_ptr<::aidl::android::hardware::audio::core::IBluetoothA2dp> mBluetoothA2dp;
+ const std::shared_ptr<::aidl::android::hardware::audio::core::IBluetoothLe> mBluetoothLe;
std::shared_ptr<::aidl::android::hardware::audio::core::sounddose::ISoundDose>
mSoundDose = nullptr;
Ports mPorts;
diff --git a/media/libaudiohal/impl/StreamHalAidl.cpp b/media/libaudiohal/impl/StreamHalAidl.cpp
index eccdfe8..d1044dc 100644
--- a/media/libaudiohal/impl/StreamHalAidl.cpp
+++ b/media/libaudiohal/impl/StreamHalAidl.cpp
@@ -122,30 +122,6 @@
return OK;
}
-namespace {
-
-// 'action' must accept a value of type 'T' and return 'status_t'.
-// The function returns 'true' if the parameter was found, and the action has succeeded.
-// The function returns 'false' if the parameter was not found.
-// Any errors get propagated, if there are errors it means the parameter was found.
-template<typename T, typename F>
-error::Result<bool> filterOutAndProcessParameter(
- AudioParameter& parameters, const String8& key, const F& action) {
- if (parameters.containsKey(key)) {
- T value;
- status_t status = parameters.get(key, value);
- if (status == OK) {
- parameters.remove(key);
- status = action(value);
- if (status == OK) return true;
- }
- return base::unexpected(status);
- }
- return false;
-}
-
-} // namespace
-
status_t StreamHalAidl::setParameters(const String8& kvPairs) {
TIME_CHECK();
if (!mStream) return NO_INIT;
@@ -579,10 +555,10 @@
if (!mStream) return NO_INIT;
AudioParameter parameters(kvPairs);
- ALOGD("%s parameters: %s", __func__, parameters.toString().c_str());
+ ALOGD("%s: parameters: \"%s\"", __func__, parameters.toString().c_str());
if (status_t status = filterAndUpdateOffloadMetadata(parameters); status != OK) {
- ALOGW("%s filtering or updating offload metadata failed: %d", __func__, status);
+ ALOGW("%s: filtering or updating offload metadata failed: %d", __func__, status);
}
return StreamHalAidl::setParameters(parameters.toString());
diff --git a/media/libeffects/config/include/media/EffectsConfig.h b/media/libeffects/config/include/media/EffectsConfig.h
index a9730e5..09a060d 100644
--- a/media/libeffects/config/include/media/EffectsConfig.h
+++ b/media/libeffects/config/include/media/EffectsConfig.h
@@ -49,26 +49,27 @@
std::string name;
std::string path;
};
-using Libraries = std::vector<Library>;
+using Libraries = std::vector<std::shared_ptr<const Library>>;
struct EffectImpl {
- Library* library; //< Only valid as long as the associated library vector is unmodified
+ //< Only valid as long as the associated library vector is unmodified
+ std::shared_ptr<const Library> library;
effect_uuid_t uuid;
};
struct Effect : public EffectImpl {
std::string name;
bool isProxy;
- EffectImpl libSw; //< Only valid if isProxy
- EffectImpl libHw; //< Only valid if isProxy
+ std::shared_ptr<EffectImpl> libSw; //< Only valid if isProxy
+ std::shared_ptr<EffectImpl> libHw; //< Only valid if isProxy
};
-using Effects = std::vector<Effect>;
+using Effects = std::vector<std::shared_ptr<const Effect>>;
template <class Type>
struct Stream {
Type type;
- std::vector<std::reference_wrapper<Effect>> effects;
+ Effects effects;
};
using OutputStream = Stream<audio_stream_type_t>;
using InputStream = Stream<audio_source_t>;
diff --git a/media/libeffects/config/src/EffectsConfig.cpp b/media/libeffects/config/src/EffectsConfig.cpp
index 3096659..2ff057e 100644
--- a/media/libeffects/config/src/EffectsConfig.cpp
+++ b/media/libeffects/config/src/EffectsConfig.cpp
@@ -19,6 +19,7 @@
#include <algorithm>
#include <cstdint>
#include <functional>
+#include <memory>
#include <string>
#include <unistd.h>
@@ -149,7 +150,10 @@
ALOGE("library must have a name and a path: %s", dump(xmlLibrary));
return false;
}
- libraries->push_back({name, path});
+
+ // need this temp variable because `struct Library` doesn't have a constructor
+ Library lib({.name = name, .path = path});
+ libraries->push_back(std::make_shared<const Library>(lib));
return true;
}
@@ -157,10 +161,10 @@
* @return nullptr if not found, the element address if found.
*/
template <class T>
-T* findByName(const char* name, std::vector<T>& collection) {
+T findByName(const char* name, std::vector<T>& collection) {
auto it = find_if(begin(collection), end(collection),
- [name] (auto& item) { return item.name == name; });
- return it != end(collection) ? &*it : nullptr;
+ [name](auto& item) { return item && item->name == name; });
+ return it != end(collection) ? *it : nullptr;
}
/** Parse an effect from an xml element describing it.
@@ -187,7 +191,7 @@
}
// Convert library name to a pointer to the previously loaded library
- auto* library = findByName(libraryName, libraries);
+ auto library = findByName(libraryName, libraries);
if (library == nullptr) {
ALOGE("Could not find library referenced in: %s", dump(xmlImpl));
return false;
@@ -211,20 +215,25 @@
effect.isProxy = true;
// Function to parse libhw and libsw
- auto parseProxy = [&xmlEffect, &parseImpl](const char* tag, EffectImpl& proxyLib) {
+ auto parseProxy = [&xmlEffect, &parseImpl](const char* tag,
+ const std::shared_ptr<EffectImpl>& proxyLib) {
auto* xmlProxyLib = xmlEffect.FirstChildElement(tag);
if (xmlProxyLib == nullptr) {
ALOGE("effectProxy must contain a <%s>: %s", tag, dump(xmlEffect));
return false;
}
- return parseImpl(*xmlProxyLib, proxyLib);
+ return parseImpl(*xmlProxyLib, *proxyLib);
};
+ effect.libSw = std::make_shared<EffectImpl>();
+ effect.libHw = std::make_shared<EffectImpl>();
if (!parseProxy("libhw", effect.libHw) || !parseProxy("libsw", effect.libSw)) {
+ effect.libSw.reset();
+ effect.libHw.reset();
return false;
}
}
- effects->push_back(std::move(effect));
+ effects->push_back(std::make_shared<const Effect>(effect));
return true;
}
@@ -250,12 +259,12 @@
ALOGE("<stream|device>/apply must have reference an effect: %s", dump(xmlApply));
return false;
}
- auto* effect = findByName(effectName, effects);
+ auto effect = findByName(effectName, effects);
if (effect == nullptr) {
ALOGE("Could not find effect referenced in: %s", dump(xmlApply));
return false;
}
- stream.effects.emplace_back(*effect);
+ stream.effects.emplace_back(effect);
}
streams->push_back(std::move(stream));
return true;
diff --git a/media/libeffects/factory/Android.bp b/media/libeffects/factory/Android.bp
index d94093e..f56abbd 100644
--- a/media/libeffects/factory/Android.bp
+++ b/media/libeffects/factory/Android.bp
@@ -21,7 +21,6 @@
vendor: true,
srcs: [
"EffectsFactory.c",
- "EffectsConfigLoader.c",
"EffectsFactoryState.c",
"EffectsXmlConfigLoader.cpp",
],
diff --git a/media/libeffects/factory/EffectsConfigLoader.c b/media/libeffects/factory/EffectsConfigLoader.c
deleted file mode 100644
index e23530e..0000000
--- a/media/libeffects/factory/EffectsConfigLoader.c
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "EffectsFactoryConfigLoader"
-//#define LOG_NDEBUG 0
-
-#include <dlfcn.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <cutils/config_utils.h>
-#include <cutils/misc.h>
-#include <log/log.h>
-
-#include <system/audio_effects/audio_effects_conf.h>
-
-#include "EffectsConfigLoader.h"
-#include "EffectsFactoryState.h"
-
-/////////////////////////////////////////////////
-// Local functions prototypes
-/////////////////////////////////////////////////
-
-static int loadEffectConfigFile(const char *path);
-static int loadLibraries(cnode *root);
-static int loadLibrary(cnode *root, const char *name);
-static int loadEffects(cnode *root);
-static int loadEffect(cnode *node);
-// To get and add the effect pointed by the passed node to the gSubEffectList
-static int addSubEffect(cnode *root);
-static lib_entry_t *getLibrary(const char *path);
-
-static lib_entry_t *gCachedLibrary; // last library accessed by getLibrary()
-
-int EffectLoadEffectConfig()
-{
- if (access(AUDIO_EFFECT_VENDOR_CONFIG_FILE, R_OK) == 0) {
- return loadEffectConfigFile(AUDIO_EFFECT_VENDOR_CONFIG_FILE);
- } else if (access(AUDIO_EFFECT_DEFAULT_CONFIG_FILE, R_OK) == 0) {
- return loadEffectConfigFile(AUDIO_EFFECT_DEFAULT_CONFIG_FILE);
- }
- return 0;
-}
-
-int loadEffectConfigFile(const char *path)
-{
- cnode *root;
- char *data;
-
- data = load_file(path, NULL);
- if (data == NULL) {
- return -ENODEV;
- }
- root = config_node("", "");
- config_load(root, data);
- loadLibraries(root);
- loadEffects(root);
- config_free(root);
- free(root);
- free(data);
-
- return 0;
-}
-
-int loadLibraries(cnode *root)
-{
- cnode *node;
-
- node = config_find(root, LIBRARIES_TAG);
- if (node == NULL) {
- return -ENOENT;
- }
- node = node->first_child;
- while (node) {
- loadLibrary(node, node->name);
- node = node->next;
- }
- return 0;
-}
-
-#ifdef __LP64__
-// audio_effects.conf always specifies 32 bit lib path: convert to 64 bit path if needed
-static const char *kLibraryPathRoot[] =
- {"/odm/lib64/soundfx", "/vendor/lib64/soundfx", "/system/lib64/soundfx"};
-#else
-static const char *kLibraryPathRoot[] =
- {"/odm/lib/soundfx", "/vendor/lib/soundfx", "/system/lib/soundfx"};
-#endif
-
-static const int kLibraryPathRootSize =
- (sizeof(kLibraryPathRoot) / sizeof(kLibraryPathRoot[0]));
-
-// Checks if the library path passed as lib_path_in can be opened and if not
-// tries in standard effect library directories with just the library name and returns correct path
-// in lib_path_out
-int checkLibraryPath(const char *lib_path_in, char *lib_path_out) {
- char *str;
- const char *lib_name;
- size_t len;
-
- if (lib_path_in == NULL || lib_path_out == NULL) {
- return -EINVAL;
- }
-
- strlcpy(lib_path_out, lib_path_in, PATH_MAX);
-
- // Try exact path first
- str = strstr(lib_path_out, "/lib/soundfx/");
- if (str == NULL) {
- return -EINVAL;
- }
-
- // Extract library name from input path
- len = str - lib_path_out;
- lib_name = lib_path_in + len + strlen("/lib/soundfx/");
-
- // Then try with library name and standard path names in order of preference
- for (int i = 0; i < kLibraryPathRootSize; i++) {
- char path[PATH_MAX];
-
- snprintf(path,
- PATH_MAX,
- "%s/%s",
- kLibraryPathRoot[i],
- lib_name);
- if (F_OK == access(path, 0)) {
- strcpy(lib_path_out, path);
- ALOGW_IF(strncmp(lib_path_out, lib_path_in, PATH_MAX) != 0,
- "checkLibraryPath() corrected library path %s to %s", lib_path_in, lib_path_out);
- return 0;
- }
- }
- return -EINVAL;
-}
-
-
-
-int loadLibrary(cnode *root, const char *name)
-{
- cnode *node;
- void *hdl = NULL;
- audio_effect_library_t *desc;
- list_elem_t *e;
- lib_entry_t *l;
- char path[PATH_MAX];
-
- node = config_find(root, PATH_TAG);
- if (node == NULL) {
- return -EINVAL;
- }
-
- if (checkLibraryPath((const char *)node->value, path) != 0) {
- ALOGW("loadLibrary() could not find library %s", path);
- goto error;
- }
-
- hdl = dlopen(path, RTLD_NOW);
- if (hdl == NULL) {
- ALOGW("loadLibrary() failed to open %s", path);
- goto error;
- }
-
- desc = (audio_effect_library_t *)dlsym(hdl, AUDIO_EFFECT_LIBRARY_INFO_SYM_AS_STR);
- if (desc == NULL) {
- ALOGW("loadLibrary() could not find symbol %s", AUDIO_EFFECT_LIBRARY_INFO_SYM_AS_STR);
- goto error;
- }
-
- if (AUDIO_EFFECT_LIBRARY_TAG != desc->tag) {
- ALOGW("getLibrary() bad tag %08x in lib info struct", desc->tag);
- goto error;
- }
-
- if (EFFECT_API_VERSION_MAJOR(desc->version) !=
- EFFECT_API_VERSION_MAJOR(EFFECT_LIBRARY_API_VERSION)) {
- ALOGW("loadLibrary() bad lib version %08x", desc->version);
- goto error;
- }
-
- // add entry for library in gLibraryList
- l = malloc(sizeof(lib_entry_t));
- l->name = strndup(name, PATH_MAX);
- l->path = strndup(path, PATH_MAX);
- l->handle = hdl;
- l->desc = desc;
- l->effects = NULL;
- pthread_mutex_init(&l->lock, NULL);
-
- e = malloc(sizeof(list_elem_t));
- e->object = l;
- pthread_mutex_lock(&gLibLock);
- e->next = gLibraryList;
- gLibraryList = e;
- pthread_mutex_unlock(&gLibLock);
- ALOGV("getLibrary() linked library %p for path %s", l, path);
-
- return 0;
-
-error:
- if (hdl != NULL) {
- dlclose(hdl);
- }
- //add entry for library errors in gLibraryFailedList
- lib_failed_entry_t *fl = malloc(sizeof(lib_failed_entry_t));
- fl->name = strndup(name, PATH_MAX);
- fl->path = strndup(path, PATH_MAX);
-
- list_elem_t *fe = malloc(sizeof(list_elem_t));
- fe->object = fl;
- fe->next = gLibraryFailedList;
- gLibraryFailedList = fe;
- ALOGV("getLibrary() linked error in library %p for path %s", fl, path);
-
- return -EINVAL;
-}
-
-// This will find the library and UUID tags of the sub effect pointed by the
-// node, gets the effect descriptor and lib_entry_t and adds the subeffect -
-// sub_entry_t to the gSubEffectList
-int addSubEffect(cnode *root)
-{
- ALOGV("addSubEffect");
- cnode *node;
- effect_uuid_t uuid;
- effect_descriptor_t *d;
- lib_entry_t *l;
- list_elem_t *e;
- node = config_find(root, LIBRARY_TAG);
- if (node == NULL) {
- return -EINVAL;
- }
- l = getLibrary(node->value);
- if (l == NULL) {
- ALOGW("addSubEffect() could not get library %s", node->value);
- return -EINVAL;
- }
- node = config_find(root, UUID_TAG);
- if (node == NULL) {
- return -EINVAL;
- }
- if (stringToUuid(node->value, &uuid) != 0) {
- ALOGW("addSubEffect() invalid uuid %s", node->value);
- return -EINVAL;
- }
- d = malloc(sizeof(effect_descriptor_t));
- if (l->desc->get_descriptor(&uuid, d) != 0) {
- char s[40];
- uuidToString(&uuid, s, 40);
- ALOGW("Error querying effect %s on lib %s", s, l->name);
- free(d);
- return -EINVAL;
- }
-#if (LOG_NDEBUG==0)
- char s[512];
- dumpEffectDescriptor(d, s, sizeof(s), 0 /* indent */);
- ALOGV("addSubEffect() read descriptor %p:%s",d, s);
-#endif
- if (EFFECT_API_VERSION_MAJOR(d->apiVersion) !=
- EFFECT_API_VERSION_MAJOR(EFFECT_CONTROL_API_VERSION)) {
- ALOGW("Bad API version %08x on lib %s", d->apiVersion, l->name);
- free(d);
- return -EINVAL;
- }
- sub_effect_entry_t *sub_effect = malloc(sizeof(sub_effect_entry_t));
- sub_effect->object = d;
- // lib_entry_t is stored since the sub effects are not linked to the library
- sub_effect->lib = l;
- e = malloc(sizeof(list_elem_t));
- e->object = sub_effect;
- e->next = gSubEffectList->sub_elem;
- gSubEffectList->sub_elem = e;
- ALOGV("addSubEffect end");
- return 0;
-}
-
-int loadEffects(cnode *root)
-{
- cnode *node;
-
- node = config_find(root, EFFECTS_TAG);
- if (node == NULL) {
- return -ENOENT;
- }
- node = node->first_child;
- while (node) {
- loadEffect(node);
- node = node->next;
- }
- return 0;
-}
-
-int loadEffect(cnode *root)
-{
- cnode *node;
- effect_uuid_t uuid;
- lib_entry_t *l;
- effect_descriptor_t *d;
- list_elem_t *e;
-
- node = config_find(root, LIBRARY_TAG);
- if (node == NULL) {
- return -EINVAL;
- }
-
- l = getLibrary(node->value);
- if (l == NULL) {
- ALOGW("loadEffect() could not get library %s", node->value);
- return -EINVAL;
- }
-
- node = config_find(root, UUID_TAG);
- if (node == NULL) {
- return -EINVAL;
- }
- if (stringToUuid(node->value, &uuid) != 0) {
- ALOGW("loadEffect() invalid uuid %s", node->value);
- return -EINVAL;
- }
- lib_entry_t *tmp;
- bool skip = false;
- if (findEffect(NULL, &uuid, &tmp, NULL) == 0) {
- ALOGW("skipping duplicate uuid %s %s", node->value,
- node->next ? "and its sub-effects" : "");
- skip = true;
- }
-
- d = malloc(sizeof(effect_descriptor_t));
- if (l->desc->get_descriptor(&uuid, d) != 0) {
- char s[40];
- uuidToString(&uuid, s, 40);
- ALOGW("Error querying effect %s on lib %s", s, l->name);
- free(d);
- return -EINVAL;
- }
-#if (LOG_NDEBUG==0)
- char s[512];
- dumpEffectDescriptor(d, s, sizeof(s), 0 /* indent */);
- ALOGV("loadEffect() read descriptor %p:%s",d, s);
-#endif
- if (EFFECT_API_VERSION_MAJOR(d->apiVersion) !=
- EFFECT_API_VERSION_MAJOR(EFFECT_CONTROL_API_VERSION)) {
- ALOGW("Bad API version %08x on lib %s", d->apiVersion, l->name);
- free(d);
- return -EINVAL;
- }
- e = malloc(sizeof(list_elem_t));
- e->object = d;
- if (skip) {
- e->next = gSkippedEffects;
- gSkippedEffects = e;
- return -EINVAL;
- } else {
- e->next = l->effects;
- l->effects = e;
- }
-
- // After the UUID node in the config_tree, if node->next is valid,
- // that would be sub effect node.
- // Find the sub effects and add them to the gSubEffectList
- node = node->next;
- int count = 2;
- bool hwSubefx = false, swSubefx = false;
- list_sub_elem_t *sube = NULL;
- if (node != NULL) {
- ALOGV("Adding the effect to gEffectSubList as there are sub effects");
- sube = malloc(sizeof(list_sub_elem_t));
- sube->object = d;
- sube->sub_elem = NULL;
- sube->next = gSubEffectList;
- gSubEffectList = sube;
- }
- while (node != NULL && count) {
- if (addSubEffect(node)) {
- ALOGW("loadEffect() could not add subEffect %s", node->value);
- // Change the gSubEffectList to point to older list;
- gSubEffectList = sube->next;
- free(sube->sub_elem);// Free an already added sub effect
- sube->sub_elem = NULL;
- free(sube);
- return -ENOENT;
- }
- sub_effect_entry_t *subEntry = (sub_effect_entry_t*)gSubEffectList->sub_elem->object;
- effect_descriptor_t *subEffectDesc = (effect_descriptor_t*)(subEntry->object);
- // Since we return a stub descriptor for the proxy during
- // get_descriptor call,we replace it with the correspoding
- // sw effect descriptor, but with Proxy UUID
- // check for Sw desc
- if (!((subEffectDesc->flags & EFFECT_FLAG_HW_ACC_MASK) ==
- EFFECT_FLAG_HW_ACC_TUNNEL)) {
- swSubefx = true;
- *d = *subEffectDesc;
- d->uuid = uuid;
- ALOGV("loadEffect() Changed the Proxy desc");
- } else
- hwSubefx = true;
- count--;
- node = node->next;
- }
- // 1 HW and 1 SW sub effect found. Set the offload flag in the Proxy desc
- if (hwSubefx && swSubefx) {
- d->flags |= EFFECT_FLAG_OFFLOAD_SUPPORTED;
- }
- return 0;
-}
-
-lib_entry_t *getLibrary(const char *name)
-{
- list_elem_t *e;
-
- if (gCachedLibrary &&
- !strncmp(gCachedLibrary->name, name, PATH_MAX)) {
- return gCachedLibrary;
- }
-
- e = gLibraryList;
- while (e) {
- lib_entry_t *l = (lib_entry_t *)e->object;
- if (!strcmp(l->name, name)) {
- gCachedLibrary = l;
- return l;
- }
- e = e->next;
- }
-
- return NULL;
-}
diff --git a/media/libeffects/factory/EffectsConfigLoader.h b/media/libeffects/factory/EffectsConfigLoader.h
deleted file mode 100644
index 3f82609..0000000
--- a/media/libeffects/factory/EffectsConfigLoader.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2017 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_EFFECTSCONFIGLOADER_H
-#define ANDROID_EFFECTSCONFIGLOADER_H
-
-#include <cutils/compiler.h>
-#include "EffectsFactoryState.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** Parses the platform effect configuration
- * and stores its content in the global EffectFactoryState. */
-ANDROID_API
-int EffectLoadEffectConfig();
-
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // ANDROID_EFFECTSCONFIGLOADER_H
diff --git a/media/libeffects/factory/EffectsFactory.c b/media/libeffects/factory/EffectsFactory.c
index dcdf634..38ba4b0 100644
--- a/media/libeffects/factory/EffectsFactory.c
+++ b/media/libeffects/factory/EffectsFactory.c
@@ -26,7 +26,6 @@
#include <media/EffectsFactoryApi.h>
-#include "EffectsConfigLoader.h"
#include "EffectsFactoryState.h"
#include "EffectsXmlConfigLoader.h"
@@ -464,8 +463,7 @@
} else {
gConfigNbElemSkipped = EffectLoadXmlEffectConfig(NULL);
if (gConfigNbElemSkipped < 0) {
- ALOGW("Failed to load XML effect configuration, fallback to .conf");
- EffectLoadEffectConfig();
+ ALOGE("Failed to load XML effect configuration with status %zd", gConfigNbElemSkipped);
} else if (gConfigNbElemSkipped > 0) {
ALOGE("Effect config is partially invalid, skipped %zd elements", gConfigNbElemSkipped);
}
diff --git a/media/libeffects/factory/EffectsXmlConfigLoader.cpp b/media/libeffects/factory/EffectsXmlConfigLoader.cpp
index 30a9007..f24c15c 100644
--- a/media/libeffects/factory/EffectsXmlConfigLoader.cpp
+++ b/media/libeffects/factory/EffectsXmlConfigLoader.cpp
@@ -26,7 +26,6 @@
#include <media/EffectsConfig.h>
-#include "EffectsConfigLoader.h"
#include "EffectsFactoryState.h"
#include "EffectsXmlConfigLoader.h"
@@ -64,7 +63,7 @@
std::string absolutePath;
if (!resolveLibrary(relativePath, &absolutePath)) {
- ALOGE("Could not find library in effect directories: %s", relativePath);
+ ALOGE("%s Could not find library in effect directories: %s", __func__, relativePath);
libEntry->path = strdup(relativePath);
return false;
}
@@ -75,20 +74,20 @@
std::unique_ptr<void, decltype(dlclose)*> libHandle(dlopen(path, RTLD_NOW),
dlclose);
if (libHandle == nullptr) {
- ALOGE("Could not dlopen library %s: %s", path, dlerror());
+ ALOGE("%s Could not dlopen library %s: %s", __func__, path, dlerror());
return false;
}
auto* description = static_cast<audio_effect_library_t*>(
dlsym(libHandle.get(), AUDIO_EFFECT_LIBRARY_INFO_SYM_AS_STR));
if (description == nullptr) {
- ALOGE("Invalid effect library, failed not find symbol '%s' in %s: %s",
+ ALOGE("%s Invalid effect library, failed not find symbol '%s' in %s: %s", __func__,
AUDIO_EFFECT_LIBRARY_INFO_SYM_AS_STR, path, dlerror());
return false;
}
if (description->tag != AUDIO_EFFECT_LIBRARY_TAG) {
- ALOGE("Bad tag %#08x in description structure, expected %#08x for library %s",
+ ALOGE("%s Bad tag %#08x in description structure, expected %#08x for library %s", __func__,
description->tag, AUDIO_EFFECT_LIBRARY_TAG, path);
return false;
}
@@ -96,8 +95,8 @@
uint32_t majorVersion = EFFECT_API_VERSION_MAJOR(description->version);
uint32_t expectedMajorVersion = EFFECT_API_VERSION_MAJOR(EFFECT_LIBRARY_API_VERSION_CURRENT);
if (majorVersion != expectedMajorVersion) {
- ALOGE("Unsupported major version %#08x, expected %#08x for library %s",
- majorVersion, expectedMajorVersion, path);
+ ALOGE("%s Unsupported major version %#08x, expected %#08x for library %s",
+ __func__, majorVersion, expectedMajorVersion, path);
return false;
}
@@ -155,14 +154,13 @@
{
size_t nbSkippedElement = 0;
for (auto& library : libs) {
-
// Construct a lib entry
auto libEntry = makeUniqueC<lib_entry_t>();
- libEntry->name = strdup(library.name.c_str());
+ libEntry->name = strdup(library->name.c_str());
libEntry->effects = nullptr;
pthread_mutex_init(&libEntry->lock, nullptr);
- if (!loadLibrary(library.path.c_str(), libEntry.get())) {
+ if (!loadLibrary(library->path.c_str(), libEntry.get())) {
// Register library load failure
listPush(std::move(libEntry), libFailedList);
++nbSkippedElement;
@@ -209,24 +207,24 @@
UniqueCPtr<effect_descriptor_t> effectDesc;
};
-LoadEffectResult loadEffect(const EffectImpl& effect, const std::string& name,
- list_elem_t* libList) {
+LoadEffectResult loadEffect(const std::shared_ptr<const EffectImpl>& effect,
+ const std::string& name, list_elem_t* libList) {
LoadEffectResult result;
// Find the effect library
- result.lib = findLibrary(effect.library->name.c_str(), libList);
+ result.lib = findLibrary(effect->library->name.c_str(), libList);
if (result.lib == nullptr) {
- ALOGE("Could not find library %s to load effect %s",
- effect.library->name.c_str(), name.c_str());
+ ALOGE("%s Could not find library %s to load effect %s",
+ __func__, effect->library->name.c_str(), name.c_str());
return result;
}
result.effectDesc = makeUniqueC<effect_descriptor_t>();
// Get the effect descriptor
- if (result.lib->desc->get_descriptor(&effect.uuid, result.effectDesc.get()) != 0) {
+ if (result.lib->desc->get_descriptor(&effect->uuid, result.effectDesc.get()) != 0) {
ALOGE("Error querying effect %s on lib %s",
- uuidToString(effect.uuid), result.lib->name);
+ uuidToString(effect->uuid), result.lib->name);
result.effectDesc.reset();
return result;
}
@@ -241,14 +239,15 @@
// Check effect is supported
uint32_t expectedMajorVersion = EFFECT_API_VERSION_MAJOR(EFFECT_CONTROL_API_VERSION);
if (EFFECT_API_VERSION_MAJOR(result.effectDesc->apiVersion) != expectedMajorVersion) {
- ALOGE("Bad API version %#08x for effect %s in lib %s, expected major %#08x",
+ ALOGE("%s Bad API version %#08x for effect %s in lib %s, expected major %#08x", __func__,
result.effectDesc->apiVersion, name.c_str(), result.lib->name, expectedMajorVersion);
return result;
}
lib_entry_t *_;
- if (findEffect(nullptr, &effect.uuid, &_, nullptr) == 0) {
- ALOGE("Effect %s uuid %s already exist", uuidToString(effect.uuid), name.c_str());
+ if (findEffect(nullptr, &effect->uuid, &_, nullptr) == 0) {
+ ALOGE("%s Effect %s uuid %s already exist", __func__, uuidToString(effect->uuid),
+ name.c_str());
return result;
}
@@ -261,8 +260,11 @@
size_t nbSkippedElement = 0;
for (auto& effect : effects) {
+ if (!effect) {
+ continue;
+ }
- auto effectLoadResult = loadEffect(effect, effect.name, libList);
+ auto effectLoadResult = loadEffect(effect, effect->name, libList);
if (!effectLoadResult.success) {
if (effectLoadResult.effectDesc != nullptr) {
listPush(std::move(effectLoadResult.effectDesc), skippedEffects);
@@ -271,9 +273,9 @@
continue;
}
- if (effect.isProxy) {
- auto swEffectLoadResult = loadEffect(effect.libSw, effect.name + " libsw", libList);
- auto hwEffectLoadResult = loadEffect(effect.libHw, effect.name + " libhw", libList);
+ if (effect->isProxy) {
+ auto swEffectLoadResult = loadEffect(effect->libSw, effect->name + " libsw", libList);
+ auto hwEffectLoadResult = loadEffect(effect->libHw, effect->name + " libhw", libList);
if (!swEffectLoadResult.success || !hwEffectLoadResult.success) {
// Push the main effect in the skipped list even if only a subeffect is invalid
// as the main effect is not usable without its subeffects.
@@ -287,7 +289,7 @@
// get_descriptor call, we replace it with the corresponding
// sw effect descriptor, but keep the Proxy UUID
*effectLoadResult.effectDesc = *swEffectLoadResult.effectDesc;
- effectLoadResult.effectDesc->uuid = effect.uuid;
+ effectLoadResult.effectDesc->uuid = effect->uuid;
effectLoadResult.effectDesc->flags |= EFFECT_FLAG_OFFLOAD_SUPPORTED;
@@ -326,8 +328,8 @@
loadEffects(result.parsedConfig->effects, gLibraryList,
&gSkippedEffects, &gSubEffectList);
- ALOGE_IF(result.nbSkippedElement != 0, "%zu errors during loading of configuration: %s",
- result.nbSkippedElement,
+ ALOGE_IF(result.nbSkippedElement != 0, "%s %zu errors during loading of configuration: %s",
+ __func__, result.nbSkippedElement,
result.configPath.empty() ? "No config file found" : result.configPath.c_str());
return result.nbSkippedElement;
diff --git a/media/libeffects/factory/test/DumpConfig.cpp b/media/libeffects/factory/test/DumpConfig.cpp
index 0a156b4..1fecf06 100644
--- a/media/libeffects/factory/test/DumpConfig.cpp
+++ b/media/libeffects/factory/test/DumpConfig.cpp
@@ -16,48 +16,31 @@
#include <media/EffectsFactoryApi.h>
#include <unistd.h>
+
#include "EffectsXmlConfigLoader.h"
-#include "EffectsConfigLoader.h"
int main(int argc, char* argv[]) {
- const char* path = nullptr;
- bool legacyFormat;
-
- if (argc == 2 && strcmp(argv[1], "--legacy") == 0) {
- legacyFormat = true;
- fprintf(stderr, "Dumping legacy effect config file\n");
- } else if ((argc == 2 || argc == 3) && strcmp(argv[1], "--xml") == 0) {
- legacyFormat = false;
+ char* path = nullptr;
+ if ((argc == 2 || argc == 3) && strcmp(argv[1], "--xml") == 0) {
if (argc == 3) {
+ path = argv[2];
fprintf(stderr, "Dumping XML effect config file: %s\n", path);
} else {
fprintf(stderr, "Dumping default XML effect config file.\n");
}
} else {
- fprintf(stderr, "Invalid arguments.\n"
- "Usage: %s [--legacy|--xml [FILE]]\n", argv[0]);
+ fprintf(stderr, "Invalid arguments.\nUsage: %s [--xml [FILE]]\n", argv[0]);
return 1;
}
- if (!legacyFormat) {
- ssize_t ret = EffectLoadXmlEffectConfig(path);
- if (ret < 0) {
- fprintf(stderr, "loadXmlEffectConfig failed, see logcat for detail.\n");
- return 2;
- }
- if (ret > 0) {
- fprintf(stderr, "Partially failed to load config. Skipped %zu elements, "
- "see logcat for detail.\n", (size_t)ret);
- }
+ ssize_t ret = EffectLoadXmlEffectConfig(path);
+ if (ret < 0) {
+ fprintf(stderr, "loadXmlEffectConfig failed, see logcat for detail.\n");
+ return 2;
}
-
- if (legacyFormat) {
- auto ret = EffectLoadEffectConfig();
- if (ret < 0) {
- fprintf(stderr, "loadEffectConfig failed, see logcat for detail.\n");
- return 3;
- }
- fprintf(stderr, "legacy loadEffectConfig has probably succeed, see logcat to make sure.\n");
+ if (ret > 0) {
+ fprintf(stderr, "Partially failed to load config. Skipped %zu elements, "
+ "see logcat for detail.\n", (size_t)ret);
}
if (EffectDumpEffects(STDOUT_FILENO) != 0) {
diff --git a/media/libmediahelper/Android.bp b/media/libmediahelper/Android.bp
index c66861b..649f813 100644
--- a/media/libmediahelper/Android.bp
+++ b/media/libmediahelper/Android.bp
@@ -49,8 +49,9 @@
"liblog",
],
header_libs: [
- "libmedia_helper_headers",
"libaudio_system_headers",
+ "libhardware_headers",
+ "libmedia_helper_headers",
],
export_header_lib_headers: [
"libmedia_helper_headers",
diff --git a/media/libmediahelper/AudioParameter.cpp b/media/libmediahelper/AudioParameter.cpp
index e25f9b7..a61a1bc 100644
--- a/media/libmediahelper/AudioParameter.cpp
+++ b/media/libmediahelper/AudioParameter.cpp
@@ -20,6 +20,7 @@
#include <utils/Log.h>
#include <media/AudioParameter.h>
+#include <hardware/audio.h>
#include <system/audio.h>
namespace android {
@@ -34,7 +35,13 @@
const char * const AudioParameter::keyScreenState = AUDIO_PARAMETER_KEY_SCREEN_STATE;
const char * const AudioParameter::keyClosing = AUDIO_PARAMETER_KEY_CLOSING;
const char * const AudioParameter::keyExiting = AUDIO_PARAMETER_KEY_EXITING;
+const char * const AudioParameter::keyBtSco = AUDIO_PARAMETER_KEY_BT_SCO;
+const char * const AudioParameter::keyBtScoHeadsetName = AUDIO_PARAMETER_KEY_BT_SCO_HEADSET_NAME;
const char * const AudioParameter::keyBtNrec = AUDIO_PARAMETER_KEY_BT_NREC;
+const char * const AudioParameter::keyBtScoWb = AUDIO_PARAMETER_KEY_BT_SCO_WB;
+const char * const AudioParameter::keyBtHfpEnable = AUDIO_PARAMETER_KEY_HFP_ENABLE;
+const char * const AudioParameter::keyBtHfpSamplingRate = AUDIO_PARAMETER_KEY_HFP_SET_SAMPLING_RATE;
+const char * const AudioParameter::keyBtHfpVolume = AUDIO_PARAMETER_KEY_HFP_VOLUME;
const char * const AudioParameter::keyHwAvSync = AUDIO_PARAMETER_HW_AV_SYNC;
const char * const AudioParameter::keyPresentationId = AUDIO_PARAMETER_STREAM_PRESENTATION_ID;
const char * const AudioParameter::keyProgramId = AUDIO_PARAMETER_STREAM_PROGRAM_ID;
@@ -52,9 +59,13 @@
AUDIO_PARAMETER_STREAM_SUP_SAMPLING_RATES;
const char * const AudioParameter::valueOn = AUDIO_PARAMETER_VALUE_ON;
const char * const AudioParameter::valueOff = AUDIO_PARAMETER_VALUE_OFF;
+const char * const AudioParameter::valueTrue = AUDIO_PARAMETER_VALUE_TRUE;
+const char * const AudioParameter::valueFalse = AUDIO_PARAMETER_VALUE_FALSE;
const char * const AudioParameter::valueListSeparator = AUDIO_PARAMETER_VALUE_LIST_SEPARATOR;
+const char * const AudioParameter::keyBtA2dpSuspended = AUDIO_PARAMETER_KEY_BT_A2DP_SUSPENDED;
const char * const AudioParameter::keyReconfigA2dp = AUDIO_PARAMETER_RECONFIG_A2DP;
const char * const AudioParameter::keyReconfigA2dpSupported = AUDIO_PARAMETER_A2DP_RECONFIG_SUPPORTED;
+const char * const AudioParameter::keyBtLeSuspended = AUDIO_PARAMETER_KEY_BT_LE_SUSPENDED;
// const char * const AudioParameter::keyDeviceSupportedEncapsulationModes =
// AUDIO_PARAMETER_DEVICE_SUP_ENCAPSULATION_MODES;
// const char * const AudioParameter::keyDeviceSupportedEncapsulationMetadataTypes =
diff --git a/media/libmediahelper/include/media/AudioParameter.h b/media/libmediahelper/include/media/AudioParameter.h
index 6c34a4f..70f8af3 100644
--- a/media/libmediahelper/include/media/AudioParameter.h
+++ b/media/libmediahelper/include/media/AudioParameter.h
@@ -55,11 +55,22 @@
static const char * const keyClosing;
static const char * const keyExiting;
+ // keyBtSco: Whether BT SCO is 'on' or 'off'
+ // keyBtScoHeadsetName: BT SCO headset name (for debugging)
// keyBtNrec: BT SCO Noise Reduction + Echo Cancellation parameters
+ // keyBtScoWb: BT SCO NR wideband mode
+ // keyHfp...: Parameters of the Hands-Free Profile
+ static const char * const keyBtSco;
+ static const char * const keyBtScoHeadsetName;
+ static const char * const keyBtNrec;
+ static const char * const keyBtScoWb;
+ static const char * const keyBtHfpEnable;
+ static const char * const keyBtHfpSamplingRate;
+ static const char * const keyBtHfpVolume;
+
// keyHwAvSync: get HW synchronization source identifier from a device
// keyMonoOutput: Enable mono audio playback
// keyStreamHwAvSync: set HW synchronization source identifier on a stream
- static const char * const keyBtNrec;
static const char * const keyHwAvSync;
static const char * const keyMonoOutput;
static const char * const keyStreamHwAvSync;
@@ -90,13 +101,19 @@
static const char * const valueOn;
static const char * const valueOff;
+ static const char * const valueTrue;
+ static const char * const valueFalse;
static const char * const valueListSeparator;
+ // keyBtA2dpSuspended: 'true' or 'false'
// keyReconfigA2dp: Ask HwModule to reconfigure A2DP offloaded codec
// keyReconfigA2dpSupported: Query if HwModule supports A2DP offload codec config
+ // keyBtLeSuspended: 'true' or 'false'
+ static const char * const keyBtA2dpSuspended;
static const char * const keyReconfigA2dp;
static const char * const keyReconfigA2dpSupported;
+ static const char * const keyBtLeSuspended;
// For querying device supported encapsulation capabilities. All returned values are integer,
// which are bit fields composed from using encapsulation capability values as position bits.
diff --git a/media/libstagefright/FrameCaptureLayer.cpp b/media/libstagefright/FrameCaptureLayer.cpp
index d2cfd41..4e71943 100644
--- a/media/libstagefright/FrameCaptureLayer.cpp
+++ b/media/libstagefright/FrameCaptureLayer.cpp
@@ -64,14 +64,6 @@
return updatedDataspace;
}
-bool isHdrY410(const BufferItem &bi) {
- ui::Dataspace dataspace = translateDataspace(static_cast<ui::Dataspace>(bi.mDataSpace));
- // pixel format is HDR Y410 masquerading as RGBA_1010102
- return ((dataspace == ui::Dataspace::BT2020_ITU_PQ ||
- dataspace == ui::Dataspace::BT2020_ITU_HLG) &&
- bi.mGraphicBuffer->getPixelFormat() == HAL_PIXEL_FORMAT_RGBA_1010102);
-}
-
struct FrameCaptureLayer::BufferLayer : public FrameCaptureProcessor::Layer {
BufferLayer(const BufferItem &bi) : mBufferItem(bi) {}
void getLayerSettings(
@@ -95,7 +87,6 @@
layerSettings->source.buffer.fence = mBufferItem.mFence;
layerSettings->source.buffer.textureName = textureName;
layerSettings->source.buffer.usePremultipliedAlpha = false;
- layerSettings->source.buffer.isY410BT2020 = isHdrY410(mBufferItem);
bool hasSmpte2086 = mBufferItem.mHdrMetadata.validTypes & HdrMetadata::SMPTE2086;
bool hasCta861_3 = mBufferItem.mHdrMetadata.validTypes & HdrMetadata::CTA861_3;
layerSettings->source.buffer.maxMasteringLuminance = hasSmpte2086
diff --git a/services/audioflinger/Effects.cpp b/services/audioflinger/Effects.cpp
index f324408..ce2d8f4 100644
--- a/services/audioflinger/Effects.cpp
+++ b/services/audioflinger/Effects.cpp
@@ -3375,8 +3375,18 @@
ALOGV("%s type %d device type %d address %s device ID %d patch.isSoftware() %d",
__func__, port->type, port->ext.device.type,
port->ext.device.address, port->id, patch.isSoftware());
- if (port->type != AUDIO_PORT_TYPE_DEVICE || port->ext.device.type != mDevice.mType
- || port->ext.device.address != mDevice.address()) {
+ if (port->type != AUDIO_PORT_TYPE_DEVICE || port->ext.device.type != mDevice.mType ||
+ port->ext.device.address != mDevice.address()) {
+ return NAME_NOT_FOUND;
+ }
+ if (((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_POST_PROC) &&
+ (audio_port_config_has_input_direction(port))) {
+ ALOGI("%s don't create postprocessing effect on record port", __func__);
+ return NAME_NOT_FOUND;
+ }
+ if (((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_PRE_PROC) &&
+ (!audio_port_config_has_input_direction(port))) {
+ ALOGI("%s don't create preprocessing effect on playback port", __func__);
return NAME_NOT_FOUND;
}
status_t status = NAME_NOT_FOUND;
@@ -3407,20 +3417,12 @@
} else if (patch.isSoftware() || patch.thread().promote() != nullptr) {
sp <ThreadBase> thread;
if (audio_port_config_has_input_direction(port)) {
- if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_POST_PROC) {
- ALOGI("%s don't create postprocessing effect on record thread", __func__);
- return NAME_NOT_FOUND;
- }
if (patch.isSoftware()) {
thread = patch.mRecord.thread();
} else {
thread = patch.thread().promote();
}
} else {
- if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_PRE_PROC) {
- ALOGI("%s don't create preprocessing effect on playback thread", __func__);
- return NAME_NOT_FOUND;
- }
if (patch.isSoftware()) {
thread = patch.mPlayback.thread();
} else {
@@ -3436,6 +3438,7 @@
} else {
status = BAD_VALUE;
}
+
if (status == NO_ERROR || status == ALREADY_EXISTS) {
Status bs;
if (isEnabled()) {
diff --git a/services/audiopolicy/service/AudioPolicyEffects.cpp b/services/audiopolicy/service/AudioPolicyEffects.cpp
index b111865..7febd2f 100644
--- a/services/audiopolicy/service/AudioPolicyEffects.cpp
+++ b/services/audiopolicy/service/AudioPolicyEffects.cpp
@@ -48,13 +48,7 @@
mDefaultDeviceEffectFuture =
std::async(std::launch::async, &AudioPolicyEffects::initDefaultDeviceEffects, this);
} else if (loadResult < 0) {
- ALOGW("Failed to query effect configuration, fallback to load .conf");
- // load automatic audio effect modules
- if (access(AUDIO_EFFECT_VENDOR_CONFIG_FILE, R_OK) == 0) {
- loadAudioEffectConfigLegacy(AUDIO_EFFECT_VENDOR_CONFIG_FILE);
- } else if (access(AUDIO_EFFECT_DEFAULT_CONFIG_FILE, R_OK) == 0) {
- loadAudioEffectConfigLegacy(AUDIO_EFFECT_DEFAULT_CONFIG_FILE);
- }
+ ALOGE("Failed to query effect configuration with status %d", loadResult);
} else if (loadResult > 0) {
ALOGE("Effect config is partially invalid, skipped %d elements", loadResult);
}
@@ -924,8 +918,7 @@
for (auto& stream : processingChain) {
auto effectDescs = std::make_unique<EffectDescVector>();
for (auto& effect : stream.effects) {
- effectDescs->mEffects.add(
- new EffectDesc{effect.get().name.c_str(), effect.get().uuid});
+ effectDescs->mEffects.add(new EffectDesc{effect->name.c_str(), effect->uuid});
}
streams.add(stream.type, effectDescs.release());
}
@@ -935,8 +928,7 @@
for (auto& deviceProcess : processingChain) {
auto effectDescs = std::make_unique<EffectDescVector>();
for (auto& effect : deviceProcess.effects) {
- effectDescs->mEffects.add(
- new EffectDesc{effect.get().name.c_str(), effect.get().uuid});
+ effectDescs->mEffects.add(new EffectDesc{effect->name.c_str(), effect->uuid});
}
auto deviceEffects = std::make_unique<DeviceEffects>(
std::move(effectDescs), deviceProcess.type, deviceProcess.address);
@@ -955,34 +947,6 @@
return skippedElements;
}
-status_t AudioPolicyEffects::loadAudioEffectConfigLegacy(const char *path)
-{
- cnode *root;
- char *data;
-
- data = (char *)load_file(path, NULL);
- if (data == NULL) {
- return -ENODEV;
- }
- root = config_node("", "");
- config_load(root, data);
-
- Vector <EffectDesc *> effects;
- loadEffects(root, effects);
- loadInputEffectConfigurations(root, effects);
- loadStreamEffectConfigurations(root, effects);
-
- for (size_t i = 0; i < effects.size(); i++) {
- delete effects[i];
- }
-
- config_free(root);
- free(root);
- free(data);
-
- return NO_ERROR;
-}
-
void AudioPolicyEffects::initDefaultDeviceEffects()
{
Mutex::Autolock _l(mLock);
diff --git a/services/audiopolicy/service/AudioPolicyEffects.h b/services/audiopolicy/service/AudioPolicyEffects.h
index 9f65a96..80b0f91 100644
--- a/services/audiopolicy/service/AudioPolicyEffects.h
+++ b/services/audiopolicy/service/AudioPolicyEffects.h
@@ -39,12 +39,7 @@
*
* This class manages all effects attached to input and output streams in AudioPolicyService.
* The effect configurations can be queried in several ways:
- *
- * With HIDL HAL, the configuration file `audio_effects.xml` will be loaded by libAudioHal. If this
- * file does not exist, AudioPolicyEffects class will fallback to load configuration from
- * `/vendor/etc/audio_effects.conf` (AUDIO_EFFECT_VENDOR_CONFIG_FILE). If this file also does not
- * exist, the configuration will be loaded from the file `/system/etc/audio_effects.conf`.
- *
+ * With HIDL HAL, the configuration file `audio_effects.xml` will be loaded by libAudioHal.
* With AIDL HAL, the configuration will be queried with the method `IFactory::queryProcessing()`.
*/
class AudioPolicyEffects : public RefBase
@@ -52,7 +47,7 @@
public:
- // The constructor will parse audio_effects.conf
+ // The constructor will parse audio_effects.xml
// First it will look whether vendor specific file exists,
// otherwise it will parse the system default file.
explicit AudioPolicyEffects(const sp<EffectsFactoryHalInterface>& effectsFactoryHal);
@@ -121,7 +116,7 @@
void initDefaultDeviceEffects();
// class to store the description of an effects and its parameters
- // as defined in audio_effects.conf
+ // as defined in audio_effects.xml
class EffectDesc {
public:
EffectDesc(const char *name,
@@ -235,8 +230,7 @@
static const char *kStreamNames[AUDIO_STREAM_PUBLIC_CNT+1]; //+1 required as streams start from -1
audio_stream_type_t streamNameToEnum(const char *name);
- // Parse audio_effects.conf
- status_t loadAudioEffectConfigLegacy(const char *path);
+ // Parse audio_effects.xml
status_t loadAudioEffectConfig(const sp<EffectsFactoryHalInterface>& effectsFactoryHal);
// Load all effects descriptors in configuration file
diff --git a/services/audiopolicy/service/AudioPolicyService.cpp b/services/audiopolicy/service/AudioPolicyService.cpp
index a0a3b65..9367949 100644
--- a/services/audiopolicy/service/AudioPolicyService.cpp
+++ b/services/audiopolicy/service/AudioPolicyService.cpp
@@ -1843,14 +1843,12 @@
void AudioPolicyService::SensorPrivacyPolicy::registerSelf() {
SensorPrivacyManager spm;
mSensorPrivacyEnabled = spm.isSensorPrivacyEnabled();
- (void)spm.addToggleSensorPrivacyListener(this);
spm.addSensorPrivacyListener(this);
}
void AudioPolicyService::SensorPrivacyPolicy::unregisterSelf() {
SensorPrivacyManager spm;
spm.removeSensorPrivacyListener(this);
- spm.removeToggleSensorPrivacyListener(this);
}
bool AudioPolicyService::SensorPrivacyPolicy::isSensorPrivacyEnabled() {
diff --git a/services/audiopolicy/service/AudioPolicyService.h b/services/audiopolicy/service/AudioPolicyService.h
index 4710a8a..6cac9f9 100644
--- a/services/audiopolicy/service/AudioPolicyService.h
+++ b/services/audiopolicy/service/AudioPolicyService.h
@@ -1072,7 +1072,7 @@
Mutex mNotificationClientsLock;
DefaultKeyedVector<int64_t, sp<NotificationClient>> mNotificationClients
GUARDED_BY(mNotificationClientsLock);
- // Manage all effects configured in audio_effects.conf
+ // Manage all effects configured in audio_effects.xml
// never hold AudioPolicyService::mLock when calling AudioPolicyEffects methods as
// those can call back into AudioPolicyService methods and try to acquire the mutex
sp<AudioPolicyEffects> mAudioPolicyEffects GUARDED_BY(mLock);
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index cecced4..eb824de 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -3910,18 +3910,21 @@
void CameraService::UidPolicy::registerWithActivityManager() {
Mutex::Autolock _l(mUidLock);
+ int32_t emptyUidArray[] = { };
if (mRegistered) return;
status_t res = mAm.linkToDeath(this);
- mAm.registerUidObserver(this, ActivityManager::UID_OBSERVER_GONE
+ mAm.registerUidObserverForUids(this, ActivityManager::UID_OBSERVER_GONE
| ActivityManager::UID_OBSERVER_IDLE
| ActivityManager::UID_OBSERVER_ACTIVE | ActivityManager::UID_OBSERVER_PROCSTATE
| ActivityManager::UID_OBSERVER_PROC_OOM_ADJ,
ActivityManager::PROCESS_STATE_UNKNOWN,
- String16("cameraserver"));
+ String16("cameraserver"), emptyUidArray, 0, mObserverToken);
if (res == OK) {
mRegistered = true;
ALOGV("UidPolicy: Registered with ActivityManager");
+ } else {
+ ALOGE("UidPolicy: Failed to register with ActivityManager: 0x%08x", res);
}
}
@@ -4019,13 +4022,16 @@
if (it->second.hasCamera) {
for (auto &monitoredUid : mMonitoredUids) {
if (monitoredUid.first != uid && adj > monitoredUid.second.procAdj) {
+ ALOGV("%s: notify uid %d", __FUNCTION__, monitoredUid.first);
notifyUidSet.emplace(monitoredUid.first);
}
}
+ ALOGV("%s: notify uid %d", __FUNCTION__, uid);
notifyUidSet.emplace(uid);
} else {
for (auto &monitoredUid : mMonitoredUids) {
if (monitoredUid.second.hasCamera && adj < monitoredUid.second.procAdj) {
+ ALOGV("%s: notify uid %d", __FUNCTION__, uid);
notifyUidSet.emplace(uid);
}
}
@@ -4056,6 +4062,10 @@
monitoredUid.procAdj = resource_policy::UNKNOWN_ADJ;
monitoredUid.refCount = 1;
it = mMonitoredUids.emplace(std::pair<uid_t, MonitoredUid>(uid, monitoredUid)).first;
+ status_t res = mAm.addUidToObserver(mObserverToken, String16("cameraserver"), uid);
+ if (res != OK) {
+ ALOGE("UidPolicy: Failed to add uid to observer: 0x%08x", res);
+ }
}
if (openCamera) {
@@ -4073,6 +4083,10 @@
it->second.refCount--;
if (it->second.refCount == 0) {
mMonitoredUids.erase(it);
+ status_t res = mAm.removeUidFromObserver(mObserverToken, String16("cameraserver"), uid);
+ if (res != OK) {
+ ALOGE("UidPolicy: Failed to remove uid from observer: 0x%08x", res);
+ }
} else if (closeCamera) {
it->second.hasCamera = false;
}
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index 8c57d26..d84cb00 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -798,6 +798,7 @@
// Monitored uid map
std::unordered_map<uid_t, MonitoredUid> mMonitoredUids;
std::unordered_map<uid_t, bool> mOverrideUids;
+ sp<IBinder> mObserverToken;
}; // class UidPolicy
// If sensor privacy is enabled then all apps, including those that are active, should be
diff --git a/services/camera/libcameraservice/CameraServiceWatchdog.cpp b/services/camera/libcameraservice/CameraServiceWatchdog.cpp
index 28dff7d..1c1bd24 100644
--- a/services/camera/libcameraservice/CameraServiceWatchdog.cpp
+++ b/services/camera/libcameraservice/CameraServiceWatchdog.cpp
@@ -43,8 +43,7 @@
mTidMap[currentThreadId].cycles++;
if (mTidMap[currentThreadId].cycles >= mMaxCycles) {
- std::string abortMessage = getAbortMessage(getpid(), currentThreadId,
- mTidMap[currentThreadId].functionName);
+ std::string abortMessage = getAbortMessage(mTidMap[currentThreadId].functionName);
android_set_abort_message(abortMessage.c_str());
ALOGW("CameraServiceWatchdog triggering abort for pid: %d tid: %d", getpid(),
currentThreadId);
@@ -60,10 +59,9 @@
return true;
}
-std::string CameraServiceWatchdog::getAbortMessage(int pid, int tid, std::string functionName) {
+std::string CameraServiceWatchdog::getAbortMessage(const std::string& functionName) {
std::string res = "CameraServiceWatchdog triggering abort during "
- + functionName + " | pid: " + std::to_string(pid)
- + " tid: " + std::to_string(tid);
+ + functionName;
return res;
}
diff --git a/services/camera/libcameraservice/CameraServiceWatchdog.h b/services/camera/libcameraservice/CameraServiceWatchdog.h
index 6f8858a..de6ac9e 100644
--- a/services/camera/libcameraservice/CameraServiceWatchdog.h
+++ b/services/camera/libcameraservice/CameraServiceWatchdog.h
@@ -144,7 +144,7 @@
*/
void stop(uint32_t tid);
- std::string getAbortMessage(int pid, int tid, std::string functionName);
+ std::string getAbortMessage(const std::string& functionName);
virtual bool threadLoop();
diff --git a/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp b/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp
index 4225366..af5f3ee 100644
--- a/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp
+++ b/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp
@@ -53,6 +53,7 @@
mSessionStats.mNewCameraState = CameraSessionStats::CAMERA_STATE_CLOSED;
mSessionStats.mLatencyMs = latencyMs;
mSessionStats.mDeviceError = deviceError;
+ mSessionStats.mSessionIndex = 0;
updateProxyDeviceState(proxyBinder);
}
@@ -74,6 +75,7 @@
mSessionStats.mNewCameraState = CameraSessionStats::CAMERA_STATE_ACTIVE;
mSessionStats.mMaxPreviewFps = maxPreviewFps;
+ mSessionStats.mSessionIndex++;
updateProxyDeviceState(proxyBinder);
// Reset mCreationDuration to -1 to distinguish between 1st session
diff --git a/services/tuner/TunerService.cpp b/services/tuner/TunerService.cpp
index e5bcf1f..9a1e8bb 100644
--- a/services/tuner/TunerService.cpp
+++ b/services/tuner/TunerService.cpp
@@ -100,8 +100,11 @@
if (fallBackToOpenDemux) {
auto status = mTuner->openDemux(&ids, &demux);
- return ::ndk::ScopedAStatus::fromServiceSpecificError(
- static_cast<int32_t>(Result::UNAVAILABLE));
+ if (status.isOk()) {
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerDemux>(demux, ids[0],
+ this->ref<TunerService>());
+ }
+ return status;
} else {
int id = TunerHelper::getResourceIdFromHandle(in_demuxHandle, DEMUX);
auto status = mTuner->openDemuxById(id, &demux);
diff --git a/services/tuner/hidl/TunerHidlFilter.cpp b/services/tuner/hidl/TunerHidlFilter.cpp
index 1789028..617622d 100644
--- a/services/tuner/hidl/TunerHidlFilter.cpp
+++ b/services/tuner/hidl/TunerHidlFilter.cpp
@@ -368,7 +368,7 @@
}
hidl_handle handle;
- handle.setTo(makeFromAidl(in_handle), true);
+ handle.setTo(makeFromAidl(in_handle));
HidlResult res = mFilter->releaseAvHandle(handle, in_avDataId);
if (res != HidlResult::SUCCESS) {
return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));