Commit graph

2414 commits

Author SHA1 Message Date
David Henningsson
38c5d6d585 module-rescue-streams: Fixup previous patch w r t fallback sink/sources
- Make sure "no evacuation sink/source found" is not printed when
   fallback source/sink is selected
 - Restore previous behaviour of fallback sink/source selected
   (first one instead of last one)

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-06-10 08:30:05 +02:00
Hui Wang
618a2167f7 rescue-streams: try to find best one using availability and priority
Recently met a problem: when I disconnect the bluetooth headset, the
pulseaudio automatically switch the sound to sink of HDMI output
instead of the sink of internal speaker even though there is no HDMI
cable connected.

To fix this problem, I want to change the rule of selecting the target
sink if the default sink is not available. (same rules apply to the
source selecting):
construct a new hashmap with all ports (of all relevant sinks) and
then call find_best on the new hashmap to find the best port, finally
find the corresponding sink using the best port.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
2014-06-10 08:08:35 +02:00
Tanu Kaskinen
de0d803e3c bluetooth: Refactor device validity management
There are several intertwined changes that I couldn't separate into
nicer commits. This is mostly just refactoring, but this also fixes
a bug: the old code set the device valid in parse_device_properties()
even if the device's adapter was invalid (had NULL address).

To improve the clarity of the code, I split the device_info_valid
variable into two booleans: properties_received and valid.

I added function device_update_valid() that checks all conditions that
affect the device validity. The function can then be called from any
place where something changes that potentially affects the device
validity. However, currently the only validity-affecting thing that
can change is the device adapter, so device_update_valid() is only
called from set_device_adapter().

I added the aforementioned set_device_adapter() function so that
whenever the adapter is set, the device validity gets updated
automatically.

The new properties_received variable allowed me to remove the
is_property_update function parameters.
2014-06-06 15:05:45 +03:00
Tanu Kaskinen
a61d065dcc bluetooth: Add "valid" flag to pa_bluetooth_adapter
This is a cosmetic change. There are a couple of places where we check
whether the adapter object is valid, and while checking whether the
address property is set works just fine, I find it nicer to have a
dedicated flag for the object validity. This improves maintainability
too, because if there will ever be more adapter properties that affect
the adapter validity, the places that check if the adapter is valid
don't need to be updated.
2014-06-06 15:05:25 +03:00
Alexander E. Patrakov
26b9d22dd2 rtp-recv: fix crash on empty UDP packets (CVE-2014-3970)
On FIONREAD returning 0 bytes, we cannot return success, as the caller
(rtpoll_work_cb in module-rtp-recv.c) would then try to
pa_memblock_unref(chunk.memblock) and, because memblock is NULL, trigger
an assertion.

Also we have to read out the possible empty packet from the socket, so
that the kernel doesn't tell us again and again about it.

Signed-off-by: Alexander E. Patrakov <patrakov@gmail.com>
2014-06-06 14:41:22 +03:00
Alexander E. Patrakov
42c814b9f3 source, sink: Support weird sample rates
This fixes assertion failures that manifest themselves with cards that
support only weird rates such as 37286Hz. Tested with snd-pcsp.

Signed-off-by: Alexander E. Patrakov <patrakov@gmail.com>
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=48109
2014-06-05 15:57:00 +03:00
Wim Taymans
d3d09c949d combine-sink: rework output add/remove
Add the output from its sink-input attached callback and remove it
again from the detach callback. This simplifies some output_enable
and we can also avoid posting 2 messages for the sink.
2014-06-05 12:19:36 +03:00
João Paulo Rechi Vita
5881368bf4 bluetooth: Notify the main thread of a stream fd HUP 2014-06-01 14:45:31 +03:00
João Paulo Rechi Vita
01feb3c162 bluetooth: Rename variable to improve code readability
The label 'u' is used throughout the code to name pointers to the struct
userdata.
2014-06-01 13:37:23 +03:00
David Henningsson
3f140f9022 alsa-mixer: Add surround 2.1 profile
Surround 2.1 is one of the more common surround profiles these days,
so it's about time we support it.

