Arun Raghavan [Mon, 17 Jun 2013 12:37:42 +0000 (18:07 +0530)]
mainloop: Document need for mainloop lock around pa_mainloop_api_once
This needs us to expose a bit of implementation detail, but this seems
to be the cleanest way without an API change.
The specific problem is that pa_mainloop_api_once() needs to first
create a defer event and then set its destroy callback. If the defer
event is completed before the callback is set, an assert will be
trigerred.
David Henningsson [Thu, 13 Jun 2013 12:26:09 +0000 (14:26 +0200)]
iochannel: Avoid unnecessary wakeup after successful write
To save some CPU (in low latency scenarios), don't re-enable the
"writable" event after it has succeeded. It is very likely the next
write will succeed right away too.
This means that we always need to handle EAGAIN/EWOULDBLOCK as a
successful write of 0 bytes, so I also verified that all callers to
pa_iochannel_write handled this correctly.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
David Henningsson [Tue, 4 Jun 2013 13:41:57 +0000 (15:41 +0200)]
alsa-mixer: Add "Line Out" path
If there is a "Line Out" jack present, then add this path. The fallback
analog-output will be a subset of this path and removed.
I only use the "Line Out Jack" or "Line Out Front Jack" for actual jack
detection - without anything connected to the front jack, it makes little
sense to enable the port.
(Another option could perhaps be to use different paths for stereo line out
and surround line outs, but that could be a possible future improvement.)
Arun Raghavan [Mon, 10 Jun 2013 12:47:39 +0000 (18:17 +0530)]
alsa-mixer: Disable headphones when playing to speakers
Assume that the headphone port volume is lower than the speaker volume.
When plugging in headphones, if the path is active, while the jack is
being inserted and before it is actually detected as being plugged in,
it will still receive the signal being played (which is at a higher
volume than it will be when plugged in completely). The volume
difference manifests as a volume spike when the headphones are plugged
in, before the final volume is set.
This patch is required to prevent such a volume spike when plugging in
headphones. The problem is not fixed completely, but the spike is
shortened. To be fixed completely, we need to apply the port volume
before unmuting the new path.
Jan Alexander Steffens (heftig) [Sun, 9 Jun 2013 16:47:05 +0000 (18:47 +0200)]
core-util: Clamp RLIMIT_RTTIME to what RealtimeKit accepts
In the default configuration, PulseAudio's rlimit-rttime is set to 1000000 (100%), which is higher than what RealtimeKit requires from
its clients (200000, 20%).
Make an attempt to still get realtime scheduling by clamping the
current RLIMIT_RTTIME to what RealtimeKit accepts. Warn about doing
this.
Arun Raghavan [Wed, 22 May 2013 10:29:24 +0000 (15:59 +0530)]
tests: Adjust latency test calibration
This makes the test more robust by:
1. Decreasing the '1' threshold during calibration - the RMS value for
the sine wave will be 0.5, so the previous code was making us take
the ALSA mixer past 0dB.
2. Using the difference rather than absolute value for 0->1 transitions,
so that we're somewhat independent noise in our calculations.
Arun Raghavan [Tue, 21 May 2013 13:09:30 +0000 (18:39 +0530)]
tests: Add a latency measurement test
This test is intended to measure real latency by playing a sample to a
sink and capturing that over a loopback interface. The loopback can
either be physical (cable running from headphone out to line in) or
virtual (monitor source or module loopback).
Also included in this is calibration code to make sure that volumes are
sufficiently adjusted to be able to detect the played back signal (and
that there aren't false positives due to line noise).
One of the objectives of all this is to later factor out the setup code
to allow us to easily write more loopback tests for various
functionality (volumes, resampling, mixing, etc.).
Arun Raghavan [Wed, 15 May 2013 04:11:19 +0000 (09:41 +0530)]
zeroconf: Make Avahi usage in m-z-publish async
This pushes all avahi-client code to a threaded mainloop from the PA
mainloop context. We need to do this because avahi-client makes blocking
D-Bus calls, and we don't want to block the mainloop for that long.
The only exception to this now that I don't see a workaround for is
during module unload time. However, this shouldn't be a huge problem
since in most cases, this will only happen at server shutdown time.
The bulk of the change is partitioning the data so that PA core objects
only (well, mostly) get accessed in the PA mainloop and Avahi calls
happen only in the Avahi threaded mainloop.
Mitchell Fang [Wed, 22 May 2013 08:23:27 +0000 (11:23 +0300)]
thread-mainloop: Fix bug in example code
Checking the operation state caused a deadlock, because the state
won't change before my_drain_callback() returns, and it doesn't
return before my_drain_stream_func() calls
pa_threaded_mainloop_accept().
Mikel Astiz [Fri, 10 May 2013 08:30:47 +0000 (10:30 +0200)]
bluetooth: Support transport auto-release
With BlueZ 5, if the remote device suspends the audio, the transport
state will change to "idle" and the endpoint is not required to release
the transport, since this could introduce race conditions. Therefore,
ignore the call to pa_bluetooth_transport_release() if the transport is
not acquired any more.
Mikel Astiz [Fri, 10 May 2013 08:30:46 +0000 (10:30 +0200)]
bluetooth: Update to new BlueZ 5 transport acquire/release API
The new D-Bus API doesn't support access rights, which weren't used by
PulseAudio anyway, but it does solve a race condition: now optional
acquires can be implemented by bluetooth-util atomically using the D-Bus
TryAcquire() method.
Mikel Astiz [Fri, 10 May 2013 08:30:45 +0000 (10:30 +0200)]
bluetooth: Support media transport's State property
BlueZ 5 exposes a 'State' property in the media transport interface.
With regard to PA, this replaces the profile-specific interfaces, since
they were being used to know if the audio was streaming or not.
Mikel Astiz [Fri, 10 May 2013 08:30:44 +0000 (10:30 +0200)]
bluetooth: Parse media transport's properties
Add the code to parse the properties of the media transport object when
a PropertiesChanged signal is received.
Note that the transport might have an owner other than BlueZ, and thus
the property changes would be emitted from arbitrary senders. For
performance reasons, the installed match considers the interface name
where the property has changed.
It could be possible to install and remove the D-Bus matches dynamically
when a new owner is registered/unregistered, but filtering based on the
interface name seems good enough already.
Mikel Astiz [Fri, 10 May 2013 08:30:42 +0000 (10:30 +0200)]
bluetooth: Support ObjectManager interface add/remove
Install matches for signals ObjectManager.InterfacesAdded and
ObjectManager.InterfacesRemoved, and process the devices that are
registered and unregistered dynamically.
Nikolay Amiantov [Sun, 5 May 2013 11:22:53 +0000 (15:22 +0400)]
pactl: Flush stdout buffer when printing subscribe events.
"pactl subscribe" is running continuously, and without flushing its output is
not usable for "process-on-arrival" per-line tasks, such as grepping. This
patch should fix this. For example, now:
pactl subscribe | grep 'server'
should print only server events as they arrive.
Mikel Astiz [Mon, 29 Apr 2013 16:27:59 +0000 (18:27 +0200)]
bluetooth: Parse the tree returned by ObjectManager
Parse the result of ObjectManager.GetManagedObjects(), which includes
all objects registered, their interfaces and the corresponding
properties per interface.
Any code that runs inside the init() callback sees an invalid module
index. Sometimes init() does things that cause hooks to be fired. This
means that any code that uses hooks may see an invalid module index.
Fix this by assigning the module index before init() is called.
There are no known issues in the upstream code base where an invalid
module index would be used, but an out-of-tree module
(module-murphy-ivi) had a problem with this.
João Paulo Rechi Vita [Sat, 27 Apr 2013 00:24:52 +0000 (21:24 -0300)]
bluetooth: Remove the 'bluez.name' property
The 'Name' property of the Device interface became optional in BlueZ 5
and may not be present anymore (that happens when testing against the
PTS 4.7.0), so it's better not to expose it to clients so they don't
rely on its existence.
Peter Meerwald [Tue, 9 Apr 2013 14:10:16 +0000 (16:10 +0200)]
fdsem: Remember pa_write() type in pa_fdsem_post()
pa_write() knows two types of operation:
calling send() and calling write()
there is a flag (a pointer to an int) passed to pa_write()
which can remember which write type was successful
if the pointer is NULL or the int is 0, send() is tried first,
with a fallback to write() if send() resulted in ENOTSOCK
pa_fdsem_post() calls pa_write() with a NULL pointer;
unfortunately (at least with HAVE_SYS_EVENTFD_H #define'd) send()
always fails here and write() is called -- causing an extra syscall
quite frequently
Tanu Kaskinen [Wed, 13 Jun 2012 09:45:16 +0000 (12:45 +0300)]
pasuspender: Resume before exiting in case of SIGINT or fork() failure.
Pressing Ctrl-C in a terminal while pasuspender is running
causes the sinks and sources to stay suspended after
pasuspender has exited, which is very annoying. This patch
fixes that problem, and also a similar problem with fork()
failures.
Tanu Kaskinen [Wed, 13 Jun 2012 08:15:03 +0000 (11:15 +0300)]
core-util: Don't accept random words in pa_parse_boolean()
The old code accepted any word that started with "y", "Y",
"n", "N", "t", "T", "f" or "F". Fix this by having
a whitelist of full strings instead of checking just the
first letter.
Peter Meerwald [Thu, 28 Mar 2013 13:46:48 +0000 (14:46 +0100)]
build: make ARM NEON check in configure.ac more strict
the check for NEON so far only checked if -mfpu=neon is understood by the compiler,
however, this is not enough:
(i) #include <arm_neon.h> should be checked
(ii) -mfpu=neon must be passed before CFLAGS because eventually the per-library CFLAGS
for NEON code in src/Makefile.am are passed to the compiler before the global CFLAGS
in case the build environment passes CFLAGS to configure and we try to set conflicting
CFLAGS option, the former take precedence; CFLAGS cannot be overridden
this does not fix
http://lists.freedesktop.org/archives/pulseaudio-discuss/2012-December/015570.html
but at least makes the build fail in configure (and not while compiling stuff)
and gives better diagnostics
Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
João Paulo Rechi Vita [Wed, 27 Mar 2013 13:45:33 +0000 (10:45 -0300)]
bluetooth: Improve code and log readability
This commit makes the code cleaner, avoiding unnecessary line breaks. It
also changes the debug message elements order, to make it look more
natural ("path, interface, member" instead of "interface, path,
member").
Tanu Kaskinen [Fri, 29 Jun 2012 15:04:58 +0000 (18:04 +0300)]
alsa-mixer: Remove the "name" option from the "General" section of path configuration files
This means that the path names will always correspond to the
path configuration file names, so they will automatically be
unique (in the scope of one card).
Tanu Kaskinen [Fri, 29 Jun 2012 15:04:57 +0000 (18:04 +0300)]
alsa-mixer: Introduce "description-key" option for paths
Previously the path description was looked up based on the
path name only. Since there can be multiple paths that use
the same description, it had to be possible to have multiple
paths with the same name.
Having the same name with multiple paths makes identifying
the paths more complex than necessary, so the plan is to
make it impossible to have paths with the same name. This
patch prepares for that by retaining the possibility to
still have the same description with multiple paths. Instead
of the path name, the path description is looked up by using
the "path description key" if it is set (path name is still
used as a fallback lookup key).
Tanu Kaskinen [Fri, 29 Jun 2012 15:04:56 +0000 (18:04 +0300)]
switch-on-port-available: Prepare for dual-direction ports going away
As an extra, I broke try_to_switch_profile() into smaller
functions, because the two levels of loops with continue
statements inside both were a bit hard to follow.
Vadim Troshchinskiy [Wed, 29 May 2013 10:58:36 +0000 (13:58 +0300)]
osx: Fix latency querying
get_latency_us() used an uninitialized variable, and an incorrect
scope for some of the AudioObjectGetPropertyData() calls. As a result,
audio would randomly not work at all.
Mikel Astiz [Mon, 20 May 2013 09:48:33 +0000 (11:48 +0200)]
bluetooth: Fix missing port->profile association
Commit 17b3cb954b179392e80b0a46d8f2ba4693aec386 merged Bluetooth ports
into two ports (one for input, one for output) but the association
between ports and profiles was lost.
David Henningsson [Thu, 16 May 2013 08:56:21 +0000 (10:56 +0200)]
alsa-mixer: Add "Line Out Jack" to analog-output.conf
A stationary computer usually has headphone jack(s) and line out jacks.
In some cases analog-output.conf will be a subset of
analog-output-headphones.conf, causing line outs to be unusable (because
headphones are unplugged).
This late in the cycle, this was the safest way I could think of to try
to fix this for a particular computer. In later versions of PulseAudio
we could consider making a dedicated line out path instead, and have
proper jack detection there.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
alsa-mixer: Don't use the mono path in the analog-stereo mapping.
As far as I can see, having a mono path in a stereo mapping doesn't
make any sense. It also causes breakage: if the Master Mono mixer
element has two volume channels, the analog-output path gets removed
due to being a subset of analog-output-mono, and that in turn causes
the Master element getting muted. Users generally don't like that.
Peter Meerwald [Wed, 17 Apr 2013 13:07:31 +0000 (15:07 +0200)]
doc: Fix description how boolean values can be specified
"any word starting with the letters" parts; this does not hold
any longer with commit 0e29e7365907ffbe90df768a4dea277dba40d495
core-util: Don't accept random words in pa_parse_boolean()
Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
David Henningsson [Tue, 16 Apr 2013 04:40:40 +0000 (06:40 +0200)]
alsa-mixer: Switch to Headphone when Headphone mic jack is plugged in
When a "Headphone Mic" jack becomes available, we do not know if
a headphone or a mic has been plugged in. Therefore, setting both
paths to "unknown" is, in theory, the correct thing to do.
However, in practice, people are more likely to plug in a headphone
rather than a mic. Therefore, allow autoswitch to the headphone port
when the jack is plugged in.
A more advanced implementation would consider what was plugged in last
time depending on what port was selected on the input side at that
time, and set availability accordingly. However, such an implementation
will have to wait (probably at least until we have our fancy routing
system implementation).
David Henningsson [Tue, 16 Apr 2013 12:56:35 +0000 (14:56 +0200)]
alsa: Fix ELD access warning on shutdown
The hdmi_eld_changed callback is called by alsa-lib at shutdown.
In that case, just exit instead of trying to access something with
already closed handles.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
David Henningsson [Tue, 16 Apr 2013 11:09:38 +0000 (13:09 +0200)]
default.pa: Load switch-on-port-available before udev-detect
We need to pick the right port as early as possible, before the
first volume is picked up. Hence this module needs to be loaded
before the sound card modules are loaded.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
If a card is hot-plugged (which all cards will be when we load
this module before module-*-detect), make sure we don't start up
a sink with an unavailable port selected.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
We know we always serve up LPCM, and exposing this via D-Bus lets Rygel
set the appropriate metadata while presenting the raw (i.e.
non-transcoded) stream to clients.