Sjoerd Simons [Mon, 16 May 2011 10:00:37 +0000 (10:00 +0000)]
build-sys: Link libpulse directly to libdbus-1 if needed
Linking libpulse with gold or when using ld --no-add-needed fails
as libpulse uses dbus methods directly but isn't explicitly linked to it.
So link to it when needed :)
Colin Guthrie [Mon, 16 May 2011 08:26:32 +0000 (09:26 +0100)]
protocol-native: Fix memory leaks introduced in protocol 21 (passthrough support)
The proplist used may never be freed if an error condition was found with
CHECK_VALIDITY macro and the formats idxset was never freed regardless
of error state.
This change fixes adds a new maco CHECK_VALIDITY_GOTO() which allows
for cleanup to be done before returning.
In a setup with one or more filter sinks or sources there is always at
least one stream existing. In such a situation normal mempool
vacuuming never happens. This patch causes suspend-on-idle module to
vacuum memory when ever it notices that all sinks and sources are
suspended. The behavior can be enabled with a module parameter.
protocol-native: Stop auto timing updates if connected to suspended sink or source
This quite is an old patch. It was added to N900 to avoid unnecessary
wake-ups when the phone is in power save mode (= blank screen and
no user interaction). In this situation if the user had a browser
window with flash animation open pulseaudio kept waking up every
10 seconds, causing a severe hit to use times.
Anyway I do not see any reason to send timing updates if the sink or
source where the stream is connected to is suspended.
Arun Raghavan [Sun, 15 May 2011 04:24:17 +0000 (09:54 +0530)]
module-tunnel: Update for recent protocol changes
This updates the tunnel module for protocol version >= 19.
module-tunnel-sink does not proxy server-side passthrough support (yet).
This would require a few more changes, namely keeping track of what
formats are available and if any other sink inputs are connected on the
server-side.
This replaces the simple string used by pa_format_info's proplist with a
JSON string (accessed via new API only). This allows us to express lists
and ranges more cleanly, and embed type information for future
extensibility.
We use json-c for JSON parsing. This is a lightweight depdency (32 KB on
my system) and avoids the hassle of having to reinvent a JSON parser.
Also included is a test which verifies functionality and is
valgrind-clean.
sink-input: Provide more information to client when format is lost
When the sink format changes and we kill the stream, clients need a way
to know (a) what device they should reconnect to, and (b) what the
stream running time was when the stream got killed (pa_stream_get_time()
won't work after the stream has been killed). This adds these two bits
of information in the event callback's proplist parameter.
format: Add correct sample spec conversion for E-AC3
IEC61937-encapsulated E-AC3 frames contain 6 audio blocks per substream,
which corresponds to 1536 samples contained a 24576-byte frame. To cope
with this, we maintain the s16le stereo sample spec, but quadruple the
sample rate so that the conversion remains accurate.
Arun Raghavan [Mon, 28 Mar 2011 03:16:40 +0000 (08:46 +0530)]
sink-input: Add a format-lost event
This event is emitted if the sink-input could not be moved to a new sink
because it doesn't support the format of the sink-input. Clients can
reconnect their stream with a different format if they wish or
gracefully exit.
Arun Raghavan [Mon, 28 Mar 2011 03:15:31 +0000 (08:45 +0530)]
sink-input: Don't print an error if a passthrough connection fails
The assertion message is misleading, since the passthrough connection
can fail for reasons the client has no control over (like other sink
inputs being connected).
Arun Raghavan [Tue, 10 May 2011 08:03:28 +0000 (13:33 +0530)]
echo-cancel: Remove unnecessary noalign attribute
This was just introduced for debugging and should not have been in the
final commit. Won't make a difference at the moment since this function
is used as a pointer, but removing this in case we change this in the
future.
PA_ALIGNED can't always guarantee that the alignment we want (the GCC
man page suggests that the linker might not be able to meet the
alignment requirements we desire). Instead, we now allocate some extra
memory and guaratee that the alignment we require is met.
Arun Raghavan [Mon, 2 May 2011 04:41:47 +0000 (10:11 +0530)]
filter-apply: Mark modules as being autoloaded
(Based on Colin's review) We mark modules as being autoloaded so that
they can handle this as a special case if needed (which is required by
module-echo-cancel for now). This inverts how things were done and makes
using these modules manually less error-prone.
Arun Raghavan [Wed, 16 Mar 2011 10:38:23 +0000 (16:08 +0530)]
core: Factor out passthrough checks into their own functions
Since we currently have two mechanisms to signal a passthrough
connection (non-PCM format or PA_SINK_INPUT_PASSTHROUGH flag), we move
all the related checks into functions and use those everywhere.
This makes things more consistent, and should we decide to get rid of
the flag, we only need to change pa_sink_input_*_is_passthrough()
accordingly.
Arun Raghavan [Tue, 8 Mar 2011 08:52:24 +0000 (14:22 +0530)]
alsa: Reconfigure sink sample rate for passthrough inputs
When a passthrough sink-input is added, we need to reconfigure the
sink's sample rate since no resampling occurs. We revert to the original
rate when the passthrough sink-input is removed.
Arun Raghavan [Thu, 3 Mar 2011 13:32:45 +0000 (19:02 +0530)]
core: Suspend monitor when a sink enters passthrough mode
In most cases it is expected that clients cannot consume compressed
data from monitor sources, so we suspend the monitor source when the
sink goes into passthrough mode.
Eventually, when the extended API includes client notifications for
changed formats, we should emit a notification on the monitor so that
clients can decide what they want to do when this happens (disconnect or
consume the data anyway).
Arun Raghavan [Wed, 2 Mar 2011 06:08:01 +0000 (11:38 +0530)]
sink-input: Kill passthrough streams if moving to an unsupported sink
This will eventually be replaced by a hook to let clients know that the
stream has moved so that they can gracefully reconnect and renegotiate a
supported format.
Arun Raghavan [Wed, 2 Mar 2011 06:01:51 +0000 (11:31 +0530)]
format: Avoid some code duplication
We frequently need to free an idxset containing pa_format_infos, so
define an internal free function that can be used directly with this
(instead of defining it once-per-file).
Arun Raghavan [Wed, 2 Mar 2011 05:21:56 +0000 (10:51 +0530)]
tests: Add a trivial test for the extended API
This is just sync-playback.c modified to use the extended API. We need
something more sophisticated for properly testing the compressed
formats, but that is a non-trivial task in itself.
Arun Raghavan [Tue, 1 Mar 2011 20:36:54 +0000 (02:06 +0530)]
sink: Remove PASSTHROUGH flag
This removes the passthrough flag from sinks since we will drop
exclusively passthrough sinks in favour of providing a list of formats
supported by each sink. We can still determine whether a sink is in
passthrough mode by checking if any non-PCM streams are attached to it.
Arun Raghavan [Mon, 28 Feb 2011 07:53:23 +0000 (13:23 +0530)]
core: Add extended stream API to support compressed formats
This is the beginning of work to support compressed formats natively in
PulseAudio. This adds a pa_stream_new_extended() that takes a format
structure, sends it to the server (=> protocol extension) and has the
server negotiate with the appropropriate sink to figure out what format
it should use.
This is work in progress, and works only with PCM streams. Actual
compressed format support in some sink needs to be implemented, and
extensive testing is required.
More details on how this is supposed to work is available at:
http://pulseaudio.org/wiki/PassthroughSupport
Arun Raghavan [Mon, 28 Feb 2011 07:30:20 +0000 (13:00 +0530)]
sink: Extend API for compressed formats support
This adds a get_formats() vfunc for sinks to provide a list of formats
they can support. pa_sink_check_formats() can be used during or after
routing to determine what formats from a stream the sink can support.
Arun Raghavan [Mon, 2 May 2011 04:38:27 +0000 (10:08 +0530)]
filter-apply: Mark modules as being autoloaded
(Based on Colin's review) We mark modules as being autoloaded so that
they can handle this as a special case if needed (which is required by
module-echo-cancel for now). This inverts how things were done and makes
using these modules manually less error-prone.
Luiz Augusto von Dentz [Fri, 29 Apr 2011 14:48:05 +0000 (17:48 +0300)]
bluetooth: Fix not updating sample spec when using Media API
When using transport configured via Media API sample spec needs to be
updated since codec configuration may affect it when e.g. headset
configure a different frequency or number of channels from default.
Arnaud Fontaine [Tue, 29 Mar 2011 20:57:28 +0000 (22:56 +0159)]
x11: More XCB fixes.
Commit 65ef80b fixed building with xcb-util >= 0.3.8, but the reply is never
checked (possible SIGSEGV if the reply is NULL) nor freed (memory leak at each
call of the functions).
Also, remove include and dependencies on xcb-atom, as it was only meaningful
for xcb_atom_get() and STRING, and depend instead on xcb >= 1.6 for
XCB_ATOM_STRING.
dbus: Fix connection idxset freeing when unloading the module.
If u->connections isn't empty when module-dbus-protocol is
unloaded, then connection_free() is called for the
remaining connections when the idxset is freed.
connection_free() tries to remove the connection from the
idxset, but that fails, because the item has already been
removed from the idxset in this scenario.
The problem is solved by not trying to remove the connection
from the idxset in connection_free(). Instead, whoever wants
to delete connections, has to remove the connection from the
idxset in addition to calling connection_free().
match: Support for both merging and replacing proplist updates.
This patch adds a new update mode specifier that can be optionally
given in match rules after the regexp. Property list updates triggered
by the rule will honour the given mode. The two allowed modes are 'merge'
and 'replace', corresponding to PA_UPDATE_MERGE and PA_UPDATE_REPLACE
respectively. If omitted, the mode defaults to PA_UPDATE_MERGE, ie. to
the original behavior.
For example, to force 'media.role' to be overwritten with 'bar' for
streams matching foo you can use an entry like this:
foo replace "bar"
This will really overwrite media.role to bar even if it has already been
set to something else by the application.
Thanks to Krisztian Litkey for the original patch and the description
above. In addition to implementing the new feature, this patch fixes
a number of bugs in the parsing code.
core: Drop empty gaps in the memblockq when playing data from it.
It's possible that the memblockq of a sink input is rewound to a negative read
index if the sink input is moved between sinks shortly after its creation. When
this happens, pa_memblockq_peek() returns a memchunk whose 'memblock' field is
NULL and whose 'length' field indicates the length of the gap caused by the
negative read index. This will trigger an assert in play-memblockq.c.
If the memblockq had a silence memchunk, pa_memblockq_peek() would return
silence for the duration of the gap and the assert would be avoided. However,
this approach would prevent the sink input from being drained and is thus not
possible. Instead, we handle the aforementioned situation by dropping the gap
indicated by the 'length' field of the memchunk and by peeking the actual data
that comes after the gap.
This scenario seems to be quite rare in everyday use, but it causes a severe
bug in the handheld world. The assert can be triggered e.g. by loading two null
sinks, playing a sample from the cache to one of them and then moving the
created sink input between the two sinks. The rewinds done by the null sinks
seem to be quite long (I don't know if this is normal behaviour or something
fishy in module-null-sink).
With automaticl filter loading by module-filter-apply, setting the
virtual sink/source to have the "phone" intended role will break routing
when you first connect a phone stream to an ALSA device and then turn on
your Bluetooth headset. This happens because module-intended-roles
doesn't move a stream if it is already on a device that provides the
required role.
This patch introduces a "manual_load" parameter that is meant to be used
when not using module-filter-apply for loading the AEC module. If this
parameter is set, the virtual devices are given the "phone" role, else
we count on module-filter-heuristics to do the right thing.
This makes the core code in the filter-* modules generic enough to be
used on sources or sinks. We need special handling for modules that
introduce more than one sink (for now echo-cancel only).
This makes sure that we handle streams moving between sinks properly. To
do this, we change the way the filter.* properties are handled a little
bit.
Firstly, this splits up the "filter.apply" property into two properties
- "filter.want" and "filter.apply". "filter.apply" acts as before - it
bypasses module-filter-heuristics and directly tells module-filter-apply
what filters are to be applied.
"filter.want" is used to tell module-filter-heuristics what filters the
client wants. The module then decides whether to actually apply the
filter or not (for now, this makes sure we don't apply echo-cancellation
even if requested on phone sinks (where it is assumed AEC is taken care
of or is not required).
Next, we also make sure that we track whether the client set
"filter.apply" or module-filter-heuristics did - and in the latter case,
we recalculate "filter.apply" and then have module-filter-apply apply
the filter if required. This introduces some evil in the form of causing
the move_finish callback to possibly trigger another move, but we
protect for this case (with a property) to be doubly sure of not causing
an infinite loop.
filter-heuristics: Only apply AEC if we're not already on a phone sink
This makes sure that we don't apply AEC on sinks that are already
connected to a "phone" device, the assumptiong being that anything
marked as such either doesn't have need it, or handles it itself.
Colin Guthrie [Fri, 22 Apr 2011 09:25:42 +0000 (10:25 +0100)]
test: Make the connect-stress less likely to bail out due to >32 streams.
When running two connect-stress tests at the same time the liklihood of >32 streams
per sink increases. All it takes is for an event sound to fire to trigger an abort of
the test.
This leaves just a little bit of wriggle room for a couple external streams.
Of course the overall problem is still there but this just makes it
slightly less likely without really affecting the test itself.
There were several memory leaks. In addition to those,
pa_dbus_protocol_add_interface() used a string from the
caller as a key to a hashmap, instead of a copy of the
string. This caused trouble when the caller freed the
string while the key was still in use in the hashmap.
Daniel Mack [Fri, 22 Apr 2011 00:27:35 +0000 (02:27 +0200)]
pulsecore:: Define _POSIX_C_SOURCE locally for rtclock on OSX
Defining this macro on a global level is disadvantageous for other APIs,
and as we need it for clock_gettime() only on Mac OS X, define it
locally in pulsecore/core-rtclock.c only.
This value is passed on to the instances of module-coreaudio-device that
are loaded upon device detection. The value is purely optional, as the
device module will fall back to to its default if it's not given.
Adds an autoclean option (defaults to TRUE) that controls whether
module-filter-apply cleans up unused modules or not. This is useful in
cases where you know that a filter will be used often and thus can avoid
overhead from repeated module load/unload.
This makes the volume tests run in two loops and print the minimum,
maximum and standard deviation of readings from the inner loop. This
makes it easier to reason out performance drops (i.e. algorithmic
problems vs. other system issues such as processor contention).