Commit graph

1646 commits

Author SHA1 Message Date
Tanu Kaskinen
37429cb07e Pass the profile object instead of the profile name to pa_card_set_profile()
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.
2013-12-05 16:00:58 +02:00
Tanu Kaskinen
c2c8475f0d source-output: Log the format negotiation result
This makes the source output code match the sink input code.
2013-11-22 19:25:26 +02:00
Tanu Kaskinen
c88a703441 sink-input, source-output: Don't assume that proplist has been initialized in free()
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().
2013-11-14 15:27:22 +02:00
Tanu Kaskinen
e3485290eb Update the protocol version of the node interface
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.
2013-10-29 20:35:03 +02:00
Tanu Kaskinen
fd8578a557 native: Add node querying to the protocol 2013-09-17 16:22:35 +03:00
Tanu Kaskinen
7aec90fb41 tagstruct: Accept only valid UTF-8 strings
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.
2013-09-17 16:22:35 +03:00
Tanu Kaskinen
9e598bfec5 tagstruct: Add pa_tagstruct_put/get_direction()
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.
2013-09-17 16:22:35 +03:00
Tanu Kaskinen
dd2b54282a native: Add node support to streams 2013-09-17 16:22:35 +03:00
Tanu Kaskinen
b1b4be48bd sink-input, source-output: Add support for nodes 2013-09-17 16:22:35 +03:00
Tanu Kaskinen
c5e1d505cb sink-input, source-output: Add pa_sink_input/source_output_get_description() 2013-09-17 16:21:40 +03:00
Tanu Kaskinen
a9e38da109 device-port: Add support for nodes 2013-09-17 16:21:40 +03:00
Tanu Kaskinen
66f5a68732 sink, source: Add support for nodes 2013-09-17 16:21:40 +03:00
Tanu Kaskinen
b7bf725f50 sink, source: Simplify pa_sink/source_new() error handling
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().
2013-09-17 16:20:18 +03:00
Tanu Kaskinen
85d0b0bd51 sink, source: Add pa_sink/source_get_description() 2013-09-17 16:16:36 +03:00
Tanu Kaskinen
8d00e420f7 sink, source: Disallow NULL or empty description 2013-09-17 16:16:36 +03:00
Tanu Kaskinen
3f2eb1e09f node: Introduce pa_node
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.
2013-09-17 16:16:36 +03:00
Arun Raghavan
6825df8cec hashmap: Add the ability to free keys
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.
2013-09-17 18:01:22 +05:30
Pierre Ossman
23c39bb540 module-tunnel: automatically find the PulseAudio server
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.
2013-09-13 16:44:15 +03:00
Tanu Kaskinen
d448ef04e9 resampler: Never return zero for max block size
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
2013-09-08 11:10:10 +03:00
Tanu Kaskinen
441a5a422c sink, source: Fix error reporting style for rate updates 2013-08-27 15:34:33 +03:00
Tanu Kaskinen
a32c5e4354 source: When updating a monitor source's rate, update the sink rate too
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.
2013-08-27 15:34:33 +03:00
Tanu Kaskinen
2c14306507 source: Fix monitor source rate changing
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
2013-08-27 15:34:33 +03:00
poljar (Damir Jelić)
9a590dd3f2 resampler: Add a choose_auto_resampler function
This function returns our preferred resampler if the user choose the
auto (or if he has chosen an unsupported) resampler.
2013-08-27 12:33:10 +02:00
poljar (Damir Jelić)
8ab6c37e10 resampler: Get rid of redundant implementation specific structs
This patch removes implementation specific structs that contain a single
member.
2013-08-27 12:33:10 +02:00
poljar (Damir Jelić)
0d525e9c85 resampler: Add assert to set_input/output_rate
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.
2013-08-27 12:33:10 +02:00
poljar (Damir Jelić)
4bdfebee5c resampler: Introduce a implementation specific struct
This struct holds all the implementation specific data in one place.
2013-08-27 12:33:10 +02:00
poljar (Damir Jelić)
c5cd65d81e Resampler: Don't use the peaks resampler for upsampling
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.
2013-08-27 12:33:10 +02:00
poljar (Damir Jelić)
2bed8cda25 resampler: Add a function for comparing sample format precision 2013-08-27 12:33:10 +02:00
poljar (Damir Jelić)
7665f60cc0 resampler: choose_work_format use switch instead of if/else
This way the function for choosing the work format should
be more readable and easier to expand in the future.
2013-08-27 12:33:09 +02:00
poljar (Damir Jelić)
78c18e71e0 resampler: Move the work format finding logic into a separate function 2013-08-27 12:33:09 +02:00
poljar (Damir Jelić)
83cf44831f resampler: fix_method use switch instead of if/else
This way the fix method function should be more readable and easier to
expand in the future.
2013-08-27 12:33:09 +02:00
poljar (Damir Jelić)
2d9aba0946 resampler: Move the fix method logic into a separate function 2013-08-27 12:33:09 +02:00
poljar (Damir Jelić)
97feeab40c resampler: Make resampler struct implementation agnostic
The pa_resampler struct contains many implementation specific
structures. These create overhead and don't belong there anyways.

