* Please see COPYING for details
*
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
+ * Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
* (see AUTHORS)
* All rights reserved.
*
* 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;
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))
return 1;
}
-#ifdef X11
-struct mixerbar_data {
- int l;
- int w, h;
-};
-
void scan_mixer_bar(struct text_object *obj, const char *arg)
{
char buf1[64];
- struct mixerbar_data *mbd;
int n;
- mbd = malloc(sizeof(struct mixerbar_data));
- memset(mbd, 0, sizeof(struct mixerbar_data));
-
if (arg && sscanf(arg, "%63s %n", buf1, &n) >= 1) {
- mbd->l = mixer_init(buf1);
- scan_bar(arg + n, &mbd->w, &mbd->h);
+ obj->data.i = mixer_init(buf1);
+ scan_bar(obj, arg + n);
} else {
- mbd->l = mixer_init(NULL);
- scan_bar(arg, &mbd->w, &mbd->h);
+ obj->data.i = mixer_init(NULL);
+ scan_bar(obj, arg);
}
- obj->data.opaque = mbd;
}
/* 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)
{
- struct mixerbar_data *mdp = obj->data.opaque;
int val;
- if (!mdp)
+ if (!p_max_size)
return;
if (chan < 0)
- val = mixer_get_left(mdp->l);
+ val = mixer_get_left(obj->data.i);
else if (chan == 0)
- val = mixer_get_avg(mdp->l);
+ val = mixer_get_avg(obj->data.i);
else
- val = mixer_get_right(mdp->l);
+ val = mixer_get_right(obj->data.i);
+
+ new_bar(obj, p, p_max_size, 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);
+}
- new_bar(p, mdp->w, mdp->h, mixer_to_255(mdp->l, val));
+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 */