diff options
author | Michael Stapelberg <michael@stapelberg.de> | 2012-05-09 18:56:57 +0200 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2012-05-09 18:56:57 +0200 |
commit | 296eb5e7063b4051927f2e2bf94e1034bf64f60c (patch) | |
tree | 9d91807302af35783372848dbd028f21494c843e /src/print_volume.c | |
parent | 88b157cc8a19a312d93cba1f9332fc40b385e253 (diff) |
Error handling: Never output null as full_text (JSON), prefix messages with i3status (Thanks Artemis)
The former made i3bar crash, the latter is helpful for debugging.
Diffstat (limited to 'src/print_volume.c')
-rw-r--r-- | src/print_volume.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/print_volume.c b/src/print_volume.c index 7b38e63..dbf5e1f 100644 --- a/src/print_volume.c +++ b/src/print_volume.c @@ -97,14 +97,14 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char * } if ((err = snd_mixer_open(&(hdl->m), 0)) < 0) { - fprintf(stderr, "ALSA: Cannot open mixer: %s\n", snd_strerror(err)); + fprintf(stderr, "i3status: ALSA: Cannot open mixer: %s\n", snd_strerror(err)); free_hdl(hdl); return; } /* Attach this mixer handle to the given device */ if ((err = snd_mixer_attach(hdl->m, device)) < 0) { - fprintf(stderr, "ALSA: Cannot attach mixer to device: %s\n", snd_strerror(err)); + fprintf(stderr, "i3status: ALSA: Cannot attach mixer to device: %s\n", snd_strerror(err)); snd_mixer_close(hdl->m); free_hdl(hdl); return; @@ -112,14 +112,14 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char * /* Register this mixer */ if ((err = snd_mixer_selem_register(hdl->m, NULL, NULL)) < 0) { - fprintf(stderr, "ALSA: snd_mixer_selem_register: %s\n", snd_strerror(err)); + fprintf(stderr, "i3status: ALSA: snd_mixer_selem_register: %s\n", snd_strerror(err)); snd_mixer_close(hdl->m); free_hdl(hdl); return; } if ((err = snd_mixer_load(hdl->m)) < 0) { - fprintf(stderr, "ALSA: snd_mixer_load: %s\n", snd_strerror(err)); + fprintf(stderr, "i3status: ALSA: snd_mixer_load: %s\n", snd_strerror(err)); snd_mixer_close(hdl->m); free_hdl(hdl); return; @@ -129,7 +129,7 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char * snd_mixer_selem_id_set_index(hdl->sid, mixer_idx); snd_mixer_selem_id_set_name(hdl->sid, mixer); if (!(hdl->elem = snd_mixer_find_selem(hdl->m, hdl->sid))) { - fprintf(stderr, "ALSA: Cannot find mixer %s (index %i)\n", + fprintf(stderr, "i3status: ALSA: Cannot find mixer %s (index %i)\n", snd_mixer_selem_id_get_name(hdl->sid), snd_mixer_selem_id_get_index(hdl->sid)); snd_mixer_close(hdl->m); free_hdl(hdl); @@ -155,7 +155,7 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char * if (snd_mixer_selem_has_playback_switch(hdl->elem)) { int pbval; if ((err = snd_mixer_selem_get_playback_switch(hdl->elem, 0, &pbval)) < 0) - fprintf (stderr, "ALSA: playback_switch: %s\n", snd_strerror(err)); + fprintf (stderr, "i3status: ALSA: playback_switch: %s\n", snd_strerror(err)); if (!pbval) avg = 0; } |