From: Andre Noll Date: Mon, 9 Jul 2012 17:44:03 +0000 (+0200) Subject: Make writer nodes honor notifications. X-Git-Tag: v0.4.12~7^2~4 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=3b2ee202452ef44ff8bcec442b986531533cc43f Make writer nodes honor notifications. Currently, nobody is notifying any writer node but the para_play executable, which will be introduced in subsequent patches, will use this facility to terminate the audio stream. --- diff --git a/alsa_write.c b/alsa_write.c index 16497bdf..3f4380a1 100644 --- a/alsa_write.c +++ b/alsa_write.c @@ -247,8 +247,10 @@ static void alsa_write_post_select(__a_unused struct sched *s, snd_pcm_sframes_t frames; int ret; + ret = task_get_notification(t); + if (ret < 0) + goto err; again: - t->error = 0; ret = btr_node_status(btrn, wn->min_iqs, BTR_NT_LEAF); if (ret == 0) return; diff --git a/file_write.c b/file_write.c index 32f6c3ab..13008c2d 100644 --- a/file_write.c +++ b/file_write.c @@ -110,7 +110,9 @@ static void file_write_post_select(__a_unused struct sched *s, char *buf; size_t bytes; - t->error = 0; + ret = task_get_notification(t); + if (ret < 0) + goto out; ret = btr_node_status(btrn, wn->min_iqs, BTR_NT_LEAF); if (ret <= 0) goto out; diff --git a/oss_write.c b/oss_write.c index d2dc963e..8ca3c525 100644 --- a/oss_write.c +++ b/oss_write.c @@ -164,13 +164,15 @@ static void oss_post_select(__a_unused struct sched *s, struct private_oss_write_data *powd = wn->private_data; struct btr_node *btrn = wn->btrn; size_t frames, bytes; - int ret = btr_node_status(btrn, wn->min_iqs, BTR_NT_LEAF); + int ret; char *data; + ret = task_get_notification(t); if (ret < 0) goto out; - if (ret == 0) - return; + ret = btr_node_status(btrn, wn->min_iqs, BTR_NT_LEAF); + if (ret <= 0) + goto out; if (!powd) { int32_t rate, ch, format; get_btr_sample_rate(btrn, &rate); diff --git a/osx_write.c b/osx_write.c index 8dcfb4cd..f8476bfd 100644 --- a/osx_write.c +++ b/osx_write.c @@ -285,15 +285,18 @@ static void osx_write_post_select(__a_unused struct sched *s, struct task *t) struct btr_node *btrn = wn->btrn; int ret; + ret = task_get_notification(t); + if (ret < 0) + goto fail; if (!powd) { ret = btr_node_status(btrn, wn->min_iqs, BTR_NT_LEAF); if (ret == 0) return; if (ret < 0) - goto remove_btrn; + goto fail; ret = core_audio_init(wn); if (ret < 0) - goto remove_btrn; + goto fail; powd = wn->private_data; AudioOutputUnitStart(powd->audio_unit); } @@ -303,17 +306,18 @@ static void osx_write_post_select(__a_unused struct sched *s, struct task *t) if (ret < 0 && need_drain_delay(powd)) ret = 0; mutex_unlock(powd->mutex); - if (ret >= 0) - goto out; - AudioOutputUnitStop(powd->audio_unit); - AudioUnitUninitialize(powd->audio_unit); - CloseComponent(powd->audio_unit); - btr_remove_node(&powd->callback_btrn); -remove_btrn: + return; +fail: + assert(ret < 0); + if (powd && powd->callback_btrn) { + AudioOutputUnitStop(powd->audio_unit); + AudioUnitUninitialize(powd->audio_unit); + CloseComponent(powd->audio_unit); + btr_remove_node(&powd->callback_btrn); + } btr_remove_node(&wn->btrn); PARA_NOTICE_LOG("%s\n", para_strerror(-ret)); -out: t->error = ret; }