This patch moves the implementation specific structures out of the
pa_resampler structure.
2013-08-27 12:33:09 +02:00
Tanu Kaskinen
1cd6a3ad70 sink, source: Return early from pa_*_update_rate(), if there's no need to do anything 2013-08-27 12:02:32 +03:00
Tanu Kaskinen
963da3de93 sink, source: Small readability improvement 2013-08-23 13:26:43 +03:00
Tanu Kaskinen
eeea84d196 sink, source: Fix default and alternate rate assertions 2013-08-23 13:26:43 +03:00
Tanu Kaskinen
22058713af sink, source: Don't care about default and alternate rate in passthrough mode
In passthrough mode the device rate is set to match the stream rate,
and the default and alternate rates are ignored.
2013-08-23 13:26:43 +03:00
Tanu Kaskinen
9aaf053dad sink, source: Reduce indentation level in *_update_rate() 2013-08-22 16:53:07 +03:00
Tanu Kaskinen
8cca3b3c10 source-output: Get the correct source for "direct_on_input" streams
If a capture stream captures from a single sink input (so the capture
stream is a so called "direct on input" stream), then it needs to
connect to the monitor source of the sink to which the sink input is
connected. Previously the correct source was not figured out
automatically, causing the capture stream creation to fail.
2013-08-21 16:59:01 +03:00
Arun Raghavan
f8f0d4c26b sink-input: Don't assert when removing non-existent volume factor
This makes it easier for users of this API to add/updated a volume
factor by doing a _remove_volume_factor() followed by an
add_volume_factor(), rather than having to either remember whether this
is the first set operation or have an API to query whether a factor has
already been set.
2013-08-08 11:58:22 +05:30
Alexander Couzens
9fa3466366 thread-mq: Support a mainloop as thread/consumer
This is needed by the tunnel module rewrite, which runs pa_mainloop in
the IO thread instead of pa_rtpoll.

Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
2013-08-06 18:26:26 +03:00
Peter Meerwald
834d10fe65 cli: Use pa_xnew0 to save some 0 inits
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-08-02 16:25:42 +02:00
Peter Meerwald
e729783331 cli: Output prompt and welcome message only when requested by 'hello'
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-08-02 16:24:41 +02:00
Kerrick Staley
328ef1d35a Fix typos in command_names 2013-07-31 14:25:17 +02:00
Tanu Kaskinen
1470fc325a resampler: Fix peaks resampler's channel handling
In the resampling phase the input and output data have the same number
of channels (o_ss.channels).
2013-07-29 10:49:19 +03:00
Tanu Kaskinen
afb2c8f9e3 sink: Add missing curly braces
The missing braces didn't cause any practical problems, but obviously
the intention was to reset the chunk only if the memblock was
non-NULL.
2013-07-16 14:01:06 +03:00
Luiz Augusto von Dentz
b98a2e158f introspect: Expose card profile available flag
Available flag can be used by clients to disable the selection of
profiles unavailable.

Update protocol to 29
2013-07-15 19:41:07 +03:00
Tanu Kaskinen
b5e1c06a5e log: Harmonize log target output
The file targets used different output format than stderr and syslog.
That's now fixed.
2013-07-15 16:47:29 +03:00
Tanu Kaskinen
a1fdbcfaa7 log: Use pa_write() instead of write() 2013-07-15 16:46:06 +03:00
Tanu Kaskinen
bc2ed3482a log: Remove pa_log_set_fd()
The function isn't used any more.
2013-07-15 16:34:19 +03:00