X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=play.c;h=2dcc37ea2bf0954ccea2776c8dd410b85c9804b2;hb=e58586b7395a84e5883b077d89b92c8ac649a1f2;hp=e6a58fce566ee7ec7553d31d91f8386b5cef7094;hpb=5dbc9ac5ce13e1d2872058f3440de253e4416dfe;p=paraslash.git diff --git a/play.c b/play.c index e6a58fce..2dcc37ea 100644 --- a/play.c +++ b/play.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2013 Andre Noll + * Copyright (C) 2012-2014 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -249,7 +249,7 @@ static int get_playback_error(struct play_task *pt) return 0; if (pt->fn.task.error >= 0) return 0; - if (pt->rn.task.error >= 0) + if (pt->rn.task->error >= 0) return 0; if (err == -E_BTR_EOF || err == -E_RECV_EOF || err == -E_EOF || err == -E_WRITE_COMMON_EOF) @@ -277,6 +277,7 @@ static int eof_cleanup(struct play_task *pt) free(pt->fn.conf); memset(&pt->fn, 0, sizeof(struct filter_node)); + task_reap(&pt->rn.task); btr_remove_node(&pt->rn.btrn); /* * On eof (ret > 0), we do not wipe the receiver node struct until a @@ -351,9 +352,6 @@ static int open_new_file(struct play_task *pt) free(tmp); tmp = NULL; } - pt->rn.task.pre_select = afh_recv->pre_select; - pt->rn.task.post_select = afh_recv->post_select; - sprintf(pt->rn.task.status, "%s receiver node", afh_recv->name); return 1; fail: wipe_receiver_node(pt); @@ -405,7 +403,13 @@ static int load_file(struct play_task *pt) pt->wn.task.error = 0; /* success, register tasks */ - register_task(&sched, &pt->rn.task); + pt->rn.task = task_register( + &(struct task_info) { + .name = afh_recv->name, + .pre_select = afh_recv->pre_select, + .post_select = afh_recv->post_select, + .context = &pt->rn + }, &sched); register_task(&sched, &pt->fn.task); register_writer_node(&pt->wn, pt->fn.btrn, &sched); return 1; @@ -431,7 +435,7 @@ static int load_next_file(struct play_task *pt) int ret; again: - if (pt->rq == CRT_NONE || pt->rq == CRT_FILE_CHANGE) { + if (pt->rq == CRT_NONE) { pt->start_chunk = 0; ret = next_valid_file(pt); if (ret < 0) @@ -974,15 +978,7 @@ out: static int play_i9e_line_handler(char *line) { - struct play_task *pt = &play_task; - int ret; - - if (line == NULL || !*line) - return 0; - ret = run_command(line, pt); - if (ret < 0) - return ret; - return 0; + return run_command(line, &play_task); } static int play_i9e_key_handler(int key) @@ -1258,6 +1254,7 @@ int main(int argc, char *argv[]) sprintf(pt->task.status, "play task"); register_task(&sched, &pt->task); ret = schedule(&sched); + sched_shutdown(&sched); if (ret < 0) PARA_ERROR_LOG("%s\n", para_strerror(-ret)); return ret < 0? EXIT_FAILURE : EXIT_SUCCESS;