If the keyboard is unplugged, it looks like the kernel is reporting
back -ENODEV when trying to close the fd. This is probably a kernel
error, but still, it's better to complain than to crash.
Buglink: https://bugs.freedesktop.org/show_bug.cgi?id=80867
Reported-by: Stelios Bounanos
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
It is possible that the chosen active_port doesn't equal
new_data->active_port, using p->name is more accurate.
Please refer to sink_new_hook_callback()
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Now a2dp and hsp sinks and sources will have different names which means that
applications and other modules can use sink/source to distinguish selected
profile.
Module module-device-restore uses sink/source name and port name as identifier,
so if different profiles have different names module-device-restore can store
volume settings for each profile.
So with this patch it is possible to configure different volume settings for
a2dp and hsp profiles.
This patch does not change port names so gnome applications will be happy.
Note that similar patch is needed also for bluez5, but I'm not using bluez5
so I cannot write or test it.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
On a machine without fixed connecting audio devices like internal
microphone or internal speaker, and when there is no external audio
devices plugging in, the default source/sink is alsa_input/alsa_output
and there is no input devices/output devices listed in the gnome
sound-setting.
Under this situation, if we connect a bluetooth headset, the gnome
sound-setting will list bluez input/output devices, but they are not
active devices by default. This looks very weird that sound-setting
lists only one input device and one output device, but they are not
active. To change this situation, we add an argument, the policy is
if a new source/sink is connected and current default source/sink's
active_port is AVAILABLE_NO, we let the new added one switch to
default one.
BugLink: http://bugs.launchpad.net/bugs/1369476
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Calling the callback while setting it up can make things
complicated for clients, as the callback can do arbitrarily
things.
In this case, a protocol error caused the srbchannel to be
owned by both the pstream and the native connection.
Now the read callback is deferred, making sure the callback
is called from a cleaner context where errors are handled
appropriately.
Reported-by: Tanu Kaskinen <tanu.kaskinen@linux.intel.com>
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
As a third parameter, add the number of samples to read/write in
every iteration. This will help slow CPUs.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
This allow 'off' profile to be choosen when no other profile is available
which is considered better since it requires less resources than other
profiles.
Now that we have switched to using the mixer handle only,
there is no use for sending hctl handles around.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
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>