The "surround21" was added to alsa-lib a few months ago, and there
hasn't yet been an alsa-lib release since, but I doubt it will change.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-05-27 12:02:31 +02:00
João Paulo Rechi Vita
09933e582b bluetooth: Change BlueZ 5 card profile name from a2dp to a2dp_sink
This name is more acurate with regards of what role we're currently
playing and we've already been using it in
pa_bluetooth_profile_to_string() since 449d6cb.
2014-05-25 12:24:17 +03:00
João Paulo Rechi Vita
7fe34cff61 bluetooth: Fix lines going over column 128 2014-05-25 12:24:03 +03:00
Tanu Kaskinen
3af39c648f bluetooth: Fix a copy-paste error in log message 2014-05-03 14:21:31 +03:00
Tanu Kaskinen
be9672b8c1 bluetooth: Remove redundant assignments 2014-05-03 14:10:52 +03:00
Tanu Kaskinen
f88912af9b solaris, tunnel: Remove some redundant boolean conversions 2014-05-02 16:00:56 +03:00
Tanu Kaskinen
ef4ae785aa sink-input, source-output: Remove redundant get_mute() functions
The functions just return the muted value. Callers can as well read
the struct field directly, it's simpler that way.
2014-05-02 16:00:56 +03:00
Tanu Kaskinen
e4a7625ba8 sink, source: Assign to s->muted from only one place
Forcing all mute changes to go through set_mute() makes it easier to
check where the muted field is changed, and it also allows us to have
only one place where notifications for changed mute are sent.
2014-05-02 16:00:49 +03:00
Tanu Kaskinen
c93cfc1ca6 echo-cancel: Remove redundant get_mute() callback
The callback just called pa_source_output_get_mute(), which doesn't
have any side effects, and the return value wasn't used either, so
the callback was essentially a no-op.
2014-05-02 15:50:15 +03:00
Arun Raghavan
c78860c97b gconf: Avoid calling deprecated function if possible
g_type_init() is need no longer be called explicitly from glib 2.36
onwards.
2014-04-26 11:32:45 +03:00
Arun Raghavan
a30650d2ce gconf: Remove unused variable 2014-04-26 11:32:34 +03:00
Hemanth Meenakshisundaram
4bd39f9501 combine-sink: fix zero adjust_time behaviour.
A value of 0 for adjust_time should disable rate adjustment.
Fix a bug where a 0 value causes rate adjustment to be called
continuously instead after an unsuspend event.
2014-04-26 11:22:25 +03:00
Juho Hämäläinen
a306d66525 dbus: Use correct initialization for source ports hashmap.
Source ports hashmap is created without value freeing function, which
results in (hashmap values) device ports not being freed when source
ports are removed or module is unloaded. This results in memory leak
during normal operation and during daemon shutdown dbus_protocol shared
object isn't unreferenced correctly, leaving dbus_protocol object in
core->shared, which causes assert when shared hashmap is checked for
isempty() before freeing.
2014-04-17 11:13:01 +03:00
Niels Ole Salscheider
3064511df6 virtual-surround-sink: Move normalization heuristic to its own function
This patch also adds a description how the heuristic works and mentions that
there is a scaling factor that can be adjusted if there is audible clipping.
2014-04-17 10:46:26 +03:00
Tanu Kaskinen
eca082a93f Use pa_hashmap_remove_and_free() where appropriate 2014-04-17 10:06:23 +03:00
Alexander E. Patrakov
a5ba31bf96 Name HDMI outputs uniquely
On Haswell hardware, there are multiple HDMI outputs capable of
digital sound output. As they were identically named, KDE's control
center was unable to distinguish them, restored the wrong profile and
thus routed sound to the wrong HDMI monitor.

Also, having identically-named menu items in other mixer applications
looks like a bug.
2014-04-15 09:03:55 +02:00
David Henningsson
319a665ce8 module-switch-on-port-available: Use new find best port function
Now that we have a generic function in device-port.h, we can use
it instead of the custom one.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-04-04 07:28:34 +02:00
David Henningsson
06ad1b7a06 module-switch-on-port-available: Use port->card pointer
We now have a port->card pointer, we can use it instead of iterating
over cards to find the correct one.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-04-04 07:24:10 +02:00
David Henningsson
ef4a41e8b0 module-switch-on-port-available: Don't switch profiles on uninitialized cards
This could cause the HDMI port to become the default on some systems
where analog output was available.

