Obtain afs status items directly from afs.
[paraslash.git] / audiod_command.c
index 3b41376dece2401eef5bb073bd27552f5a04712e..3467dbe1a1990c566b353c7450a828828996bdbc 100644 (file)
@@ -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)
@@ -422,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);