Re: [pulseaudio-discuss] alignment trap and pulseaudio being kiled

2011-04-05 Thread Daniel Mack
On Mon, Apr 4, 2011 at 8:45 PM, Baek Chang baek...@ccrma.stanford.edu wrote:
 Hi,
 Trying to debug pulseaudio 0.9.22 and I am seeing some alignment trap
 warnings from kernel
 [ 1564.095562] Alignment trap: alsa-sink (5580) PC=0x2ab2ca3c
 Instr=0xe1ca00d0 Address=0x2af9302a FSR 0x011
 [ 1564.095597] Alignment trap: alsa-sink (5580) PC=0x2ab2ca68
 Instr=0xe0ca00f8 Address=0x2af9302a FSR 0x811
 [ 1564.113377] Alignment trap: alsa-sink (5580) PC=0x2ab2ca3c
 Instr=0xe1ca00d0 Address=0x2af93032 FSR 0x011
 [ 1564.122811] Alignment trap: alsa-sink (5580) PC=0x2ab2ca68
 Instr=0xe0ca00f8 Address=0x2af93032 FSR 0x811
 [ 1564.132240] Alignment trap: alsa-sink (5580) PC=0x2ab2ca3c
 Instr=0xe1ca00d0 Address=0x2af9303a FSR 0x011
 [ 1564.141703] Alignment trap: alsa-sink (5580) PC=0x2ab2ca68
 Instr=0xe0ca00f8 Address=0x2af9303a FSR 0x811
 [ 1564.151195] Alignment trap: alsa-sink (5580) PC=0x2ab2ca3c
 Instr=0xe1ca00d0 Address=0x2af93042 FSR 0x011
 [ 1564.160625] Alignment trap: alsa-sink (5580) PC=0x2ab2ca68
 Instr=0xe0ca00f8 Address=0x2af93042 FSR 0x811
 [ 1564.170065] Alignment trap: alsa-sink (5580) PC=0x2ab2ca3c
 Instr=0xe1ca00d0 Address=0x2af9304a FSR 0x011
 I tried connecting to gdb and reproducing the issue, the problem is that
 pulseaudio doesn't crash, but eventually terminates.
 Any ideas on how to debug this?

You can tell your kernel to terminate processes which cause an
alignment trap immediately: echo 5  /proc/cpu/alignment. That
should make gdb stop right at the instruction causing it. Also see
$kernelsrc/Documentation/arm/mem_alignment. But note that this setting
is for your whole system, and not done on a per-process level.

However, I dare to doubt that the alignment trap is your problem after
all. Such exceptions are normally just silently fixed in the
background, and the only effect you could possibly see is performance
drawbacks.  Anyway, it would be nice to fix them.

Daniel
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] alignment trap and pulseaudio being kiled

2011-04-05 Thread Arun Raghavan
On Tue, 2011-04-05 at 10:21 +0200, Daniel Mack wrote:
 On Mon, Apr 4, 2011 at 8:45 PM, Baek Chang baek...@ccrma.stanford.edu wrote:
  Hi,
  Trying to debug pulseaudio 0.9.22 and I am seeing some alignment trap
  warnings from kernel
  [ 1564.095562] Alignment trap: alsa-sink (5580) PC=0x2ab2ca3c
  Instr=0xe1ca00d0 Address=0x2af9302a FSR 0x011
  [ 1564.095597] Alignment trap: alsa-sink (5580) PC=0x2ab2ca68
  Instr=0xe0ca00f8 Address=0x2af9302a FSR 0x811
  [ 1564.113377] Alignment trap: alsa-sink (5580) PC=0x2ab2ca3c
  Instr=0xe1ca00d0 Address=0x2af93032 FSR 0x011
  [ 1564.122811] Alignment trap: alsa-sink (5580) PC=0x2ab2ca68
  Instr=0xe0ca00f8 Address=0x2af93032 FSR 0x811
  [ 1564.132240] Alignment trap: alsa-sink (5580) PC=0x2ab2ca3c
  Instr=0xe1ca00d0 Address=0x2af9303a FSR 0x011
  [ 1564.141703] Alignment trap: alsa-sink (5580) PC=0x2ab2ca68
  Instr=0xe0ca00f8 Address=0x2af9303a FSR 0x811
  [ 1564.151195] Alignment trap: alsa-sink (5580) PC=0x2ab2ca3c
  Instr=0xe1ca00d0 Address=0x2af93042 FSR 0x011
  [ 1564.160625] Alignment trap: alsa-sink (5580) PC=0x2ab2ca68
  Instr=0xe0ca00f8 Address=0x2af93042 FSR 0x811
  [ 1564.170065] Alignment trap: alsa-sink (5580) PC=0x2ab2ca3c
  Instr=0xe1ca00d0 Address=0x2af9304a FSR 0x011
  I tried connecting to gdb and reproducing the issue, the problem is that
  pulseaudio doesn't crash, but eventually terminates.
  Any ideas on how to debug this?
 
 You can tell your kernel to terminate processes which cause an
 alignment trap immediately: echo 5  /proc/cpu/alignment. That
 should make gdb stop right at the instruction causing it. Also see
 $kernelsrc/Documentation/arm/mem_alignment. But note that this setting
 is for your whole system, and not done on a per-process level.
 
 However, I dare to doubt that the alignment trap is your problem after
 all. Such exceptions are normally just silently fixed in the
 background, and the only effect you could possibly see is performance
 drawbacks.  Anyway, it would be nice to fix them.

Also, if you haven't already, do take a look at
http://pulseaudio.org/wiki/Community#BugsPatchesTranslations for
instructions on running PulseAudio in gdb.

-- Arun

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH] stream-restore: add version to new entry.

2011-04-05 Thread Tanu Kaskinen
From: Harri Mähönen ext-harri.maho...@nokia.com

---
 src/modules/module-stream-restore.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/modules/module-stream-restore.c 
b/src/modules/module-stream-restore.c
index 8edfee0..d27982b 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -650,6 +650,7 @@ static void handle_add_entry(DBusConnection *conn, 
DBusMessage *msg, void *userd
 pa_assert_se(pa_hashmap_put(u-dbus_entries, dbus_entry-entry_name, 
dbus_entry) == 0);
 
 e = pa_xnew0(struct entry, 1);
+e-version = ENTRY_VERSION;
 e-muted_valid = TRUE;
 e-volume_valid = !!map.channels;
 e-device_valid = !!device[0];
-- 
1.7.4.2

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] stream-restore: add version to new entry.

2011-04-05 Thread Colin Guthrie
'Twas brillig, and Tanu Kaskinen at 05/04/11 09:58 did gyre and gimble:
 From: Harri Mähönen ext-harri.maho...@nokia.com


Thanks, merged.

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] bluetooth-device: fix rounding errors caused by few bt volume steps

