Thanks for your reply. I may not have expressed myself clearly. I appear to have the opposite problem from Daniel Sanz re Non-blocking snd_pcm_drain (also posted 10 Nov). He wants the new sound to start immediately. I want to close the pcm AFTER the sound finished.
The docs say calling drain() puts the pcm in the DRAINING state. When I obtain the state immediately after drain() it is already SETUP. I hoped a state change from DRAINING to SETUP would be the right time to close the pcm but there appears to be no such state change.
Currently I solved my problem by a usleep() based on an estimate of the time needed to finish playing the last samples in the buffer.
If there is a more elegant way I would like to know. Otherwise I will stick with usleep(),
Regards, Enno