Loading media/libaudiohal/include/media/audiohal/AudioHalVersionInfo.h +2 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ class AudioHalVersionInfo : public android::media::AudioHalVersion { minor = halMinor; } bool isHidl() const { return type == Type::HIDL; } Type getType() const { return type; } int getMajorVersion() const { return major; } Loading services/audioflinger/AudioFlinger.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ #include <audiomanager/IAudioManager.h> #include "AudioFlinger.h" #include "EffectConfiguration.h" #include "NBAIO_Tee.h" #include "PropertyUtils.h" Loading Loading @@ -372,7 +373,7 @@ AudioFlinger::AudioFlinger() BatteryNotifier::getInstance().noteResetAudio(); mDevicesFactoryHal = DevicesFactoryHalInterface::create(); mEffectsFactoryHal = EffectsFactoryHalInterface::create(); mEffectsFactoryHal = audioflinger::EffectConfiguration::getEffectsFactoryHal(); mMediaLogNotifier->run("MediaLogNotifier"); std::vector<pid_t> halPids; Loading services/audioflinger/DeviceEffectManager.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <audio_utils/primitives.h> #include "AudioFlinger.h" #include "EffectConfiguration.h" #include <media/audiohal/EffectsFactoryHalInterface.h> // ---------------------------------------------------------------------------- Loading Loading @@ -111,14 +112,16 @@ sp<AudioFlinger::EffectHandle> AudioFlinger::DeviceEffectManager::createEffect_l status_t AudioFlinger::DeviceEffectManager::checkEffectCompatibility( const effect_descriptor_t *desc) { sp<EffectsFactoryHalInterface> effectsFactory = mAudioFlinger.getEffectsFactory(); const sp<EffectsFactoryHalInterface> effectsFactory = audioflinger::EffectConfiguration::getEffectsFactoryHal(); if (effectsFactory == nullptr) { return BAD_VALUE; } static AudioHalVersionInfo sMinDeviceEffectHalVersion = static const AudioHalVersionInfo sMinDeviceEffectHalVersion = AudioHalVersionInfo(AudioHalVersionInfo::Type::HIDL, 6, 0); AudioHalVersionInfo halVersion = effectsFactory->getHalVersion(); static const AudioHalVersionInfo halVersion = audioflinger::EffectConfiguration::getAudioHalVersionInfo(); // We can trust AIDL generated AudioHalVersionInfo comparison operator (based on std::tie) as // long as the type, major and minor sequence doesn't change in the definition. Loading @@ -137,7 +140,8 @@ status_t AudioFlinger::DeviceEffectManager::createEffectHal( const effect_uuid_t *pEffectUuid, int32_t sessionId, int32_t deviceId, sp<EffectHalInterface> *effect) { status_t status = NO_INIT; sp<EffectsFactoryHalInterface> effectsFactory = mAudioFlinger.getEffectsFactory(); const sp<EffectsFactoryHalInterface> effectsFactory = audioflinger::EffectConfiguration::getEffectsFactoryHal(); if (effectsFactory != 0) { status = effectsFactory->createEffect( pEffectUuid, sessionId, AUDIO_IO_HANDLE_NONE, deviceId, effect); Loading services/audioflinger/EffectConfiguration.h 0 → 100644 +46 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 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. */ #pragma once #include <media/audiohal/EffectsFactoryHalInterface.h> namespace android::audioflinger { /** * Effect Configuration abstraction and helper class. */ class EffectConfiguration { public: static bool isHidl() { static const bool isHidl = getAudioHalVersionInfo().isHidl(); return isHidl; } static const sp<EffectsFactoryHalInterface>& getEffectsFactoryHal() { static const auto effectsFactoryHal = EffectsFactoryHalInterface::create(); return effectsFactoryHal; } static const detail::AudioHalVersionInfo& getAudioHalVersionInfo() { static const auto audioHalVersionInfo = getEffectsFactoryHal() ? getEffectsFactoryHal()->getHalVersion() : detail::AudioHalVersionInfo{ detail::AudioHalVersionInfo::Type::HIDL, 0 /* major */, 0 /* minor */ }; return audioHalVersionInfo; } }; } // namespace android::audioflinger services/audioflinger/Effects.cpp +7 −2 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ #include <mediautils/TimeCheck.h> #include "AudioFlinger.h" #include "EffectConfiguration.h" // ---------------------------------------------------------------------------- Loading @@ -65,6 +66,7 @@ namespace android { using aidl_utils::statusTFromBinderStatus; using audioflinger::EffectConfiguration; using binder::Status; namespace { Loading Loading @@ -982,6 +984,7 @@ status_t AudioFlinger::EffectModule::configure() #ifdef MULTICHANNEL_EFFECT_CHAIN if (status != NO_ERROR && EffectConfiguration::isHidl() && // only HIDL effects support channel conversion mIsOutput && (mConfig.inputCfg.channels != AUDIO_CHANNEL_OUT_STEREO || mConfig.outputCfg.channels != AUDIO_CHANNEL_OUT_STEREO)) { Loading Loading @@ -1012,7 +1015,8 @@ status_t AudioFlinger::EffectModule::configure() mSupportsFloat = true; } if (status != NO_ERROR) { // only HIDL effects support integer conversion. if (status != NO_ERROR && EffectConfiguration::isHidl()) { ALOGV("EFFECT_CMD_SET_CONFIG failed with float format, retry with int16_t."); mConfig.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT; mConfig.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT; Loading Loading @@ -3032,7 +3036,8 @@ status_t AudioFlinger::EffectChain::EffectCallback::createEffectHal( const effect_uuid_t *pEffectUuid, int32_t sessionId, int32_t deviceId, sp<EffectHalInterface> *effect) { status_t status = NO_INIT; sp<EffectsFactoryHalInterface> effectsFactory = mAudioFlinger.getEffectsFactory(); const sp<EffectsFactoryHalInterface> effectsFactory = EffectConfiguration::getEffectsFactoryHal(); if (effectsFactory != 0) { status = effectsFactory->createEffect(pEffectUuid, sessionId, io(), deviceId, effect); } Loading Loading
media/libaudiohal/include/media/audiohal/AudioHalVersionInfo.h +2 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ class AudioHalVersionInfo : public android::media::AudioHalVersion { minor = halMinor; } bool isHidl() const { return type == Type::HIDL; } Type getType() const { return type; } int getMajorVersion() const { return major; } Loading
services/audioflinger/AudioFlinger.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ #include <audiomanager/IAudioManager.h> #include "AudioFlinger.h" #include "EffectConfiguration.h" #include "NBAIO_Tee.h" #include "PropertyUtils.h" Loading Loading @@ -372,7 +373,7 @@ AudioFlinger::AudioFlinger() BatteryNotifier::getInstance().noteResetAudio(); mDevicesFactoryHal = DevicesFactoryHalInterface::create(); mEffectsFactoryHal = EffectsFactoryHalInterface::create(); mEffectsFactoryHal = audioflinger::EffectConfiguration::getEffectsFactoryHal(); mMediaLogNotifier->run("MediaLogNotifier"); std::vector<pid_t> halPids; Loading
services/audioflinger/DeviceEffectManager.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <audio_utils/primitives.h> #include "AudioFlinger.h" #include "EffectConfiguration.h" #include <media/audiohal/EffectsFactoryHalInterface.h> // ---------------------------------------------------------------------------- Loading Loading @@ -111,14 +112,16 @@ sp<AudioFlinger::EffectHandle> AudioFlinger::DeviceEffectManager::createEffect_l status_t AudioFlinger::DeviceEffectManager::checkEffectCompatibility( const effect_descriptor_t *desc) { sp<EffectsFactoryHalInterface> effectsFactory = mAudioFlinger.getEffectsFactory(); const sp<EffectsFactoryHalInterface> effectsFactory = audioflinger::EffectConfiguration::getEffectsFactoryHal(); if (effectsFactory == nullptr) { return BAD_VALUE; } static AudioHalVersionInfo sMinDeviceEffectHalVersion = static const AudioHalVersionInfo sMinDeviceEffectHalVersion = AudioHalVersionInfo(AudioHalVersionInfo::Type::HIDL, 6, 0); AudioHalVersionInfo halVersion = effectsFactory->getHalVersion(); static const AudioHalVersionInfo halVersion = audioflinger::EffectConfiguration::getAudioHalVersionInfo(); // We can trust AIDL generated AudioHalVersionInfo comparison operator (based on std::tie) as // long as the type, major and minor sequence doesn't change in the definition. Loading @@ -137,7 +140,8 @@ status_t AudioFlinger::DeviceEffectManager::createEffectHal( const effect_uuid_t *pEffectUuid, int32_t sessionId, int32_t deviceId, sp<EffectHalInterface> *effect) { status_t status = NO_INIT; sp<EffectsFactoryHalInterface> effectsFactory = mAudioFlinger.getEffectsFactory(); const sp<EffectsFactoryHalInterface> effectsFactory = audioflinger::EffectConfiguration::getEffectsFactoryHal(); if (effectsFactory != 0) { status = effectsFactory->createEffect( pEffectUuid, sessionId, AUDIO_IO_HANDLE_NONE, deviceId, effect); Loading
services/audioflinger/EffectConfiguration.h 0 → 100644 +46 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 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. */ #pragma once #include <media/audiohal/EffectsFactoryHalInterface.h> namespace android::audioflinger { /** * Effect Configuration abstraction and helper class. */ class EffectConfiguration { public: static bool isHidl() { static const bool isHidl = getAudioHalVersionInfo().isHidl(); return isHidl; } static const sp<EffectsFactoryHalInterface>& getEffectsFactoryHal() { static const auto effectsFactoryHal = EffectsFactoryHalInterface::create(); return effectsFactoryHal; } static const detail::AudioHalVersionInfo& getAudioHalVersionInfo() { static const auto audioHalVersionInfo = getEffectsFactoryHal() ? getEffectsFactoryHal()->getHalVersion() : detail::AudioHalVersionInfo{ detail::AudioHalVersionInfo::Type::HIDL, 0 /* major */, 0 /* minor */ }; return audioHalVersionInfo; } }; } // namespace android::audioflinger
services/audioflinger/Effects.cpp +7 −2 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ #include <mediautils/TimeCheck.h> #include "AudioFlinger.h" #include "EffectConfiguration.h" // ---------------------------------------------------------------------------- Loading @@ -65,6 +66,7 @@ namespace android { using aidl_utils::statusTFromBinderStatus; using audioflinger::EffectConfiguration; using binder::Status; namespace { Loading Loading @@ -982,6 +984,7 @@ status_t AudioFlinger::EffectModule::configure() #ifdef MULTICHANNEL_EFFECT_CHAIN if (status != NO_ERROR && EffectConfiguration::isHidl() && // only HIDL effects support channel conversion mIsOutput && (mConfig.inputCfg.channels != AUDIO_CHANNEL_OUT_STEREO || mConfig.outputCfg.channels != AUDIO_CHANNEL_OUT_STEREO)) { Loading Loading @@ -1012,7 +1015,8 @@ status_t AudioFlinger::EffectModule::configure() mSupportsFloat = true; } if (status != NO_ERROR) { // only HIDL effects support integer conversion. if (status != NO_ERROR && EffectConfiguration::isHidl()) { ALOGV("EFFECT_CMD_SET_CONFIG failed with float format, retry with int16_t."); mConfig.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT; mConfig.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT; Loading Loading @@ -3032,7 +3036,8 @@ status_t AudioFlinger::EffectChain::EffectCallback::createEffectHal( const effect_uuid_t *pEffectUuid, int32_t sessionId, int32_t deviceId, sp<EffectHalInterface> *effect) { status_t status = NO_INIT; sp<EffectsFactoryHalInterface> effectsFactory = mAudioFlinger.getEffectsFactory(); const sp<EffectsFactoryHalInterface> effectsFactory = EffectConfiguration::getEffectsFactoryHal(); if (effectsFactory != 0) { status = effectsFactory->createEffect(pEffectUuid, sessionId, io(), deviceId, effect); } Loading