1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 12:27:52 +00:00

convert mixer values to callbacks.percentage

This commit is contained in:
Phil Sutter 2009-11-25 01:47:53 +01:00
parent 36a202091e
commit 61591def8e
3 changed files with 12 additions and 31 deletions

View File

@ -786,13 +786,13 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
#endif /* X11*/ #endif /* X11*/
END OBJ(mixer, 0) END OBJ(mixer, 0)
parse_mixer_arg(obj, arg); parse_mixer_arg(obj, arg);
obj->callbacks.print = &print_mixer; obj->callbacks.percentage = &mixer_percentage;
END OBJ(mixerl, 0) END OBJ(mixerl, 0)
parse_mixer_arg(obj, arg); parse_mixer_arg(obj, arg);
obj->callbacks.print = &print_mixerl; obj->callbacks.percentage = &mixerl_percentage;
END OBJ(mixerr, 0) END OBJ(mixerr, 0)
parse_mixer_arg(obj, arg); parse_mixer_arg(obj, arg);
obj->callbacks.print = &print_mixerr; obj->callbacks.percentage = &mixerr_percentage;
END OBJ(mixerbar, 0) END OBJ(mixerbar, 0)
scan_mixer_bar(obj, arg); scan_mixer_bar(obj, arg);
obj->callbacks.barval = &mixer_barval; obj->callbacks.barval = &mixer_barval;

View File

@ -284,38 +284,19 @@ void parse_mixer_arg(struct text_object *obj, const char *arg)
obj->data.l = mixer_init(arg); obj->data.l = mixer_init(arg);
} }
/* chan specifies the channel to print: uint8_t mixer_percentage(struct text_object *obj)
* -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)
{ {
int val; return mixer_get_avg(obj->data.l);
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);
} }
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); return mixer_get_right(obj->data.l);
}
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) int check_mixer_muted(struct text_object *obj)

View File

@ -4,9 +4,9 @@
#define MIXER_H_ #define MIXER_H_
void parse_mixer_arg(struct text_object *, const char *); void parse_mixer_arg(struct text_object *, const char *);
void print_mixer(struct text_object *, char *, int); uint8_t mixer_percentage(struct text_object *obj);
void print_mixerl(struct text_object *, char *, int); uint8_t mixerl_percentage(struct text_object *obj);
void print_mixerr(struct text_object *, char *, int); uint8_t mixerr_percentage(struct text_object *obj);
int check_mixer_muted(struct text_object *); int check_mixer_muted(struct text_object *);
void scan_mixer_bar(struct text_object *, const char *); void scan_mixer_bar(struct text_object *, const char *);