summaryrefslogtreecommitdiff
path: root/plugins/alsa
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-04-10 14:12:32 +0200
committerGravatar waker <wakeroid@gmail.com>2011-04-10 14:12:32 +0200
commite664392c03acc5351b276a16413288f611567a87 (patch)
treeb09a19673203e1860b527d4debcd5522dfe0ca29 /plugins/alsa
parent1af89ef6e2b766a943b45cb120038cf0dd2be32d (diff)
changed alsa main loop behaviour to reduce number of CPU wakeups
Diffstat (limited to 'plugins/alsa')
-rw-r--r--plugins/alsa/alsa.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/plugins/alsa/alsa.c b/plugins/alsa/alsa.c
index 809cb7ed..7fba18d9 100644
--- a/plugins/alsa/alsa.c
+++ b/plugins/alsa/alsa.c
@@ -626,7 +626,7 @@ 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 (frames_to_deliver >= period_size) {
+ while (frames_to_deliver >= period_size, 1) {
if (alsa_terminate) {
break;
}
@@ -635,7 +635,12 @@ palsa_thread (void *context) {
int bytes_to_write = palsa_callback (buf, period_size * (plugin.fmt.bps>>3) * plugin.fmt.channels);
if (bytes_to_write >= (plugin.fmt.bps>>3) * plugin.fmt.channels) {
- err = snd_pcm_writei (audio, buf, snd_pcm_bytes_to_frames(audio, bytes_to_write));
+ UNLOCK;
+ err = snd_pcm_writei (audio, buf, snd_pcm_bytes_to_frames(audio, bytes_to_write));
+ LOCK;
+ if (alsa_terminate) {
+ break;
+ }
}
else {
UNLOCK;
@@ -672,7 +677,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 * 1000000 / plugin.fmt.samplerate / 2);
}
}