audiod: avoid another gettimeofday() call
authorAndre <maan@p133.(none)>
Sun, 28 May 2006 19:05:49 +0000 (21:05 +0200)
committerAndre <maan@p133.(none)>
Sun, 28 May 2006 19:05:49 +0000 (21:05 +0200)
The sched struct already contains the current time.

audiod.c

index 4ed9cc9..5e8cf2b 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -767,16 +767,14 @@ static void open_receiver(int format)
        register_task(&rn->task);
 }
 
-static int is_frozen(int format)
+static int is_frozen(int format, struct timeval *now)
 {
-       struct timeval now;
        struct audio_format_info *a = &afi[format];
 
-       gettimeofday(&now, NULL);
-       return (tv_diff(&now, &a->restart_barrier, NULL) > 0)? 0 : 1;
+       return (tv_diff(now, &a->restart_barrier, NULL) > 0)? 0 : 1;
 }
 
-static void start_current_receiver(void)
+static void start_current_receiver(struct timeval *now)
 {
        int i;
 
@@ -785,7 +783,7 @@ static void start_current_receiver(void)
        i = get_audio_format_num(af_status);
        if (i < 0)
                return;
-       if ((decoder_running(i) & 1) || is_frozen(i))
+       if ((decoder_running(i) & 1) || is_frozen(i, now))
                return;
        open_receiver(i);
 }
@@ -930,14 +928,14 @@ static void close_decoder_if_idle(int slot_num)
        clear_slot(slot_num);
 }
 
-static void audiod_pre_select(__a_unused struct sched *s, __a_unused struct task *t)
+static void audiod_pre_select(struct sched *s, __a_unused struct task *t)
 {
        int i;
 
        if (audiod_status != AUDIOD_ON)
                kill_all_decoders();
        else if (playing)
-               start_current_receiver();
+               start_current_receiver(&s->now);
        check_timeouts();
        FOR_EACH_SLOT(i) {
                struct receiver_node *rn;