Rework stream connect/disconnect from start/stop
Start the stream in setcaps when the format is known.
When the stream is already started in setcaps, send a format_change
message instead.
Make sure we unref the source-input when it is removed.
When the source-input is removed, we should also unref the source. Do
this by adding the source as data for the source-input and unreffing it
when the source-input is freed.
Add GAsyncReadyCallback to the introspection API. This makes it possible
to report errors in the future. Don't pass NULL in the callback anymore
now that we have the Ready callback. We also don't need to have a return
value from the callback because now we can cancel any iteration by using
the GCancelable.
Make pinos_context_info_finish() to get the final result/error of
introspection.
Update tools for new API
Check if we got tmpfile memory and if we do, don't bother waiting for
the release-fd message but unref the memory directly. We know the memory
is allocated from our allocator and that we won't reuse it.
Track the fd indices we sent to Pinos and free the associated buffer
when Pinos sends us release-fd. Only do this for non tempfile fds, as we
made the tmpfile ones ourselves and we're not going to reuse them.
Handle application/x-pinos specially; track all the fd indices in the
buffers and send a release-fd message when the buffer is freed.
We can then use the payloader also in the client-source to handle the
release-fd messages correctly.
The caps we stream between the src and sink are always
application/x-pinos. Keep the negotiated format ouside of the
capsfilter in a separate variable. We can then also avoid a query
to get the format.
If we are using the original buffer fd without copying it into a temp
file we need to make sure the memory stays alive and is not reused until
all clients are done with it.
To do this, track what fd ids are in the outgoing buffers and ref the
original buffer. We also need to know when a message is sent to a client
and when that client does a release-fd on the fd index. This is done
with some new events on the multisocketsink.
Every time a message is sent to a client we hash the fd index in it and
ref the buffer in a per-client hash table (on the socket). Every time we
receive release-fd we remove the fd index from the hash and unref the
buffer again.
Clients that are killed get their socket removed, which also cleans up
the hashtable and frees the memory again.