On Tue, 2014-02-04 at 19:03 -0300, jprvita at gmail.com wrote: > From: Jo?o Paulo Rechi Vita <jprvita at openbossa.org> > > --- > configure.ac | 10 +++++++++ > src/Makefile.am | 4 +++- > src/modules/bluetooth/bluez5-util.c | 6 +++++ > src/modules/bluetooth/hfaudioagent-null.c | 37 +++++++++++++++++++++++++++++++ > src/modules/bluetooth/hfaudioagent.h | 31 ++++++++++++++++++++++++++ > 5 files changed, 87 insertions(+), 1 deletion(-) > create mode 100644 src/modules/bluetooth/hfaudioagent-null.c > create mode 100644 src/modules/bluetooth/hfaudioagent.h > > diff --git a/configure.ac b/configure.ac > index 1d4555b..d5246a1 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -1022,6 +1022,15 @@ AS_IF([test "x$HAVE_BLUEZ_4" = "x1" || test "x$HAVE_BLUEZ_5" = "x1"], HAVE_BLUEZ > AC_SUBST(HAVE_BLUEZ) > AM_CONDITIONAL([HAVE_BLUEZ], [test "x$HAVE_BLUEZ" = x1]) > > +## Headset profiles backend ## > +AC_ARG_WITH(bluetooth_headset_backend, AS_HELP_STRING([--with-bluetooth-headset-backend=<null|ofono>],[Backend for Bluetooth headset profiles (null)])) > +if test -z "$with_bluetooth_headset_backend" ; then > + BLUETOOTH_HEADSET_BACKEND=null > +else > + BLUETOOTH_HEADSET_BACKEND=$with_bluetooth_headset_backend > +fi > +AC_SUBST(BLUETOOTH_HEADSET_BACKEND) I think there should be a check that $with_bluetooth_headset_backend is one of the supported values. Also, the ofono backend should be the default. ./configure without arguments should just work as much as possible. > + > #### UDEV support (optional) #### > > AC_ARG_ENABLE([udev], > @@ -1485,6 +1494,7 @@ echo " > Enable D-Bus: ${ENABLE_DBUS} > Enable BlueZ 4: ${ENABLE_BLUEZ_4} > Enable BlueZ 5: ${ENABLE_BLUEZ_5} > + headset backed: ${BLUETOOTH_HEADSET_BACKEND} > Enable udev: ${ENABLE_UDEV} > Enable HAL->udev compat: ${ENABLE_HAL_COMPAT} > Enable systemd login: ${ENABLE_SYSTEMD} > diff --git a/src/Makefile.am b/src/Makefile.am > index 857fda3..908eb42 100644 > --- a/src/Makefile.am > +++ b/src/Makefile.am > @@ -2070,7 +2070,9 @@ module_bluez4_device_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS) $(SBC_CFLAGS) > libbluez5_util_la_SOURCES = \ > modules/bluetooth/bluez5-util.c \ > modules/bluetooth/bluez5-util.h \ > - modules/bluetooth/a2dp-codecs.h > + modules/bluetooth/a2dp-codecs.h \ > + modules/bluetooth/hfaudioagent.h \ > + modules/bluetooth/hfaudioagent- at BLUETOOTH_HEADSET_BACKEND@.c > libbluez5_util_la_LDFLAGS = -avoid-version > libbluez5_util_la_LIBADD = $(MODULE_LIBADD) $(DBUS_LIBS) > libbluez5_util_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS) > diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c > index 142617c..c8ddbed 100644 > --- a/src/modules/bluetooth/bluez5-util.c > +++ b/src/modules/bluetooth/bluez5-util.c > @@ -34,6 +34,7 @@ > #include <pulsecore/shared.h> > > #include "a2dp-codecs.h" > +#include "hfaudioagent.h" hf_audio_agent -> hf-audio-agent.h > > #include "bluez5-util.h" > > @@ -87,6 +88,7 @@ struct pa_bluetooth_discovery { > pa_hashmap *devices; > pa_hashmap *transports; > > + hf_audio_agent_data *hf_audio_agent; > PA_LLIST_HEAD(pa_dbus_pending, pending); > }; > > @@ -1574,6 +1576,7 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) { > > endpoint_init(y, PA_BLUETOOTH_PROFILE_A2DP_SINK); > endpoint_init(y, PA_BLUETOOTH_PROFILE_A2DP_SOURCE); > + y->hf_audio_agent = hf_audio_agent_init(c); > > get_managed_objects(y); > > @@ -1615,6 +1618,9 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) { > pa_hashmap_free(y->transports); > } > > + if (y->hf_audio_agent) > + hf_audio_agent_done(y->hf_audio_agent); > + > if (y->connection) { > > if (y->matches_added) > diff --git a/src/modules/bluetooth/hfaudioagent-null.c b/src/modules/bluetooth/hfaudioagent-null.c > new file mode 100644 > index 0000000..96fca06 > --- /dev/null > +++ b/src/modules/bluetooth/hfaudioagent-null.c > @@ -0,0 +1,37 @@ > +/*** > + This file is part of PulseAudio. > + > + Copyright 2013 Jo?o Paulo Rechi Vita > + > + 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/log.h> > + > +#include "hfaudioagent.h" > + > +hf_audio_agent_data *hf_audio_agent_init(pa_core *c) { > + pa_log_debug("HandsfreeAudioAgent API support disabled"); > + return NULL; > +} > + > +void hf_audio_agent_done(hf_audio_agent_data *data) { > + /* Nothing to do here */ > +} > diff --git a/src/modules/bluetooth/hfaudioagent.h b/src/modules/bluetooth/hfaudioagent.h > new file mode 100644 > index 0000000..2982034 > --- /dev/null > +++ b/src/modules/bluetooth/hfaudioagent.h > @@ -0,0 +1,31 @@ > +#ifndef foohfagenthfoo > +#define foohfagenthfoo > + > +/*** > + This file is part of PulseAudio. > + > + Copyright 2013 Jo?o Paulo Rechi Vita > + > + 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. > +***/ > + > +#include <pulsecore/core.h> > + > +typedef struct hf_audio_agent_data hf_audio_agent_data; I don't like _data in the struct name. If a struct is named foo_data, I expect the struct's definition to be public. Just drop the _data suffix. The struct should also have pa_ prefix (maybe even pa_bluetooth_, but then the name gets pretty long, so I'm fine with pa_hf_audio_agent). > + > +hf_audio_agent_data *hf_audio_agent_init(pa_core *c); If you're allocating a new object, use _new() as the suffix instead of _init(). > +void hf_audio_agent_done(hf_audio_agent_data *data); s/done/free/ -- Tanu