[polypaudio-commits] r665 - /trunk/src/modules/oss-util.c

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


Author: lennart
Date: Sat Apr  8 02:19:29 2006
New Revision: 665

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=665&root=polypaudio&view=rev
Log:
add proper volume clipping support for OSS devices

Modified:
    trunk/src/modules/oss-util.c

Modified: trunk/src/modules/oss-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/oss-util.c?rev=665&root=polypaudio&r1=664&r2=665&view=diff
==============================================================================
--- trunk/src/modules/oss-util.c (original)
+++ trunk/src/modules/oss-util.c Sat Apr  8 02:19:29 2006
@@ -190,11 +190,16 @@
 static int pa_oss_set_volume(int fd, int mixer, const pa_sample_spec *ss, const pa_cvolume *volume) {
     char cv[PA_CVOLUME_SNPRINT_MAX];
     unsigned vol;
-
-    vol = (volume->values[0]*100)/PA_VOLUME_NORM;
-
-    if (ss->channels >= 2)
-        vol |= ((volume->values[1]*100)/PA_VOLUME_NORM) << 8;
+    pa_volume_t l, r;
+
+    l = volume->values[0] > PA_VOLUME_NORM ? PA_VOLUME_NORM : volume->values[0];
+
+    vol = (l*100)/PA_VOLUME_NORM;
+
+    if (ss->channels >= 2) {
+        r = volume->values[1] > PA_VOLUME_NORM ? PA_VOLUME_NORM : volume->values[1];
+        vol |= ((r*100)/PA_VOLUME_NORM) << 8;
+    }
     
     if (ioctl(fd, mixer, &vol) < 0)
         return -1;




More information about the pulseaudio-commits mailing list