Merge "Move handling of flags of audio ports to libaudiofoundation"
diff --git a/media/libaudioclient/AidlConversion.cpp b/media/libaudioclient/AidlConversion.cpp
index 343bcef..8314320 100644
--- a/media/libaudioclient/AidlConversion.cpp
+++ b/media/libaudioclient/AidlConversion.cpp
@@ -1589,44 +1589,29 @@
}
ConversionResult<audio_io_flags> aidl2legacy_AudioIoFlags_audio_io_flags(
- const AudioIoFlags& aidl, media::AudioPortRole role, media::AudioPortType type) {
+ const AudioIoFlags& aidl, bool isInput) {
audio_io_flags legacy;
- Direction dir = VALUE_OR_RETURN(direction(role, type));
- switch (dir) {
- case Direction::INPUT: {
- legacy.input = VALUE_OR_RETURN(
- aidl2legacy_int32_t_audio_input_flags_t_mask(
- VALUE_OR_RETURN(UNION_GET(aidl, input))));
- }
- break;
-
- case Direction::OUTPUT: {
- legacy.output = VALUE_OR_RETURN(
- aidl2legacy_int32_t_audio_output_flags_t_mask(
- VALUE_OR_RETURN(UNION_GET(aidl, output))));
- }
- break;
+ if (isInput) {
+ legacy.input = VALUE_OR_RETURN(
+ aidl2legacy_int32_t_audio_input_flags_t_mask(
+ VALUE_OR_RETURN(UNION_GET(aidl, input))));
+ } else {
+ legacy.output = VALUE_OR_RETURN(
+ aidl2legacy_int32_t_audio_output_flags_t_mask(
+ VALUE_OR_RETURN(UNION_GET(aidl, output))));
}
-
return legacy;
}
ConversionResult<AudioIoFlags> legacy2aidl_audio_io_flags_AudioIoFlags(
- const audio_io_flags& legacy, audio_port_role_t role, audio_port_type_t type) {
+ const audio_io_flags& legacy, bool isInput) {
AudioIoFlags aidl;
-
- Direction dir = VALUE_OR_RETURN(direction(role, type));
- switch (dir) {
- case Direction::INPUT:
- UNION_SET(aidl, input,
- VALUE_OR_RETURN(legacy2aidl_audio_input_flags_t_int32_t_mask(
- legacy.input)));
- break;
- case Direction::OUTPUT:
- UNION_SET(aidl, output,
- VALUE_OR_RETURN(legacy2aidl_audio_output_flags_t_int32_t_mask(
- legacy.output)));
- break;
+ if (isInput) {
+ UNION_SET(aidl, input,
+ VALUE_OR_RETURN(legacy2aidl_audio_input_flags_t_int32_t_mask(legacy.input)));
+ } else {
+ UNION_SET(aidl, output,
+ VALUE_OR_RETURN(legacy2aidl_audio_output_flags_t_int32_t_mask(legacy.output)));
}
return aidl;
}
@@ -2000,8 +1985,7 @@
}
if (aidl.hal.flags.has_value()) {
legacy.flags = VALUE_OR_RETURN(
- aidl2legacy_AudioIoFlags_audio_io_flags(
- aidl.hal.flags.value(), aidl.sys.role, aidl.sys.type));
+ aidl2legacy_AudioIoFlags_audio_io_flags(aidl.hal.flags.value(), isInput));
legacy.config_mask |= AUDIO_PORT_CONFIG_FLAGS;
}
legacy.ext = VALUE_OR_RETURN(
@@ -2037,7 +2021,7 @@
}
if (legacy.config_mask & AUDIO_PORT_CONFIG_FLAGS) {
aidl.hal.flags = VALUE_OR_RETURN(
- legacy2aidl_audio_io_flags_AudioIoFlags(legacy.flags, legacy.role, legacy.type));
+ legacy2aidl_audio_io_flags_AudioIoFlags(legacy.flags, isInput));
}
RETURN_IF_ERROR(legacy2aidl_AudioPortExt(legacy.ext, legacy.type, legacy.role,
&aidl.hal.ext, &aidl.sys.ext));
diff --git a/media/libaudioclient/include/media/AidlConversion.h b/media/libaudioclient/include/media/AidlConversion.h
index fda9efb..a6c93cf 100644
--- a/media/libaudioclient/include/media/AidlConversion.h
+++ b/media/libaudioclient/include/media/AidlConversion.h
@@ -194,10 +194,9 @@
audio_output_flags_t legacy);
ConversionResult<audio_io_flags> aidl2legacy_AudioIoFlags_audio_io_flags(
- const media::audio::common::AudioIoFlags& aidl,
- media::AudioPortRole role, media::AudioPortType type);
+ const media::audio::common::AudioIoFlags& aidl, bool isInput);
ConversionResult<media::audio::common::AudioIoFlags> legacy2aidl_audio_io_flags_AudioIoFlags(
- const audio_io_flags& legacy, audio_port_role_t role, audio_port_type_t type);
+ const audio_io_flags& legacy, bool isInput);
ConversionResult<audio_port_config_device_ext>
aidl2legacy_AudioPortDeviceExt_audio_port_config_device_ext(
diff --git a/media/libaudiofoundation/AudioPort.cpp b/media/libaudiofoundation/AudioPort.cpp
index a00e00d..634b2e1 100644
--- a/media/libaudiofoundation/AudioPort.cpp
+++ b/media/libaudiofoundation/AudioPort.cpp
@@ -24,6 +24,22 @@
namespace android {
+void AudioPort::setFlags(uint32_t flags)
+{
+ // force direct flag if offload flag is set: offloading implies a direct output stream
+ // and all common behaviors are driven by checking only the direct flag
+ // this should normally be set appropriately in the policy configuration file
+ if (mRole == AUDIO_PORT_ROLE_SOURCE &&
+ (flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) != 0) {
+ flags |= AUDIO_OUTPUT_FLAG_DIRECT;
+ }
+ if (useInputChannelMask()) {
+ mFlags.input = static_cast<audio_input_flags_t>(flags);
+ } else {
+ mFlags.output = static_cast<audio_output_flags_t>(flags);
+ }
+}
+
void AudioPort::importAudioPort(const sp<AudioPort>& port, bool force __unused)
{
for (const auto& profileToImport : port->mProfiles) {
@@ -195,16 +211,10 @@
mType == other->getType() &&
mRole == other->getRole() &&
mProfiles.equals(other->getAudioProfiles()) &&
+ getFlags() == other->getFlags() &&
mExtraAudioDescriptors == other->getExtraAudioDescriptors();
}
-status_t AudioPort::writeToParcel(Parcel *parcel) const
-{
- media::AudioPort parcelable;
- return writeToParcelable(&parcelable)
- ?: parcelable.writeToParcel(parcel);
-}
-
status_t AudioPort::writeToParcelable(media::AudioPort* parcelable) const {
parcelable->hal.name = mName;
parcelable->sys.type = VALUE_OR_RETURN_STATUS(
@@ -215,6 +225,8 @@
legacy2aidl_AudioProfileVector(mProfiles, useInputChannelMask()));
parcelable->hal.profiles = aidlProfiles.first;
parcelable->sys.profiles = aidlProfiles.second;
+ parcelable->hal.flags = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_io_flags_AudioIoFlags(mFlags, useInputChannelMask()));
parcelable->hal.extraAudioDescriptors = mExtraAudioDescriptors;
auto aidlGains = VALUE_OR_RETURN_STATUS(legacy2aidl_AudioGains(mGains));
parcelable->hal.gains = aidlGains.first;
@@ -230,12 +242,6 @@
return OK;
}
-status_t AudioPort::readFromParcel(const Parcel *parcel) {
- media::AudioPort parcelable;
- return parcelable.readFromParcel(parcel)
- ?: readFromParcelable(parcelable);
-}
-
status_t AudioPort::readFromParcelable(const media::AudioPort& parcelable) {
mName = parcelable.hal.name;
mType = VALUE_OR_RETURN_STATUS(
@@ -246,6 +252,8 @@
aidl2legacy_AudioProfileVector(
std::make_pair(parcelable.hal.profiles, parcelable.sys.profiles),
useInputChannelMask()));
+ mFlags = VALUE_OR_RETURN_STATUS(
+ aidl2legacy_AudioIoFlags_audio_io_flags(parcelable.hal.flags, useInputChannelMask()));
mExtraAudioDescriptors = parcelable.hal.extraAudioDescriptors;
mGains = VALUE_OR_RETURN_STATUS(
aidl2legacy_AudioGains(std::make_pair(parcelable.hal.gains, parcelable.sys.gains)));
@@ -277,6 +285,9 @@
if (config->config_mask & AUDIO_PORT_CONFIG_GAIN) {
mGain = config->gain;
}
+ if (config->config_mask & AUDIO_PORT_CONFIG_FLAGS) {
+ mFlags = config->flags;
+ }
return NO_ERROR;
}
@@ -330,6 +341,9 @@
} else {
dstConfig->config_mask &= ~AUDIO_PORT_CONFIG_GAIN;
}
+
+ updateField(mFlags, &audio_port_config::flags,
+ dstConfig, srcConfig, AUDIO_PORT_CONFIG_FLAGS, { AUDIO_INPUT_FLAG_NONE });
}
bool AudioPortConfig::hasGainController(bool canUseForVolume) const
@@ -342,12 +356,14 @@
: audioport->getGains().size() > 0;
}
-bool AudioPortConfig::equals(const sp<AudioPortConfig> &other) const
+bool AudioPortConfig::equals(const sp<AudioPortConfig> &other, bool isInput) const
{
return other != nullptr &&
mSamplingRate == other->getSamplingRate() &&
mFormat == other->getFormat() &&
mChannelMask == other->getChannelMask() &&
+ (isInput ? mFlags.input == other->getFlags().input :
+ mFlags.output == other->getFlags().output )&&
// Compare audio gain config
mGain.index == other->mGain.index &&
mGain.mode == other->mGain.mode &&
@@ -370,6 +386,8 @@
media::audio::common::AudioGainConfig aidl_gain = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_gain_config_AudioGainConfig(mGain, isInput));
parcelable->gain = aidl_gain;
+ parcelable->flags = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_io_flags_AudioIoFlags(mFlags, isInput));
return OK;
}
@@ -393,6 +411,10 @@
mGain = VALUE_OR_RETURN_STATUS(
aidl2legacy_AudioGainConfig_audio_gain_config(parcelable.gain.value(), isInput));
}
+ if (parcelable.flags.has_value()) {
+ mFlags = VALUE_OR_RETURN_STATUS(
+ aidl2legacy_AudioIoFlags_audio_io_flags(parcelable.flags.value(), isInput));
+ }
return OK;
}
diff --git a/media/libaudiofoundation/DeviceDescriptorBase.cpp b/media/libaudiofoundation/DeviceDescriptorBase.cpp
index b383db4..c8222e7 100644
--- a/media/libaudiofoundation/DeviceDescriptorBase.cpp
+++ b/media/libaudiofoundation/DeviceDescriptorBase.cpp
@@ -164,7 +164,7 @@
{
return other != nullptr &&
static_cast<const AudioPort*>(this)->equals(other) &&
- static_cast<const AudioPortConfig*>(this)->equals(other) &&
+ static_cast<const AudioPortConfig*>(this)->equals(other, useInputChannelMask()) &&
mDeviceTypeAddr.equals(other->mDeviceTypeAddr) &&
checkEqual(mEncodedFormats, other->mEncodedFormats);
}
@@ -183,14 +183,6 @@
return false;
}
-
-status_t DeviceDescriptorBase::writeToParcel(Parcel *parcel) const
-{
- media::AudioPort parcelable;
- return writeToParcelable(&parcelable)
- ?: parcelable.writeToParcel(parcel);
-}
-
status_t DeviceDescriptorBase::writeToParcelable(media::AudioPort* parcelable) const {
AudioPort::writeToParcelable(parcelable);
AudioPortConfig::writeToParcelable(&parcelable->hal.activeConfig, useInputChannelMask());
@@ -212,12 +204,6 @@
return OK;
}
-status_t DeviceDescriptorBase::readFromParcel(const Parcel *parcel) {
- media::AudioPort parcelable;
- return parcelable.readFromParcel(parcel)
- ?: readFromParcelable(parcelable);
-}
-
status_t DeviceDescriptorBase::readFromParcelable(const media::AudioPort& parcelable) {
if (parcelable.sys.type != media::AudioPortType::DEVICE) {
return BAD_VALUE;
diff --git a/media/libaudiofoundation/include/media/AudioPort.h b/media/libaudiofoundation/include/media/AudioPort.h
index b5a17c9..985e05e 100644
--- a/media/libaudiofoundation/include/media/AudioPort.h
+++ b/media/libaudiofoundation/include/media/AudioPort.h
@@ -33,7 +33,7 @@
namespace android {
-class AudioPort : public virtual RefBase, public virtual Parcelable
+class AudioPort : public virtual RefBase
{
public:
AudioPort(const std::string& name, audio_port_type_t type, audio_port_role_t role) :
@@ -47,6 +47,9 @@
audio_port_type_t getType() const { return mType; }
audio_port_role_t getRole() const { return mRole; }
+ virtual void setFlags(uint32_t flags);
+ uint32_t getFlags() const { return useInputChannelMask() ? mFlags.input : mFlags.output; }
+
void setGains(const AudioGains &gains) { mGains = gains; }
const AudioGains &getGains() const { return mGains; }
@@ -93,15 +96,27 @@
((mType == AUDIO_PORT_TYPE_MIX) && (mRole == AUDIO_PORT_ROLE_SINK));
}
+ bool isDirectOutput() const
+ {
+ return (mType == AUDIO_PORT_TYPE_MIX) && (mRole == AUDIO_PORT_ROLE_SOURCE) &&
+ ((mFlags.output & AUDIO_OUTPUT_FLAG_DIRECT) != 0);
+ }
+
+ bool isMmap() const
+ {
+ return (mType == AUDIO_PORT_TYPE_MIX)
+ && (((mRole == AUDIO_PORT_ROLE_SOURCE) &&
+ ((mFlags.output & AUDIO_OUTPUT_FLAG_MMAP_NOIRQ) != 0))
+ || ((mRole == AUDIO_PORT_ROLE_SINK) &&
+ ((mFlags.input & AUDIO_INPUT_FLAG_MMAP_NOIRQ) != 0)));
+ }
+
void dump(std::string *dst, int spaces, bool verbose = true) const;
void log(const char* indent) const;
bool equals(const sp<AudioPort>& other) const;
- status_t writeToParcel(Parcel* parcel) const override;
- status_t readFromParcel(const Parcel* parcel) override;
-
status_t writeToParcelable(media::AudioPort* parcelable) const;
status_t readFromParcelable(const media::AudioPort& parcelable);
@@ -130,6 +145,7 @@
// Audio capabilities that are defined by hardware descriptors when the format is unrecognized
// by the platform, e.g. short audio descriptor in EDID for HDMI.
std::vector<media::audio::common::ExtraAudioDescriptor> mExtraAudioDescriptors;
+ union audio_io_flags mFlags = { .output = AUDIO_OUTPUT_FLAG_NONE };
private:
template <typename T, std::enable_if_t<std::is_same<T, struct audio_port>::value
|| std::is_same<T, struct audio_port_v7>::value, int> = 0>
@@ -162,10 +178,11 @@
audio_format_t getFormat() const { return mFormat; }
audio_channel_mask_t getChannelMask() const { return mChannelMask; }
audio_port_handle_t getId() const { return mId; }
+ audio_io_flags getFlags() const { return mFlags; }
bool hasGainController(bool canUseForVolume = false) const;
- bool equals(const sp<AudioPortConfig>& other) const;
+ bool equals(const sp<AudioPortConfig>& other, bool isInput) const;
status_t writeToParcelable(
media::audio::common::AudioPortConfig* parcelable, bool isInput) const;
@@ -178,6 +195,7 @@
audio_channel_mask_t mChannelMask = AUDIO_CHANNEL_NONE;
audio_port_handle_t mId = AUDIO_PORT_HANDLE_NONE;
struct audio_gain_config mGain = { .index = -1 };
+ union audio_io_flags mFlags = { AUDIO_INPUT_FLAG_NONE };
};
} // namespace android
diff --git a/media/libaudiofoundation/include/media/DeviceDescriptorBase.h b/media/libaudiofoundation/include/media/DeviceDescriptorBase.h
index a4092eb..b70da8a 100644
--- a/media/libaudiofoundation/include/media/DeviceDescriptorBase.h
+++ b/media/libaudiofoundation/include/media/DeviceDescriptorBase.h
@@ -79,9 +79,6 @@
bool equals(const sp<DeviceDescriptorBase>& other) const;
- status_t writeToParcel(Parcel* parcel) const override;
- status_t readFromParcel(const Parcel* parcel) override;
-
status_t writeToParcelable(media::AudioPort* parcelable) const;
status_t readFromParcelable(const media::AudioPort& parcelable);
diff --git a/media/libaudiofoundation/tests/audiofoundation_parcelable_test.cpp b/media/libaudiofoundation/tests/audiofoundation_parcelable_test.cpp
index 0315a59..50d8dc8 100644
--- a/media/libaudiofoundation/tests/audiofoundation_parcelable_test.cpp
+++ b/media/libaudiofoundation/tests/audiofoundation_parcelable_test.cpp
@@ -112,38 +112,37 @@
}
TEST(AudioFoundationParcelableTest, ParcelingAudioPort) {
- Parcel data;
sp<AudioPort> audioPort = new AudioPort(
"AudioPortName", AUDIO_PORT_TYPE_DEVICE, AUDIO_PORT_ROLE_SINK);
audioPort->setGains(getAudioGainsForTest());
audioPort->setAudioProfiles(getAudioProfileVectorForTest());
- ASSERT_EQ(data.writeParcelable(*audioPort), NO_ERROR);
- data.setDataPosition(0);
+ media::AudioPort parcelable;
+ ASSERT_EQ(NO_ERROR, audioPort->writeToParcelable(&parcelable));
sp<AudioPort> audioPortFromParcel = new AudioPort(
"", AUDIO_PORT_TYPE_NONE, AUDIO_PORT_ROLE_NONE);
- ASSERT_EQ(data.readParcelable(audioPortFromParcel.get()), NO_ERROR);
+ ASSERT_EQ(NO_ERROR, audioPortFromParcel->readFromParcelable(parcelable));
ASSERT_TRUE(audioPortFromParcel->equals(audioPort));
}
TEST(AudioFoundationParcelableTest, ParcelingAudioPortConfig) {
+ const bool isInput = false;
Parcel data;
sp<AudioPortConfig> audioPortConfig = new AudioPortConfigTestStub();
audioPortConfig->applyAudioPortConfig(&TEST_AUDIO_PORT_CONFIG);
media::audio::common::AudioPortConfig parcelable{};
- ASSERT_EQ(NO_ERROR, audioPortConfig->writeToParcelable(&parcelable, false /*isInput*/));
+ ASSERT_EQ(NO_ERROR, audioPortConfig->writeToParcelable(&parcelable, isInput));
ASSERT_EQ(NO_ERROR, data.writeParcelable(parcelable));
data.setDataPosition(0);
media::audio::common::AudioPortConfig parcelableFromParcel{};
ASSERT_EQ(NO_ERROR, data.readParcelable(&parcelableFromParcel));
sp<AudioPortConfig> audioPortConfigFromParcel = new AudioPortConfigTestStub();
ASSERT_EQ(NO_ERROR, audioPortConfigFromParcel->readFromParcelable(
- parcelableFromParcel, false /*isInput*/));
- ASSERT_TRUE(audioPortConfigFromParcel->equals(audioPortConfig));
+ parcelableFromParcel, isInput));
+ ASSERT_TRUE(audioPortConfigFromParcel->equals(audioPortConfig, isInput));
}
TEST(AudioFoundationParcelableTest, ParcelingDeviceDescriptorBase) {
- Parcel data;
sp<DeviceDescriptorBase> desc = new DeviceDescriptorBase(AUDIO_DEVICE_OUT_SPEAKER);
desc->setGains(getAudioGainsForTest());
desc->setAudioProfiles(getAudioProfileVectorForTest());
@@ -153,10 +152,10 @@
ASSERT_EQ(desc->setEncapsulationMetadataTypes(
AUDIO_ENCAPSULATION_METADATA_TYPE_ALL_POSITION_BITS), NO_ERROR);
- ASSERT_EQ(data.writeParcelable(*desc), NO_ERROR);
- data.setDataPosition(0);
+ media::AudioPort parcelable;
+ ASSERT_EQ(NO_ERROR, desc->writeToParcelable(&parcelable));
sp<DeviceDescriptorBase> descFromParcel = new DeviceDescriptorBase(AUDIO_DEVICE_NONE);
- ASSERT_EQ(data.readParcelable(descFromParcel.get()), NO_ERROR);
+ ASSERT_EQ(NO_ERROR, descFromParcel->readFromParcelable(parcelable));
ASSERT_TRUE(descFromParcel->equals(desc));
}
diff --git a/services/audiopolicy/common/managerdefinitions/include/AudioInputDescriptor.h b/services/audiopolicy/common/managerdefinitions/include/AudioInputDescriptor.h
index a40f6aa..cf699d3 100644
--- a/services/audiopolicy/common/managerdefinitions/include/AudioInputDescriptor.h
+++ b/services/audiopolicy/common/managerdefinitions/include/AudioInputDescriptor.h
@@ -93,8 +93,10 @@
audio_patch_handle_t getPatchHandle() const override;
void setPatchHandle(audio_patch_handle_t handle) override;
bool isMmap() override {
- if (getPolicyAudioPort() != nullptr) {
- return getPolicyAudioPort()->isMmap();
+ if (const auto policyPort = getPolicyAudioPort(); policyPort != nullptr) {
+ if (const auto port = policyPort->asAudioPort(); port != nullptr) {
+ return port->isMmap();
+ }
}
return false;
}
diff --git a/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h b/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h
index 123011a..d06496d 100644
--- a/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h
+++ b/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h
@@ -270,8 +270,10 @@
audio_patch_handle_t getPatchHandle() const override;
void setPatchHandle(audio_patch_handle_t handle) override;
bool isMmap() override {
- if (getPolicyAudioPort() != nullptr) {
- return getPolicyAudioPort()->isMmap();
+ if (const auto policyPort = getPolicyAudioPort(); policyPort != nullptr) {
+ if (const auto port = policyPort->asAudioPort(); port != nullptr) {
+ return port->isMmap();
+ }
}
return false;
}
diff --git a/services/audiopolicy/common/managerdefinitions/include/IOProfile.h b/services/audiopolicy/common/managerdefinitions/include/IOProfile.h
index 0e1548f..2e680e3 100644
--- a/services/audiopolicy/common/managerdefinitions/include/IOProfile.h
+++ b/services/audiopolicy/common/managerdefinitions/include/IOProfile.h
@@ -57,11 +57,12 @@
// Once capture clients are tracked individually and not per session this can be removed
// MMAP no IRQ input streams do not have the default limitation of one active client
// max as they can be used in shared mode by the same application.
+ // NOTE: Please consider moving to AudioPort when addressing the FIXME
// NOTE: this works for explicit values set in audio_policy_configuration.xml because
// flags are parsed before maxActiveCount by the serializer.
void setFlags(uint32_t flags) override
{
- PolicyAudioPort::setFlags(flags);
+ AudioPort::setFlags(flags);
if (getRole() == AUDIO_PORT_ROLE_SINK && (flags & AUDIO_INPUT_FLAG_MMAP_NOIRQ) != 0) {
maxActiveCount = 0;
}
diff --git a/services/audiopolicy/common/managerdefinitions/include/PolicyAudioPort.h b/services/audiopolicy/common/managerdefinitions/include/PolicyAudioPort.h
index ab33b38..acf787b 100644
--- a/services/audiopolicy/common/managerdefinitions/include/PolicyAudioPort.h
+++ b/services/audiopolicy/common/managerdefinitions/include/PolicyAudioPort.h
@@ -36,7 +36,7 @@
class PolicyAudioPort : public virtual RefBase, private HandleGenerator<audio_port_handle_t>
{
public:
- PolicyAudioPort() : mFlags(AUDIO_OUTPUT_FLAG_NONE) {}
+ PolicyAudioPort() = default;
virtual ~PolicyAudioPort() = default;
@@ -49,19 +49,6 @@
virtual sp<AudioPort> asAudioPort() const = 0;
- virtual void setFlags(uint32_t flags)
- {
- //force direct flag if offload flag is set: offloading implies a direct output stream
- // and all common behaviors are driven by checking only the direct flag
- // this should normally be set appropriately in the policy configuration file
- if (asAudioPort()->getRole() == AUDIO_PORT_ROLE_SOURCE &&
- (flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) != 0) {
- flags |= AUDIO_OUTPUT_FLAG_DIRECT;
- }
- mFlags = flags;
- }
- uint32_t getFlags() const { return mFlags; }
-
virtual void attach(const sp<HwModule>& module);
virtual void detach();
bool isAttached() { return mModule != 0; }
@@ -105,22 +92,6 @@
const char *getModuleName() const;
sp<HwModule> getModule() const { return mModule; }
- inline bool isDirectOutput() const
- {
- return (asAudioPort()->getType() == AUDIO_PORT_TYPE_MIX) &&
- (asAudioPort()->getRole() == AUDIO_PORT_ROLE_SOURCE) &&
- (mFlags & (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD));
- }
-
- inline bool isMmap() const
- {
- return (asAudioPort()->getType() == AUDIO_PORT_TYPE_MIX)
- && (((asAudioPort()->getRole() == AUDIO_PORT_ROLE_SOURCE) &&
- ((mFlags & AUDIO_OUTPUT_FLAG_MMAP_NOIRQ) != 0))
- || ((asAudioPort()->getRole() == AUDIO_PORT_ROLE_SINK) &&
- ((mFlags & AUDIO_INPUT_FLAG_MMAP_NOIRQ) != 0)));
- }
-
void addRoute(const sp<AudioRoute> &route) { mRoutes.add(route); }
const AudioRouteVector &getRoutes() const { return mRoutes; }
@@ -129,7 +100,6 @@
const ChannelMaskSet &channelMasks) const;
void pickSamplingRate(uint32_t &rate, const SampleRateSet &samplingRates) const;
- uint32_t mFlags; // attribute flags mask (e.g primary output, direct output...).
sp<HwModule> mModule; // audio HW module exposing this I/O stream
AudioRouteVector mRoutes; // Routes involving this port
};
@@ -141,27 +111,18 @@
virtual sp<PolicyAudioPort> getPolicyAudioPort() const = 0;
- status_t validationBeforeApplyConfig(const struct audio_port_config *config) const;
-
- void applyPolicyAudioPortConfig(const struct audio_port_config *config) {
- if (config->config_mask & AUDIO_PORT_CONFIG_FLAGS) {
- mFlags = config->flags;
- }
+ status_t validationBeforeApplyConfig(const struct audio_port_config *config) const {
+ sp<PolicyAudioPort> policyAudioPort = getPolicyAudioPort();
+ return policyAudioPort ? policyAudioPort->checkExactAudioProfile(config) : NO_INIT;
}
- void toPolicyAudioPortConfig(
- struct audio_port_config *dstConfig,
- const struct audio_port_config *srcConfig = NULL) const;
-
-
- virtual bool hasSameHwModuleAs(const sp<PolicyAudioPortConfig>& other) const {
+ bool hasSameHwModuleAs(const sp<PolicyAudioPortConfig>& other) const {
return (other.get() != nullptr) && (other->getPolicyAudioPort().get() != nullptr) &&
(getPolicyAudioPort().get() != nullptr) &&
(other->getPolicyAudioPort()->getModuleHandle() ==
getPolicyAudioPort()->getModuleHandle());
}
- union audio_io_flags mFlags = { AUDIO_INPUT_FLAG_NONE };
};
} // namespace android
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp
index 7016a08..6c1240b 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp
@@ -62,7 +62,6 @@
toAudioPortConfig(&localBackupConfig);
if ((status = validationBeforeApplyConfig(config)) == NO_ERROR) {
AudioPortConfig::applyAudioPortConfig(config, backupConfig);
- applyPolicyAudioPortConfig(config);
}
if (backupConfig != NULL) {
@@ -83,7 +82,6 @@
}
AudioPortConfig::toAudioPortConfig(dstConfig, srcConfig);
- toPolicyAudioPortConfig(dstConfig, srcConfig);
dstConfig->role = AUDIO_PORT_ROLE_SINK;
dstConfig->type = AUDIO_PORT_TYPE_MIX;
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp
index 34b5c1a..b054c6d 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp
@@ -188,7 +188,6 @@
toAudioPortConfig(&localBackupConfig);
if ((status = validationBeforeApplyConfig(config)) == NO_ERROR) {
AudioPortConfig::applyAudioPortConfig(config, backupConfig);
- applyPolicyAudioPortConfig(config);
}
if (backupConfig != NULL) {
@@ -207,7 +206,6 @@
dstConfig->config_mask |= srcConfig->config_mask;
}
AudioPortConfig::toAudioPortConfig(dstConfig, srcConfig);
- toPolicyAudioPortConfig(dstConfig, srcConfig);
dstConfig->role = AUDIO_PORT_ROLE_SOURCE;
dstConfig->type = AUDIO_PORT_TYPE_MIX;
diff --git a/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
index 4a4ee12..141c2be 100644
--- a/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp
@@ -118,7 +118,6 @@
toAudioPortConfig(&localBackupConfig);
if ((status = validationBeforeApplyConfig(config)) == NO_ERROR) {
AudioPortConfig::applyAudioPortConfig(config, backupConfig);
- applyPolicyAudioPortConfig(config);
}
if (backupConfig != NULL) {
@@ -131,8 +130,6 @@
const struct audio_port_config *srcConfig) const
{
DeviceDescriptorBase::toAudioPortConfig(dstConfig, srcConfig);
- toPolicyAudioPortConfig(dstConfig, srcConfig);
-
dstConfig->ext.device.hw_module = getModuleHandle();
}
diff --git a/services/audiopolicy/common/managerdefinitions/src/PolicyAudioPort.cpp b/services/audiopolicy/common/managerdefinitions/src/PolicyAudioPort.cpp
index 5986069..ce8178f 100644
--- a/services/audiopolicy/common/managerdefinitions/src/PolicyAudioPort.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/PolicyAudioPort.cpp
@@ -87,7 +87,7 @@
// For direct outputs, pick minimum sampling rate: this helps ensuring that the
// channel count / sampling rate combination chosen will be supported by the connected
// sink
- if (isDirectOutput()) {
+ if (asAudioPort()->isDirectOutput()) {
uint32_t samplingRate = UINT_MAX;
for (const auto rate : samplingRates) {
if ((rate < samplingRate) && (rate > 0)) {
@@ -122,7 +122,7 @@
// For direct outputs, pick minimum channel count: this helps ensuring that the
// channel count / sampling rate combination chosen will be supported by the connected
// sink
- if (isDirectOutput()) {
+ if (asAudioPort()->isDirectOutput()) {
uint32_t channelCount = UINT_MAX;
for (const auto channelMask : channelMasks) {
uint32_t cnlCount;
@@ -236,7 +236,7 @@
audio_format_t bestFormat = sPcmFormatCompareTable[ARRAY_SIZE(sPcmFormatCompareTable) - 1];
// For mixed output and inputs, use best mixer output format.
// Do not limit format otherwise
- if ((asAudioPort()->getType() != AUDIO_PORT_TYPE_MIX) || isDirectOutput()) {
+ if ((asAudioPort()->getType() != AUDIO_PORT_TYPE_MIX) || asAudioPort()->isDirectOutput()) {
bestFormat = AUDIO_FORMAT_INVALID;
}
@@ -266,29 +266,4 @@
asAudioPort()->getName().c_str(), samplingRate, channelMask, format);
}
-// --- PolicyAudioPortConfig class implementation
-
-status_t PolicyAudioPortConfig::validationBeforeApplyConfig(
- const struct audio_port_config *config) const
-{
- sp<PolicyAudioPort> policyAudioPort = getPolicyAudioPort();
- return policyAudioPort ? policyAudioPort->checkExactAudioProfile(config) : NO_INIT;
-}
-
-void PolicyAudioPortConfig::toPolicyAudioPortConfig(struct audio_port_config *dstConfig,
- const struct audio_port_config *srcConfig) const
-{
- if (dstConfig->config_mask & AUDIO_PORT_CONFIG_FLAGS) {
- if ((srcConfig != nullptr) && (srcConfig->config_mask & AUDIO_PORT_CONFIG_FLAGS)) {
- dstConfig->flags = srcConfig->flags;
- } else {
- dstConfig->flags = mFlags;
- }
- } else {
- dstConfig->flags = { AUDIO_INPUT_FLAG_NONE };
- }
-}
-
-
-
} // namespace android