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.
Handle the case where the converter in a source needs more output
buffers (-EPIPE). Schedule the follower in that case and try to
run the converter again until we have output or we can't make progress
anymore.
If the converter needs more data, schedule the follower before we
exit the loop with the data. This gives the follower a chance to get
more data asynchronously for the next iteration.
Only try to reuse a buffer when the io area is not already in
the NEED_DATA state or else we might overwrite a previous buffer
reuse and run out of buffers.
We also always need more input.