BugLink: https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/1256511
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=73375
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-04-04 07:24:09 +02:00
Tanu Kaskinen
b75a20db10 zeroconf-publish: Don't assume any particular defer event ordering
Also, initialize userdata with zeros to avoid invalid pointers in
client_free().

This fixes a crash when client_free() is called before
create_client(). The whole issue could be avoided by using some other
mechanism than defer events for running the two functions, but I'll
do that change later (I have also other cleanups planned for
zeroconf-publish).

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=76184
2014-03-28 15:08:24 +02:00
Wim Taymans
5621b7898b device-restore: log restored mute state
Log the mute state as it was restored
2014-03-26 17:15:26 +02:00
Peter Ujfalusi
3c73e2130f alsa-util: Reset hwparams_copy before the second try of buffer setup
hwparams_copy needs to be reset (as it is also reset for the third and
fourth try) before the second try.

If the reset is not done and the first try fails:
D: [lt-pulseaudio] alsa-util.c: Maximum hw buffer size is 743 ms
I: [lt-pulseaudio] alsa-util.c: snd_pcm_hw_params_set_buffer_size_near() failed: Invalid argument
I: [lt-pulseaudio] alsa-util.c: snd_pcm_hw_params_set_period_size_near() failed: Invalid argument
I: [lt-pulseaudio] alsa-util.c: snd_pcm_hw_params_set_buffer_size_near() failed: Invalid argument
D: [lt-pulseaudio] alsa-util.c: Set only period size (to 1102 samples).

We have three failures and finally the fourth (only period size) succeed.

With this patch:
D: [lt-pulseaudio] alsa-util.c: Maximum hw buffer size is 743 ms
I: [lt-pulseaudio] alsa-util.c: snd_pcm_hw_params_set_buffer_size_near() failed: Invalid argument
D: [lt-pulseaudio] alsa-util.c: Set period size first (to 1102 samples), buffer size second (to 4408 samples).

We only fail with the first try, the second (period followed by buffer) is
fine.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
2014-03-24 10:24:00 +02:00
Tanu Kaskinen
37e73e10be zeroconf-publish: Don't react to messages while shutting down
This fixes a case where pa__done() is called while
AVAHI_MESSAGE_PUBLISH_ALL is waiting for processing. The
pa_asyncmsgq_wait_for(AVAHI_MESSAGE_SHUTDOWN_COMPLETE) call will
process all pending messages, and processing AVAHI_MESSAGE_PUBLISH_ALL
causes publish_all_services(), and that in turn accesses u->services,
which has been already freed at this point. If we are shutting down,
we shouldn't react to any of the messages that the Avahi thread is
sending to the main thread.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=76184
2014-03-24 09:28:43 +02:00
Tanu Kaskinen
d03ffdccdb zeroconf-publish: Add locking around pa_mainloop_api_once()
Commit e1e154c737 added locking around
pa_mainloop_api_once() everywhere except pa__done(). This fixes that
omission.
2014-03-24 09:28:34 +02:00
Pete Beardmore
fe6e41d7d2 alsa: Use card description in default sink/source prefix when available
When given an explicit device.description in card_properties, prefer
this information over other default prefixes (e.g. 'Built-in Audio')
when constructing sink/source descriptions.

For example, if I manually configure the card description to be
"FooBar", I then expect that the sinks and created by the card also
have "FooBar" in their description instead of generic "Built-in
Audio".
2014-03-14 16:16:46 +02:00
Tanu Kaskinen
efec98280f tunnel: Fix inverted if condition 2014-03-13 13:04:55 +02:00
David Henningsson
00922f7dc0 alsa-mixer: Fix Analog Input showing up on USB Headset
In some cases, "Analog Input" could show up as well as
"Headset Mic" (or "Headphone Mic"), because I forgot to add the
relevant "required-absent" lines when I added the headset mic path.

As a result, both "Analog Input" and "Headset Mic" showed up on the
Logitech USB 530 Headset.

