summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cf9329c)
raw | patch | inline | side by side (parent: cf9329c)
author | Max Kellermann <max@duempel.org> | |
Sat, 14 Nov 2009 01:38:26 +0000 (02:38 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Sat, 14 Nov 2009 01:38:26 +0000 (02:38 +0100) |
src/status_bar.c | patch | blob | history |
diff --git a/src/status_bar.c b/src/status_bar.c
index 2e9449963058e00a7dec38be20a41e81249dd145..4ccb6e3e42880fda3e9987f1192e00efb08227fc 100644 (file)
--- a/src/status_bar.c
+++ b/src/status_bar.c
return false;
}
+#ifndef NCMPC_MINI
+
+static void
+format_bitrate(char *p, size_t max_length, const struct mpd_status *status)
+{
+ if (options.visible_bitrate && mpd_status_get_kbit_rate(status) > 0)
+ g_snprintf(p, max_length,
+ " [%d kbps]",
+ mpd_status_get_kbit_rate(status));
+ else
+ p[0] = '\0';
+}
+
+#endif /* !NCMPC_MINI */
+
void
status_bar_paint(struct status_bar *p, const struct mpd_status *status,
const struct mpd_song *song)
/* display bitrate if visible-bitrate is true */
#ifndef NCMPC_MINI
- if (options.visible_bitrate) {
- g_snprintf(bitrate, 16,
- " [%d kbps]",
- mpd_status_get_kbit_rate(status));
- } else {
- bitrate[0] = '\0';
- }
+ format_bitrate(bitrate, sizeof(bitrate), status);
#endif
/* write out the time */
g_snprintf(buffer, sizeof(buffer), "%s [%s/%s]",
bitrate, elapsed_string, duration_string);
#ifndef NCMPC_MINI
- } else if (options.visible_bitrate) {
- g_snprintf(buffer, sizeof(buffer),
- " [%d kbps]",
- mpd_status_get_kbit_rate(status));
-#endif
} else {
+ format_bitrate(buffer, sizeof(buffer), status);
+#else
buffer[0] = 0;
+#endif
}
} else {
#ifndef NCMPC_MINI