int EffectUnloadLibrary(int handle) { int ret = init(); if (ret < 0) { return ret; } ret = unloadLibrary(handle); updateNumEffects(); return ret; }
int EffectLoadLibrary(const char *libPath, int *handle) { int ret = init(); if (ret < 0) { return ret; } if (libPath == NULL) { return -EINVAL; } ret = loadLibrary(libPath, handle); updateNumEffects(); return ret; }
int init() { int hdl; if (gInitDone) { return 0; } pthread_mutex_init(&gLibLock, NULL); if (access(AUDIO_EFFECT_VENDOR_CONFIG_FILE, R_OK) == 0) { loadEffectConfigFile(AUDIO_EFFECT_VENDOR_CONFIG_FILE); } else if (access(AUDIO_EFFECT_DEFAULT_CONFIG_FILE, R_OK) == 0) { loadEffectConfigFile(AUDIO_EFFECT_DEFAULT_CONFIG_FILE); } updateNumEffects(); gInitDone = 1; ALOGV("init() done"); return 0; }
int init() { struct dirent *ent; DIR *dir = NULL; char libpath[PATH_MAX]; int hdl; if (gInitDone) { return 0; } pthread_mutex_init(&gLibLock, NULL); // load built-in libraries dir = opendir(gEffectLibPath); if (dir == NULL) { return -ENODEV; } while ((ent = readdir(dir)) != NULL) { LOGV("init() reading file %s", ent->d_name); if ((strlen(ent->d_name) < 3) || strncmp(ent->d_name, "lib", 3) != 0 || strncmp(ent->d_name + strlen(ent->d_name) - 3, ".so", 3) != 0) { continue; } strcpy(libpath, gEffectLibPath); strcat(libpath, "/"); strcat(libpath, ent->d_name); if (loadLibrary(libpath, &hdl) < 0) { LOGW("init() failed to load library %s",libpath); } } closedir(dir); updateNumEffects(); gInitDone = 1; LOGV("init() done"); return 0; }