Reported-by: Steve Magoun <steve.magoun@canonical.com>
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-03-11 05:50:10 +01:00
Alexander E. Patrakov
305409cfcf Fix a few "it's -> its" typos 2014-03-07 18:04:02 +02:00
Peter Meerwald
89749a5379 tunnel-source-new: Fix shadow compiler warning
CC     modules/module_tunnel_sink_la-module-tunnel.lo
modules/module-tunnel-source-new.c: In function 'read_new_samples':
modules/module-tunnel-source-new.c:145:16: warning: declaration of 'read' shadows a global declaration [-Wshadow]

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2014-03-06 15:48:36 +01:00
Tanu Kaskinen
9271c11e68 alsa: Remove a redundant check
If mixer_handle is not NULL, then hctl_handle won't be NULL either.
The redundant check was confusing, because it looked like we would
leak the mixer_handle if mixer_handle is non-NULL and hctl_handle is
NULL.
2014-03-03 18:06:21 +02:00
James Bunton
3f21c21628 bluetooth: Fix timing to count based on decoded data
Currently the latency information is being updated based on the encoded
SBC data instead of the decoded PCM data. Fixing this required moving
the timing update to be after the packet has been decoded.
2014-03-03 18:06:21 +02:00
James Bunton
4a5f48e7a4 bluetooth: Don't abort on SBC decoding error
The Nokia E7 running Symbian Belle Refresh seems to generate invalid SBC
packets every few minutes. This causes pulseaudio to disconnect the
stream and log "SBC decoding error (-3)".

If a single packet is bad, pulseaudio should keep playing the stream.
2014-03-03 18:06:21 +02:00
Tanu Kaskinen
0a5adc95c4 suspend-on-idle: Fix monitor source handling
Fixes a crash that happened due to calling pa_source_check_suspend()
when d->source was NULL.
2014-03-03 16:21:21 +02:00
Tanu Kaskinen
4ebe88c2b2 rtp-send: Add "inhibit_auto_suspend" module argument
Some people want module-rtp-send to send silence when the sink that is
monitored goes idle, and some people want module-rtp-send to pause the
RTP stream to avoid unnecessary bandwidth consumption.
2014-02-28 15:54:06 +02:00
David Henningsson
b55de5179a suspend-on-idle: Ensure we still time out if a stream remains corked
If a stream is started corked and remains corked, the sink/source
remained idle without being properly suspended. This patch fixes
that issue.

BugLink: https://bugs.launchpad.net/bugs/1284415
Tested-by: Ricardo Salveti <ricardo.salveti@canonical.com>
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-02-28 13:58:40 +01:00
Tanu Kaskinen
d94cd5f730 rtp-send: Use _cb suffix with callbacks 2014-02-23 19:45:02 +02:00
Peter Meerwald
0c4c2b3110 modules: Fix uninitialized variable in rtp-send
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2014-02-23 17:03:50 +01:00
Juho Hämäläinen
6021ce3196 dbus: Use correct idxset when getting sources
This fixes get_sources() which iterates wrong idxset when
getting source object paths in GetSources or GetAll.
2014-02-11 12:02:28 +02:00
Tanu Kaskinen
c95b4c22ca card-restore: Fix a memory leak
entry_read() may set entry->profile, so we need to free that string
before we can replace it with a new string.
2014-01-29 20:56:42 +02:00
Tanu Kaskinen
588af08d25 device-manager: Don't try to use unlinked devices
This fixes an assertion crash:

[pulseaudio] source.c: Assertion 'PA_SOURCE_IS_LINKED(s->state)' failed at pulsecore/source.c:734, function pa_source_update_status(). Aborting.

The crash happened when a Bluetooth headset profile was changed from
a2dp to hsp. During the profile change three devices are created:
a sink, a monitor source for the sink, and a regular source. First
pa_sink/source_new() are called for each device, and that puts the
devices to u->core->sinks/sources. Then, pa_sink_put() is called for
the sink, and that in turn calls pa_source_put() for the source. At
that point module-device-manager decides to reroute all source
outputs. The non-monitor source that the Bluetooth card created hasn't
been linked yet at this stage, because it will only be linked after
the sink and the monitor source have been linked. So,
module-device-manager should take into account during the rerouting
that not all sinks and sources are necessarily linked. This patch does
that.

Reported-By: Iskren Hadzhinedev <i.hadzhinedev@gmail.com>
2014-01-26 21:20:31 +02:00
Daniel Albers
6b82c6122b combine-sink: fix segfault 2014-01-17 12:21:39 +02:00