SHA256
1
0
forked from pool/alsa-utils
alsa-utils/0013-aplay-add-test-code-for-snd_pcm_status-to-test-posit.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

109 lines
3.6 KiB
Diff

From 76bc37aeb77d51f995e223582d25335cd98b2eea Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Sun, 3 Jan 2021 17:19:03 +0100
Subject: [PATCH 13/25] aplay: add test code for snd_pcm_status() to
--test-position
We need to test also snd_pcm_status() values.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
aplay/aplay.c | 48 ++++++++++++++++++++++++++++++++++++++----------
1 file changed, 38 insertions(+), 10 deletions(-)
diff --git a/aplay/aplay.c b/aplay/aplay.c
index d385da25fea1..5a6d5c33102c 100644
--- a/aplay/aplay.c
+++ b/aplay/aplay.c
@@ -1953,22 +1953,38 @@ static void do_test_position(void)
static snd_pcm_sframes_t minavail, mindelay;
static snd_pcm_sframes_t badavail = 0, baddelay = 0;
snd_pcm_sframes_t outofrange;
- snd_pcm_sframes_t avail, delay;
+ snd_pcm_sframes_t avail, delay, savail, sdelay;
+ snd_pcm_status_t *status;
int err;
+ snd_pcm_status_alloca(&status);
err = snd_pcm_avail_delay(handle, &avail, &delay);
if (err < 0)
return;
+ err = snd_pcm_status(handle, status);
+ if (err < 0)
+ return;
+ savail = snd_pcm_status_get_avail(status);
+ sdelay = snd_pcm_status_get_delay(status);
outofrange = (test_coef * (snd_pcm_sframes_t)buffer_frames) / 2;
if (avail > outofrange || avail < -outofrange ||
delay > outofrange || delay < -outofrange) {
- badavail = avail; baddelay = delay;
- availsum = delaysum = samples = 0;
- maxavail = maxdelay = 0;
- minavail = mindelay = buffer_frames * 16;
- fprintf(stderr, _("Suspicious buffer position (%li total): "
- "avail = %li, delay = %li, buffer = %li\n"),
- ++counter, (long)avail, (long)delay, (long)buffer_frames);
+ badavail = avail; baddelay = delay;
+ availsum = delaysum = samples = 0;
+ maxavail = maxdelay = 0;
+ minavail = mindelay = buffer_frames * 16;
+ fprintf(stderr, _("Suspicious buffer position (%li total): "
+ "avail = %li, delay = %li, buffer = %li\n"),
+ ++counter, (long)avail, (long)delay, (long)buffer_frames);
+ } else if (savail > outofrange || savail < -outofrange ||
+ sdelay > outofrange || sdelay < -outofrange) {
+ badavail = savail; baddelay = sdelay;
+ availsum = delaysum = samples = 0;
+ maxavail = maxdelay = 0;
+ minavail = mindelay = buffer_frames * 16;
+ fprintf(stderr, _("Suspicious status buffer position (%li total): "
+ "avail = %li, delay = %li, buffer = %li\n"),
+ ++counter, (long)savail, (long)sdelay, (long)buffer_frames);
} else if (verbose) {
time(&now);
if (tmr == (time_t) -1) {
@@ -1979,19 +1995,27 @@ static void do_test_position(void)
}
if (avail > maxavail)
maxavail = avail;
+ if (savail > maxavail)
+ maxavail = savail;
if (delay > maxdelay)
maxdelay = delay;
+ if (sdelay > maxdelay)
+ maxdelay = sdelay;
if (avail < minavail)
minavail = avail;
+ if (savail < minavail)
+ minavail = savail;
if (delay < mindelay)
mindelay = delay;
+ if (sdelay < mindelay)
+ mindelay = sdelay;
availsum += avail;
delaysum += delay;
samples++;
- if (avail != 0 && now != tmr) {
+ if ((maxavail != 0 || maxdelay != 0) && now != tmr) {
fprintf(stderr, "BUFPOS: avg%li/%li "
"min%li/%li max%li/%li (%li) (%li:%li/%li)\n",
- (long)(availsum / samples),
+ (long)(availsum / samples),
(long)(delaysum / samples),
(long)minavail, (long)mindelay,
(long)maxavail, (long)maxdelay,
@@ -2000,6 +2024,10 @@ static void do_test_position(void)
tmr = now;
}
}
+ if (verbose == 1) {
+ fprintf(stderr, _("Status(R/W) (standalone avail=%li delay=%li):\n"), (long)avail, (long)delay);
+ snd_pcm_status_dump(status, log);
+ }
}
/*
--
2.26.2