[Mplayer-dev-eng] volume adjustment fix

Christian Ohm chr.ohm at gmx.net
Tue Sep 11 12:47:16 CEST 2001


hi.

the following patch fixes a problem that occurs using the oss-emulation
layer of alsa. the original increment/decrement of 1 was too low, because
alsa has just 32 volume levels instead of 100, so the values get divided by
3 and an increment of 1 becomes 0.3, which gets rounded away, so the volume
level is stuck. xmms seems to have the same problem when adjusting volume by
keyboard...

bye



Index: mixer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mixer.c,v
retrieving revision 1.8
diff -u -r1.8 mixer.c
--- mixer.c	8 Jun 2001 23:33:55 -0000	1.8
+++ mixer.c	11 Sep 2001 10:14:45 -0000
@@ -127,14 +127,15 @@
 
 #endif
 
+#define MIXER_CHANGE 3
 
 void mixer_incvolume( void )
 {
  float mixer_l, mixer_r;
  mixer_getvolume( &mixer_l,&mixer_r );
- mixer_l++;
+ mixer_l += MIXER_CHANGE;
  if ( mixer_l > 100 ) mixer_l = 100;
- mixer_r++;
+ mixer_r += MIXER_CHANGE;
  if ( mixer_r > 100 ) mixer_r = 100;
  mixer_setvolume( mixer_l,mixer_r );
 }
@@ -143,9 +144,9 @@
 {
  float mixer_l, mixer_r;
  mixer_getvolume( &mixer_l,&mixer_r );
- mixer_l--;
+ mixer_l -= MIXER_CHANGE;
  if ( mixer_l < 0 ) mixer_l = 0;
- mixer_r--;
+ mixer_r -= MIXER_CHANGE;
  if ( mixer_r < 0 ) mixer_r = 0;
  mixer_setvolume( mixer_l,mixer_r );
 }
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.276
diff -u -r1.276 mplayer.c
--- mplayer.c	6 Sep 2001 20:44:42 -0000	1.276
+++ mplayer.c	11 Sep 2001 10:14:50 -0000
@@ -1645,22 +1645,17 @@
     case '0':
     case '*':
     case '/': {
-        float mixer_l, mixer_r;
-        mixer_getvolume( &mixer_l,&mixer_r );
         if(c=='*' || c=='0'){
-            if ( ++mixer_l > 100 ) mixer_l = 100;
-            if ( ++mixer_r > 100 ) mixer_r = 100;
+		mixer_incvolume();
         } else {
-            if ( --mixer_l < 0 ) mixer_l = 0;
-            if ( --mixer_r < 0 ) mixer_r = 0;
+		mixer_decvolume();
         }
-        mixer_setvolume( mixer_l,mixer_r );
 
 #ifdef USE_OSD
         if(osd_level){
           osd_visible=sh_video->fps; // 1 sec
           vo_osd_progbar_type=OSD_VOLUME;
-          vo_osd_progbar_value=((mixer_l+mixer_r)*256.0)/200.0;
+          vo_osd_progbar_value=(mixer_getbothvolume()*256.0)/100.0;
           //printf("volume: %d\n",vo_osd_progbar_value);
         }
 #endif



-- 
One good turn deserves another.
		-- Gaius Petronius

_______________________________________________
Mplayer-dev-eng mailing list
Mplayer-dev-eng at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mplayer-dev-eng



More information about the MPlayer-dev-eng mailing list