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;
}
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)
ret = check_perms(uid);
if (ret < 0)
goto out;
- ret = -E_INVALID_AUDIOD_CMD;
cmd = para_strdup(buf);
p = strchr(cmd, '\n');
if (!p)
*/
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);