summaryrefslogtreecommitdiff
path: root/plugins/alsa
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-04-24 11:11:22 +0200
committerGravatar waker <wakeroid@gmail.com>2011-04-24 11:11:22 +0200
commit189d22b08b51cf5e05784339fc8a3530f6913794 (patch)
treee835ce48d904891eedf20a3cb5a396888d5e125c /plugins/alsa
parent9a95191e0923d8fbaf35c4a5ba243e314a69c647 (diff)
alsa: fix random stuttering
this will restore excessive CPU wakeups -- need another fix for that
Diffstat (limited to 'plugins/alsa')
-rw-r--r--plugins/alsa/alsa.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/plugins/alsa/alsa.c b/plugins/alsa/alsa.c
index e720a4cb..31c5c3e0 100644
--- a/plugins/alsa/alsa.c
+++ b/plugins/alsa/alsa.c
@@ -628,7 +628,11 @@ palsa_thread (void *context) {
LOCK;
/* find out how much space is available for playback data */
snd_pcm_sframes_t frames_to_deliver = snd_pcm_avail_update (audio);
- while (state == OUTPUT_STATE_PLAYING/*frames_to_deliver >= period_size, 1*/) {
+
+ // FIXME: pushing data without waiting for next buffer will drain entire
+ // streamer buffer, and might lead to stuttering
+ // however, waiting for buffer does a lot of cpu wakeups
+ while (/*state == OUTPUT_STATE_PLAYING*/frames_to_deliver >= period_size) {
if (alsa_terminate) {
break;
}
@@ -679,7 +683,7 @@ palsa_thread (void *context) {
frames_to_deliver = snd_pcm_avail_update (audio);
}
UNLOCK;
- //usleep (period_size * 1000000 / plugin.fmt.samplerate / 2);
+ usleep ((period_size-frames_to_deliver) * 1000000 / plugin.fmt.samplerate / plugin.fmt.channels);
}
}