Keep track of the created services in two lists: published, pending.
Move services between the lists as the avahi client's state changes:
keep services in the pending list until the avahi daemon appears on dbus,
move them to the pending list if connection is lost,
and re-publish them after reconnection.
When a module's `load()` fails, its `unload()` will unconditionally
be called. Freeing resource in `load()` while not marking those
resources freed (e.g. setting the pointers to NULL) will result
in double-free when the module's `unload()` method is called.
Whether the object is a sink or source is already queried at the
beginning of the function, and is kept in local variables.
Use those instead of calling `pw_manager_object_is_{sink,source}()` again.
Do not use the client's connection to create the adapter object,
instead, create a new connection. This avoids the need for setting
object.linger=true, which guarantees that when the pulse server goes
down, the null sink is cleaned up.
While it is not a problem since `module_free()` calls
`pw_work_queue_cancel()`, it is completely unnecessary
to do it more than once.
Introduce a new flag on the module which stores whether or
not an unloading has been scheduled.
Since `module_list` is a fixed-sized array, `SPA_FOR_EACH_ELEMENT()`
can be used. So use that. This way there is no need for explicit
indexing nor a sentinel at the end.
The module-roc-{sink,source} modules simply load the corresponding
native pipewire modules, they have no dependency on ROC.
So always compile them. This way these modules are
compile tested, and if the corresponding pipewire
modules are added to the system later, they will work
with no changes to the protocol-pulse module.
Use `meson.project_{build,source}_root()` instead of
`meson.{build,source}_root()` because those functions
do not work as expected when used inside a subproject,
and they have been deprecated in meson 0.56.0.
Previously, when a sample is "committed" from an upload stream,
its reference count is set to 1. This is problematic if,
when the sample is committed for a second time, there are
streams playing the sample as the reference count will go out
of sync.
The problem can be easily triggered, especially with longer samples:
pactl upload-sample a-long-sample.ogg
pactl play-sample a-long-sample
pactl play-sample a-long-sample
pactl upload-sample a-long-sample.ogg # while playing
When the first stream finishes playing, it will free the sample,
which can cause problems e.g. for the second stream playing the
sample at that very moment.
Fix that by decoupling the buffer from the sample and making
the buffer reference counted. And remove the reference counting
from the samples as it is no longer needed.
Futhermore, previously, the reference counts were ignored
when the removal of a sample was requested. That is fixed
as well.
The previous issue can be triggered easily as well:
pactl upload-sample a-long-sample.ogg
pactl play-sample a-long-sample
pactl remove-sample a-long-sample # while playing
Fixes#1953
Create a new event for modules ('destroy') which is emitted from
`module_free()`. It is used by the module loading logic, to handle
when a module is destroyed without properly loading first.
Store the modules whose load has been initiated by a particular
client in the `pending_modules` list of the client. When the
client disconnects, "detach" the client from the pending module
objects. This way the reference count need not be increased
for asynchronous module loads.
Furthermore, if the module can load synchronously, do not create
the pending module object at all.
Only call `spa_list_remove()` in `stream_free()` if the
stream is pending. `spa_list_remove()` does not reinitialize
the list node, therefore calling `spa_list_remove()` again
after the stream has been removed from the pending list
will corrupt the pending list of the client.
When we can't fill a complete block, report the amount of data that we
used in missing/played instead of the complete missing part.
Fixes audio breaking up when looping in mpv.
Fixes#1132
After we get a reposition request, bring the state to the SYNC state
again so that clients can align with the new position.
Fixes a problem with reposition when using the jack transport.
Fixes#1907
Always reevaluate the tlength or total buffered samples when the
quantum changes, even for the first sample because it is possible that
we completely miscalculated the length when we started, like when the
quantum is force high and the requested latency is low.
Also only increase the calculated tlength, for smaller sizes we don't
need to do anything, we can keep the latency as is it.
See #1930
When we are draining or underrunning, read whatever we have in the
ringbuffer instead of silence. This places the last samples before
the drain into the sink, padded with 0.
Fixes#1549
This reverts commit c14e89a578.
This makes it impossible for flatpak apps to remove links. Maybe:
- Flatpaks apps are not allowed to make lingering links
- Flatpak apps can only delete their own links.
- Some flatpaks apps needs to be tagged as manager in order to created
lingering links and destroy any link.
Fixes#1920
When we have a fix_* flag set, make an extra format description with the
wildcards. This makes it possible for the session manager to fall back
to something when selecting a target and format.
Also only advertize the valid pulseaudio formats for the wildcards.
Fixes#1912
Only update the quantum/rate when we have a pending change.
This works around a bug in sco-source that changes the quantum
by itself but in any case, this optimization is nice to have.
See #1905
When moving a driver to another, move the quantum and rate to the
current_ fields so that they are applied when the next cycle starts
instead of during the cycle.