[alsa-devel] Duplicate wake-ups in pcm_lib.c

pl bossart bossart.nospam at gmail.com
Thu Jan 7 05:59:22 CET 2010

>> A wake-up is generated during the period interrupt, and a second
>> wake-up is generated during the write loop, after the application was
>> awaken but just before the pointers are updated. This second wake-up
>> shouldn't exist, since the write loop actually fills the ring buffer.
>> By the time the second wake-up is actually handled, there's really no
>> space left in the buffer and a null event is generated; it'll wake-up
>> the application a second time for nothing. Maybe we should move the
>> call to snd_pcm_update_hw_ptr() after the transfer took place?
> The right fix should be to preserve wakeups when write operation is in
> progress (also for interrupts). Something like this (untested):

Thanks Jaroslav for your feedback. It seems your fix is similar to
what I suggested, that is check the pointers and generate a wake-up
after the write loop completes rather than right before the write
starts. I modified your patch to correct the behavior when errors
occur; the jumps to _end_wake compared to _end_unlock weren't self
explanatory and not always consistent. I only perform a pointer update
if nothing wrong happened. In case of errors, I unlock or just return
the status as before. I am testing the changes and should have a patch
- Pierre

More information about the Alsa-devel mailing list