Use the new mixer API to get callbacks, instead of using the hctl
API. Using the hctl API caused a memory leak, because alsa-lib itself
used the hctl callbacks, which we were previously overriding.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Instead of using the hctl interface, we can find controls belonging
to other iface types than "mixer". We do this by introducing a new
mixer class "SND_MIXER_ELEM_PULSEAUDIO" and create snd_mixer_elem's
for all PCM and CARD iface types (as Jacks are of the CARD type and
ELD controls are of the PCM type).
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Register as a HandsfreeAudioAgent with oFono during backend
initialization and unregiter during backend finalization. This commit
also adds a check when receiving method calls or signals to make sure
the sender matches with the D-Bus service we're registered with.
The remapper and channel mixing code have (faster) specialized and (slower)
generic code certain code path. The flag force_generic_code can be set to
force the generic code path which is useful for testing. Code duplication
(such as in mix-special-test) can be avoided, cleanup patches follow.
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
New function allows to pass data pointer that is a member
of the outer structure that need to be freed too when data
is not needed anymore.
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
Recognize the Dock headphone jack in the same way the normal & front
headphone jacks are detected.
Reviewed-by: David Henningsson <david.henningsson@canonical.com>
Usually, PA will use the PULSE_SERVER X11 property instead of using XDG_RUNTIME_DIR,
so this environment variable does not matter.
If this property is not available, or if one is using the pacmd cli protocol,
the client will go ahead and call pa_make_secure_dir on XDG_RUNTIME_DIR/pulse.
This will either fail (if you're another regular user), or succeed (if you're root).
Both scenarios are bad - failing will cause the connection to fail, and succeeding
is even worse, as it can cause *other* connections to fail (as the directory
ownership has changed).
Instead fail and complain loudly.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=83007
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Valgrind is not correctly handling ALSA TLV syscalls, which leads
to false warnings, looking like this:
"Conditional jump or move depends on uninitialised value(s)"
Unfortunately, alsa-lib itself also uses these values which valgrind
falsely believe are uninitialized, so not all warnings are removed,
but this is what we can do from PA until the valgrind bug is fixed.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
In the (theoretical) case that no other elements exists but
"Line HP Swap", the presence of that element signals that there are
headphone and line-out outputs, otherwise there would be nothing to
swap.
building PA with -O0 leads to test failure in mix-test on i386
issue reported by Felipe, see
http://lists.freedesktop.org/archives/pulseaudio-discuss/2014-August/021406.html
the problem is the value 0xbeffbd7f: when byte-swapped it becomes 0x7fbdffbe and according
to IEEE-754 represents a signalling NaN (starting with s111 1111 10, see http://en.wikipedia.org/wiki/NaN)
when this value is assigned to a floating point register, it becomes 0x7ffdffbe, representing
a quiet NaN (starting with s111 1111 11) -- a signalling NaN is turned into a quiet NaN!
so PA_FLOAT32_SWAP(PA_FLOAT32_SWAP(x)) != x for certain values, uhuh!
the following test code can be used; due to volatile, it will always demonstrate the issue;
without volatile, it depends on the optimization level (i386, 32-bit, gcc 4.9):
// snip
static inline float PA_FLOAT32_SWAP(float x) {
union {
float f;
uint32_t u;
} t;
t.f = x;
t.u = bswap_32(t.u);
return t.f;
}
int main() {
unsigned x = 0xbeffbd7f;
volatile float f = PA_FLOAT32_SWAP(*(float *)&x);
printf("%08x %08x %08x %f\n", 0xbeffbd7f, *(unsigned *)&f, bswap_32(*(unsigned *)&f), f);
}
// snip
the problem goes away with optimization when no temporary floating point registers are used
the proposed solution is to avoid passing swapped floating point data in a
float; this is done with new functions PA_READ_FLOAT32RE() and PA_WRITE_FLOAT32RE()
which use uint32_t to dereference a pointer and byte-swap the data, hence no temporary
float variable is used
also delete PA_FLOAT32_TO_LE()/_BE(), not used
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Reported-by: Felipe Sateler <fsateler@debian.org>
Debian/kFreeBSD 9.2 comes with sys/capability.h but it is not usable; work around it
the patch does several things:
* it makes the comment point to the correct bugtracker issue: https://bugs.freedesktop.org/show_bug.cgi?id=72580
* it handles Debian/kFreeBSD the same way as FreeBSD
* it logs a warning that capabilities are actually NOT dropped
daemon/caps.c: In function ‘pa_drop_caps’:
daemon/caps.c:93:2: error: #error "Don't know how to do capabilities on your system. Please send a patch."
#error "Don't know how to do capabilities on your system. Please send a patch."
^
Makefile:9575: recipe for target 'daemon/pulseaudio-caps.o' failed
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Since we don't have "limited" clients, a client that authenticates
correctly is automatically authorized. However, it's the authentication
that can go wrong, rather than the authorization.
Buglink: https://bugs.freedesktop.org/show_bug.cgi?id=78566
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Debug and info messages are primarily meant for developers,
rather than end users. Let's save translators' time,
and leave them untranslated.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Module-device-restore sets reference_volume, but soft_volume remains at
zero dB, so if a device only has soft_volume (i e no hw volume controls),
its volume was not restored correctly.
Reported-by: Richardo Salveti de Araujo <ricardo.salveti@canonical.com>
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
If the transport for the profile doesn't exist, the old behaviour was
to leave cp->available at the default value, which is
PA_AVAILABLE_UNKNOWN, but if there's no transport, the profile should
be marked as unavailable.
Since the RAOP sink supports only some formats and channel counts, we
shouldn't blindly use pa_core.default_sample_spec. This patch changes
things so that we default to PA_SAMPLE_S16NE and 2 channels, and only
take the sample rate from pa_core.default_sample_spec.