writers: Unify ->pre_select().
[paraslash.git] / osx_write.c
index b0dfa89..551748a 100644 (file)
@@ -187,13 +187,12 @@ static OSStatus osx_callback(void * inClientData,
 #define ENDIAN_FLAGS 0
 #endif
 
-static int osx_write_open(struct writer_node *wn)
+static void osx_write_open(struct writer_node *wn)
 {
        struct private_osx_write_data *powd = para_calloc(sizeof(*powd));
 
        wn->private_data = powd;
        init_buffers(wn);
-       return 0;
 }
 
 static int core_audio_init(struct writer_node *wn)
@@ -348,13 +347,15 @@ static void osx_write_pre_select(struct sched *s, struct task *t)
        struct private_osx_write_data *powd = wn->private_data;
        struct timeval tmp = {.tv_sec = 1, .tv_usec = 0}, delay = tmp;
        unsigned long divisor;
-       size_t numbytes = powd->to->remaining * sizeof(short);
+       size_t numbytes;
        int ret = btr_node_status(wn->btrn, wn->min_iqs, BTR_NT_LEAF);
 
-       if (ret < 0)
-               sched_min_delay(s);
-       if (ret <= 0 || numbytes < wn->min_iqs)
+       if (ret == 0)
                return;
+       if (ret < 0 || !powd->audio_unit)
+               return sched_min_delay(s);
+       numbytes = powd->to->remaining * sizeof(short);
+       assert(numbytes > 0);
        divisor = powd->sample_rate * wn->min_iqs / numbytes;
        if (divisor)
                tv_divide(divisor, &tmp, &delay);