Ejemplo n.º 1
0
static void parameters(audio_parameters *info) {
  info->has_true_mute = has_mute;
  info->is_muted = ((has_mute) && (set_volume == -144.0));
  info->minimum_volume_dB = alsa_mix_mindb;
  info->maximum_volume_dB = alsa_mix_maxdb;
  info->airplay_volume = set_volume;
  info->current_volume_dB = vol2attn(set_volume, alsa_mix_maxdb, alsa_mix_mindb);
}
Ejemplo n.º 2
0
static void volume(double vol) {
  set_volume = vol;
  double vol_setting = vol2attn(vol, alsa_mix_maxdb, alsa_mix_mindb);
  // debug(1,"Setting volume db to %f, for volume input of %f.",vol_setting/100,vol);
  if (snd_mixer_selem_set_playback_dB_all(alsa_mix_elem, vol_setting, -1) != 0)
    die("Failed to set playback dB volume");
  if (has_mute)
    snd_mixer_selem_set_playback_switch_all(alsa_mix_elem, (vol != -144.0));
}
Ejemplo n.º 3
0
static void linear_volume(double vol) {
  set_volume = vol;
  double vol_setting = vol2attn(vol, 0, alsa_mix_mindb)/2000;
  // debug(1,"Adjusted volume is %f.",vol_setting);
  double linear_volume = pow(10, vol_setting);
  // debug(1,"Linear volume is %f.",linear_volume);
  long int_vol = alsa_mix_minv + (alsa_mix_maxv - alsa_mix_minv) * linear_volume;
  // debug(1,"Setting volume to %ld, for volume input of %f.",int_vol,vol);
  if (snd_mixer_selem_set_playback_volume_all(alsa_mix_elem, int_vol) != 0)
    die("Failed to set playback volume");
  if (has_mute)
    snd_mixer_selem_set_playback_switch_all(alsa_mix_elem, (vol != -144.0));
}