[polypaudio-commits] r666 - in /trunk/src/modules: module-alsa-sink.c module-alsa-source.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Fri Apr 7 17:19:52 PDT 2006


Author: lennart
Date: Sat Apr  8 02:19:52 2006
New Revision: 666

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=666&root=polypaudio&view=rev
Log:
clip volume at PA_VOLUME_NORM for alsa devices

Modified:
    trunk/src/modules/module-alsa-sink.c
    trunk/src/modules/module-alsa-source.c

Modified: trunk/src/modules/module-alsa-sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-alsa-sink.c?rev=666&root=polypaudio&r1=665&r2=666&view=diff
==============================================================================
--- trunk/src/modules/module-alsa-sink.c (original)
+++ trunk/src/modules/module-alsa-sink.c Sat Apr  8 02:19:52 2006
@@ -239,8 +239,14 @@
     assert(u && u->mixer_elem);
 
     if (snd_mixer_selem_has_playback_volume_joined(u->mixer_elem)) {
-        vol = pa_cvolume_avg(&s->hw_volume) * (u->hw_volume_max - u->hw_volume_min) /
+        vol = pa_cvolume_avg(&s->hw_volume);
+
+        if (vol > PA_VOLUME_NORM)
+            vol = PA_VOLUME_NORM;
+        
+        vol = (vol * (u->hw_volume_max - u->hw_volume_min)) /
             PA_VOLUME_NORM + u->hw_volume_min;
+        
         err = snd_mixer_selem_set_playback_volume_all(u->mixer_elem, vol);
         if (err < 0)
             goto fail;
@@ -248,7 +254,12 @@
         int i;
 
         for (i = 0;i < s->hw_volume.channels;i++) {
-            vol = s->hw_volume.values[i] * (u->hw_volume_max - u->hw_volume_min) /
+            vol = s->hw_volume.values[i];
+
+            if (vol > PA_VOLUME_NORM)
+                vol = PA_VOLUME_NORM;
+            
+             vol = (vol * (u->hw_volume_max - u->hw_volume_min)) /
                 PA_VOLUME_NORM + u->hw_volume_min;
             err = snd_mixer_selem_set_playback_volume(u->mixer_elem, i, vol);
             if (err < 0)

Modified: trunk/src/modules/module-alsa-source.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-alsa-source.c?rev=666&root=polypaudio&r1=665&r2=666&view=diff
==============================================================================
--- trunk/src/modules/module-alsa-source.c (original)
+++ trunk/src/modules/module-alsa-source.c Sat Apr  8 02:19:52 2006
@@ -228,7 +228,12 @@
     assert(u && u->mixer_elem);
 
     if (snd_mixer_selem_has_capture_volume_joined(u->mixer_elem)) {
-        vol = pa_cvolume_avg(&s->hw_volume) * (u->hw_volume_max - u->hw_volume_min) /
+        vol = pa_cvolume_avg(&s->hw_volume);
+
+        if (vol > PA_VOLUME_NORM)
+            vol = PA_VOLUME_NORM;
+
+        vol = vol * (u->hw_volume_max - u->hw_volume_min) /
             PA_VOLUME_NORM + u->hw_volume_min;
         err = snd_mixer_selem_set_capture_volume_all(u->mixer_elem, vol);
         if (err < 0)
@@ -237,7 +242,12 @@
         int i;
 
         for (i = 0;i < s->hw_volume.channels;i++) {
-            vol = s->hw_volume.values[i] * (u->hw_volume_max - u->hw_volume_min) /
+            vol = s->hw_volume.values[i];
+
+            if (vol > PA_VOLUME_NORM)
+                vol = PA_VOLUME_NORM;
+
+            vol = vol * (u->hw_volume_max - u->hw_volume_min) /
                 PA_VOLUME_NORM + u->hw_volume_min;
             err = snd_mixer_selem_set_capture_volume(u->mixer_elem, i, vol);
             if (err < 0)




More information about the pulseaudio-commits mailing list