X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=audiod_command.c;h=3467dbe1a1990c566b353c7450a828828996bdbc;hp=a6f6776267b1183ec947cf4bbfdf268fe3e8077d;hb=e0acbd356abf4d9f1b693065b1ff23c57c53ab1e;hpb=002731cd3938f3be6b71651e56c062af1adcdec0;ds=sidebyside diff --git a/audiod_command.c b/audiod_command.c index a6f67762..3467dbe1 100644 --- a/audiod_command.c +++ b/audiod_command.c @@ -46,20 +46,22 @@ __malloc static char *audiod_status_string(void) return make_message("%s: %s\n", status_item_list[SI_AUDIOD_STATUS], status); } -static struct timeval *wstime(void) +static int get_play_time_slot_num(void) { - int i; - struct timeval *max = NULL; + int i, oldest = -1; + FOR_EACH_SLOT(i) { struct slot_info *s = &slot[i]; if (!s->wng) continue; - if (max && tv_diff(&s->wstime, max, NULL) <= 0) + if (oldest >= 0 && tv_diff(&s->wstime, &slot[oldest].wstime, + NULL) > 0) continue; - max = &s->wstime; + oldest = i; } - return max; + return oldest; } + __malloc static char *decoder_flags(void) { int i; @@ -181,8 +183,8 @@ int com_stat(int fd, __a_unused int argc, __a_unused char **argv) } PARA_INFO_LOG("mask: 0x%lx\n", mask); if (mask & (1 << SI_PLAY_TIME)) { - struct timeval *t = wstime(); - char *ts = get_time_string(t); + int slot_num = get_play_time_slot_num(); + char *ts = get_time_string(slot_num); if (ts) { ret = client_write(fd, ts); if (ret < 0) @@ -379,7 +381,6 @@ int handle_connect(int accept_fd) ret = check_perms(uid); if (ret < 0) goto out; - ret = -E_INVALID_AUDIOD_CMD; cmd = para_strdup(buf); p = strchr(cmd, '\n'); if (!p) @@ -423,11 +424,11 @@ out: */ void audiod_status_dump(void) { - struct timeval *t = wstime(); + int slot_num = get_play_time_slot_num(); char *old, *new, *tmp; old = stat_item_values[SI_PLAY_TIME]; - new = get_time_string(t); + new = get_time_string(slot_num); if (new) { if (!old || strcmp(old, new)) { free(old);