From: sylvain.bertrand@gmail.com
To: alsa-devel@alsa-project.org
Subject: [PATCH RFC] clumsy attempt at fixing rate plugin draining function
Date: Sun, 12 Apr 2020 21:05:06 +0000 [thread overview]
Message-ID: <20200412210506.GA32445@freedom> (raw)
Hi,
This is related to github issue #41.
I don't know how to update last_commit_ptr properly.
Neither if it is consistent with the rate state (boundary, app_ptr, etc).
--
Sylvain
--- a/src/pcm/pcm_rate.c
+++ b/src/pcm/pcm_rate.c
@@ -1051,6 +1051,7 @@ static int snd_pcm_rate_drain(snd_pcm_t *pcm)
/* commit the remaining fraction (if any) */
snd_pcm_uframes_t size, ofs, saved_avail_min;
snd_pcm_sw_params_t sw_params;
+ int commit_err;
__snd_pcm_lock(pcm);
/* temporarily set avail_min to one */
@@ -1064,7 +1065,7 @@ static int snd_pcm_rate_drain(snd_pcm_t *pcm)
while (size > 0) {
snd_pcm_uframes_t psize, spsize;
int err;
-
+
err = __snd_pcm_wait_in_lock(rate->gen.slave, -1);
if (err < 0)
break;
@@ -1077,14 +1078,29 @@ static int snd_pcm_rate_drain(snd_pcm_t *pcm)
if (! spsize)
break;
}
- snd_pcm_rate_commit_area(pcm, rate, ofs,
+ commit_err = snd_pcm_rate_commit_area(pcm, rate, ofs,
psize, spsize);
+ if (commit_err == 1) {
+ rate->last_commit_ptr += psize;
+ if (rate->last_commit_ptr >= pcm->boundary)
+ rate->last_commit_ptr = 0;
+ } else if (commit_err == 0) {
+ if (pcm->mode & SND_PCM_NONBLOCK != 0) {
+ commit_err = -EAGAIN;
+ break;
+ }
+ continue;
+ } else
+ break;
+
ofs = (ofs + psize) % pcm->buffer_size;
size -= psize;
}
sw_params.avail_min = saved_avail_min;
snd_pcm_sw_params(rate->gen.slave, &sw_params);
__snd_pcm_unlock(pcm);
+ if (commit_err < 0)
+ return commit_err;
}
return snd_pcm_drain(rate->gen.slave);
}
reply other threads:[~2020-04-12 21:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200412210506.GA32445@freedom \
--to=sylvain.bertrand@gmail.com \
--cc=alsa-devel@alsa-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox