Eero Nurkkala [Thu, 31 May 2012 07:44:23 +0000 (10:44 +0300)]
alsa-source: add missing header 'signal.h'
Compilation with -DDEBUG_TIMING fails due to a missing header:
modules/alsa/alsa-source.c: In function 'check_left_to_record':
modules/alsa/alsa-source.c:426:9: warning: implicit declaration of function 'raise' [-Wimplicit-function-declaration]
modules/alsa/alsa-source.c:426:9: error: 'SIGTRAP' undeclared (first use in this function)
Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
Eero Nurkkala [Thu, 31 May 2012 07:44:22 +0000 (10:44 +0300)]
alsa-sink: add missing header 'signal.h'
Compilation with -DDEBUG_TIMING fails due to a missing header:
modules/alsa/alsa-sink.c: In function 'check_left_to_play':
modules/alsa/alsa-sink.c:453:9: warning: implicit declaration of function 'raise' [-Wimplicit-function-declaration]
modules/alsa/alsa-sink.c:453:9: error: 'SIGTRAP' undeclared (first use in this function)
Signed-off-by: Eero Nurkkala <eero.nurkkala@offcode.fi>
David Henningsson [Fri, 18 May 2012 20:29:41 +0000 (22:29 +0200)]
once: Fix race causing pa_once to sometimes run twice
There was a race in the existing code that could cause the pa_once code
to be run twice, see:
http://lists.freedesktop.org/archives/pulseaudio-discuss/2012-April/013354.html
Therefore the existing implementation was rewritten to instead look like
the reference implementation here:
http://www.hpl.hp.com/research/linux/atomic_ops/example.php4
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Frédéric Danis [Tue, 15 May 2012 13:55:36 +0000 (15:55 +0200)]
bluetooth: Fix crash on disconnection
When a Bluetooth headset is connected only to HFP profile (not connected
to A2DP) and host streams to it, a crash occurs if host disconnects.
When HFP disconnects, audio thread will fail on POLLHUP then generate
a message to set PA profile to Off before ending.
If this message is managed before PA unload bluetooth device module,
all works fine.
But, if this message is managed during module unload, this finish by
re-entrance in release code (stop_thread) and a crash.
This fix prevents to process profile change when module is unloading.
Lennart Poettering [Tue, 15 May 2012 21:13:28 +0000 (23:13 +0200)]
core-util: move configuration home directory from ~/,pulse to ~/.config/pulse to follow XDG basedir spec
If ~/.pulse/ already exists we stick to it in order not to lose
configuration and so that pulse configuration may still be shared across
the network with different PA versions.
Arun Raghavan [Fri, 11 May 2012 12:02:20 +0000 (17:32 +0530)]
bluetooth: Fix crash due to usage of pa_bool_t instead of dbus_bool_t
pa_bool_t and dbus_bool_t cannot be used interchangably since their size
might (and do) vary. This caused a crash on some systems which was
reported and root caused by: Aidan Thornton <makosoft@googlemail.com>.
Tanu Kaskinen [Tue, 1 May 2012 17:09:12 +0000 (20:09 +0300)]
alsa: Add support for sound cards with 4-channel input.
Changes in v2:
- Call the mapping a generic 4-channel input mapping
instead of a 4-channel mic array mapping. The mapping
will be used also by sound cards that have two stereo
input jacks, so in those cases talking about mic arrays
is wrong.
- Added a comment about using the "hw" device name.
Tanu Kaskinen [Thu, 10 May 2012 06:19:23 +0000 (09:19 +0300)]
resampler: Add support for resamplers that consume less data than asked.
libsamplerate_resample() assumed that src_process() would
always consume the whole input buffer. That was an invalid
assumption leading to crashes.
This patch adds a leftover memchunk for storing any
non-consumed input. When pa_resampler_run() is called next
time, the leftover is prepended to the new input.
Changes in v3:
- Make the calculations in pa_resampler_result() and
pa_resampler_max_block_size() more readable and more
correct.
- Rework the leftover storing: instead of using a dedicated
buffer for it, store it in the beginning of remap_buf.
This can avoid some memory copying. (The idea was
suggested by Wang Xingchao.)
- Use a generic save_leftover() function instead of doing
the leftover copying in the resampler implementation.
- Use the leftover logic also with the speex and ffmpeg
resamplers.
[ed: dropped the speex bit since the API guarantees that
it will consume everything -- Arun]
Changes in v2:
- If add_leftover() is called with zero-length input while
the leftover length is non-zero, we don't try to acquire
the input memblock.
- Instead of taking a reference to the original input in
libsamplerate_resample(), we copy the leftover data to a
new memblock. This is done, because otherwise, if the
input is one of the internal buffers, the data can get
overwritten before reading it in add_leftover().
- Store add_leftover_buf size in bytes instead of samples
(more convenient, but less consistent with other code).
poljar [Tue, 1 May 2012 21:17:22 +0000 (23:17 +0200)]
pacmd: Added --help and --version options.
All utilities should have the --help and --version command line options.
These two were added to pacmd, also the goto label was changed from fail
to quit like in the other utilities.
Paul Menzel [Tue, 24 Apr 2012 21:36:07 +0000 (23:36 +0200)]
doc: Add entry for correct spelling
Due to the formatting of `README` the only occurence of PulseAudio in a
text is capitalized. People reading `README` should at least see the
correct spelling once.
In contrast to reformat just add a spelling section as an easy solution.
Since it is not that important the last place in the ordering might
suffice.
Colin Guthrie [Thu, 5 Apr 2012 10:41:18 +0000 (11:41 +0100)]
man: Document the cli inteface a little.
This just documents the cli interface syntax. Mostly a lift from
http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/CLI
with some minor editing and bringing up to date.
Also document a few undocumented commands.
Shuffle around the order in 'pacmd help' output to match the order
in the new docs for consistency.
David Henningsson [Tue, 3 Apr 2012 19:35:07 +0000 (21:35 +0200)]
alsa-sink/source: Really set volumes on port change
If deferred volumes were activated, set_volume does not really set
the volume, and is probably only meant to be called from the main
thread.
As we're currently really setting the port and the mute here (i e
modifying ALSA), we should really modify the volume as well.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
David Henningsson [Tue, 3 Apr 2012 16:56:21 +0000 (18:56 +0200)]
module-loopback: Reset process_msg callbacks in teardown
Make sure we can't be called into by remaining references to
sink-inputs and source-outputs after we have unloaded, as
that will likely lead to segfaults.
Thanks to Tanu for providing valuable input on this patch.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Tanu Kaskinen [Wed, 28 Mar 2012 11:47:20 +0000 (14:47 +0300)]
dbus: Add assertions to get rid of warnings from Coverity.
Coverity thinks that expected_method_sig can be NULL when
it's dereferenced by pa_streq(). Adding assertions doesn't
hurt here (in my opinion), and that should get rid of the
warnings.
Tanu Kaskinen [Wed, 28 Mar 2012 09:27:26 +0000 (12:27 +0300)]
device-manager: Add an assertion to get rid of a warning from Coverity.
Coverity thinks that device_name can be NULL when it's
dereferenced by strcmp. Adding an assertion doesn't hurt
here (in my opinion), and that should get rid of the
warning.
Tanu Kaskinen [Mon, 26 Mar 2012 11:52:27 +0000 (14:52 +0300)]
dbus: Add an assertion to get rid of a warning from Coverity.
Coverity thinks that sample can be NULL when it's
dereferenced after this line. Adding an assertion doesn't
hurt here (in my opinion), and that should get rid of the
warning.
Tanu Kaskinen [Mon, 26 Mar 2012 11:35:30 +0000 (14:35 +0300)]
alsa: Fix SND_MIXER_SCHN_LAST related stuff.
Valid channel id range is from 0 to SND_MIXER_SCHN_LAST,
inclusive, so the size of the masks array in pa_alsa_element
has to be SND_MIXER_SCHN_LAST + 1. Similar "too small"
arrays were also in alsa-sink's and alsa-source's userdata,
but actually those arrays were not used at all so they were
removed.
element_is_subset() in alsa-mixer.c skipped the last channel
id when iterating the element masks array; that's now fixed
as well.
Thanks to David Henningsson for spotting the too small
arrays in alsa-sink and alsa-source and the
element_is_subset() problem.
Tanu Kaskinen [Fri, 23 Mar 2012 09:01:22 +0000 (11:01 +0200)]
sample-util: Remove redundant check from pa_volume_memchunk.
Add also an assertion for the sample spec validity. The
existing code already does crash in case of an invalid
sample spec, but the error would not be as obvious: the
crash would happen due to a divide-by-zero operation in
pa_frame_aligned().
Maarten Lankhorst [Mon, 26 Mar 2012 21:12:24 +0000 (23:12 +0200)]
module-jack-sink/source: Set fixed latency correctly on creation
Changes since v1:
Use max value of jack_port_get_latency_range to calculate the latency
and squash compiler warnings cased by using jack_port_get_total_latency
Modifying latency only works inside a callback, and for hardware the
latency is generally fixed on jack, so just take the max value.
David Henningsson [Mon, 19 Mar 2012 10:54:12 +0000 (11:54 +0100)]
Fix input device for M-audio fasttrack pro
Some M-audio fasttrack pro devices, the input device is at index 1 instead of index 0.
According to
http://mailman.alsa-project.org/pipermail/alsa-devel/2012-March/050701.html
the reason for this is probably that the device has mutually exclusive
analog and digital input. With this patch we can catch the input regardless
of state.
Colin Guthrie [Wed, 14 Mar 2012 01:41:48 +0000 (01:41 +0000)]
core-util: Attempt to make runtime paths smaller to avoid 108 char limit.
When the runtime path gets long (which can happen on some NFS
mounts where $HOME is not just /home/$USER), it can grow
longer the 108 char limit imposed by sockaddr_un.sun_path.
This just calls realpath which should ultimately point into
/tmp in most cases and result in a much smaller path.
Only do this when we are adding on a name component to the
runtime path so creating the actual symlink will still get
the original, long name, but this shouldn't be a problem
as it never goes into the sockaddr_un.sun_path.
Arun Raghavan [Tue, 27 Mar 2012 19:31:32 +0000 (01:01 +0530)]
stream: Fix sample spec initialisation for extended API
This fixes pa_sample_spec init to use the correct API. Not doing so
triggers a valgrind warning as we call pa_sample_spec_valid() on this
later on, which checks the rate and channels fields. Thanks to Rémi
Denis-Courmont for reporting this.
David Henningsson [Mon, 26 Mar 2012 08:31:47 +0000 (10:31 +0200)]
alsa-mixer: Show HDMI ports for older Nvidia cards
Some older cards do not have jack detection. This patch makes the
port still show up.
An implementation detail: the "required = ignore" line has in itself
no effect, but we have to write *something* there, or else the entire
jack detection section will be ignored by the parser.
Deng Zhenrong [Thu, 22 Mar 2012 13:52:12 +0000 (21:52 +0800)]
fix compilation warning via PRI prefix
modules/alsa/alsa-mixer.c:3110:21:
warning: format '%lx' expects argument of type 'long unsigned int', but argument 7 has type 'pa_channel_position_mask_t' [-Wformat]
modules/alsa/alsa-mixer.c:3110:21:
warning: format '%lx' expects argument of type 'long unsigned int', but argument 8 has type 'pa_channel_position_mask_t' [-Wformat]
pa_channel_position_mask_t is type defined to uint64_t, and to display
uint64_t, it's better to use PRIx64 primitives.
David Henningsson [Mon, 19 Mar 2012 15:42:10 +0000 (16:42 +0100)]
module-switch-on-port-available: Do not switch profile if current port is available
For switching profiles, we are a little more cautious, only switch
from an unavailable port to an available one. Profile switching is
mainly used for HDMI/DisplayPort, and this is to avoid switching from
analog to HDMI/DP when it becomes available.
See http://lists.freedesktop.org/archives/pulseaudio-discuss/2012-March/012991.html
and replies for more information.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
David Henningsson [Tue, 20 Mar 2012 10:44:15 +0000 (11:44 +0100)]
module-loopback: Never call adjust_rates after teardown
Calling adjust_rates after teardown results in segfault, and
judging from the Ubuntu bug report, this can happen.
Actively prevent this by destroying the time event, and by
setting adjust_time to 0, we also prevent this routine being
called on max request update.
Arun Raghavan [Mon, 19 Mar 2012 08:59:59 +0000 (14:29 +0530)]
protocol-native: Remove redundant asserts
As David points out, the previous commit made a couple of asserts
redundant (the XOR covers all cases that were previous tested for).
Remove these redundant commits now.
Arun Raghavan [Mon, 19 Mar 2012 08:46:04 +0000 (14:16 +0530)]
protocol-native: Reinstate assert that was incorrectly removed
Commit 54cddc6ddf075b6248b0b8521120b2bd86049978 removed an assert that
looked redundant but was not. This commit reinstates it in a slightly
modified form. It is not stated as (a ^ b) instead of (!a || !b) in
order to make the condition more obvious.
David Henningsson [Fri, 16 Mar 2012 13:38:38 +0000 (14:38 +0100)]
protocol-native: Protect against clients trying to set a NULL port
For some reason, a badly behaving client was trying to set a NULL
port, which caused PulseAudio to crash. Add safeguards on two levels
just to be protected. (Also remove a redundant check.)
Lennart Poettering [Sat, 17 Mar 2012 00:52:41 +0000 (01:52 +0100)]
systemd: complement module-console-kit with module-systemd-login
ConsoleKit has been deprecated and replaced by systemd's logind daemon,
hence provide the same functionality of module-console-kit in
module-systemd-login. This also makes sure that the CK module becomes a
NOP if the system is booted with systemd, resp. that the systemd module
becomes a NOP if the system is booted without systemd, thus being nice
to OSes such as Debian which want to support multiple init systems.
David Henningsson [Mon, 12 Mar 2012 23:06:22 +0000 (00:06 +0100)]
daemon: Initialize dbus to use thread-safe mode by default
In most cases, we use dbus from more than one thread, as we
e.g. enable real-time scheduling from the ALSA threads.
Therefore set dbus to thread-safe mode by default, as recommended
in https://bugs.freedesktop.org/show_bug.cgi?id=47060#c5
This fixes a bug where PulseAudio could crash in two parallel
calls to pa_make_realtime.
If these files aren't compiled in both libpulse and
libpulsecommon, some things will try use non-public
functions from libpulse. Therefore those internal functions
have to be included directly in libpulsecommon.
This problem appears to be only visible with --as-needed,
which is why the problem wasn't noticed immediately. The
problem has existed also earlier, and it was fixed by
Maarten Bosmans in commit 2de2c735. The commit that is
now reverted basically reverted Maarten's commit (I didn't
know that when I wrote the bad patch).
Giorgos Boutsioukis [Sun, 26 Feb 2012 23:34:09 +0000 (15:34 -0800)]
xen: Add Xen paravirtualized sink support.
A part of Xen's paravirtualized audio driver has been developed as a
pulseaudio module. This module acts as a tunnel over Xen's shared memory
mechanism and allows a domU guest to send audio data to a dom0 backend.
David Henningsson [Thu, 23 Feb 2012 06:17:07 +0000 (07:17 +0100)]
alsa-mixer: Make speaker get available=no when headphones are plugged in
While developing the new UI we had to ask ourselves the question of whether
"speakers" should be considered available when headphones are plugged in.
In most cases, they are not available and therefore we should list them
as such.
OTOH, we don't want unplugging the headphones to be considered an act of
wanting to use the speakers (the user might prefer HDMI), and there might
be line-outs that keeps the speakers from unmuting anyway. So, at this point,
I think the most reasonable would be to make the speakers have
PA_PORT_AVAILABLE_NO when headphones are plugged in and
PA_PORT_AVAILABLE_UNKNOWN when they are not. But we might want to revisit
this decision once we have the priority lists up and running.
The same reasoning applies for "Internal Mic", which should become unavailable
when any other mic is plugged in.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
David Henningsson [Thu, 23 Feb 2012 06:17:06 +0000 (07:17 +0100)]
introspect: Expose port info per card to clients
For volume control UIs to be able to show ports in inactive profiles,
expose all ports together with the card info. This includes updating
the protocol and the client API to show the connection between ports
and for which profiles the ports are relevant.
Update protocol to 26.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
David Henningsson [Thu, 23 Feb 2012 06:17:02 +0000 (07:17 +0100)]
alsa: Jack detection kcontrol implementation
Support the new jack detection interface implemented in Linux 3.3
(and Ubuntu's 3.2 kernel).
Jacks are probed and detected using the snd_hctl_* commands, which
means we need to listen to them using fdlists. As this detection
needs to be active even if there is currently no sink for the jack,
so this polling is done on the card level.
Also add configuration support in paths, like this:
[Jack Headphone]
required-any = any
...where 'Jack Headphone' should match 'Headphone Jack' as given by
ALSA (as seen in e g 'amixer controls').
"Required", "required-any" and "required-absent" is supported. Using
required-any, one can have several ports even though there is no
other indication in the mixer that this path exists.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>