[pulseaudio-discuss] Interested in contributing to PulseAudio through GSOC 2013

2013-04-16 Thread Shuai Fan

Hi all,
   I'd like to introduce myself to the dev community. I am Shuai Fan, a 
student from Dalian University of Technology, China. And I am interested 
in working with PulseAudio project in GSOC2013.
   I'm interested in the idea Better JACK Configurability. Maybe I 
could have a try.
   But I have some problems with this project. I downloaded the source 
code of pulseaudio and pavucontrol through git repository. however, 
there is no configure in the root folder of pulseaudio. Could you tell 
me which branch should I merged into my workspace? And how can I get 
started with this project? Thanks in advance.



Best wishes,
   Shuai

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] /.libs/.libs/ gotcha

2013-04-16 Thread David Henningsson
When running PA manually, you probably specify -p $(pwd)/src/.libs. I 
have started to get error messages from PulseAudio about this, but I 
don't remember exactly when. Perhaps ltdl has recently been updated, or 
have we?


The gotcha is: ltdl seems to add another .libs and tries it first. As 
a result, we get a callback to bind_now_open with 
src/.libs/.libs/module.so, which we don't find and complain loudly. 
Ltdl gladly accepts this and tries instead with src/.libs/module.so, 
which succeeds.


I tried specifying -p $(pwd)/src instead, but that fails in another 
way: the .ifexists command in our CLI does not add a .libs the way 
ltdl does, so the result is fewer errors, but then, it only loads the 
required modules, and prefers module-detect over module-udev-detect, e 
g, which is quite broken.


Any thoughts on the topic? Should we add .libs too, when looking for 
files in .ifexists?
Or should we lower the severity of not finding modules? Perhaps write 
with debug severity instead, and do that regardless of if we loaded a 
module or not?


--
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] /.libs/.libs/ gotcha

2013-04-16 Thread Peter Meerwald

 When running PA manually, you probably specify -p $(pwd)/src/.libs. I have

see 25d8de9f0b788865cc966be709cb9ca815e6e4d7
doc: Fix suggested dl-search-path in README

 started to get error messages from PulseAudio about this, but I don't remember
 exactly when. Perhaps ltdl has recently been updated, or have we?

see da5f03b7f58264217c3f23881387129c953c1f0a
libtool 2.4 is now required

 I tried specifying -p $(pwd)/src instead, but that fails in another way: the
 .ifexists command in our CLI does not add a .libs the way ltdl does, so
 the result is fewer errors, but then, it only loads the required modules, and
 prefers module-detect over module-udev-detect, e g, which is quite broken.

-p $(pwd)/src worked for me, but maybe I did not look close enough

 Any thoughts on the topic? Should we add .libs too, when looking for files
 in .ifexists?
 Or should we lower the severity of not finding modules? Perhaps write with
 debug severity instead, and do that regardless of if we loaded a module or
 not?

regards, p.

-- 

Peter Meerwald
+43-664-218 (mobile)
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Interested in contributing to PulseAudio through GSOC 2013

2013-04-16 Thread Shuai Fan

On 04/16/2013 05:08 PM, Arun Raghavan wrote:

On Tue, 2013-04-16 at 15:21 +0800, Shuai Fan wrote:

Hi all,
 I'd like to introduce myself to the dev community. I am Shuai Fan, a
student from Dalian University of Technology, China. And I am interested
in working with PulseAudio project in GSOC2013.
 I'm interested in the idea Better JACK Configurability. Maybe I
could have a try.
 But I have some problems with this project. I downloaded the source
code of pulseaudio and pavucontrol through git repository. however,
there is no configure in the root folder of pulseaudio. Could you tell
me which branch should I merged into my workspace? And how can I get
started with this project? Thanks in advance.

This should help you get started:
http://colin.guthr.ie/2010/09/compiling-and-running-pulseaudio-from-git/

Cheers,
Arun



Hello, Arun
I followed the article and played a song successfully. But, I think 
something in that article should be modified.

The problem is:
[colin@jimmy build (master)]$ src/pulseaudio -n -F 
src/default.pa -p $(pwd)/src/.libs/ -

When I did like this, error found:
Failed to open module 
/padev/build/src/.libs/.libs/module-device-restore.so:


Then I changed the parameter -p $(pwd)/src/.libs/ to -p 
$(pwd)/src/, It works.
[colin@jimmy build (master)]$ src/pulseaudio -n -F 
src/default.pa -p $(pwd)/src/ -


So, I just thought, maybe this command should be changed.

Thanks very much for guiding me.

Best wishes,
Shuai

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH] alsa: Fix ELD access warning on shutdown

2013-04-16 Thread David Henningsson
The hdmi_eld_changed callback is called by alsa-lib at shutdown.
In that case, just exit instead of trying to access something with
already closed handles.

Signed-off-by: David Henningsson david.hennings...@canonical.com
---
 src/modules/alsa/module-alsa-card.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/modules/alsa/module-alsa-card.c 
b/src/modules/alsa/module-alsa-card.c
index 2529c0d..11197a8 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -409,6 +409,9 @@ static int hdmi_eld_changed(snd_hctl_elem_t *elem, unsigned 
int mask) {
 pa_hdmi_eld eld;
 bool changed = false;
 
+if (mask == SND_CTL_EVENT_MASK_REMOVE)
+return 0;
+
 p = find_port_with_eld_device(u-card-ports, device);
 if (p == NULL) {
 pa_log_error(Invalid device changed in ALSA: %d, device);
-- 
1.7.9.5

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] doc: Mostly fixing up i.e. versus i.e.\ in doxygen documentation

2013-04-16 Thread David Henningsson

On 04/10/2013 06:59 PM, Peter Meerwald wrote:

From: Peter Meerwald p.meerw...@bct-electronic.com

same for e.g. versus e.g.\ and e.g. versus E.g.

this is ueber-nitpicking: will anybody ever notice?


You did, apparently ;-)

Anyway, why should there be a \ after e.g.?



Signed-off-by: Peter Meerwald p.meerw...@bct-electronic.com
---
  src/pulse/channelmap.h |8 ++--
  src/pulse/proplist.h   |  114 
  src/pulse/sample.h |2 +-
  src/pulse/volume.h |4 +-
  4 files changed, 64 insertions(+), 64 deletions(-)

