[polypaudio-commits] r924 - /trunk/src/modules/module-lirc.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Wed May 17 14:07:47 PDT 2006


Author: lennart
Date: Wed May 17 23:07:46 2006
New Revision: 924

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=924&root=polypaudio&view=rev
Log:
modify lirc module to use pa_sink_mute() for muting and unmuting

Modified:
    trunk/src/modules/module-lirc.c

Modified: trunk/src/modules/module-lirc.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-lirc.c?rev=924&root=polypaudio&r1=923&r2=924&view=diff
==============================================================================
--- trunk/src/modules/module-lirc.c (original)
+++ trunk/src/modules/module-lirc.c Wed May 17 23:07:46 2006
@@ -88,7 +88,14 @@
         pa_xfree(c);
         
         while (lirc_code2char(u->config, code, &name) == 0 && name) {
-            enum { INVALID, UP, DOWN, MUTE, RESET, MUTE_TOGGLE } volchange = INVALID;
+            enum {
+                INVALID,
+                UP,
+                DOWN,
+                MUTE,
+                RESET,
+                MUTE_TOGGLE
+            } volchange = INVALID;
             
             pa_log_info(__FILE__": translated IR code '%s'", name);
             
@@ -111,51 +118,56 @@
                 if (!(s = pa_namereg_get(u->module->core, u->sink_name, PA_NAMEREG_SINK, 1)))
                     pa_log(__FILE__": failed to get sink '%s'", u->sink_name);
                 else {
-                    pa_volume_t v = pa_cvolume_avg(pa_sink_get_volume(s, PA_MIXER_HARDWARE));
-                    pa_cvolume cv;
+                    int i;
+                    pa_cvolume cv = *pa_sink_get_volume(s, PA_MIXER_HARDWARE);
+
 #define DELTA (PA_VOLUME_NORM/20)
 
                     switch (volchange) {
                         case UP:
-                            v += PA_VOLUME_NORM/20;
+                            for (i = 0; i < cv.channels; i++) {
+                                cv.values[i] += DELTA;
+
+                                if (cv.values[i] > PA_VOLUME_NORM)
+                                    cv.values[i] = PA_VOLUME_NORM;
+                            }
+
+                            pa_sink_set_volume(s, PA_MIXER_HARDWARE, &cv);
                             break;
                             
                         case DOWN:
-                            if (v > DELTA)
-                                v -= DELTA;
-                            else
-                                v = PA_VOLUME_MUTED;
-                            
+                            for (i = 0; i < cv.channels; i++) {
+                                if (cv.values[i] >= DELTA)
+                                    cv.values[i] -= DELTA;
+                                else
+                                    cv.values[i] = PA_VOLUME_MUTED;
+                            }
+                            
+                            pa_sink_set_volume(s, PA_MIXER_HARDWARE, &cv);
                             break;
                             
                         case MUTE:
-                            v  = PA_VOLUME_MUTED;
+                            pa_sink_set_mute(s, PA_MIXER_HARDWARE, 0);
                             break;
                             
                         case RESET:
-                            v  = PA_VOLUME_NORM;
-                            break;
-                            
-                        case MUTE_TOGGLE: {
-
-                            if (v > 0) {
-                                u->mute_toggle_save = v;
-                                v = PA_VOLUME_MUTED;
-                            } else
-                                v = u->mute_toggle_save;
-                        }
-                        default:
+                            pa_sink_set_mute(s, PA_MIXER_HARDWARE, 1);
+                            break;
+                            
+                        case MUTE_TOGGLE:
+
+                            pa_sink_set_mute(s, PA_MIXER_HARDWARE, !pa_sink_get_mute(s, PA_MIXER_HARDWARE));
+                            break;
+
+                        case INVALID:
                             ;
                     }
-
-                    pa_cvolume_set(&cv, PA_CHANNELS_MAX, v);
-                    pa_sink_set_volume(s, PA_MIXER_HARDWARE, &cv);
                 }
             }
         }
     }
 
-    free(code);
+    pa_xfree(code);
 
     return;
     




More information about the pulseaudio-commits mailing list