int am_getconfig_bool(const char * path) { char buf[CONFIG_VALUE_MAX]; int ret = -1; ret = am_getconfig(path, buf,NULL); if (ret > 0) { if(strcasecmp(buf,"true")==0 || strcmp(buf,"1")==0) return 1; } return 0; }
int am_getconfig_float(const char * path, float *value) { char buf[CONFIG_VALUE_MAX]; int ret = -1; *value = -1.0; ret = am_getconfig(path, buf,NULL); if (ret > 0) { ret = sscanf(buf, "%f", value); } return ret > 0 ? 0 : -2; }
int ammodule_load_module(const char *modulename, const struct ammodule_t **module) { int status = -ENOENT;; int i; const struct ammodule_t *hmi = NULL; char prop[PATH_MAX]; char path[PATH_MAX]; char name[PATH_MAX]; const char *prepath = NULL; snprintf(name, PATH_MAX, "%s", modulename); for (i = -1 ; i < PATH_COUNT; i++) { if (i >= 0) { prepath = defaut_path[i]; } else { if (am_getconfig(AM_LIBRARY_SETTING, prop, NULL) <= 0) { continue; } prepath = prop; } snprintf(path, sizeof(path), "%s/lib%s.so", prepath, name); if (access(path, R_OK) == 0) { break; } snprintf(path, sizeof(path), "%s/%s.so", prepath, name); if (access(path, R_OK) == 0) { break; } snprintf(path, sizeof(path), "%s/%s", prepath, name); if (access(path, R_OK) == 0) { break; } snprintf(path, sizeof(path), "%s", name); if (access(path, R_OK) == 0) { break; } } status = -ENOENT; if (i < PATH_COUNT) { /* load the module, if this fails, we're doomed, and we should not try * to load a different variant. */ status = amload(path, module); } LOGI("load mode %s,on %s %d\n", modulename, path, status); return status; }
float am_getconfig_float_def(const char * path,float defvalue) { char buf[CONFIG_VALUE_MAX]; int ret = -1; float value; ret = am_getconfig(path, buf,NULL); if (ret > 0) { ret = sscanf(buf, "%f", &value); } if(ret<=0) value=defvalue; return value; }
int ffmpeg_load_external_module(){ const char *mod_path ="media.libplayer.modules"; const int mod_item_max = 16; char value[CONFIG_VALUE_MAX]; int ret = -1; char mod[mod_item_max][CONFIG_VALUE_MAX]; //memset(value,0,CONFIG_VALUE_MAX); ret = am_getconfig(mod_path, value,NULL); if(ret<=1){ log_print("Failed to find external module,path:%s\n",mod_path); return -1; } log_print("Get modules:[%s],mod path:%s\n",value,mod_path); int pos = 0; const char * psets=value; const char *psetend; int psetlen=0; int i = 0; while(psets && psets[0]!='\0'&&i<mod_item_max){ psetlen=0; psetend=strchr(psets,','); if(psetend!=NULL && psetend>psets && psetend-psets<64){ psetlen=psetend-psets; memcpy(mod[i],psets,psetlen); mod[i][psetlen]='\0'; psets=&psetend[1];//skip ";" }else{ strcpy(mod[i],psets); psets=NULL; } if(strlen(mod[i])>0){ ammodule_simple_load_module(mod[i]); //log_print("load module:[%s]\n",mod[i]); i++; } } return 0; }
int property_get(const char *key, char *value, const char *default_value) { printf("player system property_get [%s] %s\n", __FILE__, __FUNCTION__); return am_getconfig(key, value, default_value); }