diff --git a/src/pulse/channelmap.h b/src/pulse/channelmap.h
index 8d62226..97e919d 100644
--- a/src/pulse/channelmap.h
+++ b/src/pulse/channelmap.h
@@ -331,23 +331,23 @@ int pa_channel_map_compatible(const pa_channel_map *map, 
const pa_sample_spec *s
  int pa_channel_map_superset(const pa_channel_map *a, const pa_channel_map *b) 
PA_GCC_PURE;

  /** Returns non-zero if it makes sense to apply a volume 'balance'
- * with this mapping, i.e. if there are left/right channels
+ * with this mapping, i.e.\ if there are left/right channels
   * available. \since 0.9.15 */
  int pa_channel_map_can_balance(const pa_channel_map *map) PA_GCC_PURE;

  /** Returns non-zero if it makes sense to apply a volume 'fade'
- * (i.e. 'balance' between front and rear) with this mapping, i.e. if
+ * (i.e.\ 'balance' between front and rear) with this mapping, i.e.\ if
   * there are front/rear channels available. \since 0.9.15 */
  int pa_channel_map_can_fade(const pa_channel_map *map) PA_GCC_PURE;

  /** Tries to find a well-known channel mapping name for this channel
- * mapping. I.e. stereo, surround-71 and so on. If the channel
+ * mapping, i.e.\ stereo, surround-71 and so on. If the channel
   * mapping is unknown NULL will be returned. This name can be parsed
   * with pa_channel_map_parse() \since 0.9.15 */
  const char* pa_channel_map_to_name(const pa_channel_map *map) PA_GCC_PURE;

  /** Tries to find a human readable text label for this channel
-mapping. I.e. Stereo, Surround 7.1 and so on. If the channel
+mapping, i.e.\ Stereo, Surround 7.1 and so on. If the channel
  mapping is unknown NULL will be returned. \since 0.9.15 */
  const char* pa_channel_map_to_pretty_name(const pa_channel_map *map) 
PA_GCC_PURE;

diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index cb53cf4..dc3cddc 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -33,25 +33,25 @@

  PA_C_DECL_BEGIN

-/** For streams: localized media name, formatted as UTF-8. e.g. Guns'N'Roses: 
Civil War.*/
+/** For streams: localized media name, formatted as UTF-8. E.g. Guns'N'Roses: 
Civil War.*/
  #define PA_PROP_MEDIA_NAME media.name

-/** For streams: localized media title if applicable, formatted as UTF-8. e.g. 
Civil War */
+/** For streams: localized media title if applicable, formatted as UTF-8. E.g. 
Civil War */
  #define PA_PROP_MEDIA_TITLEmedia.title

-/** For streams: localized media artist if applicable, formatted as UTF-8. e.g. 
Guns'N'Roses */
+/** For streams: localized media artist if applicable, formatted as UTF-8. E.g. 
Guns'N'Roses */
  #define PA_PROP_MEDIA_ARTIST   media.artist

-/** For streams: localized media copyright string if applicable, formatted as UTF-8. 
e.g. Evil Record Corp. */
+/** For streams: localized media copyright string if applicable, formatted as UTF-8. 
E.g. Evil Record Corp. */
  #define PA_PROP_MEDIA_COPYRIGHTmedia.copyright

-/** For streams: localized media generator software string if applicable, formatted as 
UTF-8. e.g. Foocrop AudioFrobnicator */
+/** For streams: localized media generator software string if applicable, formatted as 
UTF-8. E.g. Foocrop AudioFrobnicator */
  #define PA_PROP_MEDIA_SOFTWARE media.software

-/** For streams: media language if applicable, in standard POSIX format. e.g. 
de_DE */
+/** For streams: media language if applicable, in standard POSIX format. E.g. 
de_DE */
  #define PA_PROP_MEDIA_LANGUAGE media.language

-/** For streams: source filename if applicable, in URI format or local path. e.g. 
/home/lennart/music/foobar.ogg */
+/** For streams: source filename if applicable, in URI format or local path. E.g. 
/home/lennart/music/foobar.ogg */
  #define PA_PROP_MEDIA_FILENAME media.filename

  /** \cond fulldocs */
@@ -59,46 +59,46 @@ PA_C_DECL_BEGIN
  #define PA_PROP_MEDIA_ICON media.icon
  /** \endcond */

-/** For streams: an XDG icon name for the media. e.g. audio-x-mp3 */
+/** For streams: an XDG icon name for the media. E.g. audio-x-mp3 */
  #define PA_PROP_MEDIA_ICON_NAMEmedia.icon_name

  /** For streams: logic role of this media. One of the strings video, music, game, event, phone, 
animation, production, a11y, test */
  #define PA_PROP_MEDIA_ROLE media.role

-/** For streams: the name of a filter that is 

Re: [pulseaudio-discuss] [PATCH] doc: Mostly fixing up i.e. versus i.e.\ in doxygen documentation

2013-04-16 Thread Peter Meerwald

  same for e.g. versus e.g.\ and e.g. versus E.g.
  this is ueber-nitpicking: will anybody ever notice?

 You did, apparently ;-)
 Anyway, why should there be a \ after e.g.?

to be compliant with doxygen magic

doxygen assumes that the first sentence of a description (terminated by a 
'.') is kind-of a summary of the text; doxygen puts some extra space after 
the first sentence

if the first sentence reads
Bla bla e.g. bla bla.
then doxygen detects the end of the first sentence after 'e.g.' (the first 
'.' followed by whitespace)

Bla bla e.g.\ bla bla. fixes this; the end of the first sentence is now 
correctly detected after 'bla.'

regards, p.

-- 

Peter Meerwald
+43-664-218 (mobile)
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [RFC v2 00/15] bluetooth: BlueZ 5 development patches

2013-04-16 Thread Mikel Astiz
From: Mikel Astiz mikel.as...@bmw-carit.de

I resubmit this patchset as-is after updating it according to the latest 
upstream changes.

The patchset has been hanging around for a while and several efforts exist that 
depend on this series, so it seems we should merge this despite the existing 
discussions about how different backends (BlueZ 4, BlueZ 5, oFono, etc.) should 
be supported inside PulseAudio (next big patchset in the pipeline).

The last patch makes less sense right now (given that the Media API will not be 
used for HSP/HFP) but I'm sending the whole series for the sake of completeness.

Mikel Astiz (14):
  bluetooth: Detect BlueZ 5
  bluetooth: Parse the tree returned by ObjectManager
  bluetooth: Support ObjectManager interface add/remove
  bluetooth: Support Properties.PropertiesChanged signal
  bluetooth: Handle transports configured before UUID received
  bluetooth: BlueZ 5 interface rename to org.bluez.MediaEndpoint1
  bluetooth: BlueZ 5 interface rename to org.bluez.Media1
  bluetooth: BlueZ 5 interface rename to org.bluez.MediaTransport1
  bluetooth: Parse media transport's properties
  bluetooth: Support media transport's State property
  bluetooth: Update to new BlueZ 5 transport acquire/release API
  bluetooth: Support transport auto-release
  bluetooth: Update to new property setter API in BlueZ 5
  bluetooth: Update to volume control in BlueZ 5

Vinicius Costa Gomes (1):
  bluetooth: Add HFP 1.6 codec ID

 src/modules/bluetooth/bluetooth-util.c  | 573 ++--
 src/modules/bluetooth/module-bluetooth-device.c |   8 +-
 2 files changed, 526 insertions(+), 55 deletions(-)

-- 
1.8.1.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [RFC v2 02/15] bluetooth: Parse the tree returned by ObjectManager

2013-04-16 Thread Mikel Astiz
From: Mikel Astiz mikel.as...@bmw-carit.de

Parse the result of ObjectManager.GetManagedObjects(), which includes
all objects registered, their interfaces and the corresponding
properties per interface.
---
 src/modules/bluetooth/bluetooth-util.c | 120 +++--
 1 file changed, 114 insertions(+), 6 deletions(-)

diff --git a/src/modules/bluetooth/bluetooth-util.c 
b/src/modules/bluetooth/bluetooth-util.c
index 1883c8a..ebdb684 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -362,8 +362,6 @@ static int parse_device_property(pa_bluetooth_device *d, 
DBusMessageIter *i, boo
 
 dbus_message_iter_recurse(i, variant_i);
 
-/* pa_log_debug(Parsing property org.bluez.Device.%s, key); */
-
 switch (dbus_message_iter_get_arg_type(variant_i)) {
 
 case DBUS_TYPE_STRING: {
@@ -452,6 +450,11 @@ static int parse_device_property(pa_bluetooth_device *d, 
DBusMessageIter *i, boo
 uuiddata.uuid = value;
 
pa_hook_fire(d-discovery-hooks[PA_BLUETOOTH_HOOK_DEVICE_UUID_ADDED], 
uuiddata);
 
+if (d-discovery-version = BLUEZ_VERSION_5) {
+dbus_message_iter_next(ai);
+continue;
+}
+
 /* Vudentz said the interfaces are here when the UUIDs are 
announced */
 if (strcasecmp(HSP_AG_UUID, value) == 0 || 
strcasecmp(HFP_AG_UUID, value) == 0) {
 pa_assert_se(m = 
dbus_message_new_method_call(org.bluez, d-path, org.bluez.HandsfreeGateway,
@@ -867,16 +870,20 @@ static void register_endpoint(pa_bluetooth_discovery *y, 
const char *path, const
 send_and_add_to_pending(y, m, register_endpoint_reply, 
pa_xstrdup(endpoint));
 }
 
+static void register_adapter_endpoints(pa_bluetooth_discovery *y, const char 
*path) {
+register_endpoint(y, path, HFP_AG_ENDPOINT, HFP_AG_UUID);
+register_endpoint(y, path, HFP_HS_ENDPOINT, HFP_HS_UUID);
+register_endpoint(y, path, A2DP_SOURCE_ENDPOINT, A2DP_SOURCE_UUID);
+register_endpoint(y, path, A2DP_SINK_ENDPOINT, A2DP_SINK_UUID);
+}
+
 static void found_adapter(pa_bluetooth_discovery *y, const char *path) {
 DBusMessage *m;
 
 pa_assert_se(m = dbus_message_new_method_call(org.bluez, path, 
org.bluez.Adapter, GetProperties));
 send_and_add_to_pending(y, m, get_properties_reply, NULL);
 
-register_endpoint(y, path, HFP_AG_ENDPOINT, HFP_AG_UUID);
-register_endpoint(y, path, HFP_HS_ENDPOINT, HFP_HS_UUID);
-register_endpoint(y, path, A2DP_SOURCE_ENDPOINT, A2DP_SOURCE_UUID);
-register_endpoint(y, path, A2DP_SINK_ENDPOINT, A2DP_SINK_UUID);
+register_adapter_endpoints(y, path);
 }
 
 static void list_adapters(pa_bluetooth_discovery *y) {
@@ -887,10 +894,94 @@ static void list_adapters(pa_bluetooth_discovery *y) {
 send_and_add_to_pending(y, m, get_properties_reply, NULL);
 }
 
+static int parse_device_properties(pa_bluetooth_device *d, DBusMessageIter *i, 
bool is_property_change) {
+DBusMessageIter element_i;
+int ret = 0;
+
+dbus_message_iter_recurse(i, element_i);
+
+while (dbus_message_iter_get_arg_type(element_i) == DBUS_TYPE_DICT_ENTRY) 
{
+DBusMessageIter dict_i;
+
+dbus_message_iter_recurse(element_i, dict_i);
+
+if (parse_device_property(d, dict_i, is_property_change))
+ret = -1;
+
+dbus_message_iter_next(element_i);
+}
+
+if (!d-name || !d-address || !d-alias || d-paired  0 || d-trusted  
0) {
+pa_log_error(Non-optional information missing for device %s, 
d-path);
+d-device_info_valid = -1;
+return -1;
+}
+
+d-device_info_valid = 1;
+return ret;
+}
+
+static int parse_interfaces_and_properties(pa_bluetooth_discovery *y, 
DBusMessageIter *dict_i) {
+DBusMessageIter element_i;
+const char *path;
+
+pa_assert(dbus_message_iter_get_arg_type(dict_i) == DBUS_TYPE_OBJECT_PATH);
+dbus_message_iter_get_basic(dict_i, path);
+
+pa_assert_se(dbus_message_iter_next(dict_i));
+pa_assert(dbus_message_iter_get_arg_type(dict_i) == DBUS_TYPE_ARRAY);
+
+dbus_message_iter_recurse(dict_i, element_i);
+
+while (dbus_message_iter_get_arg_type(element_i) == DBUS_TYPE_DICT_ENTRY) 
{
+DBusMessageIter iface_i;
+const char *interface;
+
+dbus_message_iter_recurse(element_i, iface_i);
+
+pa_assert(dbus_message_iter_get_arg_type(iface_i) == 
DBUS_TYPE_STRING);
+dbus_message_iter_get_basic(iface_i, interface);
+
+pa_assert_se(dbus_message_iter_next(iface_i));
+pa_assert(dbus_message_iter_get_arg_type(iface_i) == DBUS_TYPE_ARRAY);
+
+if (pa_streq(interface, org.bluez.Adapter1)) {
+pa_log_debug(Adapter %s found, path);
+register_adapter_endpoints(y, path);
+} else if (pa_streq(interface, org.bluez.Device1)) {
+pa_bluetooth_device *d;
+
+if 

[pulseaudio-discuss] [RFC v2 03/15] bluetooth: Support ObjectManager interface add/remove

2013-04-16 Thread Mikel Astiz
From: Mikel Astiz mikel.as...@bmw-carit.de

Install matches for signals ObjectManager.InterfacesAdded and
ObjectManager.InterfacesRemoved, and process the devices that are
registered and unregistered dynamically.
---
 src/modules/bluetooth/bluetooth-util.c | 58 ++
 1 file changed, 58 insertions(+)

diff --git a/src/modules/bluetooth/bluetooth-util.c 
b/src/modules/bluetooth/bluetooth-util.c
index ebdb684..acf704a 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1204,6 +1204,60 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, 
DBusMessage *m, void *us
 goto fail;
 
 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+} else if (dbus_message_is_signal(m, org.freedesktop.DBus.ObjectManager, 
InterfacesAdded)) {
+DBusMessageIter arg_i;
+
+if (y-version != BLUEZ_VERSION_5)
+return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; /* No reply received 
yet from GetManagedObjects */
+
+if (!dbus_message_iter_init(m, arg_i) || 
!pa_streq(dbus_message_get_signature(m), oa{sa{sv}})) {
+pa_log(Invalid signature found in InterfacesAdded);
+goto fail;
+}
+
+if (parse_interfaces_and_properties(y, arg_i)  0)
+goto fail;
+
+return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+} else if (dbus_message_is_signal(m, org.freedesktop.DBus.ObjectManager, 
InterfacesRemoved)) {
+const char *path;
+DBusMessageIter arg_i;
+DBusMessageIter element_i;
+
+if (y-version != BLUEZ_VERSION_5)
+return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; /* No reply received 
yet from GetManagedObjects */
+
+if (!dbus_message_iter_init(m, arg_i) || 
!pa_streq(dbus_message_get_signature(m), oas)) {
+pa_log(Invalid signature found in InterfacesRemoved);
+goto fail;
+}
+
+dbus_message_iter_get_basic(arg_i, path);
+
+pa_assert_se(dbus_message_iter_next(arg_i));
+pa_assert(dbus_message_iter_get_arg_type(arg_i) == DBUS_TYPE_ARRAY);
+
+dbus_message_iter_recurse(arg_i, element_i);
+
+while (dbus_message_iter_get_arg_type(element_i) == DBUS_TYPE_STRING) 
{
+const char *interface;
+
+dbus_message_iter_get_basic(element_i, interface);
+
+if (pa_streq(interface, org.bluez.Device1)) {
+pa_bluetooth_device *d;
+
+if ((d = pa_hashmap_remove(y-devices, path))) {
+pa_log_debug(Device %s removed, d-path);
+run_callback(d, true);
+device_free(d);
+}
+}
+
+dbus_message_iter_next(element_i);
+}
+
+return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
 
 fail:
@@ -1856,6 +1910,8 @@ pa_bluetooth_discovery* 
pa_bluetooth_discovery_get(pa_core *c) {
 
type='signal',sender='org.bluez',interface='org.bluez.AudioSource',member='PropertyChanged',
 
type='signal',sender='org.bluez',interface='org.bluez.HandsfreeGateway',member='PropertyChanged',
 
type='signal',sender='org.bluez',interface='org.bluez.MediaTransport',member='PropertyChanged',
+
type='signal',sender='org.bluez',interface='org.freedesktop.DBus.ObjectManager',member='InterfacesAdded',
+
type='signal',sender='org.bluez',interface='org.freedesktop.DBus.ObjectManager',member='InterfacesRemoved',
 NULL)  0) {
 pa_log(Failed to add D-Bus matches: %s, err.message);
 goto fail;
@@ -1929,6 +1985,8 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery 
*y) {
 
type='signal',sender='org.bluez',interface='org.bluez.AudioSource',member='PropertyChanged',
 
type='signal',sender='org.bluez',interface='org.bluez.HandsfreeGateway',member='PropertyChanged',
 
type='signal',sender='org.bluez',interface='org.bluez.MediaTransport',member='PropertyChanged',
+
type='signal',sender='org.bluez',interface='org.freedesktop.DBus.ObjectManager',member='InterfacesAdded',
+
type='signal',sender='org.bluez',interface='org.freedesktop.DBus.ObjectManager',member='InterfacesRemoved',
 NULL);
 
 if (y-filter_added)
-- 
1.8.1.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [RFC v2 04/15] bluetooth: Support Properties.PropertiesChanged signal

2013-04-16 Thread Mikel Astiz
From: Mikel Astiz mikel.as...@bmw-carit.de

Install matches for signal Properties.PropertiesChanged and process the
properties corresponding to the tracked devices.
---
 src/modules/bluetooth/bluetooth-util.c | 29 +
 1 file changed, 29 insertions(+)

diff --git a/src/modules/bluetooth/bluetooth-util.c 
b/src/modules/bluetooth/bluetooth-util.c
index acf704a..e7dea39 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1258,6 +1258,33 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, 
DBusMessage *m, void *us
 }
 
 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+} else if (dbus_message_is_signal(m, org.freedesktop.DBus.Properties, 
PropertiesChanged)) {
+DBusMessageIter arg_i;
+const char *interface;
+
+if (y-version != BLUEZ_VERSION_5)
+return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; /* No reply received 
yet from GetManagedObjects */
+
+if (!dbus_message_iter_init(m, arg_i) || 
!pa_streq(dbus_message_get_signature(m), sa{sv}as)) {
+pa_log(Invalid signature found in PropertiesChanged);
+goto fail;
+}
+
+dbus_message_iter_get_basic(arg_i, interface);
+
+pa_assert_se(dbus_message_iter_next(arg_i));
+pa_assert(dbus_message_iter_get_arg_type(arg_i) == DBUS_TYPE_ARRAY);
+
+if (pa_streq(interface, org.bluez.Device1)) {
+pa_bluetooth_device *d;
+
+if (!(d = pa_hashmap_get(y-devices, dbus_message_get_path(m
+return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; /* Device not 
being tracked */
+
+parse_device_properties(d, arg_i, true);
+}
+
+return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
 
 fail:
@@ -1912,6 +1939,8 @@ pa_bluetooth_discovery* 
pa_bluetooth_discovery_get(pa_core *c) {
 
type='signal',sender='org.bluez',interface='org.bluez.MediaTransport',member='PropertyChanged',
 
type='signal',sender='org.bluez',interface='org.freedesktop.DBus.ObjectManager',member='InterfacesAdded',
 
type='signal',sender='org.bluez',interface='org.freedesktop.DBus.ObjectManager',member='InterfacesRemoved',
+
type='signal',sender='org.bluez',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged'
+,arg0='org.bluez.Device1',
 NULL)  0) {
 pa_log(Failed to add D-Bus matches: %s, err.message);
 goto fail;
-- 
1.8.1.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [RFC v2 05/15] bluetooth: Add HFP 1.6 codec ID

2013-04-16 Thread Mikel Astiz
From: Vinicius Costa Gomes vinicius.go...@openbossa.org

According to the HFP 1.6 spec, the default codec (CVSD) has ID 0x01.

This change has no effect in older versions of BlueZ since the codec ID
was ignored for HFP, due to the fact that HFP versions prior to 1.6 do
not have such a field.
---
 src/modules/bluetooth/bluetooth-util.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/modules/bluetooth/bluetooth-util.c 
b/src/modules/bluetooth/bluetooth-util.c
index e7dea39..eb504e5 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -827,7 +827,7 @@ finish:
 static void register_endpoint(pa_bluetooth_discovery *y, const char *path, 
const char *endpoint, const char *uuid) {
 DBusMessage *m;
 DBusMessageIter i, d;
-uint8_t codec = 0;
+uint8_t codec;
 
 pa_log_debug(Registering %s on adapter %s., endpoint, path);
 
@@ -843,14 +843,18 @@ static void register_endpoint(pa_bluetooth_discovery *y, 
const char *path, const
 
 pa_dbus_append_basic_variant_dict_entry(d, UUID, DBUS_TYPE_STRING, 
uuid);
 
-pa_dbus_append_basic_variant_dict_entry(d, Codec, DBUS_TYPE_BYTE, 
codec);
 
 if (pa_streq(uuid, HFP_AG_UUID) || pa_streq(uuid, HFP_HS_UUID)) {
 uint8_t capability = 0;
+
+codec = 1;
+
 pa_dbus_append_basic_array_variant_dict_entry(d, Capabilities, 
DBUS_TYPE_BYTE, capability, 1);
 } else {
 a2dp_sbc_t capabilities;
 
+codec = 0;
+
 capabilities.channel_mode = SBC_CHANNEL_MODE_MONO | 
SBC_CHANNEL_MODE_DUAL_CHANNEL |
 SBC_CHANNEL_MODE_STEREO | 
SBC_CHANNEL_MODE_JOINT_STEREO;
 capabilities.frequency = SBC_SAMPLING_FREQ_16000 | 
SBC_SAMPLING_FREQ_32000 |
@@ -865,6 +869,8 @@ static void register_endpoint(pa_bluetooth_discovery *y, 
const char *path, const
 pa_dbus_append_basic_array_variant_dict_entry(d, Capabilities, 
DBUS_TYPE_BYTE, capabilities, sizeof(capabilities));
 }
 
+pa_dbus_append_basic_variant_dict_entry(d, Codec, DBUS_TYPE_BYTE, 
codec);
+
 dbus_message_iter_close_container(i, d);
 
 send_and_add_to_pending(y, m, register_endpoint_reply, 
pa_xstrdup(endpoint));
-- 
1.8.1.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [RFC v2 06/15] bluetooth: Handle transports configured before UUID received

2013-04-16 Thread Mikel Astiz
From: Mikel Astiz mikel.as...@bmw-carit.de

Now that the transport can be configured from some other process (i.e.
oFono), there is no guarantee that the UUID from BlueZ will already have
been received.

This requires PulseAudio to assume that the UUID is actually supported
by the device and that BlueZ will eventually propagate it.
---
 src/modules/bluetooth/bluetooth-util.c | 53 ++
 1 file changed, 53 insertions(+)

diff --git a/src/modules/bluetooth/bluetooth-util.c 
b/src/modules/bluetooth/bluetooth-util.c
index eb504e5..f2de3c8 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -140,6 +140,33 @@ static int profile_from_interface(const char *interface, 
enum profile *p) {
 return -1;
 }
 
+static void profile_to_remote_uuid(enum profile p, const char *res[2]) {
+pa_assert(p != PROFILE_OFF);
+
+switch(p) {
+case PROFILE_A2DP:
+res[0] = A2DP_SINK_UUID;
+res[1] = NULL;
+return;
+case PROFILE_A2DP_SOURCE:
+res[0] = A2DP_SOURCE_UUID;
+res[1] = NULL;
+return;
+case PROFILE_HSP:
+res[0] = HSP_HS_UUID;
+res[1] = HFP_HS_UUID;
+return;
+case PROFILE_HFGW:
+res[0] = HSP_AG_UUID;
+res[1] = HFP_AG_UUID;
+return;
+case PROFILE_OFF:
+break;
+}
+
+pa_assert_not_reached();
+}
+
 static pa_bluetooth_transport_state_t 
audio_state_to_transport_state(pa_bt_audio_state_t state) {
 switch (state) {
 case PA_BT_AUDIO_STATE_INVALID: /* Typically if state hasn't been 
received yet */
@@ -1526,6 +1553,7 @@ static DBusMessage 
*endpoint_set_configuration(DBusConnection *conn, DBusMessage
 DBusMessageIter args, props;
 DBusMessage *r;
 bool old_any_connected;
+const char *remote_uuid[2];
 
 if (!dbus_message_iter_init(m, args) || 
!pa_streq(dbus_message_get_signature(m), oa{sv})) {
 pa_log(Invalid signature for method SetConfiguration);
@@ -1588,6 +1616,10 @@ static DBusMessage 
*endpoint_set_configuration(DBusConnection *conn, DBusMessage
 dbus_message_iter_next(props);
 }
 
+/* FIXME: with BlueZ 5, check if this is racy in case a newly paired
+ * device gets connected very fast, before BlueZ has created it. This is
+ * very unlikely since the device will be created before the pairing
+ * procedure is complete */
 d = found_device(y, dev_path);
 if (!d)
 goto fail;
@@ -1601,6 +1633,27 @@ static DBusMessage 
*endpoint_set_configuration(DBusConnection *conn, DBusMessage
 else
 p = PROFILE_A2DP_SOURCE;
 
+/* Check if the UUID was already reported by BlueZ, since the telephony
+ * component (oFono) could be faster than BlueZ */
+profile_to_remote_uuid(p, remote_uuid);
+
+if (!pa_bluetooth_uuid_has(d-uuids, remote_uuid[0])  
!pa_bluetooth_uuid_has(d-uuids, remote_uuid[1])) {
+pa_bluetooth_uuid *node;
+struct pa_bluetooth_hook_uuid_data uuiddata;
+
+pa_log_info(Endpoint with UUID '%s' configured before remote UUID was 
reported by BlueZ., uuid);
+
+/* This might generate duplicated UUID_ADDED hooks since the endpoint
+ * doesn't receive the exact remote UUID (HSP cannot be distinguished
+ * from HFP). However, these duplicated hooks should do no harm */
+node = uuid_new(remote_uuid[0]);
+PA_LLIST_PREPEND(pa_bluetooth_uuid, d-uuids, node);
+
+uuiddata.device = d;
+uuiddata.uuid = uuid;
+
pa_hook_fire(d-discovery-hooks[PA_BLUETOOTH_HOOK_DEVICE_UUID_ADDED], 
uuiddata);
+}
+
 if (d-transports[p] != NULL) {
 pa_log(Cannot configure transport %s because profile %d is already 
used, path, p);
 goto fail2;
-- 
1.8.1.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [RFC v2 07/15] bluetooth: BlueZ 5 interface rename to org.bluez.MediaEndpoint1

2013-04-16 Thread Mikel Astiz
From: Mikel Astiz mikel.as...@bmw-carit.de

Use the new interface name if BlueZ 5 has been detected.
---
 src/modules/bluetooth/bluetooth-util.c | 56 +-
 1 file changed, 42 insertions(+), 14 deletions(-)

diff --git a/src/modules/bluetooth/bluetooth-util.c 
b/src/modules/bluetooth/bluetooth-util.c
index f2de3c8..a58c28a 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -61,6 +61,30 @@
  /interface \
 /node
 
+#define MEDIA_ENDPOINT_1_INTROSPECT_XML \
+DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE   \
+node\
+ interface name=\org.bluez.MediaEndpoint1\\
+  method name=\SetConfiguration\  \
+   arg name=\transport\ direction=\in\ type=\o\/  \
+   arg name=\configuration\ direction=\in\ type=\ay\/ \
+  /method   \
+  method name=\SelectConfiguration\   \
+   arg name=\capabilities\ direction=\in\ type=\ay\/  \
+   arg name=\configuration\ direction=\out\ type=\ay\/\
+  /method   \
+  method name=\ClearConfiguration\\
+  /method   \
+  method name=\Release\   \
+  /method   \
+ /interface \
+ interface name=\org.freedesktop.DBus.Introspectable\ \
+  method name=\Introspect\\
+   arg name=\data\ type=\s\ direction=\out\/  \
+  /method   \
+ /interface \
+/node
+
 typedef enum pa_bluez_version {
 BLUEZ_VERSION_UNKNOWN,
 BLUEZ_VERSION_4,
@@ -1563,7 +1587,7 @@ static DBusMessage 
*endpoint_set_configuration(DBusConnection *conn, DBusMessage
 dbus_message_iter_get_basic(args, path);
 
 if (pa_hashmap_get(y-transports, path)) {
-pa_log(org.bluez.MediaEndpoint.SetConfiguration: Transport %s is 
already configured., path);
+pa_log(Endpoint SetConfiguration: Transport %s is already 
configured., path);
 goto fail2;
 }
 
@@ -1682,11 +1706,10 @@ static DBusMessage 
*endpoint_set_configuration(DBusConnection *conn, DBusMessage
 return NULL;
 
 fail:
-pa_log(org.bluez.MediaEndpoint.SetConfiguration: invalid arguments);
+pa_log(Endpoint SetConfiguration: invalid arguments);
 
 fail2:
-pa_assert_se(r = dbus_message_new_error(m, 
org.bluez.MediaEndpoint.Error.InvalidArguments,
-Unable to set configuration));
+pa_assert_se(r = dbus_message_new_error(m, 
org.bluez.Error.InvalidArguments, Unable to set configuration));
 return r;
 }
 
@@ -1700,7 +1723,7 @@ static DBusMessage 
*endpoint_clear_configuration(DBusConnection *c, DBusMessage
 dbus_error_init(e);
 
 if (!dbus_message_get_args(m, e, DBUS_TYPE_OBJECT_PATH, path, 
DBUS_TYPE_INVALID)) {
-pa_log(org.bluez.MediaEndpoint.ClearConfiguration: %s, e.message);
+pa_log(Endpoint ClearConfiguration: %s, e.message);
 dbus_error_free(e);
 goto fail;
 }
@@ -1725,8 +1748,7 @@ static DBusMessage 
*endpoint_clear_configuration(DBusConnection *c, DBusMessage
 return r;
 
 fail:
-pa_assert_se(r = dbus_message_new_error(m, 
org.bluez.MediaEndpoint.Error.InvalidArguments,
-Unable to clear configuration));
+pa_assert_se(r = dbus_message_new_error(m, 
org.bluez.Error.InvalidArguments, Unable to clear configuration));
 return r;
 }
 
@@ -1796,7 +1818,7 @@ static DBusMessage 
*endpoint_select_configuration(DBusConnection *c, DBusMessage
 dbus_error_init(e);
 
 if (!dbus_message_get_args(m, e, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, cap, 
size, DBUS_TYPE_INVALID)) {
-pa_log(org.bluez.MediaEndpoint.SelectConfiguration: %s, e.message);
+pa_log(Endpoint SelectConfiguration: %s, e.message);
 dbus_error_free(e);
 goto fail;
 }
@@ -1893,8 +1915,7 @@ done:
 return r;
 
 fail:
-pa_assert_se(r = dbus_message_new_error(m, 
org.bluez.MediaEndpoint.Error.InvalidArguments,
-Unable to select configuration));
+pa_assert_se(r = dbus_message_new_error(m, 
org.bluez.Error.InvalidArguments, Unable to select configuration));
 return r;
 }
 
@@ -1906,6 +1927,13 @@ static DBusHandlerResult endpoint_handler(DBusConnection 
*c, DBusMessage *m, voi
 
 pa_assert(y);
 
+interface = y-version == 

[pulseaudio-discuss] [RFC v2 09/15] bluetooth: BlueZ 5 interface rename to org.bluez.MediaTransport1

2013-04-16 Thread Mikel Astiz
From: Mikel Astiz mikel.as...@bmw-carit.de

Use the new interface name if BlueZ 5 has been detected.
---
 src/modules/bluetooth/bluetooth-util.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/modules/bluetooth/bluetooth-util.c 
b/src/modules/bluetooth/bluetooth-util.c
index c9285c1..7e5604d 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1415,6 +1415,7 @@ bool pa_bluetooth_device_any_audio_connected(const 
pa_bluetooth_device *d) {
 
 int pa_bluetooth_transport_acquire(pa_bluetooth_transport *t, bool optional, 
size_t *imtu, size_t *omtu) {
 const char *accesstype = rw;
+const char *interface;
 DBusMessage *m, *r;
 DBusError err;
 int ret;
@@ -1424,6 +1425,8 @@ int pa_bluetooth_transport_acquire(pa_bluetooth_transport 
*t, bool optional, siz
 pa_assert(t-device);
 pa_assert(t-device-discovery);
 
+interface = t-device-discovery-version == BLUEZ_VERSION_4 ? 
org.bluez.MediaTransport : org.bluez.MediaTransport1;
+
 if (optional) {
 /* FIXME: we are trying to acquire the transport only if the stream is
playing, without actually initiating the stream request from our 
side
@@ -1440,7 +1443,7 @@ int pa_bluetooth_transport_acquire(pa_bluetooth_transport 
*t, bool optional, siz
 
 dbus_error_init(err);
 
-pa_assert_se(m = dbus_message_new_method_call(t-owner, t-path, 
org.bluez.MediaTransport, Acquire));
+pa_assert_se(m = dbus_message_new_method_call(t-owner, t-path, 
interface, Acquire));
 pa_assert_se(dbus_message_append_args(m, DBUS_TYPE_STRING, accesstype, 
DBUS_TYPE_INVALID));
 r = 
dbus_connection_send_with_reply_and_block(pa_dbus_connection_get(t-device-discovery-connection),
 m, -1, err);
 
@@ -1451,7 +1454,7 @@ int pa_bluetooth_transport_acquire(pa_bluetooth_transport 
*t, bool optional, siz
 
 if (!dbus_message_get_args(r, err, DBUS_TYPE_UNIX_FD, ret, 
DBUS_TYPE_UINT16, i, DBUS_TYPE_UINT16, o,
DBUS_TYPE_INVALID)) {
-pa_log(Failed to parse org.bluez.MediaTransport.Acquire(): %s, 
err.message);
+pa_log(Failed to parse the media transport Acquire() reply: %s, 
err.message);
 ret = -1;
 dbus_error_free(err);
 goto fail;
@@ -1470,6 +1473,7 @@ fail:
 
 void pa_bluetooth_transport_release(pa_bluetooth_transport *t) {
 const char *accesstype = rw;
+const char *interface;
 DBusMessage *m;
 DBusError err;
 
@@ -1477,9 +1481,11 @@ void 
pa_bluetooth_transport_release(pa_bluetooth_transport *t) {
 pa_assert(t-device);
 pa_assert(t-device-discovery);
 
+interface = t-device-discovery-version == BLUEZ_VERSION_4 ? 
org.bluez.MediaTransport : org.bluez.MediaTransport1;
+
 dbus_error_init(err);
 
-pa_assert_se(m = dbus_message_new_method_call(t-owner, t-path, 
org.bluez.MediaTransport, Release));
+pa_assert_se(m = dbus_message_new_method_call(t-owner, t-path, 
interface, Release));
 pa_assert_se(dbus_message_append_args(m, DBUS_TYPE_STRING, accesstype, 
DBUS_TYPE_INVALID));
 
dbus_connection_send_with_reply_and_block(pa_dbus_connection_get(t-device-discovery-connection),
 m, -1, err);
 
-- 
1.8.1.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [RFC v2 08/15] bluetooth: BlueZ 5 interface rename to org.bluez.Media1

2013-04-16 Thread Mikel Astiz
From: Mikel Astiz mikel.as...@bmw-carit.de

Use the new interface name if BlueZ 5 has been detected.
---
 src/modules/bluetooth/bluetooth-util.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/modules/bluetooth/bluetooth-util.c 
b/src/modules/bluetooth/bluetooth-util.c
index a58c28a..c9285c1 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -861,8 +861,7 @@ static void register_endpoint_reply(DBusPendingCall 
*pending, void *userdata) {
 }
 
 if (dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR) {
-pa_log(org.bluez.Media.RegisterEndpoint() failed: %s: %s, 
dbus_message_get_error_name(r),
-   pa_dbus_get_error_message(r));
+pa_log(RegisterEndpoint() failed: %s: %s, 
dbus_message_get_error_name(r), pa_dbus_get_error_message(r));
 goto finish;
 }
 
@@ -879,10 +878,11 @@ static void register_endpoint(pa_bluetooth_discovery *y, 
const char *path, const
 DBusMessage *m;
 DBusMessageIter i, d;
 uint8_t codec;
+const char *interface = y-version == BLUEZ_VERSION_4 ? org.bluez.Media 
: org.bluez.Media1;
 
 pa_log_debug(Registering %s on adapter %s., endpoint, path);
 
-pa_assert_se(m = dbus_message_new_method_call(org.bluez, path, 
org.bluez.Media, RegisterEndpoint));
+pa_assert_se(m = dbus_message_new_method_call(org.bluez, path, 
interface, RegisterEndpoint));
 
 dbus_message_iter_init_append(m, i);
 
-- 
1.8.1.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [RFC v2 10/15] bluetooth: Parse media transport's properties

2013-04-16 Thread Mikel Astiz
From: Mikel Astiz mikel.as...@bmw-carit.de

Consider the media transport when a PropertiesChanged signal is
received.

Note that the transport might have an owner other than BlueZ, and thus
the property changes would be emitted from arbitrary senders. For
performance reasons, the installed match considers the interface name
where the property has changed.

It could be possible to install and remove the D-Bus matches dynamically
when a new owner is registered/unregistered, but filtering based on the
interface name seems good enough already.
---
 src/modules/bluetooth/bluetooth-util.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/src/modules/bluetooth/bluetooth-util.c 
b/src/modules/bluetooth/bluetooth-util.c
index 7e5604d..006f8cc 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1122,6 +1122,24 @@ static int 
transport_parse_property(pa_bluetooth_transport *t, DBusMessageIter *
 return 0;
 }
 
+static int parse_transport_properties(pa_bluetooth_transport *t, 
DBusMessageIter *i) {
+DBusMessageIter element_i;
+
+dbus_message_iter_recurse(i, element_i);
+
+while (dbus_message_iter_get_arg_type(element_i) == DBUS_TYPE_DICT_ENTRY) 
{
+DBusMessageIter dict_i;
+
+dbus_message_iter_recurse(element_i, dict_i);
+
+transport_parse_property(t, dict_i);
+
+dbus_message_iter_next(element_i);
+}
+
+return 0;
+}
+
 static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void 
*userdata) {
 DBusError err;
 pa_bluetooth_discovery *y;
@@ -1339,6 +1357,13 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, 
DBusMessage *m, void *us
 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; /* Device not 
being tracked */
 
 parse_device_properties(d, arg_i, true);
+} else if (pa_streq(interface, org.bluez.MediaTransport1)) {
+pa_bluetooth_transport *t;
+
+if (!(t = pa_hashmap_get(y-transports, dbus_message_get_path(m
+return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+parse_transport_properties(t, arg_i);
 }
 
 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -2034,6 +2059,8 @@ pa_bluetooth_discovery* 
pa_bluetooth_discovery_get(pa_core *c) {
 
type='signal',sender='org.bluez',interface='org.freedesktop.DBus.ObjectManager',member='InterfacesRemoved',
 
type='signal',sender='org.bluez',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged'
 ,arg0='org.bluez.Device1',
+
type='signal',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged'
+,arg0='org.bluez.MediaTransport1',
 NULL)  0) {
 pa_log(Failed to add D-Bus matches: %s, err.message);
 goto fail;
-- 
1.8.1.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [RFC v2 11/15] bluetooth: Support media transport's State property

2013-04-16 Thread Mikel Astiz
From: Mikel Astiz mikel.as...@bmw-carit.de

BlueZ 5 exposes a 'State' property in the media transport interface.
With regard to PA, this replaces the profile-specific interfaces, since
they were being used to know if the audio was streaming or not.
---
 src/modules/bluetooth/bluetooth-util.c | 42 +-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/src/modules/bluetooth/bluetooth-util.c 
b/src/modules/bluetooth/bluetooth-util.c
index 006f8cc..62bb597 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -126,6 +126,20 @@ static pa_bt_audio_state_t audio_state_from_string(const 
char* value) {
 return PA_BT_AUDIO_STATE_INVALID;
 }
 
+static int transport_state_from_string(const char* value, 
pa_bluetooth_transport_state_t *state) {
+pa_assert(value);
+pa_assert(state);
+
+if (pa_streq(value, idle))
+*state = PA_BLUETOOTH_TRANSPORT_STATE_IDLE;
+else if (pa_streq(value, pending) || pa_streq(value, active)) /* We 
don't need such a separation */
+*state = PA_BLUETOOTH_TRANSPORT_STATE_PLAYING;
+else
+return -1;
+
+return 0;
+}
+
 const char *pa_bt_profile_to_string(enum profile profile) {
 switch(profile) {
 case PROFILE_A2DP:
@@ -1117,6 +1131,29 @@ static int 
transport_parse_property(pa_bluetooth_transport *t, DBusMessageIter *
 
 break;
  }
+
+case DBUS_TYPE_STRING: {
+
+const char *value;
+dbus_message_iter_get_basic(variant_i, value);
+
+if (pa_streq(key, State)) { /* Added in BlueZ 5.0 */
+bool old_any_connected = 
pa_bluetooth_device_any_audio_connected(t-device);
+
+if (transport_state_from_string(value, t-state)  0) {
+pa_log(Transport %s has an invalid state: '%s', t-path, 
value);
+return -1;
+}
+
+pa_log_debug(dbus: transport %s set to state '%s', t-path, 
value);
+
pa_hook_fire(t-device-discovery-hooks[PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED],
 t);
+
+if (old_any_connected != 
pa_bluetooth_device_any_audio_connected(t-device))
+run_callback(t-device, old_any_connected);
+}
+
+break;
+}
 }
 
 return 0;
@@ -1591,7 +1628,10 @@ static pa_bluetooth_transport 
*transport_new(pa_bluetooth_device *d, const char
 memcpy(t-config, config, size);
 }
 
-t-state = audio_state_to_transport_state(d-profile_state[p]);
+if (d-discovery-version == BLUEZ_VERSION_4)
+t-state = audio_state_to_transport_state(d-profile_state[p]);
+else
+t-state = PA_BLUETOOTH_TRANSPORT_STATE_IDLE;
 
 return t;
 }
-- 
1.8.1.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [RFC v2 12/15] bluetooth: Update to new BlueZ 5 transport acquire/release API

2013-04-16 Thread Mikel Astiz
From: Mikel Astiz mikel.as...@bmw-carit.de

The new D-Bus API doesn't support access rights, which weren't used by
PulseAudio anyway, but it does solve a race condition: now optional
acquires can be implemented by bluetooth-util atomically using the D-Bus
TryAcquire() method.
---
 src/modules/bluetooth/bluetooth-util.c  | 66 +++--
 src/modules/bluetooth/module-bluetooth-device.c |  8 +--
 2 files changed, 42 insertions(+), 32 deletions(-)

diff --git a/src/modules/bluetooth/bluetooth-util.c 
b/src/modules/bluetooth/bluetooth-util.c
index 62bb597..d63f189 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1476,40 +1476,52 @@ bool pa_bluetooth_device_any_audio_connected(const 
pa_bluetooth_device *d) {
 }
 
 int pa_bluetooth_transport_acquire(pa_bluetooth_transport *t, bool optional, 
size_t *imtu, size_t *omtu) {
-const char *accesstype = rw;
-const char *interface;
 DBusMessage *m, *r;
 DBusError err;
 int ret;
 uint16_t i, o;
+const char *method;
 
 pa_assert(t);
 pa_assert(t-device);
 pa_assert(t-device-discovery);
 
-interface = t-device-discovery-version == BLUEZ_VERSION_4 ? 
org.bluez.MediaTransport : org.bluez.MediaTransport1;
-
-if (optional) {
-/* FIXME: we are trying to acquire the transport only if the stream is
-   playing, without actually initiating the stream request from our 
side
-   (which is typically undesireable specially for hfgw use-cases.
-   However this approach is racy, since the stream could have been
-   suspended in the meantime, so we can't really guarantee that the
-   stream will not be requested until BlueZ's API supports this
-   atomically. */
-if (t-state  PA_BLUETOOTH_TRANSPORT_STATE_PLAYING) {
-pa_log_info(Failed optional acquire of transport %s, t-path);
-return -1;
+dbus_error_init(err);
+
+if (t-device-discovery-version == BLUEZ_VERSION_4) {
+const char *accesstype = rw;
+
+if (optional) {
+/* We are trying to acquire the transport only if the stream is
+   playing, without actually initiating the stream request from 
our side
+   (which is typically undesireable specially for hfgw use-cases.
+   However this approach is racy, since the stream could have been
+   suspended in the meantime, so we can't really guarantee that the
+   stream will not be requested with the API in BlueZ 4.x */
+if (t-state  PA_BLUETOOTH_TRANSPORT_STATE_PLAYING) {
+pa_log_info(Failed optional acquire of unavailable transport 
%s, t-path);
+return -1;
+}
 }
-}
 
-dbus_error_init(err);
+method = Acquire;
+pa_assert_se(m = dbus_message_new_method_call(t-owner, t-path, 
org.bluez.MediaTransport, method));
+pa_assert_se(dbus_message_append_args(m, DBUS_TYPE_STRING, 
accesstype, DBUS_TYPE_INVALID));
+} else {
+pa_assert(t-device-discovery-version == BLUEZ_VERSION_5);
+
+method = optional ? TryAcquire : Acquire;
+pa_assert_se(m = dbus_message_new_method_call(t-owner, t-path, 
org.bluez.MediaTransport1, method));
+}
 
-pa_assert_se(m = dbus_message_new_method_call(t-owner, t-path, 
interface, Acquire));
-pa_assert_se(dbus_message_append_args(m, DBUS_TYPE_STRING, accesstype, 
DBUS_TYPE_INVALID));
 r = 
dbus_connection_send_with_reply_and_block(pa_dbus_connection_get(t-device-discovery-connection),
 m, -1, err);
 
 if (!r) {
+if (optional  pa_streq(err.name, org.bluez.Error.NotAvailable))
+pa_log_info(Failed optional acquire of unavailable transport %s, 
t-path);
+else
+pa_log(Transport %s() failed for transport %s (%s), method, 
t-path, err.message);
+
 dbus_error_free(err);
 return -1;
 }
@@ -1534,8 +1546,6 @@ fail:
 }
 
 void pa_bluetooth_transport_release(pa_bluetooth_transport *t) {
-const char *accesstype = rw;
-const char *interface;
 DBusMessage *m;
 DBusError err;
 
@@ -1543,12 +1553,18 @@ void 
pa_bluetooth_transport_release(pa_bluetooth_transport *t) {
 pa_assert(t-device);
 pa_assert(t-device-discovery);
 
-interface = t-device-discovery-version == BLUEZ_VERSION_4 ? 
org.bluez.MediaTransport : org.bluez.MediaTransport1;
-
 dbus_error_init(err);
 
-pa_assert_se(m = dbus_message_new_method_call(t-owner, t-path, 
interface, Release));
-pa_assert_se(dbus_message_append_args(m, DBUS_TYPE_STRING, accesstype, 
DBUS_TYPE_INVALID));
+if (t-device-discovery-version == BLUEZ_VERSION_4) {
+const char *accesstype = rw;
+
+pa_assert_se(m = dbus_message_new_method_call(t-owner, t-path, 
org.bluez.MediaTransport, Release));
+pa_assert_se(dbus_message_append_args(m, DBUS_TYPE_STRING, 
accesstype, DBUS_TYPE_INVALID));
+} else {
+ 

[pulseaudio-discuss] [RFC v2 13/15] bluetooth: Support transport auto-release

2013-04-16 Thread Mikel Astiz
From: Mikel Astiz mikel.as...@bmw-carit.de

With BlueZ 5, if the remote device suspends the audio, the transport
state will change to idle and the endpoint is not required to release
the transport, since this could introduce race conditions. Therefore,
ignore the call to pa_bluetooth_transport_release() if the transport is
not acquired any more.
---
 src/modules/bluetooth/bluetooth-util.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/modules/bluetooth/bluetooth-util.c 
b/src/modules/bluetooth/bluetooth-util.c
index d63f189..cd6db4b 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1560,6 +1560,9 @@ void 
pa_bluetooth_transport_release(pa_bluetooth_transport *t) {
 
 pa_assert_se(m = dbus_message_new_method_call(t-owner, t-path, 
org.bluez.MediaTransport, Release));
 pa_assert_se(dbus_message_append_args(m, DBUS_TYPE_STRING, 
accesstype, DBUS_TYPE_INVALID));
+} else if (t-state = PA_BLUETOOTH_TRANSPORT_STATE_IDLE) {
+pa_log_info(Transport %s auto-released by BlueZ or already released, 
t-path);
+return;
 } else {
 pa_assert(t-device-discovery-version == BLUEZ_VERSION_5);
 pa_assert_se(m = dbus_message_new_method_call(t-owner, t-path, 
org.bluez.MediaTransport1, Release));
-- 
1.8.1.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [RFC v2 14/15] bluetooth: Update to new property setter API in BlueZ 5

2013-04-16 Thread Mikel Astiz
From: Mikel Astiz mikel.as...@bmw-carit.de

If BlueZ 5 is in use, the standard org.freedesktop.DBus.Properties needs
to be used instead of the old SetProperty() method.
---
 src/modules/bluetooth/bluetooth-util.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/src/modules/bluetooth/bluetooth-util.c 
b/src/modules/bluetooth/bluetooth-util.c
index cd6db4b..7589c22 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1587,6 +1587,20 @@ static void set_property(pa_bluetooth_discovery *y, 
const char *bus, const char
 pa_assert(interface);
 pa_assert(prop_name);
 
+if (y-version = BLUEZ_VERSION_5) {
+pa_assert_se(m = dbus_message_new_method_call(bus, path, 
org.freedesktop.DBus.Properties, Set));
+dbus_message_iter_init_append(m, i);
+dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, interface);
+dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, prop_name);
+pa_dbus_append_basic_variant(i, prop_type, prop_value);
+
+dbus_message_set_no_reply(m, true);
+
pa_assert_se(dbus_connection_send(pa_dbus_connection_get(y-connection), m, 
NULL));
+dbus_message_unref(m);
+
+return;
+}
+
 pa_assert_se(m = dbus_message_new_method_call(bus, path, interface, 
SetProperty));
 dbus_message_iter_init_append(m, i);
 dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, prop_name);
-- 
1.8.1.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [RFC v2 15/15] bluetooth: Update to volume control in BlueZ 5

2013-04-16 Thread Mikel Astiz
From: Mikel Astiz mikel.as...@bmw-carit.de

In BlueZ 5, the microphone and speaker gains are exposed as properties
of the MediaTransport1 interface.
---
 src/modules/bluetooth/bluetooth-util.c | 41 ++
 1 file changed, 41 insertions(+)

diff --git a/src/modules/bluetooth/bluetooth-util.c 
b/src/modules/bluetooth/bluetooth-util.c
index 7589c22..de4dbce 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1154,6 +1154,32 @@ static int 
transport_parse_property(pa_bluetooth_transport *t, DBusMessageIter *
 
 break;
 }
+
+case DBUS_TYPE_BYTE: {
+uint8_t value;
+
+dbus_message_iter_get_basic(variant_i, value);
+
+if (pa_streq(key, MicrophoneGain)) {
+uint8_t gain;
+
+if ((gain = PA_MIN(value, HSP_MAX_GAIN)) == t-microphone_gain)
+break;
+
+t-microphone_gain = gain;
+
pa_hook_fire(t-device-discovery-hooks[PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED],
 t);
+} else if (pa_streq(key, SpeakerGain)) {
+uint8_t gain;
+
+if ((gain = PA_MIN(value, HSP_MAX_GAIN)) == t-speaker_gain)
+break;
+
+t-speaker_gain = gain;
+
pa_hook_fire(t-device-discovery-hooks[PA_BLUETOOTH_HOOK_TRANSPORT_SPEAKER_GAIN_CHANGED],
 t);
+}
+
+break;
+}
 }
 
 return 0;
@@ -1617,6 +1643,14 @@ void 
pa_bluetooth_transport_set_microphone_gain(pa_bluetooth_transport *t, uint1
 pa_assert(t);
 pa_assert(t-profile == PROFILE_HSP);
 
+if (t-device-discovery-version = BLUEZ_VERSION_5) {
+uint8_t g = (uint8_t) gain;
+
+set_property(t-device-discovery, t-owner, t-path, 
org.bluez.MediaTransport1,
+ MicrophoneGain, DBUS_TYPE_BYTE, g);
+return;
+}
+
 set_property(t-device-discovery, org.bluez, t-device-path, 
org.bluez.Headset,
  MicrophoneGain, DBUS_TYPE_UINT16, gain);
 }
@@ -1627,6 +1661,13 @@ void 
pa_bluetooth_transport_set_speaker_gain(pa_bluetooth_transport *t, uint16_t
 pa_assert(t);
 pa_assert(t-profile == PROFILE_HSP);
 
+if (t-device-discovery-version = BLUEZ_VERSION_5) {
+uint8_t g = (uint8_t) gain;
+
+set_property(t-device-discovery, t-owner, t-path, 
org.bluez.MediaTransport1, SpeakerGain, DBUS_TYPE_BYTE, g);
+return;
+}
+
 set_property(t-device-discovery, org.bluez, t-device-path, 
org.bluez.Headset,
  SpeakerGain, DBUS_TYPE_UINT16, gain);
 }
-- 
1.8.1.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] Ideas for GSoC 2013

2013-04-16 Thread Michele Bussolotto
Dear Sirs,

I am Michele Bussolotto, an M.Sc. student in Electronic Engineer. I would
like to partecipate to this edition of Google Summer of Code and I will be
very glad if you could give me an opinion about a project idea.

In particular, I would like to pay attention to problems in audio
transmissions between two devices, like an IP transmission using for
example module-rtp-send and module-rtp-recv. I am wondering if exist any
mechanism to avoid underrun/overrun due to clock drift, to maintain
synchronism between two remote devices, and if could be interesting to
improve the performance about.

I'm looking forward to hear from you,

Sincere greetings,



Michele Bussolotto
Cellulare: 528538
e-mail: michelebussolo...@gmail.com
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 0/3] Fix muted headphones in guest account

2013-04-16 Thread David Henningsson
Don't worry about this being a three patch series, because the
first two patches are really small.

This is a fix for a long term issue: that if you log in to a guest account
(or new account) with your headphones plugged in, your headphones will be
muted by default.

This is the current chain of events:

 1) User plugs in headphones, which mutes the Speaker alsamixer control.
 2) User switches to guest account.
 3) Guest's PulseAudio starts up and detects the card.
 4) When the sink is loaded, there is no port or volume stored in the database.
Therefore the highest port is selected (analog-output-speaker), and the
volume is read from ALSA
 5) PulseAudio assumes sink is muted, because Speaker was muted.
 6) Later, module-switch-on-port-available is loaded and selects 
analog-output-headphones,
because analog-output-speaker is unavailable.
 7) Headphones are now muted as there is nothing stored in the database for 
headphones either.

The patch series fixes this by making sure that module-switch-on-port-available,
as well as the available status for ports, are both present when the sink is 
created.
Therefore the correct port is selected from the beginning.

I consider this a fix rather than a new feature, so I think this should go into 
4.0.

David Henningsson (3):
  default.pa: Load switch-on-port-available before udev-detect
  alsa: Initialize ports before sinks/sources
  module-switch-on-port-available: Handle hotplugged cards

 src/daemon/default.pa.in  |  4 +-
 src/modules/alsa/module-alsa-card.c   |  2 +-
 src/modules/module-switch-on-port-available.c | 69 +--
 3 files changed, 67 insertions(+), 8 deletions(-)

-- 
1.8.1.2

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 2/3] alsa: Initialize ports before sinks/sources

2013-04-16 Thread David Henningsson
This way port availability has been filled in when we create the
sink, which will later enable us to pick the right port directly.

Signed-off-by: David Henningsson david.hennings...@canonical.com
---
 src/modules/alsa/module-alsa-card.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/modules/alsa/module-alsa-card.c 
b/src/modules/alsa/module-alsa-card.c
index 2529c0d..9b739dc 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -748,8 +748,8 @@ int pa__init(pa_module *m) {
 u-card-userdata = u;
 u-card-set_profile = card_set_profile;
 
-init_profile(u);
 init_jacks(u);
+init_profile(u);
 init_eld_ctls(u);
 
 if (reserve)
-- 
1.8.1.2

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 3/3] module-switch-on-port-available: Handle hotplugged cards

2013-04-16 Thread David Henningsson
If a card is hot-plugged (which all cards are, now that we load
this module before module-*-detect), make sure we don't start up
a sink with an unavailable port selected.

Signed-off-by: David Henningsson david.hennings...@canonical.com
---
 src/modules/module-switch-on-port-available.c | 69 +--
 1 file changed, 64 insertions(+), 5 deletions(-)

diff --git a/src/modules/module-switch-on-port-available.c 
b/src/modules/module-switch-on-port-available.c
index 9b2029b..063c9fd 100644
--- a/src/modules/module-switch-on-port-available.c
+++ b/src/modules/module-switch-on-port-available.c
@@ -31,7 +31,9 @@
 #include module-switch-on-port-available-symdef.h
 
 struct userdata {
- pa_hook_slot *callback_slot;
+ pa_hook_slot *available_slot;
+ pa_hook_slot *sink_new_slot;
+ pa_hook_slot *source_new_slot;
 };
 
 static pa_device_port* find_best_port(pa_hashmap *ports) {
@@ -218,6 +220,54 @@ static void handle_all_unavailable(pa_core *core) {
 }
 }
 
+static pa_device_port *new_sink_source(pa_hashmap *ports, const char *name) {
+
+void *state;
+pa_device_port *i, *p = NULL;
+
+if (!ports)
+return NULL;
+if (name)
+p = pa_hashmap_get(ports, name);
+if (!p)
+PA_HASHMAP_FOREACH(i, ports, state)
+if (!p || i-priority  p-priority)
+p = i;
+if (!p)
+return NULL;
+if (p-available != PA_AVAILABLE_NO)
+return NULL;
+
+pa_assert_se(p = find_best_port(ports));
+return p;
+}
+
+static pa_hook_result_t sink_new_hook_callback(pa_core *c, pa_sink_new_data 
*new_data, struct userdata *u) {
+
+pa_device_port *p = new_sink_source(new_data-ports, 
new_data-active_port);
+
+if (p) {
+pa_log_debug(Switching initial port for sink '%s' to '%s', 
new_data-name, p-name);
+pa_sink_new_data_set_port(new_data, p-name);
+new_data-save_port = true;
+}
+return PA_HOOK_OK;
+}
+
+static pa_hook_result_t source_new_hook_callback(pa_core *c, 
pa_source_new_data *new_data, struct userdata *u) {
+
+pa_device_port *p = new_sink_source(new_data-ports, 
new_data-active_port);
+
+if (p) {
+pa_log_debug(Switching initial port for source '%s' to '%s', 
new_data-name,
+ new_data-active_port);
+pa_source_new_data_set_port(new_data, p-name);
+new_data-save_port = true;
+}
+return PA_HOOK_OK;
+}
+
+
 int pa__init(pa_module*m) {
 struct userdata *u;
 
@@ -225,8 +275,13 @@ int pa__init(pa_module*m) {
 
 m-userdata = u = pa_xnew(struct userdata, 1);
 
-u-callback_slot = 
pa_hook_connect(m-core-hooks[PA_CORE_HOOK_PORT_AVAILABLE_CHANGED],
-   PA_HOOK_LATE, (pa_hook_cb_t) 
port_available_hook_callback, u);
+/* Make sure we are after module-device-restore, so we can overwrite that 
suggestion if necessary */
+u-sink_new_slot = pa_hook_connect(m-core-hooks[PA_CORE_HOOK_SINK_NEW],
+   PA_HOOK_NORMAL, (pa_hook_cb_t) 
sink_new_hook_callback, u);
+u-source_new_slot = 
pa_hook_connect(m-core-hooks[PA_CORE_HOOK_SOURCE_NEW],
+ PA_HOOK_NORMAL, (pa_hook_cb_t) 
source_new_hook_callback, u);
+u-available_slot = 
pa_hook_connect(m-core-hooks[PA_CORE_HOOK_PORT_AVAILABLE_CHANGED],
+PA_HOOK_LATE, (pa_hook_cb_t) 
port_available_hook_callback, u);
 
 handle_all_unavailable(m-core);
 
@@ -241,8 +296,12 @@ void pa__done(pa_module*m) {
 if (!(u = m-userdata))
 return;
 
-if (u-callback_slot)
-pa_hook_slot_free(u-callback_slot);
+if (u-available_slot)
+pa_hook_slot_free(u-available_slot);
+if (u-sink_new_slot)
+pa_hook_slot_free(u-sink_new_slot);
+if (u-source_new_slot)
+pa_hook_slot_free(u-source_new_slot);
 
 pa_xfree(u);
 }
-- 
1.8.1.2

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH 1/3] default.pa: Load switch-on-port-available before udev-detect

2013-04-16 Thread João Paulo Rechi Vita
On Tue, Apr 16, 2013 at 11:44 AM, David Henningsson
david.hennings...@canonical.com wrote:
 We need to pick the right port as early as possible, before the
 first volume is picked up. Hence this module needs to be loaded
 before the sound card modules are loaded.

 Signed-off-by: David Henningsson david.hennings...@canonical.com
 ---
  src/daemon/default.pa.in | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

 diff --git a/src/daemon/default.pa.in b/src/daemon/default.pa.in
 index b4c4965..e61a41f 100755
 --- a/src/daemon/default.pa.in
 +++ b/src/daemon/default.pa.in
 @@ -44,6 +44,8 @@ load-module module-card-restore
  ### stored in /usr/share/application
  load-module module-augment-properties

 +load-module module-switch-on-port-available
 +

I would add a comment here stating that this module should be loaded
before all others that lead to card creation.

  ### Load audio drivers statically
  ### (it's probably better to not load these drivers manually, but instead
  ### use module-udev-detect -- see below -- for doing this automatically)
 @@ -193,8 +195,6 @@ ifelse(@HAVE_X11@, 1, [dnl
  #.endif
  ])dnl

 -load-module module-switch-on-port-available
 -
  ### Make some devices default
  #set-default-sink output
  #set-default-source input


--
João Paulo Rechi Vita
http://about.me/jprvita
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] Compile error with PA

2013-04-16 Thread D K
Hi,

I am getting following compile error with PA. Any pointer to fix it
would be appreciated.

CCLD   interpol-test
  CC sync_playback-sync-playback.o
  CCLD   sync-playback
make[3]: *** No rule to make target `daemon/pulseaudio.desktop', needed by
`all-am'.  Stop.
make[3]: Leaving directory `/home/projects/pa_2.1/pulseaudio-2.1/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/projects/pa_2.1/pulseaudio-2.1/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/projects/pa_2.1/pulseaudio-2.1'
make: *** [all] Error 2


thanks,
Pankaj
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Compile error with PA

2013-04-16 Thread D K
  CCLD   connect-stress
  CC extended_test-extended-test.o
  CCLD   extended-test
  CC interpol_test-interpol-test.o
  CCLD   interpol-test
  CC sync_playback-sync-playback.o
  CCLD   sync-playback
cd ..  /bin/sh ./config.status src/esdcompat
config.status: creating src/esdcompat
cd ..  /bin/sh ./config.status src/start-pulseaudio-kde
config.status: creating src/start-pulseaudio-kde
/bin/sed -e s|@pkglibdir[@]|/usr/local/lib/pulseaudio|g utils/padsp.in 
padsp
cd ..  /bin/sh ./config.status src/daemon.conf
config.status: creating src/daemon.conf
cd ..  /bin/sh ./config.status src/client.conf
config.status: creating src/client.conf
make[3]: *** No rule to make target `daemon/pulseaudio.desktop', needed by
`all-am'.  Stop.
make[3]: Leaving directory `/home//projects/pa_2.1/pulseaudio-2.1/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home//projects/pa_2.1/pulseaudio-2.1/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home//projects/pa_2.1/pulseaudio-2.1'
make: *** [all] Error 2



On Tue, Apr 16, 2013 at 1:40 PM, D K dsp...@gmail.com wrote:

 Hi,

 I am getting following compile error with PA. Any pointer to fix it
 would be appreciated.

 CCLD   interpol-test
   CC sync_playback-sync-playback.o
   CCLD   sync-playback
 make[3]: *** No rule to make target `daemon/pulseaudio.desktop', needed by
 `all-am'.  Stop.
 make[3]: Leaving directory `/home/projects/pa_2.1/pulseaudio-2.1/src'
 make[2]: *** [all] Error 2
 make[2]: Leaving directory `/home/projects/pa_2.1/pulseaudio-2.1/src'
 make[1]: *** [all-recursive] Error 1
 make[1]: Leaving directory `/home/projects/pa_2.1/pulseaudio-2.1'
 make: *** [all] Error 2


 thanks,
 Pankaj


___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH] alsa-source: Fix log message

2013-04-16 Thread jprvita
From: João Paulo Rechi Vita jprv...@openbossa.org

The log message when updating the source sample rate wrongly mentions
Sink instead of Source. This was probably a copy and paste error.
---
 src/modules/alsa/alsa-source.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 1481c98..dedb673 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -1424,7 +1424,7 @@ static pa_bool_t source_update_rate_cb(pa_source *s, 
uint32_t rate)
 }
 
 if (!supported) {
-pa_log_info(Sink does not support sample rate of %d Hz, rate);
+pa_log_info(Source does not support sample rate of %d Hz, rate);
 return FALSE;
 }
 
-- 
1.7.11.7

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss