mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 20:24:19 +00:00
audio: Set connectedProfiles for non-attached device ports. am: f7492518c7 am: 6788dcd1f8
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2794108 Change-Id: I50f7d219467acb503d810328a3442af3c4f85c1a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
committed by
Automerger Merge Worker
commit
abcc5cd2c8
@@ -135,6 +135,22 @@ static AudioRoute createRoute(const std::vector<AudioPort>& sources, const Audio
|
|||||||
return route;
|
return route;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<AudioProfile> getStandard16And24BitPcmAudioProfiles() {
|
||||||
|
auto createStdPcmAudioProfile = [](const PcmType& pcmType) {
|
||||||
|
return AudioProfile{
|
||||||
|
.format = AudioFormatDescription{.type = AudioFormatType::PCM, .pcm = pcmType},
|
||||||
|
.channelMasks = {AudioChannelLayout::make<AudioChannelLayout::layoutMask>(
|
||||||
|
AudioChannelLayout::LAYOUT_MONO),
|
||||||
|
AudioChannelLayout::make<AudioChannelLayout::layoutMask>(
|
||||||
|
AudioChannelLayout::LAYOUT_STEREO)},
|
||||||
|
.sampleRates = {8000, 11025, 16000, 32000, 44100, 48000}};
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
createStdPcmAudioProfile(PcmType::INT_16_BIT),
|
||||||
|
createStdPcmAudioProfile(PcmType::INT_24_BIT),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Primary (default) configuration:
|
// Primary (default) configuration:
|
||||||
//
|
//
|
||||||
// Device ports:
|
// Device ports:
|
||||||
|
|||||||
@@ -185,6 +185,11 @@ std::ostream& operator<<(std::ostream& os, Module::Type t) {
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Module::Module(Type type, std::unique_ptr<Configuration>&& config)
|
||||||
|
: mType(type), mConfig(std::move(config)) {
|
||||||
|
populateConnectedProfiles();
|
||||||
|
}
|
||||||
|
|
||||||
void Module::cleanUpPatch(int32_t patchId) {
|
void Module::cleanUpPatch(int32_t patchId) {
|
||||||
erase_all_values(mPatches, std::set<int32_t>{patchId});
|
erase_all_values(mPatches, std::set<int32_t>{patchId});
|
||||||
}
|
}
|
||||||
@@ -320,6 +325,22 @@ ndk::ScopedAStatus Module::findPortIdForNewStream(int32_t in_portConfigId, Audio
|
|||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Module::populateConnectedProfiles() {
|
||||||
|
Configuration& config = getConfig();
|
||||||
|
for (const AudioPort& port : config.ports) {
|
||||||
|
if (port.ext.getTag() == AudioPortExt::device) {
|
||||||
|
if (auto devicePort = port.ext.get<AudioPortExt::device>();
|
||||||
|
!devicePort.device.type.connection.empty() && port.profiles.empty()) {
|
||||||
|
if (auto connIt = config.connectedProfiles.find(port.id);
|
||||||
|
connIt == config.connectedProfiles.end()) {
|
||||||
|
config.connectedProfiles.emplace(
|
||||||
|
port.id, internal::getStandard16And24BitPcmAudioProfiles());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <typename C>
|
template <typename C>
|
||||||
std::set<int32_t> Module::portIdsFromPortConfigIds(C portConfigIds) {
|
std::set<int32_t> Module::portIdsFromPortConfigIds(C portConfigIds) {
|
||||||
std::set<int32_t> result;
|
std::set<int32_t> result;
|
||||||
|
|||||||
@@ -23,5 +23,7 @@
|
|||||||
namespace aidl::android::hardware::audio::core::internal {
|
namespace aidl::android::hardware::audio::core::internal {
|
||||||
|
|
||||||
std::unique_ptr<Module::Configuration> getConfiguration(Module::Type moduleType);
|
std::unique_ptr<Module::Configuration> getConfiguration(Module::Type moduleType);
|
||||||
|
std::vector<aidl::android::media::audio::common::AudioProfile>
|
||||||
|
getStandard16And24BitPcmAudioProfiles();
|
||||||
|
|
||||||
} // namespace aidl::android::hardware::audio::core::internal
|
} // namespace aidl::android::hardware::audio::core::internal
|
||||||
|
|||||||
@@ -60,8 +60,7 @@ class Module : public BnModule {
|
|||||||
std::unique_ptr<Configuration>&& config);
|
std::unique_ptr<Configuration>&& config);
|
||||||
static std::optional<Type> typeFromString(const std::string& type);
|
static std::optional<Type> typeFromString(const std::string& type);
|
||||||
|
|
||||||
Module(Type type, std::unique_ptr<Configuration>&& config)
|
Module(Type type, std::unique_ptr<Configuration>&& config);
|
||||||
: mType(type), mConfig(std::move(config)) {}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// The vendor extension done via inheritance can override interface methods and augment
|
// The vendor extension done via inheritance can override interface methods and augment
|
||||||
@@ -235,6 +234,7 @@ class Module : public BnModule {
|
|||||||
const Streams& getStreams() const { return mStreams; }
|
const Streams& getStreams() const { return mStreams; }
|
||||||
Type getType() const { return mType; }
|
Type getType() const { return mType; }
|
||||||
bool isMmapSupported();
|
bool isMmapSupported();
|
||||||
|
void populateConnectedProfiles();
|
||||||
template <typename C>
|
template <typename C>
|
||||||
std::set<int32_t> portIdsFromPortConfigIds(C portConfigIds);
|
std::set<int32_t> portIdsFromPortConfigIds(C portConfigIds);
|
||||||
void registerPatch(const AudioPatch& patch);
|
void registerPatch(const AudioPatch& patch);
|
||||||
|
|||||||
Reference in New Issue
Block a user