When setting attribute foo, or in this case the card profile, in my
opinion the thing passed to the set_foo() function should be of the
type of foo, not a string identifier that can be used to search for
the actual foo in set_foo().
This is mostly a question of taste, but there's at least some small
benefit from passing the actual object: often the profile object is
already available when calling pa_card_set_profile(), so passing the
card name would cause unnecessary searching when pa_card_set_profile()
needs to look up the profile from the hashmap.
It's bad form to assume in free() that any member of the struct has
been initialized. I ran into problems with this when I reordered
things in pa_sink_input_new() and pa_source_output_new().
Protocol version 29 will correspond to PA 5.0, and the node stuff has
been postponed until 6.0, so the node interface needs to bump the
protocol version to 30.
If we agree that all strings sent over the native protocol must be
valid UTF-8, then it can be checked in pa_tagstruct_gets(), so
callers don't have to the checking themselves. There were not many
callers that were checking the UTF-8 validity, but there probably
should have been many more.
This will be used for dealing with node directions. Someone might ask
what's the point of adding functions for serializing just one byte;
the point is the validation in pa_tagstruct_get_direction(). It's nice
to be able to assume that the function will return a valid direction,
instead of an arbitrary 8-bit value.
Now the only exit from the function is either via "goto fail" or
normal success. I changed pa_hook_fire() return value checking into
assertions, because it's simpler (and I verified that none of the
hooks can ever fail in the current code base). I also changed all
pa_return_null_if_fail() calls into assertions.
Further simplification could be achieved if adding the sinks and
sources to the idxsets in pa_core were moved to _put() and if
unregistering the sink and source names was moved to _free(). Then
_new() wouldn't have to call _unlink() and _unlink() would have fewer
things to worry about.
The pa_sink/pa_source field initialization order was changed somewhat,
because _unlink() and _unref() rely on certain fields to be
initialized, so they had to be initialized before the first "goto
fail" line in _new().
This commit adds very basic node objects to the core. This is just
a starting point, the nodes don't do anything useful yet.
A node represents a "routing endpoint" - the purpose is to make
routing easier. There are input nodes and output nodes, which can be
connected together. Generally speaking, sources and sink inputs map to
input nodes and sinks and source outputs map to output nodes. The
nodes form a new logical routing layer, which is an addition, not
replacement, to the current "low level" layer of sinks, sink inputs
and so on.
One goal is to be able to easily route any input to any output. For
example, with the node interface it should be easy to route a source
to a sink, without needing to care about the details, such as setting
up module-loopback. Routing sink inputs to source outputs should be
possible too, perhaps causing a null sink to be created between the
streams.
Another goal is to support new kinds of routing endpoints
that are not well suited to be implemented as sinks, sources or
streams. One example would be audio paths that exist in hardware only
(like cellular audio in many phone designs) that still have some
routing options. Another example would be a "gateway node" that makes
streams go to a remote PulseAudio as separate streams. The gateway
node implementation could dynamically create private tunnel sinks for
each stream.
In this first version the nodes have very few attributes, but the
intention is to add as much attributes as necessary for routing policy
modules to make good automatic routing decisions.
This patch is based on work by Janos Kovacs.
Add new PlaybackRate/CaptureRate values for UCM that can be used to
specify custom rates for devices. This value can either be set on the
verb, which makes it apply to all devices, or on the device to override
the verb setting.
This allows mappings to override some or all of the sample_spec used to
open the ALSA device. The intention, to start with, is to use this for
devices in UCM that need to be opened at a specific rate (like modem
devices). This can be extended to allow overrides in profile-sets as
well.
Since the hashmap stores a pointer to the key provided at pa_hashmap_put()
time, it make sense to allow the hashmap to be given ownership of the key and
have it free it at pa_hashmap_remove/free time.
To do this cleanly, we now provide the key and value free functions at hashmap
creation time with a pa_hashmap_new_full. With this, we do away with the free
function that was provided at remove/free time for freeing the value.
Make the PulseAudio tunnel behave the same way as a client
when it comes to figuring out how to connect to the current
PulseAudio daemon. This can be useful if you start a second
PulseAudio instance for e.g. network access.
Sometimes it would be nice to disable module-suspend-on-idle for
specific devices. For me the use case is to keep a HDMI sink running
all the time to avoid loss of audio when starting to play a stream to
the device (the HDMI receiver eats a bit from the beginning of the
stream when the device is opened). This is arguably a hacky solution
to the problem, but on the other hand, I think it's very sensible to
interpret negative timeout in the module-suspend-on-idle.timeout
property as disabling the suspending altogher. This is also how the
exit-idle-time configuration option behaves (negative value disables
automatic exiting).
I moved the property parsing from the timer restart function to the
function that creates the device_info objects, because if the timeout
is negative, we don't need to create the device_info object at all.
The old tunnel module duplicates functionality that is in libpulse,
due to implementing the native protocol, and the protocol code in
the old tunnel module tends to get broken every now and then, because
people forget to update the tunnel module protocol implementation
when changing the native protocol. module-tunnel-source-new avoids this
problem by using libpulse to communicate with the remote server.
With very low input sample rates the memory pool max block size may
not be big enough, in which case we should return the size of one
frame. Returning zero caused crashing.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=68616
This patch adds the ability to restore profiles if they are added after
card creation.
Adding profiles after card creation mainly happens for bluetooth cards.
Buglink: https://bugs.freedesktop.org/show_bug.cgi?id=65349
There is no function to load the authentication cookie for a context.
You can only set environment variables. This patch adds
pa_context_load_cookie_from_file().
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
If the sink rate is not updated, then the monitor source will appear
to have a different rate than the sink, but in reality there's never
any resampling done when moving data from the sink to the monitor
source, so it's a lie that the monitor source has a different rate.
The result of lying is that clients that capture from the monitor
source will have streams that run too fast or slow.
When a sink changes its sample rate, also the monitor source rate
needs to be changed. In order to determine whether a source supports
rate changing, the code checks if the update_rate() callback is set,
but monitor sources don't have that callback set, so the old code
always failed to change the monitor source rate.
This patch fixes the monitor source rate changing by handling monitor
sources as a special case in pa_source_update_rate(): if the source is
a monitor source, then the update_rate() callback is not required.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=66424
This adds asserts to check if the implementation has an update rate
function defined for the unlikely event that some implementation forgets
to assign a update rate function we can simply bail.
It is expected from the resampling implementations to have such a
function even if the state of the resampler is completely reset.
This patch fixes this assertion:
Assertion 'r->i_ss.rate >= r->o_ss.rate' failed at ../../src/pulsecore/resampler.c:1744, function peaks_init(). Aborting.