SHA256
1
0
forked from pool/alsa-utils
alsa-utils/0007-aplay-fix-the-CPU-busy-loop-in-the-pause-handler.patch
Takashi Iwai f936d7ca95 Accepting request 865332 from home:tiwai:branches:multimedia:libs
- Backport upstream fixes:
  various fixes in aplay, alsamixer, alsactl and alsaloop, updated
  translations, etc:
  0001-aplay-try-to-use-16-bit-format-to-increase-capture-q.patch
  0002-alsamixer-Fix-the-mixer-views-description-in-man-pag.patch
  0003-Add-Slovak-translation.patch
  0004-Add-Basque-translation.patch
  0006-aplay-cosmetic-code-fix-in-xrun.patch
  0007-aplay-fix-the-CPU-busy-loop-in-the-pause-handler.patch
  0008-alsa-info-Add-lsusb-and-stream-outputs.patch
  0013-aplay-add-test-code-for-snd_pcm_status-to-test-posit.patch
  0014-ucm-fix-typo-in-docs.patch
  0015-aplay-add-avail-delay-checks-to-test-position.patch
  0016-alsactl-daemon-read_pid_file-fix-the-returned-code-o.patch
  0017-alsactl-init-set_ctl_value-fix-bytes-parsing.patch
  0018-alsactl-init-parse-fix-possible-double-free.patch
  0019-alsaloop-fix-possible-memory-leak-in-create_loopback.patch
  0020-alsaloop-get_queued_playback_samples-simplify-code.patch
  0021-topology-fix-possible-double-free-in-load.patch
  0022-alsamixer-remove-dead-fcn-widget_handle_key-in-widge.patch
  0023-alsamixer-remove-unused-variable-y-in-display_scroll.patch
  0024-alsamixer-fix-shift-in-parse_words.patch
  0025-aplay-fix-the-test-position-test-for-playback-avail-.patch

OBS-URL: https://build.opensuse.org/request/show/865332
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa-utils?expand=0&rev=188
2021-01-21 10:13:28 +00:00

60 lines
1.6 KiB
Diff

From c1b92db5ef01311e5fc983f3134caa00826d0c2d Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Sun, 8 Nov 2020 19:11:12 +0100
Subject: [PATCH 07/25] aplay: fix the CPU busy loop in the pause handler
Use the standard poll mechanism to ensure that there's
something in the input to avoid busy loop on the file
descriptor with the non-block mode set.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
aplay/aplay.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/aplay/aplay.c b/aplay/aplay.c
index ae609880bfd7..d385da25fea1 100644
--- a/aplay/aplay.c
+++ b/aplay/aplay.c
@@ -1553,6 +1553,19 @@ static void done_stdin(void)
tcsetattr(fileno(stdin), TCSANOW, &term);
}
+static char wait_for_input(void)
+{
+ struct pollfd pfd;
+ unsigned char b;
+
+ do {
+ pfd.fd = fileno(stdin);
+ pfd.events = POLLIN;
+ poll(&pfd, 1, -1);
+ } while (read(fileno(stdin), &b, 1) != 1);
+ return b;
+}
+
static void do_pause(void)
{
int err;
@@ -1571,7 +1584,7 @@ static void do_pause(void)
return;
}
while (1) {
- while (read(fileno(stdin), &b, 1) != 1);
+ b = wait_for_input();
if (b == ' ' || b == '\r') {
while (read(fileno(stdin), &b, 1) == 1);
if (snd_pcm_state(handle) == SND_PCM_STATE_SUSPENDED)
@@ -1596,7 +1609,7 @@ static void check_stdin(void)
while (read(fileno(stdin), &b, 1) == 1);
fprintf(stderr, _("\r=== PAUSE === "));
fflush(stderr);
- do_pause();
+ do_pause();
fprintf(stderr, " \r");
fflush(stderr);
}
--
2.26.2