summaryrefslogtreecommitdiff
path: root/aplay
diff options
context:
space:
mode:
authorAndreas Pape <apape@de.adit-jv.com>2021-03-19 11:57:13 +0100
committerJaroslav Kysela <perex@perex.cz>2021-03-19 12:53:39 +0100
commitc9e9a79c6cfef3212bdb5f9be4f6ea1d2a5e8670 (patch)
treeff4f6ef7473f78e2bd9545e66afd2351ff0b4938 /aplay
parent00be486131129a6d209de62202d2a4974638127f (diff)
downloadalsa-utils-c9e9a79c6cfef3212bdb5f9be4f6ea1d2a5e8670.tar.gz
aplay: avoid any further PCM writing if in abort
Terminating stream with CTRL-C will set in_aborting flag which is used to leave any write/read loop on the ALSA device. After ending the read/write loop aplay tries to drain the stream which is not required and can also lead to malfunctions: -If user interrupts a blocked/non responsive PCM (e.g. usb uac2 gadget which does not consume data due to stream stopped by host) it will successfully terminate the write loop but will hang again in drain call. This would require to hit CTRL-C again to unblock which should be avoided. Aplay currently anyhow allows signal handler to get invoked only once. Signed-off-by: Andreas Pape <apape@de.adit-jv.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'aplay')
-rw-r--r--aplay/aplay.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/aplay/aplay.c b/aplay/aplay.c
index 9ebaae4..0b7884e 100644
--- a/aplay/aplay.c
+++ b/aplay/aplay.c
@@ -2570,7 +2570,9 @@ static void voc_play(int fd, int ofs, char *name)
}
} /* while(1) */
__end:
- voc_pcm_flush();
+ if (!in_aborting) {
+ voc_pcm_flush();
+ }
free(buf);
}
/* that was a big one, perhaps somebody split it :-) */
@@ -2885,9 +2887,11 @@ static void playback_go(int fd, size_t loaded, off64_t count, int rtype, char *n
written += r;
l = 0;
}
- snd_pcm_nonblock(handle, 0);
- snd_pcm_drain(handle);
- snd_pcm_nonblock(handle, nonblock);
+ if (!in_aborting) {
+ snd_pcm_nonblock(handle, 0);
+ snd_pcm_drain(handle);
+ snd_pcm_nonblock(handle, nonblock);
+ }
}
static int read_header(int *loaded, int header_size)
@@ -3363,9 +3367,11 @@ static void playbackv_go(int* fds, unsigned int channels, size_t loaded, off64_t
r = r * bits_per_frame / 8;
count -= r;
}
- snd_pcm_nonblock(handle, 0);
- snd_pcm_drain(handle);
- snd_pcm_nonblock(handle, nonblock);
+ if (!in_aborting) {
+ snd_pcm_nonblock(handle, 0);
+ snd_pcm_drain(handle);
+ snd_pcm_nonblock(handle, nonblock);
+ }
}
static void capturev_go(int* fds, unsigned int channels, off64_t count, int rtype, char **names)