Skip to content

Commit

Permalink
Merge ZP1A.240612.001
Browse files Browse the repository at this point in the history
Change-Id: I0fceb185aac522900115417be23e13c048ccaae5
  • Loading branch information
Scott Lobdell committed Jun 25, 2024
2 parents 27fbe1e + 450f978 commit fb9c03a
Show file tree
Hide file tree
Showing 43 changed files with 590 additions and 316 deletions.
10 changes: 3 additions & 7 deletions camera/ndk/include/camera/NdkCameraMetadataTags.h
Original file line number Diff line number Diff line change
Expand Up @@ -2287,12 +2287,11 @@ typedef enum acamera_metadata_tag {
* <p>When low light boost is enabled by setting the AE mode to
* 'ON_LOW_LIGHT_BOOST_BRIGHTNESS_PRIORITY', it can dynamically apply a low light
* boost when the light level threshold is exceeded.</p>
* <p>This field is present in the CaptureResult when the AE mode is set to
* 'ON_LOW_LIGHT_BOOST_BRIGHTNESS_PRIORITY'. Otherwise, the field is not present.</p>
* <p>This state indicates when low light boost is 'ACTIVE' and applied. Similarly, it can
* indicate when it is not being applied by returning 'INACTIVE'.</p>
* <p>This key will be absent from the CaptureResult if AE mode is not set to
* 'ON_LOW_LIGHT_BOOST_BRIGHTNESS_PRIORITY.</p>
* <p>The default value will always be 'INACTIVE'.</p>
*/
ACAMERA_CONTROL_LOW_LIGHT_BOOST_STATE = // byte (acamera_metadata_enum_android_control_low_light_boost_state_t)
ACAMERA_CONTROL_START + 59,
Expand Down Expand Up @@ -8311,11 +8310,8 @@ typedef enum acamera_metadata_enum_acamera_control_ae_mode {
* <p>If the session configuration is not supported, the AE mode reported in the
* CaptureResult will be 'ON' instead of 'ON_LOW_LIGHT_BOOST_BRIGHTNESS_PRIORITY'.</p>
* <p>When this AE mode is enabled, the CaptureResult field
* ACAMERA_CONTROL_LOW_LIGHT_BOOST_STATE will be present and not null. Otherwise, the
* ACAMERA_CONTROL_LOW_LIGHT_BOOST_STATE field will not be present in the CaptureResult.</p>
* <p>The application can observe the CaptureResult field
* ACAMERA_CONTROL_LOW_LIGHT_BOOST_STATE to determine when low light boost is 'ACTIVE' or
* 'INACTIVE'.</p>
* ACAMERA_CONTROL_LOW_LIGHT_BOOST_STATE will indicate when low light boost is 'ACTIVE'
* or 'INACTIVE'. By default ACAMERA_CONTROL_LOW_LIGHT_BOOST_STATE will be 'INACTIVE'.</p>
* <p>The low light boost is 'ACTIVE' once the scene lighting condition is less than the
* upper bound lux value defined by ACAMERA_CONTROL_LOW_LIGHT_BOOST_INFO_LUMINANCE_RANGE.
* This mode will be 'INACTIVE' once the scene lighting condition is greater than the
Expand Down
2 changes: 1 addition & 1 deletion include/media/Interpolator.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class Interpolator : public std::map<S, T> {

std::string toString() const {
std::stringstream ss;
ss << "Interpolator{mInterpolatorType=" << static_cast<int32_t>(mInterpolatorType);
ss << "Interpolator{mInterpolatorType=" << media::toString(mInterpolatorType);
ss << ", mFirstSlope=" << mFirstSlope;
ss << ", mLastSlope=" << mLastSlope;
ss << ", {";
Expand Down
51 changes: 48 additions & 3 deletions include/media/VolumeShaper.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ class VolumeShaper {
TYPE_SCALE,
};

static std::string toString(Type type) {
switch (type) {
case TYPE_ID: return "TYPE_ID";
case TYPE_SCALE: return "TYPE_SCALE";
default:
return std::string("Unknown Type: ")
.append(std::to_string(static_cast<int>(type)));
}
}

// Must match with VolumeShaper.java in frameworks/base.
enum OptionFlag : int32_t {
OPTION_FLAG_NONE = 0,
Expand All @@ -125,6 +135,22 @@ class VolumeShaper {
OPTION_FLAG_ALL = (OPTION_FLAG_VOLUME_IN_DBFS | OPTION_FLAG_CLOCK_TIME),
};

static std::string toString(OptionFlag flag) {
std::string s;
for (const auto& flagPair : std::initializer_list<std::pair<OptionFlag, const char*>>{
{OPTION_FLAG_VOLUME_IN_DBFS, "OPTION_FLAG_VOLUME_IN_DBFS"},
{OPTION_FLAG_CLOCK_TIME, "OPTION_FLAG_CLOCK_TIME"},
}) {
if (flag & flagPair.first) {
if (!s.empty()) {
s.append("|");
}
s.append(flagPair.second);
}
}
return s;
}

// Bring from base class; must match with VolumeShaper.java in frameworks/base.
using InterpolatorType = Interpolator<S, T>::InterpolatorType;

Expand Down Expand Up @@ -329,10 +355,10 @@ class VolumeShaper {
// Returns a string for debug printing.
std::string toString() const {
std::stringstream ss;
ss << "VolumeShaper::Configuration{mType=" << static_cast<int32_t>(mType);
ss << "VolumeShaper::Configuration{mType=" << toString(mType);
ss << ", mId=" << mId;
if (mType != TYPE_ID) {
ss << ", mOptionFlags=" << static_cast<int32_t>(mOptionFlags);
ss << ", mOptionFlags=" << toString(mOptionFlags);
ss << ", mDurationMs=" << mDurationMs;
ss << ", " << Interpolator<S, T>::toString().c_str();
}
Expand Down Expand Up @@ -414,6 +440,25 @@ class VolumeShaper {
| FLAG_CREATE_IF_NECESSARY),
};

static std::string toString(Flag flag) {
std::string s;
for (const auto& flagPair : std::initializer_list<std::pair<Flag, const char*>>{
{FLAG_REVERSE, "FLAG_REVERSE"},
{FLAG_TERMINATE, "FLAG_TERMINATE"},
{FLAG_JOIN, "FLAG_JOIN"},
{FLAG_DELAY, "FLAG_DELAY"},
{FLAG_CREATE_IF_NECESSARY, "FLAG_CREATE_IF_NECESSARY"},
}) {
if (flag & flagPair.first) {
if (!s.empty()) {
s.append("|");
}
s.append(flagPair.second);
}
}
return s;
}

Operation()
: Operation(FLAG_NONE, -1 /* replaceId */) {
}
Expand Down Expand Up @@ -508,7 +553,7 @@ class VolumeShaper {

std::string toString() const {
std::stringstream ss;
ss << "VolumeShaper::Operation{mFlags=" << static_cast<int32_t>(mFlags) ;
ss << "VolumeShaper::Operation{mFlags=" << toString(mFlags);
ss << ", mReplaceId=" << mReplaceId;
ss << ", mXOffset=" << mXOffset;
ss << "}";
Expand Down
7 changes: 7 additions & 0 deletions media/audio/aconfig/audio.aconfig
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ flag {
bug: "307588546"
}

flag {
name: "music_fx_edge_to_edge"
namespace: "media_audio"
description: "Enable Edge-to-edge feature for MusicFx and handle insets"
bug: "336204940"
}

flag {
name: "port_to_piid_simplification"
namespace: "media_audio"
Expand Down
7 changes: 7 additions & 0 deletions media/audio/aconfig/audioserver.aconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ flag {
bug: "294525897"
}

flag {
name: "effect_chain_callback_improve"
namespace: "media_audio"
description: "Improve effect chain callback mutex logic."
bug: "342413767"
}

flag {
name: "fdtostring_timeout_fix"
namespace: "media_audio"
Expand Down
20 changes: 2 additions & 18 deletions media/audioaidlconversion/AidlConversionCppNdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1069,13 +1069,6 @@ ::android::status_t aidl2legacy_AudioDevice_audio_device(
if (mac.size() != 6) return BAD_VALUE;
snprintf(addressBuffer, AUDIO_DEVICE_MAX_ADDRESS_LEN, "%02X:%02X:%02X:%02X:%02X:%02X",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
// special case for anonymized mac address:
// change anonymized bytes back from FD:FF:FF:FF to XX:XX:XX:XX
std::string address(addressBuffer);
if (address.compare(0, strlen("FD:FF:FF:FF"), "FD:FF:FF:FF") == 0) {
address.replace(0, strlen("FD:FF:FF:FF"), "XX:XX:XX:XX");
}
strcpy(addressBuffer, address.c_str());
} break;
case Tag::ipv4: {
const std::vector<uint8_t>& ipv4 = aidl.address.get<AudioDeviceAddress::ipv4>();
Expand Down Expand Up @@ -1136,20 +1129,11 @@ legacy2aidl_audio_device_AudioDevice(
if (!legacyAddress.empty()) {
switch (suggestDeviceAddressTag(aidl.type)) {
case Tag::mac: {
// special case for anonymized mac address:
// change anonymized bytes so that they can be scanned as HEX bytes
// Use '01' for LSB bits 0 and 1 as Bluetooth MAC addresses are never multicast
// and universaly administered
std::string address = legacyAddress;
if (address.compare(0, strlen("XX:XX:XX:XX"), "XX:XX:XX:XX") == 0) {
address.replace(0, strlen("XX:XX:XX:XX"), "FD:FF:FF:FF");
}

std::vector<uint8_t> mac(6);
int status = sscanf(address.c_str(), "%hhX:%hhX:%hhX:%hhX:%hhX:%hhX",
int status = sscanf(legacyAddress.c_str(), "%hhX:%hhX:%hhX:%hhX:%hhX:%hhX",
&mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);
if (status != mac.size()) {
ALOGE("%s: malformed MAC address: \"%s\"", __func__, address.c_str());
ALOGE("%s: malformed MAC address: \"%s\"", __func__, legacyAddress.c_str());
return unexpected(BAD_VALUE);
}
aidl.address = AudioDeviceAddress::make<AudioDeviceAddress::mac>(std::move(mac));
Expand Down
36 changes: 26 additions & 10 deletions media/codec2/hal/aidl/ComponentStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <ostream>
#include <sstream>

#ifndef __ANDROID_APEX__
#ifndef __ANDROID_APEX__ // Filters are not supported for APEX modules
#include <codec2/hidl/plugin/FilterPlugin.h>
#include <dlfcn.h>
#include <C2Config.h>
Expand All @@ -51,7 +51,7 @@ namespace media {
namespace c2 {
namespace utils {

#ifndef __ANDROID_APEX__
#ifndef __ANDROID_APEX__ // Filters are not supported for APEX modules
using ::android::DefaultFilterPlugin;
using ::android::FilterWrapper;
#endif
Expand Down Expand Up @@ -144,7 +144,15 @@ ComponentStore::ComponentStore(const std::shared_ptr<C2ComponentStore>& store)
::android::SetPreferredCodec2ComponentStore(store);

// Retrieve struct descriptors
mParamReflector = mStore->getParamReflector();
mParamReflectors.push_back(mStore->getParamReflector());
#ifndef __ANDROID_APEX__ // Filters are not supported for APEX modules
std::shared_ptr<C2ParamReflector> paramReflector =
GetFilterWrapper()->getParamReflector();
if (paramReflector != nullptr) {
ALOGD("[%s] added param reflector from filter wrapper", mStore->getName().c_str());
mParamReflectors.push_back(paramReflector);
}
#endif

// Retrieve supported parameters from store
using namespace std::placeholders;
Expand Down Expand Up @@ -173,8 +181,7 @@ c2_status_t ComponentStore::validateSupportedParams(
std::lock_guard<std::mutex> lock(mStructDescriptorsMutex);
auto it = mStructDescriptors.find(coreIndex);
if (it == mStructDescriptors.end()) {
std::shared_ptr<C2StructDescriptor> structDesc =
mParamReflector->describe(coreIndex);
std::shared_ptr<C2StructDescriptor> structDesc = describe(coreIndex);
if (!structDesc) {
// All supported params must be described
res = C2_BAD_INDEX;
Expand All @@ -189,7 +196,7 @@ std::shared_ptr<ParameterCache> ComponentStore::getParameterCache() const {
return mParameterCache;
}

#ifndef __ANDROID_APEX__
#ifndef __ANDROID_APEX__ // Filters are not supported for APEX modules
// static
std::shared_ptr<FilterWrapper> ComponentStore::GetFilterWrapper() {
constexpr const char kPluginPath[] = "libc2filterplugin.so";
Expand Down Expand Up @@ -220,7 +227,7 @@ ScopedAStatus ComponentStore::createComponent(
mStore->createComponent(name, &c2component);

if (status == C2_OK) {
#ifndef __ANDROID_APEX__
#ifndef __ANDROID_APEX__ // Filters are not supported for APEX modules
c2component = GetFilterWrapper()->maybeWrapComponent(c2component);
#endif
onInterfaceLoaded(c2component->intf());
Expand Down Expand Up @@ -254,7 +261,7 @@ ScopedAStatus ComponentStore::createInterface(
std::shared_ptr<C2ComponentInterface> c2interface;
c2_status_t res = mStore->createInterface(name, &c2interface);
if (res == C2_OK) {
#ifndef __ANDROID_APEX__
#ifndef __ANDROID_APEX__ // Filters are not supported for APEX modules
c2interface = GetFilterWrapper()->maybeWrapInterface(c2interface);
#endif
onInterfaceLoaded(c2interface);
Expand Down Expand Up @@ -314,8 +321,7 @@ ScopedAStatus ComponentStore::getStructDescriptors(
if (item == mStructDescriptors.end()) {
// not in the cache, and not known to be unsupported, query local reflector
if (!mUnsupportedStructDescriptors.count(coreIndex)) {
std::shared_ptr<C2StructDescriptor> structDesc =
mParamReflector->describe(coreIndex);
std::shared_ptr<C2StructDescriptor> structDesc = describe(coreIndex);
if (!structDesc) {
mUnsupportedStructDescriptors.emplace(coreIndex);
} else {
Expand Down Expand Up @@ -368,6 +374,16 @@ ScopedAStatus ComponentStore::getConfigurable(
return ScopedAStatus::ok();
}

std::shared_ptr<C2StructDescriptor> ComponentStore::describe(const C2Param::CoreIndex &index) {
for (const std::shared_ptr<C2ParamReflector> &reflector : mParamReflectors) {
std::shared_ptr<C2StructDescriptor> desc = reflector->describe(index);
if (desc) {
return desc;
}
}
return nullptr;
}

// Called from createComponent() after a successful creation of `component`.
void ComponentStore::reportComponentBirth(Component* component) {
ComponentStatus componentStatus;
Expand Down
5 changes: 4 additions & 1 deletion media/codec2/hal/aidl/include/codec2/aidl/ComponentStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ struct ComponentStore : public BnComponentStore {

c2_status_t mInit;
std::shared_ptr<C2ComponentStore> mStore;
std::shared_ptr<C2ParamReflector> mParamReflector;
std::vector<std::shared_ptr<C2ParamReflector>> mParamReflectors;

std::map<C2Param::CoreIndex, std::shared_ptr<C2StructDescriptor>> mStructDescriptors;
std::set<C2Param::CoreIndex> mUnsupportedStructDescriptors;
Expand All @@ -132,6 +132,9 @@ struct ComponentStore : public BnComponentStore {
mutable std::mutex mComponentRosterMutex;
std::map<Component*, ComponentStatus> mComponentRoster;

// describe from mParamReflectors
std::shared_ptr<C2StructDescriptor> describe(const C2Param::CoreIndex &index);

// Called whenever Component is created.
void reportComponentBirth(Component* component);
// Called only from the destructor of Component.
Expand Down
26 changes: 21 additions & 5 deletions media/codec2/hal/hidl/1.0/utils/ComponentStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,15 @@ ComponentStore::ComponentStore(const std::shared_ptr<C2ComponentStore>& store)
SetPreferredCodec2ComponentStore(store);

// Retrieve struct descriptors
mParamReflector = mStore->getParamReflector();
mParamReflectors.push_back(mStore->getParamReflector());
#ifndef __ANDROID_APEX__
std::shared_ptr<C2ParamReflector> paramReflector =
GetFilterWrapper()->getParamReflector();
if (paramReflector != nullptr) {
ALOGD("[%s] added param reflector from filter wrapper", mStore->getName().c_str());
mParamReflectors.push_back(paramReflector);
}
#endif

// Retrieve supported parameters from store
using namespace std::placeholders;
Expand Down Expand Up @@ -168,8 +176,7 @@ c2_status_t ComponentStore::validateSupportedParams(
std::lock_guard<std::mutex> lock(mStructDescriptorsMutex);
auto it = mStructDescriptors.find(coreIndex);
if (it == mStructDescriptors.end()) {
std::shared_ptr<C2StructDescriptor> structDesc =
mParamReflector->describe(coreIndex);
std::shared_ptr<C2StructDescriptor> structDesc = describe(coreIndex);
if (!structDesc) {
// All supported params must be described
res = C2_BAD_INDEX;
Expand Down Expand Up @@ -307,8 +314,7 @@ Return<void> ComponentStore::getStructDescriptors(
if (item == mStructDescriptors.end()) {
// not in the cache, and not known to be unsupported, query local reflector
if (!mUnsupportedStructDescriptors.count(coreIndex)) {
std::shared_ptr<C2StructDescriptor> structDesc =
mParamReflector->describe(coreIndex);
std::shared_ptr<C2StructDescriptor> structDesc = describe(coreIndex);
if (!structDesc) {
mUnsupportedStructDescriptors.emplace(coreIndex);
} else {
Expand Down Expand Up @@ -354,6 +360,16 @@ Return<sp<IConfigurable>> ComponentStore::getConfigurable() {
return mConfigurable;
}

std::shared_ptr<C2StructDescriptor> ComponentStore::describe(const C2Param::CoreIndex &index) {
for (const std::shared_ptr<C2ParamReflector> &reflector : mParamReflectors) {
std::shared_ptr<C2StructDescriptor> desc = reflector->describe(index);
if (desc) {
return desc;
}
}
return nullptr;
}

// Called from createComponent() after a successful creation of `component`.
void ComponentStore::reportComponentBirth(Component* component) {
ComponentStatus componentStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,12 @@ struct ComponentStore : public IComponentStore {
// Does bookkeeping for an interface that has been loaded.
void onInterfaceLoaded(const std::shared_ptr<C2ComponentInterface> &intf);

// describe from mParamReflectors
std::shared_ptr<C2StructDescriptor> describe(const C2Param::CoreIndex &index);

c2_status_t mInit;
std::shared_ptr<C2ComponentStore> mStore;
std::shared_ptr<C2ParamReflector> mParamReflector;
std::vector<std::shared_ptr<C2ParamReflector>> mParamReflectors;

std::map<C2Param::CoreIndex, std::shared_ptr<C2StructDescriptor>> mStructDescriptors;
std::set<C2Param::CoreIndex> mUnsupportedStructDescriptors;
Expand Down
Loading

0 comments on commit fb9c03a

Please sign in to comment.