I have firewire mixing console and I wrote an udev rule which calls a script to set up the whole audio chain (alsa -> pulseaudio -> jackd -> firewire) as soon an the console is switched on.
Now I noticed that, while
jackd gets started, it dies a few seconds later. I captured its output an it contained an error message. For testing I faked the udev event via
udevadm trigger and everything worked fine.
This made me believe, that it just takes some time between the the moment the (real) udev event fires and when the device is actually ready. My faked udev event did not suffer from this problem, because the console was switched on and /dev/fw1 was present and ready all the time.
Indeed, adding a
sleep 2 to my script solved the problem, but I am not happy with this solution. It looks fragile, because under heavy load I might need three or four seconds. And beeing too generous with
sleep my pile up a lot of unnecessary latencies.
So - is there any way to know when a device is actually ready?