changeset 951:57c72488d475 trunk

[svn] fixed incorrect range conversion in volume functions
author giacomo
date Thu, 20 Apr 2006 10:25:02 -0700
parents 008bf9a501b1
children ebb63be7721c
files Plugins/Input/amidi-plug/i_common.h Plugins/Input/amidi-plug/i_seq.c
diffstat 2 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Input/amidi-plug/i_common.h	Tue Apr 18 07:00:25 2006 -0700
+++ b/Plugins/Input/amidi-plug/i_common.h	Thu Apr 20 10:25:02 2006 -0700
@@ -44,7 +44,7 @@
 #endif /* DEBUG */
 
 
-#define AMIDIPLUG_VERSION "0.2"
+#define AMIDIPLUG_VERSION "0.2+"
 #define PLAYER_NAME "Audacious"
 #define G_PATH_GET_BASENAME(x) g_path_get_basename(x)
 #define G_STRING_PRINTF(...) g_string_printf(__VA_ARGS__)
--- a/Plugins/Input/amidi-plug/i_seq.c	Tue Apr 18 07:00:25 2006 -0700
+++ b/Plugins/Input/amidi-plug/i_seq.c	Thu Apr 20 10:25:02 2006 -0700
@@ -429,15 +429,15 @@
       if ( snd_mixer_selem_has_playback_channel( mixer_elem , SND_MIXER_SCHN_FRONT_LEFT ) )
       {
         snd_mixer_selem_get_playback_volume( mixer_elem , SND_MIXER_SCHN_FRONT_LEFT , &lc );
-        /* convert the range to 0-100 (for the unlucky case that pv_range is not 0-100 already) */
-        *left_volume = (gint)(((lc - pv_min) * pv_range) / 100);
+        /* convert the range to 0-100 (for the case that pv_range is not 0-100 already) */
+        *left_volume = (gint)(((lc - pv_min) * 100) / pv_range);
         DEBUGMSG( "GET VOLUME requested, get left channel (%i)\n" , *left_volume );
       }
       if ( snd_mixer_selem_has_playback_channel( mixer_elem , SND_MIXER_SCHN_FRONT_RIGHT ) )
       {
         snd_mixer_selem_get_playback_volume( mixer_elem , SND_MIXER_SCHN_FRONT_RIGHT , &rc );
-        /* convert the range to 0-100 (for the unlucky case that pv_range is not 0-100 already) */
-        *right_volume = (gint)(((rc - pv_min) * pv_range) / 100);
+        /* convert the range to 0-100 (for the case that pv_range is not 0-100 already) */
+        *right_volume = (gint)(((rc - pv_min) * 100) / pv_range);
         DEBUGMSG( "GET VOLUME requested, get right channel (%i)\n" , *right_volume );
       }
     }
@@ -474,13 +474,13 @@
       {
         DEBUGMSG( "SET VOLUME requested, setting left channel to %i%%\n" , left_volume );
         snd_mixer_selem_set_playback_volume( mixer_elem , SND_MIXER_SCHN_FRONT_LEFT ,
-                                             (gint)(((gdouble)pv_range * ((gdouble)left_volume*.01)) + pv_min) );
+                                             (gint)((gdouble)(0.01 * (gdouble)(left_volume * pv_range)) + pv_min) );
       }
       if ( snd_mixer_selem_has_playback_channel( mixer_elem , SND_MIXER_SCHN_FRONT_RIGHT ) )
       {
         DEBUGMSG( "SET VOLUME requested, setting right channel to %i%%\n" , right_volume );
         snd_mixer_selem_set_playback_volume( mixer_elem , SND_MIXER_SCHN_FRONT_RIGHT ,
-                                             (gint)(((gdouble)pv_range * ((gdouble)right_volume*.01)) + pv_min) );
+                                             (gint)((gdouble)(0.01 * (gdouble)(right_volume * pv_range)) + pv_min) );
       }
     }
   }