diff options
author | Jaroslav Kysela <perex@perex.cz> | 2018-10-24 15:20:22 +0200 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2018-10-24 16:01:06 +0200 |
commit | 8bc1bc53d0a8b3797337bddd30cd345ba1049817 (patch) | |
tree | 3a7eff72b9e6a9735ea9e0c3562ff4048e7edba4 /alsaloop | |
parent | 805d30b260d0f7f7c4453ef09e11f2c3f1b548d5 (diff) | |
download | alsa-utils-8bc1bc53d0a8b3797337bddd30cd345ba1049817.tar.gz |
alsaloop: more avail_min cleanups
1) do not increase avail_min forever
It seems that there are broken plugins like pulse which returns from poll()
immediately regardless avail_min settings.
2) remove ommited debug printf()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'alsaloop')
-rw-r--r-- | alsaloop/pcmjob.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/alsaloop/pcmjob.c b/alsaloop/pcmjob.c index 9cf3a5b..4c9517b 100644 --- a/alsaloop/pcmjob.c +++ b/alsaloop/pcmjob.c @@ -286,8 +286,16 @@ static int increase_playback_avail_min(struct loopback_handle *lhandle) { snd_pcm_t *handle = lhandle->handle; snd_pcm_sw_params_t *swparams; + struct timespec ts; int err; + if (lhandle->avail_min + (lhandle->period_size / 2) > lhandle->buffer_size) { + /* avoid 100% CPU usage for broken plugins */ + ts.tv_sec = 0; + ts.tv_nsec = 10000; + err = nanosleep(&ts, NULL); + return 0; + } snd_pcm_sw_params_alloca(&swparams); err = snd_pcm_sw_params_current(handle, swparams); if (err < 0) { @@ -302,7 +310,6 @@ static int increase_playback_avail_min(struct loopback_handle *lhandle) snd_pcm_sw_params_get_avail_min(swparams, &lhandle->avail_min); if (verbose > 6) snd_output_printf(lhandle->loopback->output, "%s: change avail_min=%li\n", lhandle->id, lhandle->avail_min); - printf("%s: change avail_min=%li\n", lhandle->id, lhandle->avail_min); err = snd_pcm_sw_params(handle, swparams); if (err < 0) { logit(LOG_CRIT, "Unable to set sw params for %s: %s\n", lhandle->id, snd_strerror(err)); |