]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge branch 't/sched_improvements'
authorAndre Noll <maan@systemlinux.org>
Sat, 26 Mar 2011 12:50:34 +0000 (13:50 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 26 Mar 2011 12:50:34 +0000 (13:50 +0100)
alsa_write.c
audiod.c
audiod.cmd
audiod_command.c
error.h
grab_client.c
oss_write.c
sched.c
sched.h
write.c

index ae3bbfbab60c82ab26311c00b1d0389a7544ec5c..8cf5cfd25bf3909e0f4d338d2397ca0e017c29ab 100644 (file)
@@ -214,7 +214,7 @@ again:
        bytes = btr_next_buffer(btrn, &data);
        if (ret < 0 || bytes < wn->min_iqs) { /* eof */
                assert(btr_no_parent(btrn));
-               ret = -E_ALSA_EOF;
+               ret = -E_WRITE_COMMON_EOF;
                if (!pad)
                        goto err;
                /* wait until pending frames are played */
index e66373cc87ed475682655a9dac17baec92144496..e5db0cd2b075c726e931f22ea854d0b916b7e8ef 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -1083,17 +1083,17 @@ static void try_to_close_slot(int slot_num)
 
        if (s->format < 0)
                return;
-       if (s->receiver_node && s->receiver_node->task.error != -E_TASK_UNREGISTERED)
+       if (s->receiver_node && s->receiver_node->task.error >= 0)
                return;
        for (i = 0; i < a->num_filters; i++)
-               if (s->fns && s->fns[i].task.error != -E_TASK_UNREGISTERED)
+               if (s->fns && s->fns[i].task.error >= 0)
                        return;
        if (a->num_writers > 0) {
                for (i = 0; i < a->num_writers; i++)
-                       if (s->wns && s->wns[i].task.error != -E_TASK_UNREGISTERED)
+                       if (s->wns && s->wns[i].task.error >= 0)
                                return;
        } else {
-               if (s->wns && s->wns[0].task.error != -E_TASK_UNREGISTERED)
+               if (s->wns && s->wns[0].task.error >= 0)
                        return;
        }
        PARA_INFO_LOG("closing slot %d\n", slot_num);
@@ -1174,7 +1174,7 @@ static void status_post_select(__a_unused struct sched *s, struct task *t)
                        kill_btrn(st->ct->btrn, &st->ct->task, -E_AUDIOD_OFF);
                        goto out;
                }
-               if (st->ct->task.error != -E_TASK_UNREGISTERED)
+               if (st->ct->task.error >= 0)
                        goto out;
                close_stat_pipe();
                st->clock_diff_count = conf.clock_diff_count_arg;
@@ -1185,7 +1185,7 @@ static void status_post_select(__a_unused struct sched *s, struct task *t)
                size_t sz;
                int ret;
                if (st->ct->task.error < 0) {
-                       if (st->ct->task.error != -E_TASK_UNREGISTERED)
+                       if (st->ct->task.error >= 0)
                                goto out;
                        close_stat_pipe();
                        goto out;
index 759f19173c111ac3aeff55b660eefc1c8b1d58da..c58907448f12eeb44551b98d113c3ef52ba9979f 100644 (file)
@@ -49,11 +49,6 @@ H: in any way. But now these days are gone, I'm not so self assured. Now I find
 H: I've changed my mind and opened up the doors.
 H:                                                              -- Beatles: Help
 ---
-N: kill
-D: kill an active audiod task
-U: kill task_id [task_id ...]
-H: Simulate an error condition for the given task(s)
----
 N: off
 D: deactivate para_audiod
 U: off
index eed9fc154c7191513c3e315a65fe552641823b1b..bfd7c4aa5df170235f24961813bc4cc2e69790fa 100644 (file)
@@ -301,21 +301,6 @@ int com_tasks(int fd, __a_unused int argc, __a_unused char **argv)
        return ret;
 }
 
-int com_kill(int fd, int argc, char **argv)
-{
-       int i, ret = 1;
-       if (argc < 2)
-               return -E_AUDIOD_SYNTAX;
-       for (i = 1; i < argc; i++) {
-               ret = kill_task(argv[i]);
-               if (ret < 0)
-                       break;
-       }
-       if (ret > 0)
-               close(fd);
-       return ret;
-}
-
 int com_stat(int fd, int argc, char **argv)
 {
        int i, ret, parser_friendly = 0;
diff --git a/error.h b/error.h
index 5a2e39b468fa58d7cb66bc3ca07f71012b02c2e2..de5dacf298667a9ccaf5708f921ddabcc8baf95b 100644 (file)
--- a/error.h
+++ b/error.h
@@ -103,7 +103,6 @@ extern const char **para_errlist[];
        PARA_ERROR(BAD_SAMPLE_FORMAT, "sample format not supported"), \
        PARA_ERROR(BAD_CHANNEL_COUNT, "channel count not supported"), \
        PARA_ERROR(BAD_SAMPLERATE, "sample rate not supported"), \
-       PARA_ERROR(OSS_EOF, "oss: end of file"), \
 
 
 #define COMPRESS_FILTER_ERRORS \
@@ -230,10 +229,8 @@ extern const char **para_errlist[];
 
 
 #define SCHED_ERRORS \
-       PARA_ERROR(TASK_KILLED, "task killed"), \
-       PARA_ERROR(TASK_UNREGISTERED, "task has been unscheduled"), \
-       PARA_ERROR(NO_SUCH_TASK, "task not found"), \
        PARA_ERROR(NOT_INITIALIZED, "scheduler not yet initialized"), \
+       PARA_ERROR(SCHED_SHUTDOWN, "scheduler was shut down"), \
 
 
 #define NET_ERRORS \
@@ -414,12 +411,11 @@ extern const char **para_errlist[];
        PARA_ERROR(SET_RATE, "snd_pcm_hw_params_set_rate_near failed"), \
        PARA_ERROR(START_THRESHOLD, "snd_pcm_sw_params_set_start_threshold() failed"), \
        PARA_ERROR(STOP_THRESHOLD, "snd_pcm_sw_params_set_stop_threshold() failed"), \
-       PARA_ERROR(ALSA_EOF, "alsa: end of file"), \
-
 
 
 #define WRITE_COMMON_ERRORS \
        PARA_ERROR(WRITE_COMMON_SYNTAX, "syntax error in write option"), \
+       PARA_ERROR(WRITE_COMMON_EOF, "end of file"), \
 
 
 #define AACDEC_FILTER_ERRORS \
index 8e6715036769dace2f633d867d4bdb436901b6e0..c410b3b934f398a6eb6bbd480f5d7e8f31535d62 100644 (file)
@@ -156,7 +156,7 @@ void activate_grab_clients(void)
        struct grab_client *gc, *tmp;
 
        list_for_each_entry_safe(gc, tmp, &inactive_grab_client_list, node) {
-               if (gc->task.error == -E_TASK_UNREGISTERED) {
+               if (gc->task.error < 0) {
                        list_del(&gc->node);
                        free(gc);
                        continue;
index 70a58203db8a2f2e3eca5cfc12506334ed7133da..e79ea6ced6c62f3fdfe1b6ce59cf7f7784cb9614 100644 (file)
@@ -185,7 +185,7 @@ static void oss_post_select(__a_unused struct sched *s,
        bytes = btr_next_buffer(btrn, &data);
        frames = bytes / powd->bytes_per_frame;
        if (!frames) { /* eof and less than a single frame available */
-               ret = -E_OSS_EOF;
+               ret = -E_WRITE_COMMON_EOF;
                goto out;
        }
        ret = 0;
diff --git a/sched.c b/sched.c
index b0e9ce12f221e901d761108899d98190ccf984d6..9be3a2e83109f0db884c5fdebf3e7e62f4f9b3c5 100644 (file)
--- a/sched.c
+++ b/sched.c
@@ -38,21 +38,20 @@ static void unregister_task(struct task *t)
 {
        if (!initialized)
                return;
+       assert(t->error < 0);
        PARA_INFO_LOG("unregistering %s (%s)\n", t->status,
-               t->error <0? para_strerror(-t->error) : "shutdown");
+               para_strerror(-t->error));
        if (t->pre_select)
                list_del(&t->pre_select_node);
        if (t->post_select)
                list_del(&t->post_select_node);
-       t->error = -E_TASK_UNREGISTERED;
 }
 
-
 static void sched_preselect(struct sched *s)
 {
        struct task *t, *tmp;
        list_for_each_entry_safe(t, tmp, &pre_select_list, pre_select_node) {
-               if (t->error >= 0 && t->pre_select)
+               if (t->pre_select)
                        t->pre_select(s, t);
 //             PARA_INFO_LOG("%s \n", t->status);
                if (t->error >= 0)
@@ -207,10 +206,14 @@ void sched_shutdown(void)
 
        if (!initialized)
                return;
-       list_for_each_entry_safe(t, tmp, &pre_select_list, pre_select_node)
+       list_for_each_entry_safe(t, tmp, &pre_select_list, pre_select_node) {
+               t->error = -E_SCHED_SHUTDOWN;
                unregister_task(t);
-       list_for_each_entry_safe(t, tmp, &post_select_list, post_select_node)
+       }
+       list_for_each_entry_safe(t, tmp, &post_select_list, post_select_node) {
+               t->error = -E_SCHED_SHUTDOWN;
                unregister_task(t);
+       }
        initialized = 0;
 }
 
@@ -219,8 +222,7 @@ void sched_shutdown(void)
  *
  * \return The task list.
  *
- * Each entry of the list contains an identifier which is simply a hex number
- * that may be used in \a kill_task() to terminate the task.
+ * Each entry of the list contains an identifier which is simply a hex number.
  * The result is dynamically allocated and must be freed by the caller.
  */
 char *get_task_list(void)
@@ -248,41 +250,6 @@ char *get_task_list(void)
        return msg;
 }
 
-/**
- * Simulate an error for the given task.
- *
- * \param id The task identifier.
- *
- * Find the task identified by \a id, set the tasks' error value to
- * \p -E_TASK_KILLED and unregister the task.
- *
- * \return Positive on success, negative on errors (e.g. if \a id does not
- * correspond to a registered task).
- */
-int kill_task(char *id)
-{
-       struct task *t, *tmp;
-       char buf[20];
-
-       if (!initialized)
-               return -E_NOT_INITIALIZED;
-       list_for_each_entry_safe(t, tmp, &pre_select_list, pre_select_node) {
-               sprintf(buf, "%p", t);
-               if (strcmp(id, buf))
-                       continue;
-               t->error = -E_TASK_KILLED;
-               return 1;
-       }
-       list_for_each_entry_safe(t, tmp, &post_select_list, post_select_node) {
-               sprintf(buf, "%p", t);
-               if (strcmp(id, buf))
-                       continue;
-               t->error = -E_TASK_KILLED;
-               return 1;
-       }
-       return -E_NO_SUCH_TASK;
-}
-
 /**
  * Set the select timeout to the minimal possible value.
  *
diff --git a/sched.h b/sched.h
index 7158a8732c314b88ad1e162cbb6743c710d01240..e018c2fe9d0c35d2431b96967f97eb69f8ea0238 100644 (file)
--- a/sched.h
+++ b/sched.h
@@ -77,7 +77,6 @@ extern struct timeval *now;
 void register_task(struct task *t);
 int schedule(struct sched *s);
 char *get_task_list(void);
-int kill_task(char *id);
 void sched_shutdown(void);
 void sched_min_delay(struct sched *s);
 void sched_request_timeout(struct timeval *to, struct sched *s);
diff --git a/write.c b/write.c
index 2ea9d2132bee5f64224f3f9d635af8f83777a33e..b3824a081f594dee23617502caf65261717d77b9 100644 (file)
--- a/write.c
+++ b/write.c
@@ -209,6 +209,20 @@ static int main_btr(struct sched *s)
        s->default_timeout.tv_sec = 10;
        s->default_timeout.tv_usec = 50000;
        ret = schedule(s);
+       if (ret >= 0) {
+               int j;
+               for (j = 0; j < i; j++) {
+                       struct task *t = &wns[j].task;
+                       assert(t->error < 0);
+                       if (t->error != -E_WRITE_COMMON_EOF
+                                       && t->error != -E_BTR_EOF) {
+                               PARA_ERROR_LOG("%s: %s\n", t->status,
+                                       para_strerror(-t->error));
+                               if (ret >= 0)
+                                       ret = t->error;
+                       }
+               }
+       }
 out:
        for (i--; i >= 0; i--) {
                struct writer_node *wn = wns + i;