static const char *get_percent(int val, int min, int max) { static char str[32]; int p; p = convert_prange(val, min, max); sprintf(str, "%i [%i%%]", val, p); return str; }
static const char *get_percent1(int val, int min, int max, int min_dB, int max_dB) { static char str[32]; int p, db; p = convert_prange(val, min, max); db = convert_db_range(val, min, max, min_dB, max_dB); sprintf(str, "%i [%i%%] [%i.%02idB]", val, p, db / 100, abs(db % 100)); return str; }
/** * Gets the current volume in the range from 0 - 100. * * @return current volume */ int getvol(void) { if (normalize_vol()) { return lrint(get_normalized_volume( elem, SND_MIXER_SCHN_FRONT_RIGHT) * 100); } else { long val, pmin = 0, pmax = 0; snd_mixer_selem_get_playback_volume_range(elem, &pmin, &pmax); snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_FRONT_RIGHT, &val); DEBUG_PRINT("[getvol] From mixer: %li pmin: %li pmax: %li", val, pmin, pmax); return convert_prange(val, pmin, pmax); } }