Revert "Deprecate support for legacy effect config file audio_effects.conf"
This reverts commit c11621e64e3a009fe88a8a3ba1dffab5d9828601.
Reason for revert: The legacy effect config parsing logic will be kept in the framework for now, but we will add metrics to track any possible partner usage of the config file.
Change-Id: I873e2e18924688df52c9ed761950f132d16dcc29
diff --git a/services/audiopolicy/service/AudioPolicyEffects.cpp b/services/audiopolicy/service/AudioPolicyEffects.cpp
index 4ea3751..b111865 100644
--- a/services/audiopolicy/service/AudioPolicyEffects.cpp
+++ b/services/audiopolicy/service/AudioPolicyEffects.cpp
@@ -48,7 +48,13 @@
mDefaultDeviceEffectFuture =
std::async(std::launch::async, &AudioPolicyEffects::initDefaultDeviceEffects, this);
} else if (loadResult < 0) {
- ALOGE("Failed to query effect configuration with status %d", loadResult);
+ 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);
+ }
} else if (loadResult > 0) {
ALOGE("Effect config is partially invalid, skipped %d elements", loadResult);
}
@@ -949,6 +955,34 @@
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 80b0f91..9f65a96 100644
--- a/services/audiopolicy/service/AudioPolicyEffects.h
+++ b/services/audiopolicy/service/AudioPolicyEffects.h
@@ -39,7 +39,12 @@
*
* 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.
+ *
+ * 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 AIDL HAL, the configuration will be queried with the method `IFactory::queryProcessing()`.
*/
class AudioPolicyEffects : public RefBase
@@ -47,7 +52,7 @@
public:
- // The constructor will parse audio_effects.xml
+ // The constructor will parse audio_effects.conf
// First it will look whether vendor specific file exists,
// otherwise it will parse the system default file.
explicit AudioPolicyEffects(const sp<EffectsFactoryHalInterface>& effectsFactoryHal);
@@ -116,7 +121,7 @@
void initDefaultDeviceEffects();
// class to store the description of an effects and its parameters
- // as defined in audio_effects.xml
+ // as defined in audio_effects.conf
class EffectDesc {
public:
EffectDesc(const char *name,
@@ -230,7 +235,8 @@
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.xml
+ // Parse audio_effects.conf
+ status_t loadAudioEffectConfigLegacy(const char *path);
status_t loadAudioEffectConfig(const sp<EffectsFactoryHalInterface>& effectsFactoryHal);
// Load all effects descriptors in configuration file
diff --git a/services/audiopolicy/service/AudioPolicyService.h b/services/audiopolicy/service/AudioPolicyService.h
index 6cac9f9..4710a8a 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.xml
+ // Manage all effects configured in audio_effects.conf
// 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);