示例#1
0
文件: alsa.c 项目: aarizkuren/pnmixer
/**
 * 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);
    }
}
double get_normalized_capture_volume(snd_mixer_elem_t *elem,
				     snd_mixer_selem_channel_id_t channel)
{
	return get_normalized_volume(elem, channel, CAPTURE);
}
double get_normalized_playback_volume(snd_mixer_elem_t *elem,
				      snd_mixer_selem_channel_id_t channel)
{
	return get_normalized_volume(elem, channel, PLAYBACK);
}