aboutsummaryrefslogtreecommitdiffstats
path: root/include/sound
diff options
context:
space:
mode:
authorDavid Dillow <dave@thedillows.org>2010-06-27 00:13:20 +0200
committerJaroslav Kysela <perex@perex.cz>2010-06-28 09:42:09 +0200
commit5daeba34d2aab669aea07abee13d53cd116578fb (patch)
tree4213fce45c60b6c16160fa9c777aa923ef562172 /include/sound
parentALSA: hda-intel - fix wallclk variable update and condition (diff)
downloadlinux-dev-5daeba34d2aab669aea07abee13d53cd116578fb.tar.xz
linux-dev-5daeba34d2aab669aea07abee13d53cd116578fb.zip
ALSA: pcm_lib: avoid timing jitter in snd_pcm_read/write()
When using poll() to wait for the next period -- or avail_min samples -- one gets a consistent delay for each system call that is usually just a little short of the selected period time. However, When using snd_pcm_read/write(), one gets a jittery delay that alternates between less than a millisecond and approximately two period times. This is caused by snd_pcm_lib_{read,write}1() transferring any available samples to the user's buffer and adjusting the application pointer prior to sleeping to the end of the current period. When the next period interrupt occurs, there is then less than avail_min samples remaining to be transferred in the period, so we end up sleeping until a second period occurs. This is solved by using runtime->twake as the number of samples needed for a wakeup in addition to selecting the proper wait queue to wake in snd_pcm_update_state(). This requires twake to be non-zero when used by snd_pcm_lib_{read,write}1() even if avail_min is zero. Signed-off-by: Dave Dillow <dave@thedillows.org> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'include/sound')
-rw-r--r--include/sound/pcm.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index dd76cdede64d..83c6fa6aac43 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -313,7 +313,7 @@ struct snd_pcm_runtime {
struct snd_pcm_mmap_control *control;
/* -- locking / scheduling -- */
- unsigned int twake: 1; /* do transfer (!poll) wakeup */
+ snd_pcm_uframes_t twake; /* do transfer (!poll) wakeup if non-zero */
wait_queue_head_t sleep; /* poll sleep */
wait_queue_head_t tsleep; /* transfer sleep */
struct fasync_struct *fasync;