-static int client_write(int fd, const char *buf)
-{
- size_t len = strlen(buf);
- return write(fd, buf, len) != len? -E_CLIENT_WRITE: 1;
-}
-
-static char *get_time_string(struct timeval *newest_stime)
-{
- struct timeval now, diff, adj_stream_start, tmp;
- int total = 0, use_server_time = 1;
-
- if (!playing) {
- if (length_seconds)
- return NULL;
- return make_message("%s:\n", status_item_list[SI_PLAY_TIME]);
- }
- if (audiod_status == AUDIOD_OFF)
- goto out;
- if (sa_time_diff_sign > 0)
- tv_diff(&server_stream_start, &sa_time_diff,
- &adj_stream_start);
- else
- tv_add(&server_stream_start, &sa_time_diff,
- &adj_stream_start);
- tmp = adj_stream_start;
- if (newest_stime && audiod_status == AUDIOD_ON) {
- tv_diff(newest_stime, &adj_stream_start, &diff);
- if (tv2ms(&diff) < 5000) {
- tmp = *newest_stime;
- use_server_time = 0;
- }
- }
- gettimeofday(&now, NULL);
- tv_diff(&now, &tmp, &diff);
- total = diff.tv_sec + offset_seconds;
- if (total > length_seconds)
- total = length_seconds;
- if (total < 0)
- total = 0;
-out:
- return make_message(
- "%s:%s%d:%02d [%d:%02d] (%d%%/%d:%02d)\n",
- status_item_list[SI_PLAY_TIME],
- use_server_time? "~" : "",
- total / 60,
- total % 60,
- (length_seconds - total) / 60,
- (length_seconds - total) % 60,
- length_seconds? (total * 100 + length_seconds / 2) /
- length_seconds : 0,
- length_seconds / 60,
- length_seconds % 60
- );
-}
-
-__malloc static char *audiod_status_string(void)
-{
- const char *status = (audiod_status == AUDIOD_ON)?
- "on" : (audiod_status == AUDIOD_OFF)? "off": "sb";
- return make_message("%s:%s\n", status_item_list[SI_AUDIOD_STATUS], status);
-}
-
-static struct timeval *wstime(void)
-{
- int i;
- struct timeval *max = NULL;
- FOR_EACH_SLOT(i) {
- struct slot_info *s = &slot[i];
- if (s->wpid <= 0)
- continue;
- if (max && tv_diff(&s->wstime, max, NULL) <= 0)
- continue;
- max = &s->wstime;
- }
- return max;
-}
-__malloc static char *decoder_flags(void)
-{
- int i;
- char decoder_flags[MAX_STREAM_SLOTS + 1];
-
- FOR_EACH_SLOT(i) {
- struct slot_info *s = &slot[i];
- char flag = '0';
- if (s->receiver_node)
- flag += 1;
- if (s->wpid > 0)
- flag += 2;
- if (flag != '0')
- flag += s->format * 4;
- decoder_flags[i] = flag;
- }
- decoder_flags[MAX_STREAM_SLOTS] = '\0';
- return make_message("%s:%s\n", status_item_list[SI_DECODER_FLAGS],
- decoder_flags);
-}
-