diff --git a/src/core.c b/src/core.c index 6886ad07..5038470a 100644 --- a/src/core.c +++ b/src/core.c @@ -786,13 +786,13 @@ struct text_object *construct_text_object(const char *s, const char *arg, long #endif /* X11*/ END OBJ(mixer, 0) parse_mixer_arg(obj, arg); - obj->callbacks.print = &print_mixer; + obj->callbacks.percentage = &mixer_percentage; END OBJ(mixerl, 0) parse_mixer_arg(obj, arg); - obj->callbacks.print = &print_mixerl; + obj->callbacks.percentage = &mixerl_percentage; END OBJ(mixerr, 0) parse_mixer_arg(obj, arg); - obj->callbacks.print = &print_mixerr; + obj->callbacks.percentage = &mixerr_percentage; END OBJ(mixerbar, 0) scan_mixer_bar(obj, arg); obj->callbacks.barval = &mixer_barval; diff --git a/src/mixer.c b/src/mixer.c index 5dff58a4..655e4dbb 100644 --- a/src/mixer.c +++ b/src/mixer.c @@ -284,38 +284,19 @@ void parse_mixer_arg(struct text_object *obj, const char *arg) obj->data.l = mixer_init(arg); } -/* chan specifies the channel to print: - * -1 := left channel - * 0 := channel average - * 1 := right channel - */ -static void print_mixer_chan(struct text_object *obj, int chan, char *p, int p_max_size) +uint8_t mixer_percentage(struct text_object *obj) { - int val; - - if (chan < 0) - val = mixer_get_left(obj->data.l); - else if (chan == 0) - val = mixer_get_avg(obj->data.l); - else - val = mixer_get_right(obj->data.l); - - percent_print(p, p_max_size, val); + return mixer_get_avg(obj->data.l); } -void print_mixer(struct text_object *obj, char *p, int p_max_size) +uint8_t mixerl_percentage(struct text_object *obj) { - print_mixer_chan(obj, 0, p, p_max_size); + return mixer_get_left(obj->data.l); } -void print_mixerl(struct text_object *obj, char *p, int p_max_size) +uint8_t mixerr_percentage(struct text_object *obj) { - 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); + return mixer_get_right(obj->data.l); } int check_mixer_muted(struct text_object *obj) diff --git a/src/mixer.h b/src/mixer.h index a1f4d174..34dc1bdb 100644 --- a/src/mixer.h +++ b/src/mixer.h @@ -4,9 +4,9 @@ #define MIXER_H_ void parse_mixer_arg(struct text_object *, const char *); -void print_mixer(struct text_object *, char *, int); -void print_mixerl(struct text_object *, char *, int); -void print_mixerr(struct text_object *, char *, int); +uint8_t mixer_percentage(struct text_object *obj); +uint8_t mixerl_percentage(struct text_object *obj); +uint8_t mixerr_percentage(struct text_object *obj); int check_mixer_muted(struct text_object *); void scan_mixer_bar(struct text_object *, const char *);