2011-04-05 Thread Colin Guthrie
'Twas brillig, and Juho Hämäläinen at 04/04/11 13:24 did gyre and gimble:
 
 When volume changes in bluetooth device PulseAudio volume is rounded
 one too low, so if bluetooth headset changes volume and that volume
 is immediately set again for bluetooth device, bluetooth step drifts
 lower all the time. Volume is incremented by one in the conversion so
 that we get right bluetooth step when re-applying volume.
 
 Signed-off-by: Juho Hämäläinen ext-juho.hamalai...@nokia.com
 ---
  src/modules/bluetooth/module-bluetooth-device.c |   48
 +-
  1 files changed, 37 insertions(+), 11 deletions(-)


I don't know the volume stuff very well, but I'll take your word for it!

Applied with a couple minor formatting tweaks (spacing and brackets)

Cheers

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH] call-state-tracker: New component.

2011-04-05 Thread Tanu Kaskinen
From: Tanu Kaskinen ext-tanu.kaski...@nokia.com

---
 src/Makefile.am|1 +
 src/pulsecore/call-state-tracker.c |  127 
 src/pulsecore/call-state-tracker.h |   54 +++
 3 files changed, 182 insertions(+), 0 deletions(-)
 create mode 100644 src/pulsecore/call-state-tracker.c
 create mode 100644 src/pulsecore/call-state-tracker.h

