]> git.alsa-project.org Git - alsa-utils.git/commitdiff
axfer: add an option to finish transmission at XRUN
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Tue, 13 Nov 2018 06:41:33 +0000 (15:41 +0900)
committerTakashi Iwai <tiwai@suse.de>
Tue, 13 Nov 2018 11:04:36 +0000 (12:04 +0100)
In aplay, '--fatal-errors' option has an effect to give up recovery of PCM
substream from XRUN state. This commit adds support for this option.

In original implementation, this option brings program abort. This seems
to generate core dump of process VMA. However, typically, XRUN comes from
timing mismatch between hardware and application, therefore core dump has
less helpful. This commit finishes this program in usual way with this
option at XRUN.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
axfer/xfer-libasound.c
axfer/xfer-libasound.h

index 60e9aaba027821fb708d4635eedf2289bea97286..77c142e2c7729e66b239e31cbc14a7525ae2059b 100644 (file)
@@ -9,9 +9,16 @@
 #include "xfer-libasound.h"
 #include "misc.h"
 
+enum no_short_opts {
+        // 200 or later belong to non us-ascii character set.
+       OPT_FATAL_ERRORS = 200,
+};
+
 #define S_OPTS "D:"
 static const struct option l_opts[] = {
        {"device",              1, 0, 'D'},
+       // For debugging.
+       {"fatal-errors",        0, 0, OPT_FATAL_ERRORS},
 };
 
 static int xfer_libasound_init(struct xfer_context *xfer,
@@ -39,6 +46,8 @@ static int xfer_libasound_parse_opt(struct xfer_context *xfer, int key,
 
        if (key == 'D')
                state->node_literal = arg_duplicate_string(optarg, &err);
+       else if (key == OPT_FATAL_ERRORS)
+               state->finish_at_xrun = true;
        else
                err = -ENXIO;
 
@@ -305,7 +314,7 @@ static int xfer_libasound_process_frames(struct xfer_context *xfer,
        if (err < 0) {
                if (err == -EAGAIN)
                        return err;
-               if (err == -EPIPE) {
+               if (err == -EPIPE && !state->finish_at_xrun) {
                        // Recover the stream and continue processing
                        // immediately. In this program -EPIPE comes from
                        // libasound implementation instead of file I/O.
index 3f3ae6e45e75c8d26d89e057328d2631a5c1ceb6..270288d838a6b886ba29af82be361b2de55f44fb 100644 (file)
@@ -29,6 +29,8 @@ struct libasound_state {
        bool verbose;
 
        char *node_literal;
+
+       bool finish_at_xrun:1;
 };
 
 // For internal use in 'libasound' module.