mixer: convert to common signature
authorPhil Sutter <phil@nwl.cc>
Sun, 8 Nov 2009 15:36:35 +0000 (16:36 +0100)
committerPhil Sutter <phil@nwl.cc>
Thu, 19 Nov 2009 22:56:01 +0000 (23:56 +0100)
src/conky.c
src/mixer.c
src/mixer.h

index 250d26b..41815f4 100644 (file)
@@ -1444,23 +1444,23 @@ void generate_text_internal(char *p, int p_max_size,
 #endif /* X11 */
                        /* mixer stuff */
                        OBJ(mixer) {
-                               print_mixer(obj, 0, p, p_max_size);
+                               print_mixer(obj, p, p_max_size);
                        }
                        OBJ(mixerl) {
-                               print_mixer(obj, -1, p, p_max_size);
+                               print_mixerl(obj, p, p_max_size);
                        }
                        OBJ(mixerr) {
-                               print_mixer(obj, 1, p, p_max_size);
+                               print_mixerr(obj, p, p_max_size);
                        }
 #ifdef X11
                        OBJ(mixerbar) {
-                               print_mixer_bar(obj, 0, p);
+                               print_mixer_bar(obj, p, p_max_size);
                        }
                        OBJ(mixerlbar) {
-                               print_mixer_bar(obj, -1, p);
+                               print_mixerl_bar(obj, p, p_max_size);
                        }
                        OBJ(mixerrbar) {
-                               print_mixer_bar(obj, 1, p);
+                               print_mixerr_bar(obj, p, p_max_size);
                        }
 #endif /* X11 */
                        OBJ(if_mixer_mute) {
index 1e3d962..784fcb0 100644 (file)
@@ -289,7 +289,7 @@ void parse_mixer_arg(struct text_object *obj, const char *arg)
  *  0 := channel average
  *  1 := right channel
  */
-void print_mixer(struct text_object *obj, int chan, char *p, int p_max_size)
+static void print_mixer_chan(struct text_object *obj, int chan, char *p, int p_max_size)
 {
        int val;
 
@@ -303,6 +303,21 @@ void print_mixer(struct text_object *obj, int chan, char *p, int p_max_size)
        percent_print(p, p_max_size, val);
 }
 
+void print_mixer(struct text_object *obj, char *p, int p_max_size)
+{
+       print_mixer_chan(obj, 0, p, p_max_size);
+}
+
+void print_mixerl(struct text_object *obj, char *p, int p_max_size)
+{
+       print_mixer_chan(obj, -1, p, p_max_size);
+}
+
+void print_mixerr(struct text_object *obj, char *p, int p_max_size)
+{
+       print_mixer_chan(obj, 1, p, p_max_size);
+}
+
 int check_mixer_muted(struct text_object *obj)
 {
        if (!mixer_is_mute(obj->data.l))
@@ -326,10 +341,13 @@ void scan_mixer_bar(struct text_object *obj, const char *arg)
 }
 
 /* see print_mixer() above for a description of 'chan' */
-void print_mixer_bar(struct text_object *obj, int chan, char *p)
+static void print_mixer_bar_chan(struct text_object *obj, int chan, char *p, int p_max_size)
 {
        int val;
 
+       if (!p_max_size)
+               return;
+
        if (chan < 0)
                val = mixer_get_left(obj->data.i);
        else if (chan == 0)
@@ -339,4 +357,20 @@ void print_mixer_bar(struct text_object *obj, int chan, char *p)
 
        new_bar(obj, p, mixer_to_255(obj->data.i, val));
 }
+
+void print_mixer_bar(struct text_object *obj, char *p, int p_max_size)
+{
+       print_mixer_bar_chan(obj, 0, p, p_max_size);
+}
+
+void print_mixerl_bar(struct text_object *obj, char *p, int p_max_size)
+{
+       print_mixer_bar_chan(obj, -1, p, p_max_size);
+}
+
+void print_mixerr_bar(struct text_object *obj, char *p, int p_max_size)
+{
+       print_mixer_bar_chan(obj, 1, p, p_max_size);
+}
+
 #endif /* X11 */
index 334386d..6db54d5 100644 (file)
@@ -4,12 +4,16 @@
 #define MIXER_H_
 
 void parse_mixer_arg(struct text_object *, const char *);
-void print_mixer(struct text_object *, int, char *, int);
+void print_mixer(struct text_object *, char *, int);
+void print_mixerl(struct text_object *, char *, int);
+void print_mixerr(struct text_object *, char *, int);
 int check_mixer_muted(struct text_object *);
 
 #ifdef X11
 void scan_mixer_bar(struct text_object *, const char *);
-void print_mixer_bar(struct text_object *, int, char *);
+void print_mixer_bar(struct text_object *, char *, int);
+void print_mixerl_bar(struct text_object *, char *, int);
+void print_mixerr_bar(struct text_object *, char *, int);
 #endif /* X11 */
 
 #endif /*MIXER_H_*/