diff --git a/src/Makefile.am b/src/Makefile.am
index bdedded..85c5602 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -835,6 +835,7 @@ libpulsecore_@PA_MAJORMINOR@_la_SOURCES = \
pulsecore/asyncmsgq.c pulsecore/asyncmsgq.h \
pulsecore/asyncq.c pulsecore/asyncq.h \
pulsecore/auth-cookie.c pulsecore/auth-cookie.h \
+   pulsecore/call-state-tracker.c pulsecore/call-state-tracker.h \
pulsecore/cli-command.c pulsecore/cli-command.h \
pulsecore/cli-text.c pulsecore/cli-text.h \
pulsecore/client.c pulsecore/client.h \
diff --git a/src/pulsecore/call-state-tracker.c 
b/src/pulsecore/call-state-tracker.c
new file mode 100644
index 000..a605685
--- /dev/null
+++ b/src/pulsecore/call-state-tracker.c
@@ -0,0 +1,127 @@
+/***
+  This file is part of PulseAudio.
+
+  Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2.1 of the License,
+  or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include pulsecore/core.h
+#include pulsecore/hook-list.h
+#include pulsecore/log.h
+#include pulsecore/macro.h
+#include pulsecore/refcnt.h
+#include pulsecore/shared.h
+
+#include call-state-tracker.h
+
+struct pa_call_state_tracker {
+PA_REFCNT_DECLARE;
+
+pa_core *core;
+pa_bool_t active;
+pa_hook hooks[PA_CALL_STATE_HOOK_MAX];
+};
+
+static pa_call_state_tracker* call_state_tracker_new(pa_core *c) {
+pa_call_state_tracker *t;
+pa_call_state_hook_t h;
+
+pa_assert(c);
+
+t = pa_xnew0(pa_call_state_tracker, 1);
+PA_REFCNT_INIT(t);
+t-core = pa_core_ref(c);
+t-active = FALSE;
+
+for (h = 0; h  PA_CALL_STATE_HOOK_MAX; h++)
+pa_hook_init(t-hooks[h], t);
+
+pa_assert_se(pa_shared_set(c, call-state-tracker, t) = 0);
+
+return t;
+}
+
+pa_call_state_tracker *pa_call_state_tracker_get(pa_core *core) {
+pa_call_state_tracker *t;
+
+if ((t = pa_shared_get(core, call-state-tracker)))
+return pa_call_state_tracker_ref(t);
+
+return call_state_tracker_new(core);
+}
+
+pa_call_state_tracker *pa_call_state_tracker_ref(pa_call_state_tracker *t) {
+pa_assert(t);
+pa_assert(PA_REFCNT_VALUE(t) = 1);
+
+PA_REFCNT_INC(t);
+
+return t;
+}
+
+void pa_call_state_tracker_unref(pa_call_state_tracker *t) {
+pa_call_state_hook_t h;
+
+pa_assert(t);
+pa_assert(PA_REFCNT_VALUE(t) = 1);
+
+if (PA_REFCNT_DEC(t)  0)
+return;
+
+for (h = 0; h  PA_CALL_STATE_HOOK_MAX; h++)
+pa_hook_done(t-hooks[h]);
+
+pa_assert_se(pa_shared_remove(t-core, call-state-tracker) = 0);
+
+pa_core_unref(t-core);
+
+pa_xfree(t);
+}
+
+pa_bool_t pa_call_state_tracker_get_active(pa_call_state_tracker *t) {
+pa_assert(t);
+pa_assert(PA_REFCNT_VALUE(t) = 1);
+
+return t-active;
+}
+
+void pa_call_state_tracker_set_active(pa_call_state_tracker *t, pa_bool_t 
active) {
+pa_bool_t changed;
+
+pa_assert(t);
+pa_assert(PA_REFCNT_VALUE(t) = 1);
+
+changed = active != t-active;
+
+t-active = active;
+
+if (changed)
+pa_hook_fire(t-hooks[PA_CALL_STATE_HOOK_CHANGED], (void *) active);
+
+pa_log_debug(Call state set %s (%s), active ? active : inactive, 
changed ? changed : not changed);
+}
+
+pa_hook *pa_call_state_tracker_hooks(pa_call_state_tracker *t) {
+pa_assert(t);
+pa_assert(PA_REFCNT_VALUE(t) = 1);
+
+return t-hooks;
+}
diff --git a/src/pulsecore/call-state-tracker.h 
b/src/pulsecore/call-state-tracker.h
new file mode 100644
index 000..9a6c60b
--- /dev/null
+++ b/src/pulsecore/call-state-tracker.h
@@ -0,0 +1,54 @@
+#ifndef foocallstatetrackerhfoo
+#define foocallstatetrackerhfoo
+
+/***
+  This file is part of PulseAudio.
+
+  Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  

[pulseaudio-discuss] [PATCH] alsa-mixer: Add workaround for some USB headsets

2011-04-05 Thread David Henningsson
As I discussed with Tanu Kaskinen yesterday, we should do something 
about when one profile path prevents another from using the hw volume 
capabilities. However, with Ubuntu a few weeks from release, I went for 
the workaround approach and created a separate profile for the devices 
instead to minimise regression potential.

So, until this is fixed the right way, feel free to use the attached patch.

Bug reference: 
https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/671560


--
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic
From 6f41a4140013dac7737847bb5eddc78906eb09b7 Mon Sep 17 00:00:00 2001
From: David Henningsson david.hennings...@canonical.com
Date: Tue, 5 Apr 2011 11:37:59 +0200
Subject: [PATCH] alsa-mixer: Add workaround for some USB headsets

This is a workaround - these usb headsets have one output volume
control only, labeled Speaker. This causes the default profile
set to not control the volume at all, which is a bug. Workaround
that by creating a separate profile set.

Signed-off-by: David Henningsson david.hennings...@canonical.com
---
 src/Makefile.am|3 +-
 .../alsa/mixer/profile-sets/90-pulseaudio.rules|3 ++
 .../alsa/mixer/profile-sets/usb-headset.conf   |   35 
 3 files changed, 40 insertions(+), 1 deletions(-)
 create mode 100644 src/modules/alsa/mixer/profile-sets/usb-headset.conf

diff --git a/src/Makefile.am b/src/Makefile.am
index cc38db2..0a4862f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -115,7 +115,8 @@ ALSA_PROFILES = \
 		modules/alsa/mixer/profile-sets/native-instruments-audio4dj.conf \
 		modules/alsa/mixer/profile-sets/native-instruments-audio8dj.conf \
 		modules/alsa/mixer/profile-sets/native-instruments-traktorkontrol-s4.conf \
-		modules/alsa/mixer/profile-sets/native-instruments-korecontroller.conf
+		modules/alsa/mixer/profile-sets/native-instruments-korecontroller.conf \
+		modules/alsa/mixer/profile-sets/usb-headset.conf
 
 ALSA_PATHS = \
 		modules/alsa/mixer/paths/analog-input-aux.conf \
diff --git a/src/modules/alsa/mixer/profile-sets/90-pulseaudio.rules b/src/modules/alsa/mixer/profile-sets/90-pulseaudio.rules
index f964b00..ff91ccf 100644
--- a/src/modules/alsa/mixer/profile-sets/90-pulseaudio.rules
+++ b/src/modules/alsa/mixer/profile-sets/90-pulseaudio.rules
@@ -20,6 +20,9 @@ SUBSYSTEM!=sound, GOTO=pulseaudio_end
 ACTION!=change, GOTO=pulseaudio_end
 KERNEL!=card*, GOTO=pulseaudio_end
 
+SUBSYSTEMS==usb, ATTRS{idVendor}==046d, ATTRS{idProduct}==01ab, ENV{PULSE_PROFILE_SET}=usb-headset.conf
+SUBSYSTEMS==usb, ATTRS{idVendor}==046d, ATTRS{idProduct}==0a0c, ENV{PULSE_PROFILE_SET}=usb-headset.conf
+SUBSYSTEMS==usb, ATTRS{idVendor}==1395, ATTRS{idProduct}==0002, ENV{PULSE_PROFILE_SET}=usb-headset.conf
 SUBSYSTEMS==usb, ATTRS{idVendor}==17cc, ATTRS{idProduct}==1978, ENV{PULSE_PROFILE_SET}=native-instruments-audio8dj.conf
 SUBSYSTEMS==usb, ATTRS{idVendor}==17cc, ATTRS{idProduct}==0839, ENV{PULSE_PROFILE_SET}=native-instruments-audio4dj.conf
 SUBSYSTEMS==usb, ATTRS{idVendor}==17cc, ATTRS{idProduct}==baff, ENV{PULSE_PROFILE_SET}=native-instruments-traktorkontrol-s4.conf
diff --git a/src/modules/alsa/mixer/profile-sets/usb-headset.conf b/src/modules/alsa/mixer/profile-sets/usb-headset.conf
new file mode 100644
index 000..adf78d1
--- /dev/null
+++ b/src/modules/alsa/mixer/profile-sets/usb-headset.conf
@@ -0,0 +1,35 @@
+# This file is part of PulseAudio.
+#
+# PulseAudio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of the
+# License, or (at your option) any later version.
+#
+# PulseAudio is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with PulseAudio; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+
+; This is a workaround - these usb headsets have one output volume control only, labeled Speaker.
+; This causes the default profile set to not control the volume at all, which is a bug.
+
+[General]
+auto-profiles = yes
+
+[Mapping analog-mono]
+device-strings = hw:%f
+channel-map = mono
+paths-output = analog-output-speaker
+paths-input = analog-input analog-input-mic analog-input-linein analog-input-aux analog-input-video analog-input-tvtuner analog-input-fm analog-input-mic-line
+priority = 1
+
+[Mapping analog-stereo]
+device-strings = front:%f hw:%f
+channel-map = left,right
+paths-output = analog-output-speaker
+paths-input = analog-input analog-input-mic analog-input-linein analog-input-aux analog-input-video analog-input-tvtuner analog-input-fm analog-input-mic-line
+priority = 10
-- 
1.7.4.1


Re: [pulseaudio-discuss] [RFC PATCH] Log PCM samples to files

2011-04-05 Thread Becker, VincentX
To: Maarten Bosmans; General PulseAudio Discussion
Subject: Re: [pulseaudio-discuss] [RFC PATCH] Log PCM samples to files
2011/3/21 Vincent Becker vincentx.bec...@intel.com:
 Hi,

 I recently created a new PA module (module-log-pcm) which is able to
log PCM samples from any source/sink and its corresponding
outputs/inputs. For testing audio quality, checking signal processing
or
verifying the right implementation of a sound device mixed in PA,
application fields are many.

What is the use case you are specifically interested in?


Hi, I just wished to relive the announcement of creating a new module dedicated 
to log PCM samples. It could be interesting to make it part of Pulseaudio.  
It can be useful at anytime and provides complementary differences with parec. 
I know it can sound 'gadget' and not properly useful but for some architectures 
containing a lot of sinks/sources, it can log actually simultaneous living 
devices. Wow, at some point it can be worth it! The advantages of this feature 
are many and if needed, I can provide a fully documented manual for it.

Vincent
-
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: Les Montalets- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 0/6] alsa UCM integration

2011-04-05 Thread Margarita Olaya
Hi,

This set of patches shows the integration of pulseaudio with ALSA Use Case
Manager (UCM) - released in alsa-lib 1.0.24.

The approach is to use the module-alsa-card, where almost all the ALSA
stuff in done, to load the UCM per card, the UCM data is gotten after
parse the ucm verbs, this data is used to generate the new pulseaudio
profiles and basically each profile is linked to a verb.

This series also add support for jack insertion/removal detection.

Margarita Olaya Cabrera (6):
  alsa: add jack detection support
  alsa: make visible profile functions
  alsa: add ucm data structures
  alsa: add proplist ucm data
  alsa: create ucm profiles
  alsa: load jack detection module

 src/Makefile.am|9 +-
 src/modules/alsa/alsa-mixer.c  |   10 +-
 src/modules/alsa/alsa-mixer.h  |   51 +++
 src/modules/alsa/module-alsa-card.c|  657 +++-
 src/modules/alsa/module-alsa-jack-detect.c |  204 +
 src/modules/module-udev-detect.c   |  291 -
 src/pulse/proplist.h   |   27 ++
 src/pulsecore/core.h   |2 +
 src/pulsecore/jack-detect.h|   42 ++
 9 files changed, 1268 insertions(+), 25 deletions(-)
 create mode 100644 src/modules/alsa/module-alsa-jack-detect.c
 create mode 100644 src/pulsecore/jack-detect.h
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 1/6] alsa: add jack detection support

2011-04-05 Thread Margarita Olaya
This patch adds support for reading the status of sound card jack input
devices (i.e. jack insertion/removal detection).

A new module is created in order to monitor the status of sound card
jack insertion and removal events. It does this by creating a thread
that blocks on reading the sound card input event device and then firing
a hook that reports the jack status change.

Signed-off-by: Margarita Olaya Cabrera m...@slimlogic.co.uk
---
 src/Makefile.am|9 +-
 src/modules/alsa/module-alsa-jack-detect.c |  204 
 src/pulsecore/core.h   |2 +
 src/pulsecore/jack-detect.h|   42 ++
 4 files changed, 256 insertions(+), 1 deletions(-)
 create mode 100644 src/modules/alsa/module-alsa-jack-detect.c
 create mode 100644 src/pulsecore/jack-detect.h

diff --git a/src/Makefile.am b/src/Makefile.am
index dc2a1cd..b475350 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1114,7 +1114,8 @@ modlibexec_LTLIBRARIES += \
libalsa-util.la \
module-alsa-sink.la \
module-alsa-source.la \
-   module-alsa-card.la
+   module-alsa-card.la \
+   module-alsa-jack-detect.la

 dist_alsaprofilesets_DATA = \
modules/alsa/mixer/profile-sets/default.conf \
@@ -1303,6 +1304,7 @@ SYMDEF_FILES = \
module-alsa-sink-symdef.h \
module-alsa-source-symdef.h \
module-alsa-card-symdef.h \
+   modules/alsa/module-alsa-jack-detect-symdef.h\
module-coreaudio-detect-symdef.h \
module-coreaudio-device-symdef.h \
module-solaris-symdef.h \
@@ -1616,6 +1618,11 @@ module_alsa_card_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_alsa_card_la_LIBADD = $(MODULE_LIBADD) $(ASOUNDLIB_LIBS) libalsa-util.la
 module_alsa_card_la_CFLAGS = $(AM_CFLAGS) $(ASOUNDLIB_CFLAGS)

+module_alsa_jack_detect_la_SOURCES = modules/alsa/module-alsa-jack-detect.c
+module_alsa_jack_detect_la_LDFLAGS = $(MODULE_LDFLAGS)
+module_alsa_jack_detect_la_LIBADD = $(MODULE_LIBADD)
$(ASOUNDLIB_LIBS) libalsa-util.la
+module_alsa_jack_detect_la_CFLAGS = $(AM_CFLAGS) $(ASOUNDLIB_CFLAGS)
+
 # Solaris

 module_solaris_la_SOURCES = modules/module-solaris.c
diff --git a/src/modules/alsa/module-alsa-jack-detect.c
b/src/modules/alsa/module-alsa-jack-detect.c
new file mode 100644
index 000..4635dc4
--- /dev/null
+++ b/src/modules/alsa/module-alsa-jack-detect.c
@@ -0,0 +1,204 @@
+/***
+ This file is part of PulseAudio.
+
+ Copyright 2011 Wolfson Microelectronics PLC
+ Author Margarita Olaya m...@slimlogic.co.uk
+
+ PulseAudio is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License,
+ or (at your option) any later version.
+
+ PulseAudio is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with PulseAudio; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+
+ Jack detect integration was kindly sponsored by Wolfson Microelectronics PLC.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include pulse/xmalloc.h
+#include pulsecore/core-util.h
+#include pulsecore/modargs.h
+#include pulsecore/jack-detect.h
+#include pulse/proplist.h
+
+#include alsa-util.h
+#include sys/types.h
+#include sys/stat.h
+#include fcntl.h
+#include unistd.h
+#include sys/ioctl.h
+#include linux/input.h
+#include pthread.h
+
+#include module-alsa-jack-detect-symdef.h
+
+PA_MODULE_AUTHOR(Margarita Olaya);
+PA_MODULE_DESCRIPTION(ALSA Jack Detect);
+PA_MODULE_VERSION(PACKAGE_VERSION);
+PA_MODULE_LOAD_ONCE(FALSE);
+PA_MODULE_USAGE(
+device_id=ALSA jack device 
+card_name=name for the card );
+
+static const char* const valid_modargs[] = {
+card_name,
+device_id,
+NULL
+};
+
+#define DEFAULT_DEVICE_ID 0
+
+struct userdata {
+pa_core *core;
+pa_module *module;
+
+char *device_id;
+int fd;
+
+char *card_name;
+pthread_t reader;
+};
+
+static void jack_report(struct userdata *u, struct input_event *event)
+{
+pa_jack_detect_t jack;
+
+jack.card = u-card_name;
+
+pa_log_debug(card %s event type %x code %x value %x,
u-card_name, event-code, event-type, event-value);
+
+/* only process switch events */
+if (event-type != EV_SW) {
+pa_log_debug(card %s ignored event type %x, u-card_name,
event-type);
+return;
+}
+
+switch (event-code) {
+case SW_HEADPHONE_INSERT:
+jack.event = PA_JACK_HEADPHONES;
+break;
+case SW_MICROPHONE_INSERT:
+jack.event = 

[pulseaudio-discuss] [PATCH 2/6] alsa: make visible profile functions

2011-04-05 Thread Margarita Olaya
Export the alsa-mixer mapping API so that it can be used by the UCM core
to create UCM mappings.

Signed-off-by: Margarita Olaya Cabrera m...@slimlogic.co.uk
---
 src/modules/alsa/alsa-mixer.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index f236da0..6e67dab 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -2979,7 +2979,7 @@ void pa_alsa_profile_set_free(pa_alsa_profile_set *ps) {
 pa_xfree(ps);
 }

-static pa_alsa_mapping *mapping_get(pa_alsa_profile_set *ps, const
char *name) {
+pa_alsa_mapping *mapping_get(pa_alsa_profile_set *ps, const char *name) {
 pa_alsa_mapping *m;

 if (!pa_startswith(name, Mapping ))
@@ -3434,7 +3434,7 @@ fail:
 return -1;
 }

-static int mapping_verify(pa_alsa_mapping *m, const pa_channel_map *bonus) {
+int mapping_verify(pa_alsa_mapping *m, const pa_channel_map *bonus) {

 static const struct description_map well_known_descriptions[] = {
 { analog-mono,N_(Analog Mono) },
@@ -3507,7 +3507,7 @@ void pa_alsa_mapping_dump(pa_alsa_mapping *m) {
  m-direction);
 }

-static void profile_set_add_auto_pair(
+void profile_set_add_auto_pair(
 pa_alsa_profile_set *ps,
 pa_alsa_mapping *m, /* output */
 pa_alsa_mapping *n  /* input */) {
@@ -3555,7 +3555,7 @@ static void profile_set_add_auto_pair(
 pa_hashmap_put(ps-profiles, p-name, p);
 }

-static void profile_set_add_auto(pa_alsa_profile_set *ps) {
+void profile_set_add_auto(pa_alsa_profile_set *ps) {
 pa_alsa_mapping *m, *n;
 void *m_state, *n_state;

@@ -3572,7 +3572,7 @@ static void
profile_set_add_auto(pa_alsa_profile_set *ps) {
 profile_set_add_auto_pair(ps, NULL, n);
 }

-static int profile_verify(pa_alsa_profile *p) {
+int profile_verify(pa_alsa_profile *p) {

 static const struct description_map well_known_descriptions[] = {
 { output:analog-mono+input:analog-mono, N_(Analog Mono
Duplex) },
-- 
1.7.1
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 3/6] alsa: add ucm data structures

2011-04-05 Thread Margarita Olaya
The UCM stores the mixer settings per use case in configuration files, these
files contains information such:
- list of use case verbs per card or machine
- supported devices per use case verb
- use case sink device
- use case source device
- hardware playback volume control id (per use case verb and device)
- hardware playback mute switch id
- hardware capture volume control id
- hardware capture mute switch id

The new ucm data structures are used to store that info so it can be used by
pulseaudio.

Signed-off-by: Margarita Olaya Cabrera m...@slimlogic.co.uk
---
 src/modules/alsa/alsa-mixer.h |   51 +
 1 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/src/modules/alsa/alsa-mixer.h b/src/modules/alsa/alsa-mixer.h
index a29aed1..072a7cb 100644
--- a/src/modules/alsa/alsa-mixer.h
+++ b/src/modules/alsa/alsa-mixer.h
@@ -24,6 +24,7 @@
 ***/

 #include asoundlib.h
+#include use-case.h

 #include pulse/sample.h
 #include pulse/volume.h
@@ -49,6 +50,10 @@ typedef struct pa_alsa_profile pa_alsa_profile;
 typedef struct pa_alsa_decibel_fix pa_alsa_decibel_fix;
 typedef struct pa_alsa_profile_set pa_alsa_profile_set;
 typedef struct pa_alsa_port_data pa_alsa_port_data;
+typedef struct pa_alsa_ucm_verb pa_alsa_ucm_verb;
+typedef struct pa_alsa_ucm_modifier pa_alsa_ucm_modifier;
+typedef struct pa_alsa_ucm_device pa_alsa_ucm_device;
+typedef struct pa_alsa_ucm_config pa_alsa_ucm_config;

 #include alsa-util.h

@@ -87,6 +92,11 @@ typedef enum pa_alsa_direction {
 PA_ALSA_DIRECTION_INPUT
 } pa_alsa_direction_t;

+typedef enum pa_alsa_ucm_mapping_type {
+PA_ALSA_UCM_MAPPING_DEVICE,
+PA_ALSA_UCM_MAPPING_MODIFIER
+} pa_alsa_ucm_mapping_type_t;
+
 /* A setting combines a couple of options into a single entity that
  * may be selected. Only one setting can be active at the same
  * time. */
@@ -229,6 +239,10 @@ void pa_alsa_path_set_probe(pa_alsa_path_set *s,
snd_mixer_t *m, pa_bool_t ignor
 void pa_alsa_path_set_dump(pa_alsa_path_set *s);
 void pa_alsa_path_set_set_callback(pa_alsa_path_set *ps, snd_mixer_t
*m, snd_mixer_elem_callback_t cb, void *userdata);
 void pa_alsa_path_set_free(pa_alsa_path_set *s);
+pa_alsa_mapping *mapping_get(pa_alsa_profile_set *ps, const char *name);
+int mapping_verify(pa_alsa_mapping *m, const pa_channel_map *bonus);
+void profile_set_add_auto(pa_alsa_profile_set *ps);
+int profile_verify(pa_alsa_profile *p);

 struct pa_alsa_mapping {
 pa_alsa_profile_set *profile_set;
@@ -237,6 +251,7 @@ struct pa_alsa_mapping {
 char *description;
 unsigned priority;
 pa_alsa_direction_t direction;
+pa_alsa_ucm_mapping_type_t ucm_type;

 pa_channel_map channel_map;

@@ -329,4 +344,40 @@ struct pa_alsa_port_data {

 void pa_alsa_add_ports(pa_hashmap **p, pa_alsa_path_set *ps);

+/* UCM - Use Case Manager is available on some audio cards */
+
+typedef enum pa_alsa_ucm_status {
+PA_ALSA_UCM_DISABLED = 0,
+PA_ALSA_UCM_ENABLED,
+} pa_alsa_ucm_status_t;
+
+struct pa_alsa_ucm_device {
+PA_LLIST_FIELDS(pa_alsa_ucm_device);
+pa_proplist *proplist;
+pa_alsa_ucm_status_t status;
+};
+
+struct pa_alsa_ucm_modifier {
+PA_LLIST_FIELDS(pa_alsa_ucm_modifier);
+pa_proplist *proplist;
+pa_alsa_ucm_status_t status;
+};
+
+struct pa_alsa_ucm_verb {
+PA_LLIST_FIELDS(pa_alsa_ucm_verb);
+pa_proplist *proplist;
+pa_alsa_ucm_status_t status;
+PA_LLIST_HEAD(pa_alsa_ucm_device, devices);
+PA_LLIST_HEAD(pa_alsa_ucm_modifier, modifiers);
+};
+
+struct pa_alsa_ucm_config {
+snd_use_case_mgr_t *ucm_mgr;
+const char *verb_ini;
+const char *verb_new;
+pa_alsa_ucm_status_t status;
+
+PA_LLIST_HEAD(pa_alsa_ucm_verb, verbs);
+};
+
 #endif
-- 
1.7.1
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 4/6] alsa: add proplist ucm data

2011-04-05 Thread Margarita Olaya
UCM has various properties we would like to store in a proplist. Add
these properties to the proplist property types.

Signed-off-by: Margarita Olaya Cabrera m...@slimlogic.co.uk
---
 src/pulse/proplist.h |   27 +++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index 5db3ada..26429d7 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -245,6 +245,33 @@ PA_C_DECL_BEGIN
 /** For modules: a version string for the module. e.g. 0.9.15 */
 #define PA_PROP_MODULE_VERSION module.version

+/** For devices: List of verbs, devices or modifiers availables */
+#define PA_PROP_UCM_NAME   ucm.name
+
+/** For devices: List of supported devices per verb*/
+#define PA_PROP_UCM_DESCRIPTIONucm.description
+
+/** For devices: Playback device name e.g PlaybackPCM */
+#define PA_PROP_UCM_SINK   ucm.sink
+
+/** For devices: Capture device name e.g CapturePCM*/
+#define PA_PROP_UCM_SOURCE ucm.source
+
+/** For devices: Playback control volume ID string. e.g PlaybackVolume */
+#define PA_PROP_UCM_PLAYBACK_VOLUMEucm.playback.volume
+
+/** For devices: Playback switch e.g PlaybackSwitch */
+#define PA_PROP_UCM_PLAYBACK_SWITCHucm.playback.switch
+
+/** For devices: Capture controls volume ID string. e.g CaptureVolume */
+#define PA_PROP_UCM_CAPTURE_VOLUME ucm.capture.volume
+
+/** For devices: Capture switch e.g CaptureSwitch */
+#define PA_PROP_UCM_CAPTURE_SWITCH ucm.capture.switch
+
+/** For devices: Quality of Service */
+#define PA_PROP_UCM_QOSucm.qos
+
 /** A property list object. Basically a dictionary with ASCII strings
  * as keys and arbitrary data as values. \since 0.9.11 */
 typedef struct pa_proplist pa_proplist;
-- 
1.7.1
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 5/6] alsa: create ucm profiles

2011-04-05 Thread Margarita Olaya
This patch adds ALSA UCM (Use Case Manager) support to module alsa card.
It checks if UCM is available for each card and if found, scans each UCM
property verb, device and modifier for the card. It then then creates
mappings for each supported UCM verb and device so that changes to the
pulseaudio profile cause corresponding changes to the UCM verb and
device for the card.

This patch also adds hook for jack insertion and removal in order for
the UCM device to be changed upon a jack event.

Signed-off-by: Margarita Olaya Cabrera m...@slimlogic.co.uk
---
 src/modules/alsa/module-alsa-card.c |  657 ++-
 1 files changed, 650 insertions(+), 7 deletions(-)

diff --git a/src/modules/alsa/module-alsa-card.c
b/src/modules/alsa/module-alsa-card.c
index e60aa5e..8794c7c 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -106,12 +106,207 @@ struct userdata {
 pa_modargs *modargs;

 pa_alsa_profile_set *profile_set;
+
+pa_alsa_ucm_config ucm;
+
+pa_hook_slot
+*jack_insert_new_hook_slot,
+*jack_remove_new_hook_slot;
 };

 struct profile_data {
 pa_alsa_profile *profile;
 };

+struct ucm_items {
+const char *id;
+const char *property;
+};
+
+struct ucm_info {
+const char *id;
+int priority;
+pa_alsa_direction_t direction;
+int channels;
+};
+
+static struct ucm_items item[] = {
+{PlaybackPCM, PA_PROP_UCM_SINK},
+{CapturePCM, PA_PROP_UCM_SOURCE},
+{PlaybackVolume, PA_PROP_UCM_PLAYBACK_VOLUME},
+{PlaybackSwitch, PA_PROP_UCM_PLAYBACK_SWITCH},
+{CaptureVolume, PA_PROP_UCM_CAPTURE_VOLUME},
+{CaptureSwitch, PA_PROP_UCM_CAPTURE_SWITCH},
+{TQ, PA_PROP_UCM_QOS},
+{NULL, NULL},
+};
+
+/* UCM device info - this should eventually be part of policy manangement */
+static struct ucm_info dev_info[] = {
+{SND_USE_CASE_DEV_SPEAKER, 100, PA_ALSA_DIRECTION_OUTPUT, 2},
+{SND_USE_CASE_DEV_LINE, 100, PA_ALSA_DIRECTION_ANY, 2},
+{SND_USE_CASE_DEV_HEADPHONES, 100, PA_ALSA_DIRECTION_OUTPUT, 2},
+{SND_USE_CASE_DEV_HEADSET, 300, PA_ALSA_DIRECTION_ANY, 2},
+{SND_USE_CASE_DEV_HANDSET, 200, PA_ALSA_DIRECTION_ANY, 2},
+{SND_USE_CASE_DEV_BLUETOOTH, 400, PA_ALSA_DIRECTION_ANY, 1},
+{SND_USE_CASE_DEV_EARPIECE, 100, PA_ALSA_DIRECTION_OUTPUT, 1},
+{SND_USE_CASE_DEV_SPDIF, 100, PA_ALSA_DIRECTION_ANY, 2},
+{SND_USE_CASE_DEV_HDMI, 100, PA_ALSA_DIRECTION_ANY, 8},
+{SND_USE_CASE_DEV_NONE, 100, PA_ALSA_DIRECTION_ANY, 2},
+{NULL, 0, PA_ALSA_DIRECTION_ANY, 0},
+};
+
+/* UCM profile properties - The verb data is store so it can be used to fill
+ * the new profiles properties */
+
+static int ucm_get_property(struct pa_alsa_ucm_verb *verb,
snd_use_case_mgr_t *uc_mgr, const char *verb_name) {
+const char *value;
+int i = 0;
+
+do {
+int err;
+
+err = snd_use_case_get(uc_mgr, item[i].id, value);
+if (err  0 ) {
+pa_log_info(No %s for verb %s, item[i].id, verb_name);
+continue;
+}
+
+pa_log_info(Got %s for verb %s, item[i].id, verb_name);
+pa_proplist_sets(verb-proplist, item[i].property, value);
+}  while (item[++i].id);
+
+return 0;
+};
+
+/* Create a property list for this ucm device */
+static int ucm_get_device_property(struct pa_alsa_ucm_device *device,
snd_use_case_mgr_t *uc_mgr, const char *device_name) {
+const char *value;
+char *id;
+int i = 0;
+
+do {
+int err;
+
+id = pa_sprintf_malloc(%s/%s, item[i].id, device_name);
+
+err = snd_use_case_get(uc_mgr, id, value);
+if (err  0 ) {
+pa_log_info(No %s for device %s, id, device_name);
+pa_xfree(id);
+continue;
+}
+
+pa_log_info(Got %s for device %s, id, device_name);
+pa_xfree(id);
+pa_proplist_sets(device-proplist, item[i].property, value);
+}  while (item[++i].id);
+
+return 0;
+};
+
+/* Create a property list for this ucm modifier */
+static int ucm_get_modifier_property(struct pa_alsa_ucm_modifier
*modifier, snd_use_case_mgr_t *uc_mgr, const char *modifier_name) {
+const char *value;
+char *id;
+int i = 0;
+
+do {
+int err;
+
+id = pa_sprintf_malloc(%s/%s, item[i].id, modifier_name);
+
+err = snd_use_case_get(uc_mgr, id, value);
+if (err  0 ) {
+pa_log_info(No %s for modifier %s, id, modifier_name);
+pa_xfree(id);
+continue;
+}
+
+pa_log_info(Got %s for modifier %s, id, modifier_name);
+pa_xfree(id);
+pa_proplist_sets(modifier-proplist, item[i].property, value);
+}  while (item[++i].id);
+
+return 0;
+};
+
+/* Create a list of devices for this verb */
+static int ucm_get_devices(struct pa_alsa_ucm_verb *verb,
snd_use_case_mgr_t *uc_mgr) {
+const char **dev_list;
+int num_dev, i;
+
+num_dev = snd_use_case_get_list(uc_mgr, _devices, dev_list);
+if 

[pulseaudio-discuss] [PATCH 6/6] alsa: load jack detection module

2011-04-05 Thread Margarita Olaya
This patch adds support for udev detection of sound card jack event
devices.

The udev methods used to detect ALSA sound cards and sound card input
devices (for jack insertion/removal) are similar and we duplicate the
method in order to detect whether a sound card also has an associated
input event device to report jack status.

If we find a sound card input device, we then load the jack detection
module and pass in details of the newly discovered input device.

Signed-off-by: Margarita Olaya Cabrera m...@slimlogic.co.uk
---
 src/modules/module-udev-detect.c |  291 --
 1 files changed, 279 insertions(+), 12 deletions(-)

diff --git a/src/modules/module-udev-detect.c b/src/modules/module-udev-detect.c
index 63ad195..be7a2dc 100644
--- a/src/modules/module-udev-detect.c
+++ b/src/modules/module-udev-detect.c
@@ -60,6 +60,7 @@ struct device {
 struct userdata {
 pa_core *core;
 pa_hashmap *devices;
+pa_hashmap *input_devices;

 pa_bool_t use_tsched:1;
 pa_bool_t ignore_dB:1;
@@ -71,6 +72,9 @@ struct userdata {

 int inotify_fd;
 pa_io_event *inotify_io;
+
+int inotify_input_fd;
+pa_io_event *inotify_input_io;
 };

 static const char* const valid_modargs[] = {
@@ -81,6 +85,7 @@ static const char* const valid_modargs[] = {
 };

 static int setup_inotify(struct userdata *u);
+static int setup_input_notify(struct userdata *u);

 static void device_free(struct device *d) {
 pa_assert(d);
@@ -163,6 +168,21 @@ static pa_bool_t pcm_is_modem(const char
*card_idx, const char *pcm) {
 return is_modem;
 }

+static const char *path_get_input_id(const char *path) {
+const char *e;
+
+if (!path)
+return NULL;
+
+if (!(e = strrchr(path, '/')))
+return NULL;
+
+if (!pa_startswith(e, /event))
+return NULL;
+
+return e + 6;
+}
+
 static pa_bool_t is_card_busy(const char *id) {
 char *card_path = NULL, *pcm_path = NULL, *sub_status = NULL;
 DIR *card_dir = NULL, *pcm_dir = NULL;
@@ -352,6 +372,40 @@ static void verify_access(struct userdata *u,
struct device *d) {
 }
 }

+static void verify_input_access(struct userdata *u, struct device *d) {
+char *cd;
+char *args;
+pa_card *card;
+pa_bool_t accessible;
+
+pa_assert(u);
+pa_assert(d);
+
+cd = pa_sprintf_malloc(%s/input/event%s,
udev_get_dev_path(u-udev), path_get_input_id(d-path));
+accessible = access(cd, R_OK) = 0;
+pa_log_debug(%s is accessible: %s, cd, pa_yes_no(accessible));
+
+if (d-module == PA_INVALID_INDEX) {
+
+/* If we are not loaded, try to load */
+if (accessible) {
+pa_module *m;
+
+args = pa_sprintf_malloc(device_id=\%s\
+card_name=\%s\ , cd, d-card_name);
+
+pa_log_debug(Loading module-alsa-jack detect with
arguments '%s', args);
+m = pa_module_load(u-core, module-alsa-jack-detect, args);
+if (m) {
+  d-module = m-index;
+  pa_log_info(Card %s (%s) jack module loaded.,
d-path, d-card_name);
+} else
+  pa_log_info(Card %s (%s) failed to load jack
module., d-path, d-card_name);
+}
+}
+pa_xfree(cd);
+}
+
 static void card_changed(struct userdata *u, struct udev_device *dev) {
 struct device *d;
 const char *path;
@@ -364,6 +418,8 @@ static void card_changed(struct userdata *u,
struct udev_device *dev) {
 /* Maybe /dev/snd is now available? */
 setup_inotify(u);

+setup_input_notify(u);
+
 path = udev_device_get_devpath(dev);

 if ((d = pa_hashmap_get(u-devices, path))) {
@@ -421,6 +477,53 @@ static void remove_card(struct userdata *u,
struct udev_device *dev) {
 device_free(d);
 }

+static void input_changed(struct userdata *u, struct udev_device *dev) {
+struct device *d;
+const char *path;
+const char *t;
+char *n;
+
+pa_assert(u);
+pa_assert(dev);
+
+/* Maybe /dev/snd is now available? */
+setup_inotify(u);
+
+setup_input_notify(u);
+
+path = udev_device_get_devpath(dev);
+
+if ((d = pa_hashmap_get(u-input_devices, path))) {
+verify_input_access(u, d);
+return;
+}
+
+d = pa_xnew0(struct device, 1);
+d-path = pa_xstrdup(path);
+d-module = PA_INVALID_INDEX;
+PA_INIT_RATELIMIT(d-ratelimit, 10*PA_USEC_PER_SEC, 5);
+pa_hashmap_put(u-input_devices, d-path, d);
+
+verify_input_access(u, d);
+}
+
+static void remove_input(struct userdata *u, struct udev_device *dev) {
+struct device *d;
+
+pa_assert(u);
+pa_assert(dev);
+
+if (!(d = pa_hashmap_remove(u-input_devices,
udev_device_get_devpath(dev
+return;
+
+pa_log_info(Input %s removed., d-path);
+
+if (d-module != PA_INVALID_INDEX)
+pa_module_unload_request_by_index(u-core, d-module, TRUE);
+
+device_free(d);
+}
+
 static void process_device(struct userdata *u, struct udev_device *dev) {
 const char 

Re: [pulseaudio-discuss] [PATCH] call-state-tracker: New component.

2011-04-05 Thread Colin Guthrie
'Twas brillig, and Tanu Kaskinen at 05/04/11 12:43 did gyre and gimble:
 From: Tanu Kaskinen ext-tanu.kaski...@nokia.com

The commit message is a little bit lacking Can you describe this a
bit and it's use cases etc. etc.?

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] alsa-mixer: Add workaround for some USB headsets

2011-04-05 Thread Colin Guthrie
'Twas brillig, and David Henningsson at 05/04/11 13:03 did gyre and gimble:
 As I discussed with Tanu Kaskinen yesterday, we should do something
 about when one profile path prevents another from using the hw volume
 capabilities. However, with Ubuntu a few weeks from release, I went for
 the workaround approach and created a separate profile for the devices
 instead to minimise regression potential.
 So, until this is fixed the right way, feel free to use the attached patch.
 
 Bug reference:
 https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/671560

While I appreciate this is a work around, is it worth committing
(especially to stable-queue) in the short term?

We'll likely push out stable-queue very soon. If you've got a fairly
recent snapshot for Ubuntu already, then bumping the version to 0.9.23
should be uncontroversial (tho' version bumps may still be banned by
policy regardless).

What do you think?

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] call-state-tracker: New component.

2011-04-05 Thread Maarten Bosmans
What are the users of this state tracker? Is it only some out-of-tree
Meego modules? Are you planning to submit those too? At least a
snippet of how it should be used would be nice.

If I read correctly it is a global boolean state tracker that is a
thin wrapper around pa_shared. Is it possible to add the update-hook
capability pa_shared and just use that from the modules. It would
probably mean a couple of lines more in the modules, but the
functionality in pulsecore would be more generic and more widely
usable then.

Maarten

2011/4/5 Tanu Kaskinen tanu.kaski...@digia.com:
 From: Tanu Kaskinen ext-tanu.kaski...@nokia.com

 ---
  src/Makefile.am                    |    1 +
  src/pulsecore/call-state-tracker.c |  127 
 
  src/pulsecore/call-state-tracker.h |   54 +++
  3 files changed, 182 insertions(+), 0 deletions(-)
  create mode 100644 src/pulsecore/call-state-tracker.c
  create mode 100644 src/pulsecore/call-state-tracker.h

 diff --git a/src/Makefile.am b/src/Makefile.am
 index bdedded..85c5602 100644
 --- a/src/Makefile.am
 +++ b/src/Makefile.am
 @@ -835,6 +835,7 @@ libpulsecore_@PA_MAJORMINOR@_la_SOURCES = \
                pulsecore/asyncmsgq.c pulsecore/asyncmsgq.h \
                pulsecore/asyncq.c pulsecore/asyncq.h \
                pulsecore/auth-cookie.c pulsecore/auth-cookie.h \
 +               pulsecore/call-state-tracker.c pulsecore/call-state-tracker.h 
 \
                pulsecore/cli-command.c pulsecore/cli-command.h \
                pulsecore/cli-text.c pulsecore/cli-text.h \
                pulsecore/client.c pulsecore/client.h \
 diff --git a/src/pulsecore/call-state-tracker.c 
 b/src/pulsecore/call-state-tracker.c
 new file mode 100644
 index 000..a605685
 --- /dev/null
 +++ b/src/pulsecore/call-state-tracker.c
 @@ -0,0 +1,127 @@
 +/***
 +  This file is part of PulseAudio.
 +
 +  Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 +
 +  PulseAudio is free software; you can redistribute it and/or modify
 +  it under the terms of the GNU Lesser General Public License as published
 +  by the Free Software Foundation; either version 2.1 of the License,
 +  or (at your option) any later version.
 +
 +  PulseAudio is distributed in the hope that it will be useful, but
 +  WITHOUT ANY WARRANTY; without even the implied warranty of
 +  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 +  General Public License for more details.
 +
 +  You should have received a copy of the GNU Lesser General Public License
 +  along with PulseAudio; if not, write to the Free Software
 +  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 +  USA.
 +***/
 +
 +#ifdef HAVE_CONFIG_H
 +#include config.h
 +#endif
 +
 +#include pulsecore/core.h
 +#include pulsecore/hook-list.h
 +#include pulsecore/log.h
 +#include pulsecore/macro.h
 +#include pulsecore/refcnt.h
 +#include pulsecore/shared.h
 +
 +#include call-state-tracker.h
 +
 +struct pa_call_state_tracker {
 +    PA_REFCNT_DECLARE;
 +
 +    pa_core *core;
 +    pa_bool_t active;
 +    pa_hook hooks[PA_CALL_STATE_HOOK_MAX];
 +};
 +
 +static pa_call_state_tracker* call_state_tracker_new(pa_core *c) {
 +    pa_call_state_tracker *t;
 +    pa_call_state_hook_t h;
 +
 +    pa_assert(c);
 +
 +    t = pa_xnew0(pa_call_state_tracker, 1);
 +    PA_REFCNT_INIT(t);
 +    t-core = pa_core_ref(c);
 +    t-active = FALSE;
 +
 +    for (h = 0; h  PA_CALL_STATE_HOOK_MAX; h++)
 +        pa_hook_init(t-hooks[h], t);
 +
 +    pa_assert_se(pa_shared_set(c, call-state-tracker, t) = 0);
 +
 +    return t;
 +}
 +
 +pa_call_state_tracker *pa_call_state_tracker_get(pa_core *core) {
 +    pa_call_state_tracker *t;
 +
 +    if ((t = pa_shared_get(core, call-state-tracker)))
 +        return pa_call_state_tracker_ref(t);
 +
 +    return call_state_tracker_new(core);
 +}
 +
 +pa_call_state_tracker *pa_call_state_tracker_ref(pa_call_state_tracker *t) {
 +    pa_assert(t);
 +    pa_assert(PA_REFCNT_VALUE(t) = 1);
 +
 +    PA_REFCNT_INC(t);
 +
 +    return t;
 +}
 +
 +void pa_call_state_tracker_unref(pa_call_state_tracker *t) {
 +    pa_call_state_hook_t h;
 +
 +    pa_assert(t);
 +    pa_assert(PA_REFCNT_VALUE(t) = 1);
 +
 +    if (PA_REFCNT_DEC(t)  0)
 +        return;
 +
 +    for (h = 0; h  PA_CALL_STATE_HOOK_MAX; h++)
 +        pa_hook_done(t-hooks[h]);
 +
 +    pa_assert_se(pa_shared_remove(t-core, call-state-tracker) = 0);
 +
 +    pa_core_unref(t-core);
 +
 +    pa_xfree(t);
 +}
 +
 +pa_bool_t pa_call_state_tracker_get_active(pa_call_state_tracker *t) {
 +    pa_assert(t);
 +    pa_assert(PA_REFCNT_VALUE(t) = 1);
 +
 +    return t-active;
 +}
 +
 +void pa_call_state_tracker_set_active(pa_call_state_tracker *t, pa_bool_t 
 active) {
 +    pa_bool_t changed;
 +
 +    pa_assert(t);
 +    pa_assert(PA_REFCNT_VALUE(t) = 1);
 +
 +    changed = active != t-active;
 +
 +    t-active = active;
 +
 +    if (changed)
 +        pa_hook_fire(t-hooks[PA_CALL_STATE_HOOK_CHANGED], (void *)