Wait until we have linked the stream to a device or stream before
we emit the READY state. This is what pulseaudio expects.
Remove stream_index from disconnecting stream so that we don't
accidentally use it again. It is possible that we already created a
new stream with the same id before the old stream could complete the
disconnect.
When a port is plugged/unplugged, first update all the profile states
and then emit a profile change only for the current profile. This way
the device can look at all the updated profiles to select the best one.
This ensures we first finish all pending operations and then get
notifications of the new events. Brings pactl subscribe in line
with what it does on real PulseAudio.
First sync the globals and if no global created new pending operations,
run through the operations. This ensures no operation is run before
all globals have data.
When a stream does not specify ADJUST_LATENCY, use some slightly
different metrics to implement the readable_size. We want the app
to fill as much space as possible. Makes mplayer work and paplay
use the right amount of buffering.
Some drivers seem to only use 2 buffers when asked for 16 buffers. We
can see this because the buffer is already queued. In this case, just
use the 2 buffers.
See #294
When we have accurate enough hardware volume, set the software volume to
1.0. Also fixes the issue of going to 0 volume and then staying silent
until we raise the volume above 1.0.
The flag means that the process function might not complete
synchronously.
We can use this knowledge to improve the adapter. In sync mode we
can pull before scheduling the converter. In async mode we need to
schedule the follower after the converter to get the data ready for
the next iteration.
We can also improve the stream when it is operating async to schedule
a process call when a new buffer is ready to be filled.
This reduces a cycle latency from alsa and improves latency in
pulse.