Remove an overambitious sanity check in the fecdec filter.
[paraslash.git] / audiod_command.c
index a6f6776..3467dbe 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)
@@ -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);