]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
para_write: Return proper error code.
authorAndre Noll <maan@systemlinux.org>
Sun, 20 Feb 2011 18:41:09 +0000 (19:41 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 12 Mar 2011 20:37:50 +0000 (21:37 +0100)
Currently the exit code of para_write is always the value returned
by schedule().  This is zero unless the call to select() fails,
usually does not happen, so errors resulting from the writers do not
cause para_write to exit with a non-zero exit code.

In particular, para_write exits successfully if the underlying
writer(s) nodes could not open their sound device or unregistered
their task due to other errors.

Fix this by investigating each writer node's t->error value after
schedule() has returned. If this value does not correspond to an end
of file condition, the strerror text of this error code is written
to stderr, and para_write exits non-zero.

alsa_write.c
error.h
oss_write.c
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));
        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 */
                if (!pad)
                        goto err;
                /* wait until pending frames are played */
diff --git a/error.h b/error.h
index e35952bd390aeb8ff5fab8c8b17c2ccbfe95f354..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(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 \
 
 
 #define COMPRESS_FILTER_ERRORS \
@@ -412,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(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"), \
 
 
 #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 \
 
 
 #define AACDEC_FILTER_ERRORS \
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 */
        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;
                goto out;
        }
        ret = 0;
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);
        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;
 out:
        for (i--; i >= 0; i--) {
                struct writer_node *wn = wns + i;