# HG changeset patch # User joyping # Date 1089766106 0 # Node ID d5f8efddac6c0a53078fc9cb1e14c83ea8432f97 # Parent f4711a685291d2d042edb40f4798e63117d24216 volume calc fixes for mixer, by reimar dffinger, 10l reverse by me diff -r f4711a685291 -r d5f8efddac6c libao2/ao_alsa.c --- a/libao2/ao_alsa.c Tue Jul 13 23:08:00 2004 +0000 +++ b/libao2/ao_alsa.c Wed Jul 14 00:48:26 2004 +0000 @@ -152,11 +152,11 @@ } snd_mixer_selem_get_playback_volume_range(elem,&pmin,&pmax); - f_multi = (100 / (float)pmax - pmin); + f_multi = (100 / (float)(pmax - pmin)); if (cmd == AOCONTROL_SET_VOLUME) { - set_vol = (vol->left + pmin) / f_multi + 0.5; + set_vol = vol->left / f_multi + pmin + 0.5; //setting channels if ((err = snd_mixer_selem_set_playback_volume(elem, 0, set_vol)) < 0) { @@ -166,7 +166,7 @@ } mp_msg(MSGT_AO,MSGL_DBG2,"left=%li, ", set_vol); - set_vol = (vol->right + pmin) / f_multi + 0.5; + set_vol = vol->right / f_multi + pmin + 0.5; if ((err = snd_mixer_selem_set_playback_volume(elem, 1, set_vol)) < 0) { mp_msg(MSGT_AO,MSGL_ERR,"alsa-control: error setting right channel, %s\n", @@ -178,9 +178,9 @@ } else { snd_mixer_selem_get_playback_volume(elem, 0, &get_vol); - vol->left = (get_vol * f_multi) - pmin; + vol->left = (get_vol - pmin) * f_multi; snd_mixer_selem_get_playback_volume(elem, 1, &get_vol); - vol->right = (get_vol * f_multi) - pmin; + vol->right = (get_vol - pmin) * f_multi; mp_msg(MSGT_AO,MSGL_DBG2,"left=%f, right=%f\n",vol->left,vol->right); } @@ -1103,7 +1103,7 @@ } } - if (snd_pcm_status_get_state(status) == SND_PCM_STATE_RUNNING) + if (snd_pcm_status_get_state(status) != SND_PCM_STATE_RUNNING) mp_msg(MSGT_AO,MSGL_V,"alsa-space: free space = %i, status=%i, %s --\n", ret, status, str_status); if (ret < 0) {