* [PATCH BlueZ 2/2] audio: Move to profiles directory
From: Luiz Augusto von Dentz @ 2012-11-08 15:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1352388350-29194-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
In addiction fix the include path to profiles and change avinfo to use
audio path when including a2dp-codecs.h
---
Makefile.am | 52 +++++++++++++++-------------
{audio => profiles/audio}/a2dp-codecs.h | 0
{audio => profiles/audio}/a2dp.c | 0
{audio => profiles/audio}/a2dp.h | 0
{audio => profiles/audio}/audio.conf | 0
{audio => profiles/audio}/avctp.c | 0
{audio => profiles/audio}/avctp.h | 0
{audio => profiles/audio}/avdtp.c | 0
{audio => profiles/audio}/avdtp.h | 0
{audio => profiles/audio}/avrcp.c | 0
{audio => profiles/audio}/avrcp.h | 0
{audio => profiles/audio}/control.c | 0
{audio => profiles/audio}/control.h | 0
{audio => profiles/audio}/device.c | 0
{audio => profiles/audio}/device.h | 0
{audio => profiles/audio}/gateway.c | 0
{audio => profiles/audio}/gateway.h | 0
{audio => profiles/audio}/headset.c | 0
{audio => profiles/audio}/headset.h | 0
{audio => profiles/audio}/main.c | 0
{audio => profiles/audio}/manager.c | 0
{audio => profiles/audio}/manager.h | 0
{audio => profiles/audio}/media.c | 0
{audio => profiles/audio}/media.h | 0
{audio => profiles/audio}/player.c | 0
{audio => profiles/audio}/player.h | 0
{audio => profiles/audio}/rtp.h | 0
{audio => profiles/audio}/sink.c | 0
{audio => profiles/audio}/sink.h | 0
{audio => profiles/audio}/source.c | 0
{audio => profiles/audio}/source.h | 0
{audio => profiles/audio}/telephony-dummy.c | 0
{audio => profiles/audio}/telephony-maemo5.c | 0
{audio => profiles/audio}/telephony-maemo6.c | 0
{audio => profiles/audio}/telephony-ofono.c | 0
{audio => profiles/audio}/telephony.h | 0
{audio => profiles/audio}/transport.c | 0
{audio => profiles/audio}/transport.h | 0
tools/avinfo.c | 2 +-
39 files changed, 28 insertions(+), 26 deletions(-)
rename {audio => profiles/audio}/a2dp-codecs.h (100%)
rename {audio => profiles/audio}/a2dp.c (100%)
rename {audio => profiles/audio}/a2dp.h (100%)
rename {audio => profiles/audio}/audio.conf (100%)
rename {audio => profiles/audio}/avctp.c (100%)
rename {audio => profiles/audio}/avctp.h (100%)
rename {audio => profiles/audio}/avdtp.c (100%)
rename {audio => profiles/audio}/avdtp.h (100%)
rename {audio => profiles/audio}/avrcp.c (100%)
rename {audio => profiles/audio}/avrcp.h (100%)
rename {audio => profiles/audio}/control.c (100%)
rename {audio => profiles/audio}/control.h (100%)
rename {audio => profiles/audio}/device.c (100%)
rename {audio => profiles/audio}/device.h (100%)
rename {audio => profiles/audio}/gateway.c (100%)
rename {audio => profiles/audio}/gateway.h (100%)
rename {audio => profiles/audio}/headset.c (100%)
rename {audio => profiles/audio}/headset.h (100%)
rename {audio => profiles/audio}/main.c (100%)
rename {audio => profiles/audio}/manager.c (100%)
rename {audio => profiles/audio}/manager.h (100%)
rename {audio => profiles/audio}/media.c (100%)
rename {audio => profiles/audio}/media.h (100%)
rename {audio => profiles/audio}/player.c (100%)
rename {audio => profiles/audio}/player.h (100%)
rename {audio => profiles/audio}/rtp.h (100%)
rename {audio => profiles/audio}/sink.c (100%)
rename {audio => profiles/audio}/sink.h (100%)
rename {audio => profiles/audio}/source.c (100%)
rename {audio => profiles/audio}/source.h (100%)
rename {audio => profiles/audio}/telephony-dummy.c (100%)
rename {audio => profiles/audio}/telephony-maemo5.c (100%)
rename {audio => profiles/audio}/telephony-maemo6.c (100%)
rename {audio => profiles/audio}/telephony-ofono.c (100%)
rename {audio => profiles/audio}/telephony.h (100%)
rename {audio => profiles/audio}/transport.c (100%)
rename {audio => profiles/audio}/transport.h (100%)
diff --git a/Makefile.am b/Makefile.am
index b069c03..47c24ed 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -105,29 +105,31 @@ endif
if AUDIOPLUGIN
builtin_modules += audio
-builtin_sources += audio/main.c \
- audio/manager.h audio/manager.c \
- audio/gateway.h audio/gateway.c \
- audio/headset.h audio/headset.c \
- audio/control.h audio/control.c \
- audio/avctp.h audio/avctp.c \
- audio/avrcp.h audio/avrcp.c \
- audio/device.h audio/device.c \
- audio/source.h audio/source.c \
- audio/sink.h audio/sink.c \
- audio/a2dp.h audio/a2dp.c \
- audio/avdtp.h audio/avdtp.c \
- audio/media.h audio/media.c \
- audio/transport.h audio/transport.c \
- audio/player.h audio/player.c \
- audio/telephony.h audio/a2dp-codecs.h
-builtin_nodist += audio/telephony.c
-
-noinst_LIBRARIES += audio/libtelephony.a
-
-audio_libtelephony_a_SOURCES = audio/telephony.h audio/telephony-dummy.c \
- audio/telephony-maemo5.c audio/telephony-ofono.c \
- audio/telephony-maemo6.c
+builtin_sources += profiles/audio/main.c \
+ profiles/audio/manager.h profiles/audio/manager.c \
+ profiles/audio/gateway.h profiles/audio/gateway.c \
+ profiles/audio/headset.h profiles/audio/headset.c \
+ profiles/audio/control.h profiles/audio/control.c \
+ profiles/audio/avctp.h profiles/audio/avctp.c \
+ profiles/audio/avrcp.h profiles/audio/avrcp.c \
+ profiles/audio/device.h profiles/audio/device.c \
+ profiles/audio/source.h profiles/audio/source.c \
+ profiles/audio/sink.h profiles/audio/sink.c \
+ profiles/audio/a2dp.h profiles/audio/a2dp.c \
+ profiles/audio/avdtp.h profiles/audio/avdtp.c \
+ profiles/audio/media.h profiles/audio/media.c \
+ profiles/audio/transport.h profiles/audio/transport.c \
+ profiles/audio/player.h profiles/audio/player.c \
+ profiles/audio/telephony.h profiles/audio/a2dp-codecs.h
+builtin_nodist += profiles/audio/telephony.c
+
+noinst_LIBRARIES += profiles/audio/libtelephony.a
+
+profiles_audio_libtelephony_a_SOURCES = profiles/audio/telephony.h
+ profiles/audio/telephony-dummy.c \
+ profiles/audio/telephony-maemo5.c \
+ profiles/audio/telephony-ofono.c \
+ profiles/audio/telephony-maemo6.c
endif
if SAPPLUGIN
@@ -360,7 +362,7 @@ EXTRA_DIST += doc/manager-api.txt \
AM_CFLAGS += @DBUS_CFLAGS@ @GLIB_CFLAGS@
AM_CPPFLAGS = -I$(builddir)/lib -I$(builddir)/src -I$(srcdir)/src \
- -I$(srcdir)/audio -I$(srcdir)/gdbus \
+ -I$(srcdir)/profiles -I$(srcdir)/gdbus \
-I$(srcdir)/attrib -I$(srcdir)/btio \
-I$(srcdir)/tools -I$(builddir)/tools \
-I$(srcdir)/monitor
@@ -401,7 +403,7 @@ MAINTAINERCLEANFILES = Makefile.in \
src/builtin.h: src/genbuiltin $(builtin_sources)
$(AM_V_GEN)$(srcdir)/src/genbuiltin $(builtin_modules) > $@
-audio/telephony.c: audio/@TELEPHONY_DRIVER@
+profiles/audio/telephony.c: profiles/audio/@TELEPHONY_DRIVER@
$(AM_V_GEN)$(LN_S) $(abs_top_builddir)/$< $@
profiles/sap/sap.c: profiles/sap/@SAP_DRIVER@
diff --git a/audio/a2dp-codecs.h b/profiles/audio/a2dp-codecs.h
similarity index 100%
rename from audio/a2dp-codecs.h
rename to profiles/audio/a2dp-codecs.h
diff --git a/audio/a2dp.c b/profiles/audio/a2dp.c
similarity index 100%
rename from audio/a2dp.c
rename to profiles/audio/a2dp.c
diff --git a/audio/a2dp.h b/profiles/audio/a2dp.h
similarity index 100%
rename from audio/a2dp.h
rename to profiles/audio/a2dp.h
diff --git a/audio/audio.conf b/profiles/audio/audio.conf
similarity index 100%
rename from audio/audio.conf
rename to profiles/audio/audio.conf
diff --git a/audio/avctp.c b/profiles/audio/avctp.c
similarity index 100%
rename from audio/avctp.c
rename to profiles/audio/avctp.c
diff --git a/audio/avctp.h b/profiles/audio/avctp.h
similarity index 100%
rename from audio/avctp.h
rename to profiles/audio/avctp.h
diff --git a/audio/avdtp.c b/profiles/audio/avdtp.c
similarity index 100%
rename from audio/avdtp.c
rename to profiles/audio/avdtp.c
diff --git a/audio/avdtp.h b/profiles/audio/avdtp.h
similarity index 100%
rename from audio/avdtp.h
rename to profiles/audio/avdtp.h
diff --git a/audio/avrcp.c b/profiles/audio/avrcp.c
similarity index 100%
rename from audio/avrcp.c
rename to profiles/audio/avrcp.c
diff --git a/audio/avrcp.h b/profiles/audio/avrcp.h
similarity index 100%
rename from audio/avrcp.h
rename to profiles/audio/avrcp.h
diff --git a/audio/control.c b/profiles/audio/control.c
similarity index 100%
rename from audio/control.c
rename to profiles/audio/control.c
diff --git a/audio/control.h b/profiles/audio/control.h
similarity index 100%
rename from audio/control.h
rename to profiles/audio/control.h
diff --git a/audio/device.c b/profiles/audio/device.c
similarity index 100%
rename from audio/device.c
rename to profiles/audio/device.c
diff --git a/audio/device.h b/profiles/audio/device.h
similarity index 100%
rename from audio/device.h
rename to profiles/audio/device.h
diff --git a/audio/gateway.c b/profiles/audio/gateway.c
similarity index 100%
rename from audio/gateway.c
rename to profiles/audio/gateway.c
diff --git a/audio/gateway.h b/profiles/audio/gateway.h
similarity index 100%
rename from audio/gateway.h
rename to profiles/audio/gateway.h
diff --git a/audio/headset.c b/profiles/audio/headset.c
similarity index 100%
rename from audio/headset.c
rename to profiles/audio/headset.c
diff --git a/audio/headset.h b/profiles/audio/headset.h
similarity index 100%
rename from audio/headset.h
rename to profiles/audio/headset.h
diff --git a/audio/main.c b/profiles/audio/main.c
similarity index 100%
rename from audio/main.c
rename to profiles/audio/main.c
diff --git a/audio/manager.c b/profiles/audio/manager.c
similarity index 100%
rename from audio/manager.c
rename to profiles/audio/manager.c
diff --git a/audio/manager.h b/profiles/audio/manager.h
similarity index 100%
rename from audio/manager.h
rename to profiles/audio/manager.h
diff --git a/audio/media.c b/profiles/audio/media.c
similarity index 100%
rename from audio/media.c
rename to profiles/audio/media.c
diff --git a/audio/media.h b/profiles/audio/media.h
similarity index 100%
rename from audio/media.h
rename to profiles/audio/media.h
diff --git a/audio/player.c b/profiles/audio/player.c
similarity index 100%
rename from audio/player.c
rename to profiles/audio/player.c
diff --git a/audio/player.h b/profiles/audio/player.h
similarity index 100%
rename from audio/player.h
rename to profiles/audio/player.h
diff --git a/audio/rtp.h b/profiles/audio/rtp.h
similarity index 100%
rename from audio/rtp.h
rename to profiles/audio/rtp.h
diff --git a/audio/sink.c b/profiles/audio/sink.c
similarity index 100%
rename from audio/sink.c
rename to profiles/audio/sink.c
diff --git a/audio/sink.h b/profiles/audio/sink.h
similarity index 100%
rename from audio/sink.h
rename to profiles/audio/sink.h
diff --git a/audio/source.c b/profiles/audio/source.c
similarity index 100%
rename from audio/source.c
rename to profiles/audio/source.c
diff --git a/audio/source.h b/profiles/audio/source.h
similarity index 100%
rename from audio/source.h
rename to profiles/audio/source.h
diff --git a/audio/telephony-dummy.c b/profiles/audio/telephony-dummy.c
similarity index 100%
rename from audio/telephony-dummy.c
rename to profiles/audio/telephony-dummy.c
diff --git a/audio/telephony-maemo5.c b/profiles/audio/telephony-maemo5.c
similarity index 100%
rename from audio/telephony-maemo5.c
rename to profiles/audio/telephony-maemo5.c
diff --git a/audio/telephony-maemo6.c b/profiles/audio/telephony-maemo6.c
similarity index 100%
rename from audio/telephony-maemo6.c
rename to profiles/audio/telephony-maemo6.c
diff --git a/audio/telephony-ofono.c b/profiles/audio/telephony-ofono.c
similarity index 100%
rename from audio/telephony-ofono.c
rename to profiles/audio/telephony-ofono.c
diff --git a/audio/telephony.h b/profiles/audio/telephony.h
similarity index 100%
rename from audio/telephony.h
rename to profiles/audio/telephony.h
diff --git a/audio/transport.c b/profiles/audio/transport.c
similarity index 100%
rename from audio/transport.c
rename to profiles/audio/transport.c
diff --git a/audio/transport.h b/profiles/audio/transport.h
similarity index 100%
rename from audio/transport.h
rename to profiles/audio/transport.h
diff --git a/tools/avinfo.c b/tools/avinfo.c
index f036cf8..b01068d 100644
--- a/tools/avinfo.c
+++ b/tools/avinfo.c
@@ -39,7 +39,7 @@
#include <sys/ioctl.h>
#include <sys/socket.h>
-#include <a2dp-codecs.h>
+#include <audio/a2dp-codecs.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
--
1.7.11.7
^ permalink raw reply related
* Re: Moving bluetooth plugin to gstreamer
From: Luiz Augusto von Dentz @ 2012-11-08 15:20 UTC (permalink / raw)
To: Discussion of the development of and with GStreamer
Cc: linux-bluetooth, Thiago Sousa Santos, Tim-Philipp Müller
In-Reply-To: <CAD2+Bb1+32YKBTNnG93dchn9SNU0ur4ZKCZtKV80ohc3bkwsYg@mail.gmail.com>
Hi Guys,
On Fri, Aug 17, 2012 at 12:26 PM, sreerenj b <bsreerenj@gmail.com> wrote:
> Hi Tim,
>
> Are you planning to integrate bluez-gstreamer to plugsin-bad? or some new
> plugins for sbc?
>
>
> On Fri, Aug 17, 2012 at 6:13 AM, Marcel Holtmann <marcel@holtmann.org>
> wrote:
>>
>> Hi Tim,
>>
>> > > Since we now have a proper library for SBC codec
>> > > (http://git.kernel.org/?p=bluetooth/sbc.git;a=summary) and its patent
>> > > has expired June 2, 2010. (source:
>> > > http://en.wikipedia.org/wiki/SBC_(codec)), I wonder if it wouldn't be
>> > > a good idea to move the plugin to gstreamer tree?
>> > >
>> > > The plugin has the following elements:
>> > >
>> > > bluetooth: sbcenc: Bluetooth SBC encoder
>> > > bluetooth: sbcdec: Bluetooth SBC decoder
>> > > bluetooth: sbcparse: Bluetooth SBC parser
>> > > bluetooth: avdtpsink: Bluetooth AVDTP sink
>> > > bluetooth: a2dpsink: Bluetooth A2DP sink
>> > > bluetooth: rtpsbcpay: RTP packet payloader
>> >
>> > Sounds like a good idea to me.
>> >
>> > We'd probably add them to gst-plugins-bad first though, since that's
>> > where new plugins are usually added before they get moved to -good or
>> > elsewhere. And probably only to git master (ie. for the upcoming
>> > 0.11/1.0 API version).
>> >
>> > Would the idea be that you'd turn libsbc from noinst into a proper
>> > library, or would we just move that over into the plugin as well?
>>
>> as Luiz pointed out, that has already been done. It is standalone now
>> with its own GIT tree and a released 1.0 tarball for distributions to
>> package.
>>
>> Regards
>>
>> Marcel
Im about to send a patch to remove this from BlueZ, I hope somebody
from gstreamer community can step up and take the task to move this to
gstreamer tree, if nobody does I will eventually do it but this might
take some time for me since Im quite busy with upcoming BlueZ 5.0
(which is also the reason why we are cleaning up the tree).
--
Luiz Augusto von Dentz
^ permalink raw reply
* [PATCH v1 4/4] source: Add profile .connect and .disconnect
From: Mikel Astiz @ 2012-11-08 15:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz
In-Reply-To: <1352387785-20002-1-git-send-email-mikel.astiz.oss@gmail.com>
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
Add the connection and disconnection hooks to the a2dp_source
btd_profile.
---
audio/manager.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 82 insertions(+)
diff --git a/audio/manager.c b/audio/manager.c
index c5d295e..77e3540 100644
--- a/audio/manager.c
+++ b/audio/manager.c
@@ -83,6 +83,12 @@ struct audio_adapter {
gint ref;
};
+struct profile_req {
+ struct btd_device *device;
+ struct btd_profile *profile;
+ btd_profile_cb cb;
+};
+
static gboolean auto_connect = TRUE;
static int max_connected_headsets = 1;
static GKeyFile *config = NULL;
@@ -776,6 +782,79 @@ static int avrcp_probe(struct btd_profile *p, struct btd_device *device,
return 0;
}
+static struct profile_req *new_profile_request(struct btd_device *dev,
+ struct btd_profile *profile,
+ btd_profile_cb cb)
+{
+ struct profile_req *req;
+
+ req = g_new0(struct profile_req, 1);
+ req->device = dev;
+ req->profile = profile;
+ req->cb = cb;
+
+ return req;
+}
+
+static void profile_cb(struct audio_device *dev, int err, void *data)
+{
+ struct profile_req *req = data;
+
+ req->cb(req->profile, req->device, err);
+
+ g_free(req);
+}
+
+static int a2dp_source_connect(struct btd_device *dev,
+ struct btd_profile *profile,
+ btd_profile_cb cb)
+{
+ struct audio_device *audio_dev;
+ struct profile_req *req;
+ int err;
+
+ audio_dev = get_audio_dev(dev);
+ if (!audio_dev) {
+ DBG("unable to get a device object");
+ return -1;
+ }
+
+ req = new_profile_request(dev, profile, cb);
+
+ err = source_connect(audio_dev, profile_cb, req);
+ if (err < 0) {
+ g_free(req);
+ return err;
+ }
+
+ return 0;
+}
+
+static int a2dp_source_disconnect(struct btd_device *dev,
+ struct btd_profile *profile,
+ btd_profile_cb cb)
+{
+ struct audio_device *audio_dev;
+ struct profile_req *req;
+ int err;
+
+ audio_dev = get_audio_dev(dev);
+ if (!audio_dev) {
+ DBG("unable to get a device object");
+ return -1;
+ }
+
+ req = new_profile_request(dev, profile, cb);
+
+ err = source_disconnect(audio_dev, profile_cb, req);
+ if (err < 0) {
+ g_free(req);
+ return err;
+ }
+
+ return 0;
+}
+
static struct audio_adapter *audio_adapter_ref(struct audio_adapter *adp)
{
adp->ref++;
@@ -1150,6 +1229,9 @@ static struct btd_profile a2dp_source_profile = {
.device_probe = a2dp_source_probe,
.device_remove = audio_remove,
+ .connect = a2dp_source_connect,
+ .disconnect = a2dp_source_disconnect,
+
.adapter_probe = a2dp_source_server_probe,
};
--
1.7.11.7
^ permalink raw reply related
* [PATCH v1 3/4] source: Expose internal connection API
From: Mikel Astiz @ 2012-11-08 15:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz
In-Reply-To: <1352387785-20002-1-git-send-email-mikel.astiz.oss@gmail.com>
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
Separate the D-Bus code from the internal connection handling code,
exposing an internal API in case some internal codepath/plugin is
interested in using it.
---
audio/device.h | 3 ++
audio/source.c | 146 ++++++++++++++++++++++++++++++++-------------------------
audio/source.h | 2 +
3 files changed, 88 insertions(+), 63 deletions(-)
diff --git a/audio/device.h b/audio/device.h
index 1e2cac1..41e5635 100644
--- a/audio/device.h
+++ b/audio/device.h
@@ -22,6 +22,7 @@
*
*/
+struct audio_device;
struct source;
struct control;
struct target;
@@ -30,6 +31,8 @@ struct headset;
struct gateway;
struct dev_priv;
+typedef void (*audio_device_cb) (struct audio_device *dev, int err, void *data);
+
struct audio_device {
struct btd_device *btd_dev;
diff --git a/audio/source.c b/audio/source.c
index 04971d9..e48e308 100644
--- a/audio/source.c
+++ b/audio/source.c
@@ -53,7 +53,8 @@
#define STREAM_SETUP_RETRY_TIMER 2
struct pending_request {
- DBusMessage *msg;
+ audio_device_cb cb;
+ void *cb_data;
unsigned int id;
};
@@ -152,10 +153,12 @@ static void avdtp_state_callback(struct audio_device *dev,
}
static void pending_request_free(struct audio_device *dev,
- struct pending_request *pending)
+ struct pending_request *pending,
+ int err)
{
- if (pending->msg)
- dbus_message_unref(pending->msg);
+ if (pending->cb)
+ pending->cb(dev, err, pending->cb_data);
+
if (pending->id)
a2dp_cancel(dev, pending->id);
@@ -177,15 +180,12 @@ static void stream_state_changed(struct avdtp_stream *stream,
switch (new_state) {
case AVDTP_STATE_IDLE:
if (source->disconnect) {
- DBusMessage *reply;
struct pending_request *p;
p = source->disconnect;
source->disconnect = NULL;
- reply = dbus_message_new_method_return(p->msg);
- g_dbus_send_message(btd_get_dbus_connection(), reply);
- pending_request_free(dev, p);
+ pending_request_free(dev, p, 0);
}
if (source->session) {
@@ -211,35 +211,24 @@ static void stream_state_changed(struct avdtp_stream *stream,
source->stream_state = new_state;
}
-static void error_failed(DBusMessage *msg,
- const char *desc)
-{
- DBusMessage *reply = btd_error_failed(msg, desc);
- g_dbus_send_message(btd_get_dbus_connection(), reply);
-}
-
static gboolean stream_setup_retry(gpointer user_data)
{
struct source *source = user_data;
struct pending_request *pending = source->connect;
+ int err;
source->retry_id = 0;
if (source->stream_state >= AVDTP_STATE_OPEN) {
DBG("Stream successfully created, after XCASE connect:connect");
- if (pending->msg) {
- DBusMessage *reply;
- reply = dbus_message_new_method_return(pending->msg);
- g_dbus_send_message(btd_get_dbus_connection(), reply);
- }
+ err = 0;
} else {
DBG("Stream setup failed, after XCASE connect:connect");
- if (pending->msg)
- error_failed(pending->msg, "Stream setup failed");
+ err = -EIO;
}
source->connect = NULL;
- pending_request_free(source->dev, pending);
+ pending_request_free(source->dev, pending, err);
return FALSE;
}
@@ -258,14 +247,8 @@ static void stream_setup_complete(struct avdtp *session, struct a2dp_sep *sep,
if (stream) {
DBG("Stream successfully created");
- if (pending->msg) {
- DBusMessage *reply;
- reply = dbus_message_new_method_return(pending->msg);
- g_dbus_send_message(btd_get_dbus_connection(), reply);
- }
-
source->connect = NULL;
- pending_request_free(source->dev, pending);
+ pending_request_free(source->dev, pending, 0);
return;
}
@@ -279,10 +262,8 @@ static void stream_setup_complete(struct avdtp *session, struct a2dp_sep *sep,
stream_setup_retry,
source);
} else {
- if (pending->msg)
- error_failed(pending->msg, "Stream setup failed");
source->connect = NULL;
- pending_request_free(source->dev, pending);
+ pending_request_free(source->dev, pending, -EIO);
DBG("Stream setup failed : %s", avdtp_strerror(err));
}
}
@@ -309,9 +290,7 @@ static void select_complete(struct avdtp *session, struct a2dp_sep *sep,
return;
failed:
- if (pending->msg)
- error_failed(pending->msg, "Stream setup failed");
- pending_request_free(source->dev, pending);
+ pending_request_free(source->dev, pending, -EIO);
source->connect = NULL;
avdtp_unref(source->session);
source->session = NULL;
@@ -352,9 +331,7 @@ static void discovery_complete(struct avdtp *session, GSList *seps, struct avdtp
return;
failed:
- if (pending->msg)
- error_failed(pending->msg, "Stream setup failed");
- pending_request_free(source->dev, pending);
+ pending_request_free(source->dev, pending, -EIO);
source->connect = NULL;
avdtp_unref(source->session);
source->session = NULL;
@@ -379,71 +356,114 @@ gboolean source_setup_stream(struct source *source, struct avdtp *session)
return TRUE;
}
+static void generic_cb(struct audio_device *dev, int err, void *data)
+{
+ DBusMessage *msg = data;
+ DBusMessage *reply;
+
+ if (err < 0) {
+ reply = btd_error_failed(msg, strerror(-err));
+ g_dbus_send_message(btd_get_dbus_connection(), reply);
+ dbus_message_unref(msg);
+ return;
+ }
+
+ g_dbus_send_reply(btd_get_dbus_connection(), msg, DBUS_TYPE_INVALID);
+
+ dbus_message_unref(msg);
+}
+
static DBusMessage *local_connect(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct audio_device *dev = data;
+ int err;
+
+ err = source_connect(dev, generic_cb, msg);
+ if (err < 0)
+ return btd_error_failed(msg, strerror(-err));
+
+ dbus_message_ref(msg);
+
+ return NULL;
+}
+
+int source_connect(struct audio_device *dev, audio_device_cb cb, void *data)
+{
struct source *source = dev->source;
struct pending_request *pending;
if (!source->session)
source->session = avdtp_get(&dev->src, &dev->dst);
- if (!source->session)
- return btd_error_failed(msg, "Unable to get a session");
+ if (!source->session) {
+ DBG("Unable to get a session");
+ return -EIO;
+ }
if (source->connect || source->disconnect)
- return btd_error_busy(msg);
+ return -EBUSY;
if (source->stream_state >= AVDTP_STATE_OPEN)
- return btd_error_already_connected(msg);
+ return -EALREADY;
- if (!source_setup_stream(source, NULL))
- return btd_error_failed(msg, "Failed to create a stream");
+ if (!source_setup_stream(source, NULL)) {
+ DBG("Failed to create a stream");
+ return -EIO;
+ }
dev->auto_connect = FALSE;
pending = source->connect;
-
- pending->msg = dbus_message_ref(msg);
+ pending->cb = cb;
+ pending->cb_data = data;
DBG("stream creation in progress");
- return NULL;
+ return 0;
}
static DBusMessage *local_disconnect(DBusConnection *conn,
DBusMessage *msg, void *data)
{
+ struct audio_device *dev = data;
+ int err;
+
+ err = source_disconnect(dev, generic_cb, msg);
+ if (err < 0)
+ return btd_error_failed(msg, strerror(-err));
+
+ dbus_message_ref(msg);
+
+ return NULL;
+}
+
+int source_disconnect(struct audio_device *dev, audio_device_cb cb, void *data)
+{
struct audio_device *device = data;
struct source *source = device->source;
struct pending_request *pending;
int err;
if (!source->session)
- return btd_error_not_connected(msg);
+ return -ENOTCONN;
if (source->connect || source->disconnect)
- return btd_error_busy(msg);
+ return -EBUSY;
- if (source->stream_state < AVDTP_STATE_OPEN) {
- DBusMessage *reply = dbus_message_new_method_return(msg);
- if (!reply)
- return NULL;
- avdtp_unref(source->session);
- source->session = NULL;
- return reply;
- }
+ if (source->stream_state < AVDTP_STATE_OPEN)
+ return -ENOTCONN;
err = avdtp_close(source->session, source->stream, FALSE);
if (err < 0)
- return btd_error_failed(msg, strerror(-err));
+ return err;
pending = g_new0(struct pending_request, 1);
- pending->msg = dbus_message_ref(msg);
+ pending->cb = cb;
+ pending->cb_data = data;
source->disconnect = pending;
- return NULL;
+ return 0;
}
static DBusMessage *local_get_properties(DBusConnection *conn,
@@ -504,10 +524,10 @@ static void source_free(struct audio_device *dev)
avdtp_unref(source->session);
if (source->connect)
- pending_request_free(dev, source->connect);
+ pending_request_free(dev, source->connect, -ECANCELED);
if (source->disconnect)
- pending_request_free(dev, source->disconnect);
+ pending_request_free(dev, source->disconnect, -ECANCELED);
if (source->retry_id)
g_source_remove(source->retry_id);
diff --git a/audio/source.h b/audio/source.h
index 695bded..dadb392 100644
--- a/audio/source.h
+++ b/audio/source.h
@@ -44,6 +44,8 @@ struct source *source_init(struct audio_device *dev);
void source_unregister(struct audio_device *dev);
gboolean source_is_active(struct audio_device *dev);
source_state_t source_get_state(struct audio_device *dev);
+int source_connect(struct audio_device *dev, audio_device_cb cb, void *data);
+int source_disconnect(struct audio_device *dev, audio_device_cb cb, void *data);
gboolean source_new_stream(struct audio_device *dev, struct avdtp *session,
struct avdtp_stream *stream);
gboolean source_setup_stream(struct source *source, struct avdtp *session);
--
1.7.11.7
^ permalink raw reply related
* [PATCH v1 2/4] audio: Trivial function rename
From: Mikel Astiz @ 2012-11-08 15:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz
In-Reply-To: <1352387785-20002-1-git-send-email-mikel.astiz.oss@gmail.com>
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
Use the local_ name prefix for local functions implementing the D-Bus
API.
---
audio/sink.c | 12 ++++++------
audio/source.c | 12 ++++++------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/audio/sink.c b/audio/sink.c
index 2e63579..b9e4fe0 100644
--- a/audio/sink.c
+++ b/audio/sink.c
@@ -390,7 +390,7 @@ gboolean sink_setup_stream(struct sink *sink, struct avdtp *session)
return TRUE;
}
-static DBusMessage *sink_connect(DBusConnection *conn,
+static DBusMessage *local_connect(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct audio_device *dev = data;
@@ -423,7 +423,7 @@ static DBusMessage *sink_connect(DBusConnection *conn,
return NULL;
}
-static DBusMessage *sink_disconnect(DBusConnection *conn,
+static DBusMessage *local_disconnect(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct audio_device *device = data;
@@ -457,7 +457,7 @@ static DBusMessage *sink_disconnect(DBusConnection *conn,
return NULL;
}
-static DBusMessage *sink_get_properties(DBusConnection *conn,
+static DBusMessage *local_get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct audio_device *device = data;
@@ -489,11 +489,11 @@ static DBusMessage *sink_get_properties(DBusConnection *conn,
}
static const GDBusMethodTable sink_methods[] = {
- { GDBUS_ASYNC_METHOD("Connect", NULL, NULL, sink_connect) },
- { GDBUS_ASYNC_METHOD("Disconnect", NULL, NULL, sink_disconnect) },
+ { GDBUS_ASYNC_METHOD("Connect", NULL, NULL, local_connect) },
+ { GDBUS_ASYNC_METHOD("Disconnect", NULL, NULL, local_disconnect) },
{ GDBUS_METHOD("GetProperties",
NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
- sink_get_properties) },
+ local_get_properties) },
{ }
};
diff --git a/audio/source.c b/audio/source.c
index 1d0c74a..04971d9 100644
--- a/audio/source.c
+++ b/audio/source.c
@@ -379,7 +379,7 @@ gboolean source_setup_stream(struct source *source, struct avdtp *session)
return TRUE;
}
-static DBusMessage *source_connect(DBusConnection *conn,
+static DBusMessage *local_connect(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct audio_device *dev = data;
@@ -412,7 +412,7 @@ static DBusMessage *source_connect(DBusConnection *conn,
return NULL;
}
-static DBusMessage *source_disconnect(DBusConnection *conn,
+static DBusMessage *local_disconnect(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct audio_device *device = data;
@@ -446,7 +446,7 @@ static DBusMessage *source_disconnect(DBusConnection *conn,
return NULL;
}
-static DBusMessage *source_get_properties(DBusConnection *conn,
+static DBusMessage *local_get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct audio_device *device = data;
@@ -478,11 +478,11 @@ static DBusMessage *source_get_properties(DBusConnection *conn,
}
static const GDBusMethodTable source_methods[] = {
- { GDBUS_ASYNC_METHOD("Connect", NULL, NULL, source_connect) },
- { GDBUS_ASYNC_METHOD("Disconnect", NULL, NULL, source_disconnect) },
+ { GDBUS_ASYNC_METHOD("Connect", NULL, NULL, local_connect) },
+ { GDBUS_ASYNC_METHOD("Disconnect", NULL, NULL, local_disconnect) },
{ GDBUS_METHOD("GetProperties",
NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
- source_get_properties) },
+ local_get_properties) },
{ }
};
--
1.7.11.7
^ permalink raw reply related
* [PATCH v1 1/4] audio: Split A2DP into three btd_profile
From: Mikel Astiz @ 2012-11-08 15:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz
In-Reply-To: <1352387785-20002-1-git-send-email-mikel.astiz.oss@gmail.com>
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
Merging the three audio profiles (AVDTP, A2DP sink and A2DP source)
into one was convenient in the past was doesn't fit very well the new
btd_profile approach. The split is also more consistent with the
approach of the HFP/HSP profile.
---
audio/a2dp.c | 88 ++++++++++++++++++++++-------------------------
audio/a2dp.h | 4 ++-
audio/manager.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++---------
3 files changed, 133 insertions(+), 64 deletions(-)
diff --git a/audio/a2dp.c b/audio/a2dp.c
index 7799420..6bfc8c2 100644
--- a/audio/a2dp.c
+++ b/audio/a2dp.c
@@ -1167,73 +1167,67 @@ static struct a2dp_server *find_server(GSList *list, const bdaddr_t *src)
return NULL;
}
-int a2dp_register(const bdaddr_t *src, GKeyFile *config)
+int a2dp_server_register(const bdaddr_t *src, GKeyFile *config)
{
- gboolean source = TRUE, sink = FALSE;
gboolean delay_reporting = FALSE;
- char *str;
- GError *err = NULL;
struct a2dp_server *server;
+ int av_err;
- if (!config)
- goto proceed;
+ server = find_server(servers, src);
+ if (server)
+ return 0;
- str = g_key_file_get_string(config, "General", "Enable", &err);
+ server = g_new0(struct a2dp_server, 1);
- if (err) {
- DBG("audio.conf: %s", err->message);
- g_clear_error(&err);
- } else {
- if (strstr(str, "Sink"))
- source = TRUE;
- if (strstr(str, "Source"))
- sink = TRUE;
- g_free(str);
+ av_err = avdtp_init(src, config, &server->version);
+ if (av_err < 0) {
+ g_free(server);
+ return av_err;
}
- str = g_key_file_get_string(config, "General", "Disable", &err);
+ bacpy(&server->src, src);
+ servers = g_slist_append(servers, server);
- if (err) {
- DBG("audio.conf: %s", err->message);
- g_clear_error(&err);
- } else {
- if (strstr(str, "Sink"))
- source = FALSE;
- if (strstr(str, "Source"))
- sink = FALSE;
- g_free(str);
- }
+ if (config)
+ delay_reporting = g_key_file_get_boolean(config, "A2DP",
+ "DelayReporting", NULL);
-proceed:
+ if (delay_reporting)
+ server->version = 0x0103;
+ else
+ server->version = 0x0102;
+
+ return 0;
+}
+
+int a2dp_source_register(const bdaddr_t *src, GKeyFile *config)
+{
+ struct a2dp_server *server;
server = find_server(servers, src);
if (!server) {
- int av_err;
+ DBG("AVDTP not registered");
+ return -EPROTONOSUPPORT;
- server = g_new0(struct a2dp_server, 1);
+ }
- av_err = avdtp_init(src, config, &server->version);
- if (av_err < 0) {
- g_free(server);
- return av_err;
- }
+ server->source_enabled = TRUE;
- bacpy(&server->src, src);
- servers = g_slist_append(servers, server);
- }
+ return 0;
+}
- if (config)
- delay_reporting = g_key_file_get_boolean(config, "A2DP",
- "DelayReporting", NULL);
+int a2dp_sink_register(const bdaddr_t *src, GKeyFile *config)
+{
+ struct a2dp_server *server;
- if (delay_reporting)
- server->version = 0x0103;
- else
- server->version = 0x0102;
+ server = find_server(servers, src);
+ if (!server) {
+ DBG("AVDTP not registered");
+ return -EPROTONOSUPPORT;
- server->source_enabled = source;
+ }
- server->sink_enabled = sink;
+ server->sink_enabled = TRUE;
return 0;
}
diff --git a/audio/a2dp.h b/audio/a2dp.h
index 736bc66..c471499 100644
--- a/audio/a2dp.h
+++ b/audio/a2dp.h
@@ -64,7 +64,9 @@ typedef void (*a2dp_stream_cb_t) (struct avdtp *session,
struct avdtp_error *err,
void *user_data);
-int a2dp_register(const bdaddr_t *src, GKeyFile *config);
+int a2dp_server_register(const bdaddr_t *src, GKeyFile *config);
+int a2dp_source_register(const bdaddr_t *src, GKeyFile *config);
+int a2dp_sink_register(const bdaddr_t *src, GKeyFile *config);
void a2dp_unregister(const bdaddr_t *src);
struct a2dp_sep *a2dp_add_sep(const bdaddr_t *src, uint8_t type,
diff --git a/audio/manager.c b/audio/manager.c
index 4ea61bf..c5d295e 100644
--- a/audio/manager.c
+++ b/audio/manager.c
@@ -722,7 +722,7 @@ static int ag_probe(struct btd_profile *p, struct btd_device *device,
return 0;
}
-static int a2dp_probe(struct btd_profile *p, struct btd_device *device,
+static int a2dp_source_probe(struct btd_profile *p, struct btd_device *device,
GSList *uuids)
{
struct audio_device *audio_dev;
@@ -733,13 +733,23 @@ static int a2dp_probe(struct btd_profile *p, struct btd_device *device,
return -1;
}
- if (g_slist_find_custom(uuids, A2DP_SINK_UUID, bt_uuid_strcmp) &&
- audio_dev->sink == NULL)
- audio_dev->sink = sink_init(audio_dev);
+ audio_dev->source = source_init(audio_dev);
- if (g_slist_find_custom(uuids, A2DP_SOURCE_UUID, bt_uuid_strcmp) &&
- audio_dev->source == NULL)
- audio_dev->source = source_init(audio_dev);
+ return 0;
+}
+
+static int a2dp_sink_probe(struct btd_profile *p, struct btd_device *device,
+ GSList *uuids)
+{
+ struct audio_device *audio_dev;
+
+ audio_dev = get_audio_dev(device);
+ if (!audio_dev) {
+ DBG("unable to get a device object");
+ return -1;
+ }
+
+ audio_dev->sink = sink_init(audio_dev);
return 0;
}
@@ -975,7 +985,7 @@ static int a2dp_server_probe(struct btd_profile *p,
if (!adp)
return -EINVAL;
- err = a2dp_register(adapter_get_address(adapter), config);
+ err = a2dp_server_register(adapter_get_address(adapter), config);
if (err < 0)
audio_adapter_unref(adp);
@@ -998,6 +1008,40 @@ static void a2dp_server_remove(struct btd_profile *p,
audio_adapter_unref(adp);
}
+static int a2dp_source_server_probe(struct btd_profile *p,
+ struct btd_adapter *adapter)
+{
+ struct audio_adapter *adp;
+ const gchar *path = adapter_get_path(adapter);
+
+ DBG("path %s", path);
+
+ adp = audio_adapter_get(adapter);
+ if (!adp)
+ return -EINVAL;
+
+ audio_adapter_unref(adp); /* Referenced by a2dp server */
+
+ return a2dp_source_register(adapter_get_address(adapter), config);
+}
+
+static int a2dp_sink_server_probe(struct btd_profile *p,
+ struct btd_adapter *adapter)
+{
+ struct audio_adapter *adp;
+ const gchar *path = adapter_get_path(adapter);
+
+ DBG("path %s", path);
+
+ adp = audio_adapter_get(adapter);
+ if (!adp)
+ return -EINVAL;
+
+ audio_adapter_unref(adp); /* Referenced by a2dp server */
+
+ return a2dp_sink_register(adapter_get_address(adapter), config);
+}
+
static int avrcp_server_probe(struct btd_profile *p,
struct btd_adapter *adapter)
{
@@ -1090,18 +1134,35 @@ static struct btd_profile gateway_profile = {
.adapter_remove = gateway_server_remove,
};
-static struct btd_profile a2dp_profile = {
- .name = "audio-a2dp",
+static struct btd_profile avdtp_profile = {
+ .name = "audio-avdtp",
- .remote_uuids = BTD_UUIDS(A2DP_SOURCE_UUID, A2DP_SINK_UUID,
- ADVANCED_AUDIO_UUID),
- .device_probe = a2dp_probe,
- .device_remove = audio_remove,
+ .remote_uuids = BTD_UUIDS(ADVANCED_AUDIO_UUID),
.adapter_probe = a2dp_server_probe,
.adapter_remove = a2dp_server_remove,
};
+static struct btd_profile a2dp_source_profile = {
+ .name = "audio-source",
+
+ .remote_uuids = BTD_UUIDS(A2DP_SOURCE_UUID),
+ .device_probe = a2dp_source_probe,
+ .device_remove = audio_remove,
+
+ .adapter_probe = a2dp_source_server_probe,
+};
+
+static struct btd_profile a2dp_sink_profile = {
+ .name = "audio-sink",
+
+ .remote_uuids = BTD_UUIDS(A2DP_SINK_UUID),
+ .device_probe = a2dp_sink_probe,
+ .device_remove = audio_remove,
+
+ .adapter_probe = a2dp_sink_server_probe,
+};
+
static struct btd_profile avrcp_profile = {
.name = "audio-avrcp",
@@ -1194,7 +1255,13 @@ proceed:
btd_profile_register(&gateway_profile);
if (enabled.source || enabled.sink)
- btd_profile_register(&a2dp_profile);
+ btd_profile_register(&avdtp_profile);
+
+ if (enabled.source)
+ btd_profile_register(&a2dp_source_profile);
+
+ if (enabled.sink)
+ btd_profile_register(&a2dp_sink_profile);
if (enabled.control)
btd_profile_register(&avrcp_profile);
@@ -1219,8 +1286,14 @@ void audio_manager_exit(void)
if (enabled.gateway)
btd_profile_unregister(&gateway_profile);
+ if (enabled.source)
+ btd_profile_unregister(&a2dp_source_profile);
+
+ if (enabled.sink)
+ btd_profile_unregister(&a2dp_sink_profile);
+
if (enabled.source || enabled.sink)
- btd_profile_unregister(&a2dp_profile);
+ btd_profile_unregister(&avdtp_profile);
if (enabled.control)
btd_profile_unregister(&avrcp_profile);
--
1.7.11.7
^ permalink raw reply related
* [PATCH v1 0/4] Adopt btd_profile for A2DP
From: Mikel Astiz @ 2012-11-08 15:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
I resend the patches which were previously part of RFC v0 "WIP: btd_profile connect and disconnect", focusing now on the audio-related patches.
The proposal is to split A2DP roles into different btd_profile instances, in order to expose .connect and .disconnect.
The implementation includes the Source role only (patches 3 and 4), but you can imagine that the Sink would be analogous.
Mikel Astiz (4):
audio: Split A2DP into three btd_profile
audio: Trivial function rename
source: Expose internal connection API
source: Add profile .connect and .disconnect
audio/a2dp.c | 88 +++++++++++++-------------
audio/a2dp.h | 4 +-
audio/device.h | 3 +
audio/manager.c | 187 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
audio/sink.c | 12 ++--
audio/source.c | 158 ++++++++++++++++++++++++++---------------------
audio/source.h | 2 +
7 files changed, 315 insertions(+), 139 deletions(-)
--
1.7.11.7
^ permalink raw reply
* Re: DBus.Properties: help for remaining convertions
From: Mikel Astiz @ 2012-11-08 15:04 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: Lucas De Marchi, BlueZ development
In-Reply-To: <CABBYNZK_W7q=cc4m4W2QwWdAp8+JEe7NkFGhwSjFPcyRzqN=OA@mail.gmail.com>
Hi,
On Wed, Nov 7, 2012 at 11:34 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> Hi Lucas,
>
> On Wed, Nov 7, 2012 at 9:20 PM, Lucas De Marchi
> <lucas.demarchi@profusion.mobi> wrote:
>> Luiz, do you plan to convert to DBus.Properties after you finish the
>> pending features you are doing? I think audio/transport.c is the only
>> one still requiring a feature in gdbus: security check for the sender
>> as discussed previously. I can add this when we are converting audio.
>
> I can take care of converting the audio after we move it to profiles,
> and yes we need the sender check for in gdbus, but that can come
> latter.
I agree that we need to move to the new profile infrastructure first.
Some of these D-Bus interfaces might even disappear completely
(Headset, AudioSink, etc.), to be replaced by the generic
profile-handling API.
I sent some related patches in a previous RFC, which I will resend now
focusing on the audio part only.
Cheers,
Mikel
^ permalink raw reply
* [RFC v0 7/7] adapter: Remove FindDevice method from D-Bus API
From: Mikel Astiz @ 2012-11-08 14:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz
In-Reply-To: <1352385015-2127-1-git-send-email-mikel.astiz.oss@gmail.com>
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
ObjectManager.GetManagedObjects() returns all devices and their
corresponding properties to any interested client. The device address is
included in the property dictionary and therefore having such a
FindDevice method is an unnecessary duplication.
---
doc/adapter-api.txt | 7 -------
src/adapter.c | 38 --------------------------------------
2 files changed, 45 deletions(-)
diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
index 98a3919..f976992 100644
--- a/doc/adapter-api.txt
+++ b/doc/adapter-api.txt
@@ -64,13 +64,6 @@ Methods void RequestSession()
org.bluez.Error.Failed
org.bluez.Error.NotAuthorized
- object FindDevice(string address)
-
- Returns the object path of device for given address.
-
- Possible Errors: org.bluez.Error.DoesNotExist
- org.bluez.Error.InvalidArguments
-
void RemoveDevice(object device)
This removes the remote device object at the given
diff --git a/src/adapter.c b/src/adapter.c
index 4d9820f..2be01d6 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1472,40 +1472,6 @@ static DBusMessage *remove_device(DBusConnection *conn, DBusMessage *msg,
return NULL;
}
-static DBusMessage *find_device(DBusConnection *conn, DBusMessage *msg,
- void *data)
-{
- struct btd_adapter *adapter = data;
- struct btd_device *device;
- DBusMessage *reply;
- const gchar *address;
- GSList *l;
- const gchar *dev_path;
-
- if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address,
- DBUS_TYPE_INVALID))
- return btd_error_invalid_args(msg);
-
- l = g_slist_find_custom(adapter->devices,
- address, (GCompareFunc) device_address_cmp);
- if (!l)
- return btd_error_does_not_exist(msg);
-
- device = l->data;
-
- reply = dbus_message_new_method_return(msg);
- if (!reply)
- return NULL;
-
- dev_path = device_get_path(device);
-
- dbus_message_append_args(reply,
- DBUS_TYPE_OBJECT_PATH, &dev_path,
- DBUS_TYPE_INVALID);
-
- return reply;
-}
-
static void agent_removed(struct agent *agent, struct btd_adapter *adapter)
{
mgmt_set_io_capability(adapter->dev_id, IO_CAPABILITY_NOINPUTNOOUTPUT);
@@ -1577,10 +1543,6 @@ static const GDBusMethodTable adapter_methods[] = {
{ GDBUS_ASYNC_METHOD("RemoveDevice",
GDBUS_ARGS({ "device", "o" }), NULL,
remove_device) },
- { GDBUS_METHOD("FindDevice",
- GDBUS_ARGS({ "address", "s" }),
- GDBUS_ARGS({ "device", "o" }),
- find_device) },
{ GDBUS_METHOD("RegisterAgent",
GDBUS_ARGS({ "agent", "o" },
{ "capability", "s" }), NULL,
--
1.7.11.7
^ permalink raw reply related
* [RFC v0 6/7] adapter: Remove redundant Devices property
From: Mikel Astiz @ 2012-11-08 14:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz
In-Reply-To: <1352385015-2127-1-git-send-email-mikel.astiz.oss@gmail.com>
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
The ObjectManager interface already reports the list of devices, so the
the property can be entirely removed.
---
doc/adapter-api.txt | 4 ----
src/adapter.c | 30 ------------------------------
2 files changed, 34 deletions(-)
diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
index 13941c9..98a3919 100644
--- a/doc/adapter-api.txt
+++ b/doc/adapter-api.txt
@@ -171,10 +171,6 @@ Properties string Address [readonly]
Indicates that a device discovery procedure is active.
- array{object} Devices [readonly]
-
- List of device object paths.
-
array{string} UUIDs [readonly]
List of 128-bit UUIDs that represents the available
diff --git a/src/adapter.c b/src/adapter.c
index 9c4765e..4d9820f 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -974,9 +974,6 @@ static struct btd_device *adapter_create_device(struct btd_adapter *adapter,
adapter->devices = g_slist_append(adapter->devices, device);
- g_dbus_emit_property_changed(btd_get_dbus_connection(),
- adapter->path, ADAPTER_INTERFACE, "Devices");
-
return device;
}
@@ -1027,9 +1024,6 @@ void adapter_remove_device(struct btd_adapter *adapter,
service_auth_cancel(auth);
}
- g_dbus_emit_property_changed(btd_get_dbus_connection(),
- adapter->path, ADAPTER_INTERFACE, "Devices");
-
device_remove(dev, remove_storage);
}
@@ -1335,29 +1329,6 @@ static gboolean adapter_property_get_discovering(
return TRUE;
}
-static gboolean adapter_property_get_devices(
- const GDBusPropertyTable *property,
- DBusMessageIter *iter, void *data)
-{
- struct btd_adapter *adapter = data;
- DBusMessageIter entry;
- GSList *l;
-
- dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
- DBUS_TYPE_OBJECT_PATH_AS_STRING, &entry);
-
- for (l = adapter->devices; l != NULL; l = l->next) {
- const char *path = device_get_path(l->data);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_OBJECT_PATH,
- &path);
- }
-
- dbus_message_iter_close_container(iter, &entry);
-
- return TRUE;
-}
-
static gboolean adapter_property_get_uuids(const GDBusPropertyTable *property,
DBusMessageIter *iter, void *data)
{
@@ -1636,7 +1607,6 @@ static const GDBusPropertyTable adapter_properties[] = {
{ "PairableTimeout", "u", adapter_property_get_pairable_timeout,
adapter_property_set_pairable_timeout },
{ "Discovering", "b", adapter_property_get_discovering },
- { "Devices", "ao", adapter_property_get_devices },
{ "UUIDs", "as", adapter_property_get_uuids },
{ }
};
--
1.7.11.7
^ permalink raw reply related
* [RFC v0 5/7] adapter: Remove DevicesFound signal
From: Mikel Astiz @ 2012-11-08 14:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz
In-Reply-To: <1352385015-2127-1-git-send-email-mikel.astiz.oss@gmail.com>
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
ObjectManager reports the D-Bus interfaces of all known devices,
including the ones detected during discovery. Therefore this signal is
not required.
---
doc/adapter-api.txt | 13 ++-----
src/adapter.c | 102 ++--------------------------------------------------
2 files changed, 4 insertions(+), 111 deletions(-)
diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
index 132e60f..13941c9 100644
--- a/doc/adapter-api.txt
+++ b/doc/adapter-api.txt
@@ -45,8 +45,8 @@ Methods void RequestSession()
resolving. Use StopDiscovery to release the sessions
acquired.
- This process will start emitting DevicesFound and
- PropertyChanged "Discovering" signals.
+ This process will start creating Device objects as
+ new devices are discovered.
Possible errors: org.bluez.Error.NotReady
org.bluez.Error.Failed
@@ -107,15 +107,6 @@ Methods void RequestSession()
Possible errors: org.bluez.Error.DoesNotExist
-Signals DevicesFound(array{object path, dict values})
-
- This signal will be sent every time devices have
- been found. In general they only appear during a
- device discovery.
-
- The dictionary contains the properties from the
- org.bluez.Device interface.
-
Properties string Address [readonly]
The Bluetooth device address.
diff --git a/src/adapter.c b/src/adapter.c
index 1f02f0b..9c4765e 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -82,7 +82,6 @@
#define IO_CAPABILITY_INVALID 0xFF
#define REMOVE_TEMP_TIMEOUT (3 * 60)
-#define PENDING_FOUND_MAX 5
#define SETTINGS_PATH STORAGEDIR "/%s/settings"
#define CACHE_PATH STORAGEDIR "/%s/cache/%s"
@@ -119,9 +118,7 @@ struct service_auth {
};
struct discovery {
- guint id;
GSList *found;
- GSList *pending;
};
struct btd_adapter {
@@ -560,49 +557,6 @@ static uint8_t get_needed_mode(struct btd_adapter *adapter, uint8_t mode)
return mode;
}
-static void send_devices_found(struct btd_adapter *adapter)
-{
- struct discovery *discovery = adapter->discovery;
- DBusConnection *conn = btd_get_dbus_connection();
- DBusMessageIter iter, props;
- DBusMessage *signal;
-
- if (!discovery || !discovery->pending)
- return;
-
- signal = dbus_message_new_signal(adapter->path, ADAPTER_INTERFACE,
- "DevicesFound");
- if (!signal) {
- error("Unable to allocate DevicesFound signal");
- g_slist_free(discovery->pending);
- discovery->pending = NULL;
- return;
- }
-
- dbus_message_iter_init_append(signal, &iter);
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{oa{sv}}",
- &props);
-
- while (discovery->pending) {
- struct btd_device *dev = discovery->pending->data;
- const char *path = device_get_path(dev);
- DBusMessageIter entry;
-
- dbus_message_iter_open_container(&props, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_OBJECT_PATH,
- &path);
- g_dbus_get_properties(conn, path, DEVICE_INTERFACE, &entry);
- dbus_message_iter_close_container(&props, &entry);
-
- discovery->pending = g_slist_remove(discovery->pending, dev);
- }
-
- dbus_message_iter_close_container(&iter, &props);
-
- g_dbus_send_message(conn, signal);
-}
-
static void invalidate_rssi(gpointer a)
{
struct btd_device *dev = a;
@@ -617,11 +571,6 @@ static void discovery_cleanup(struct btd_adapter *adapter)
if (!discovery)
return;
- if (discovery->id > 0)
- g_source_remove(discovery->id);
-
- send_devices_found(adapter);
-
adapter->discovery = NULL;
g_slist_free_full(discovery->found, invalidate_rssi);
@@ -1057,10 +1006,8 @@ void adapter_remove_device(struct btd_adapter *adapter,
adapter->devices = g_slist_remove(adapter->devices, dev);
- if (discovery) {
+ if (discovery)
discovery->found = g_slist_remove(discovery->found, dev);
- discovery->pending = g_slist_remove(discovery->pending, dev);
- }
adapter->connections = g_slist_remove(adapter->connections, dev);
@@ -1673,12 +1620,6 @@ static const GDBusMethodTable adapter_methods[] = {
{ }
};
-static const GDBusSignalTable adapter_signals[] = {
- { GDBUS_SIGNAL("DevicesFound",
- GDBUS_ARGS({ "devices", "a{oa{sv}}" })) },
- { }
-};
-
static const GDBusPropertyTable adapter_properties[] = {
{ "Address", "s", adapter_property_get_address },
{ "Name", "s", adapter_property_get_name, adapter_property_set_name },
@@ -2740,7 +2681,7 @@ struct btd_adapter *adapter_create(int id)
if (!g_dbus_register_interface(btd_get_dbus_connection(),
path, ADAPTER_INTERFACE,
- adapter_methods, adapter_signals,
+ adapter_methods, NULL,
adapter_properties, adapter,
adapter_free)) {
error("Adapter interface init failed on path %s", path);
@@ -2803,26 +2744,6 @@ void adapter_set_allow_name_changes(struct btd_adapter *adapter,
adapter->allow_name_changes = allow_name_changes;
}
-static gboolean send_found(gpointer user_data)
-{
- struct btd_adapter *adapter = user_data;
- struct discovery *discovery = adapter->discovery;
-
- if (!discovery)
- return FALSE;
-
- discovery->id = 0;
-
- if (!discovery->pending)
- return FALSE;
-
- send_devices_found(adapter);
-
- discovery->id = g_timeout_add_seconds(1, send_found, adapter);
-
- return FALSE;
-}
-
static gboolean adapter_remove_temp(gpointer data)
{
struct btd_adapter *adapter = data;
@@ -2847,14 +2768,11 @@ static gboolean adapter_remove_temp(gpointer data)
void adapter_set_discovering(struct btd_adapter *adapter,
gboolean discovering)
{
- struct discovery *discovery;
guint connect_list_len;
if (discovering && !adapter->discovery)
adapter->discovery = g_new0(struct discovery, 1);
- discovery = adapter->discovery;
-
g_dbus_emit_property_changed(btd_get_dbus_connection(), adapter->path,
ADAPTER_INTERFACE, "Discovering");
@@ -2863,7 +2781,6 @@ void adapter_set_discovering(struct btd_adapter *adapter,
g_source_remove(adapter->remove_temp);
adapter->remove_temp = 0;
}
- discovery->id = g_timeout_add_seconds(1, send_found, adapter);
return;
}
@@ -3016,21 +2933,6 @@ void adapter_update_found_devices(struct btd_adapter *adapter,
eir_data_free(&eir_data);
- if (!g_slist_find(discovery->pending, dev)) {
- guint pending_count;
-
- discovery->pending = g_slist_prepend(discovery->pending, dev);
-
- pending_count = g_slist_length(discovery->pending);
-
- if (discovery->id == 0) {
- discovery->id = g_idle_add(send_found, adapter);
- } else if (pending_count > PENDING_FOUND_MAX) {
- g_source_remove(discovery->id);
- discovery->id = g_idle_add(send_found, adapter);
- }
- }
-
if (g_slist_find(discovery->found, dev))
return;
--
1.7.11.7
^ permalink raw reply related
* [RFC v0 4/7] adapter: Remove redundant D-Bus signals
From: Mikel Astiz @ 2012-11-08 14:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz
In-Reply-To: <1352385015-2127-1-git-send-email-mikel.astiz.oss@gmail.com>
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
The Adapter interface already reports changes in the device list in form
of property changes, so there is no need to keep these two signals.
---
doc/adapter-api.txt | 8 --------
src/adapter.c | 17 -----------------
2 files changed, 25 deletions(-)
diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
index b638586..132e60f 100644
--- a/doc/adapter-api.txt
+++ b/doc/adapter-api.txt
@@ -116,14 +116,6 @@ Signals DevicesFound(array{object path, dict values})
The dictionary contains the properties from the
org.bluez.Device interface.
- DeviceCreated(object device)
-
- Parameter is object path of created device.
-
- DeviceRemoved(object device)
-
- Parameter is object path of removed device.
-
Properties string Address [readonly]
The Bluetooth device address.
diff --git a/src/adapter.c b/src/adapter.c
index f4bb622..1f02f0b 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1014,7 +1014,6 @@ static struct btd_device *adapter_create_device(struct btd_adapter *adapter,
uint8_t bdaddr_type)
{
struct btd_device *device;
- const char *path;
DBG("%s", address);
@@ -1026,12 +1025,6 @@ static struct btd_device *adapter_create_device(struct btd_adapter *adapter,
adapter->devices = g_slist_append(adapter->devices, device);
- path = device_get_path(device);
- g_dbus_emit_signal(btd_get_dbus_connection(), adapter->path,
- ADAPTER_INTERFACE, "DeviceCreated",
- DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
-
g_dbus_emit_property_changed(btd_get_dbus_connection(),
adapter->path, ADAPTER_INTERFACE, "Devices");
@@ -1059,7 +1052,6 @@ void adapter_remove_device(struct btd_adapter *adapter,
struct btd_device *dev,
gboolean remove_storage)
{
- const gchar *dev_path = device_get_path(dev);
struct discovery *discovery = adapter->discovery;
GList *l;
@@ -1091,11 +1083,6 @@ void adapter_remove_device(struct btd_adapter *adapter,
g_dbus_emit_property_changed(btd_get_dbus_connection(),
adapter->path, ADAPTER_INTERFACE, "Devices");
- g_dbus_emit_signal(btd_get_dbus_connection(), adapter->path,
- ADAPTER_INTERFACE, "DeviceRemoved",
- DBUS_TYPE_OBJECT_PATH, &dev_path,
- DBUS_TYPE_INVALID);
-
device_remove(dev, remove_storage);
}
@@ -1687,10 +1674,6 @@ static const GDBusMethodTable adapter_methods[] = {
};
static const GDBusSignalTable adapter_signals[] = {
- { GDBUS_SIGNAL("DeviceCreated",
- GDBUS_ARGS({ "device", "o" })) },
- { GDBUS_SIGNAL("DeviceRemoved",
- GDBUS_ARGS({ "device", "o" })) },
{ GDBUS_SIGNAL("DevicesFound",
GDBUS_ARGS({ "devices", "a{oa{sv}}" })) },
{ }
--
1.7.11.7
^ permalink raw reply related
* [RFC v0 3/7] manager: Remove redundant Adapters property
From: Mikel Astiz @ 2012-11-08 14:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz
In-Reply-To: <1352385015-2127-1-git-send-email-mikel.astiz.oss@gmail.com>
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
The ObjectManager interface already reports the available adapters, so
the property can be entirely removed.
---
doc/manager-api.txt | 6 +-----
src/manager.c | 30 ------------------------------
2 files changed, 1 insertion(+), 35 deletions(-)
diff --git a/doc/manager-api.txt b/doc/manager-api.txt
index b6e4a0f..d225239 100644
--- a/doc/manager-api.txt
+++ b/doc/manager-api.txt
@@ -99,10 +99,6 @@ Object path /
Possible errors: org.bluez.Error.DoesNotExist
-Properties array{object} Adapters [readonly]
-
- List of adapter object paths.
-
- object DefaultAdapter [readonly, optional]
+Properties object DefaultAdapter [readonly, optional]
Object path for the default adapter, if any.
diff --git a/src/manager.c b/src/manager.c
index f07cefe..d3e37b1 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -109,29 +109,6 @@ done:
return reply;
}
-static gboolean manager_property_get_adapters(
- const GDBusPropertyTable *property,
- DBusMessageIter *iter, void *data)
-{
- DBusMessageIter entry;
- GSList *l;
-
- dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
- DBUS_TYPE_OBJECT_PATH_AS_STRING, &entry);
-
- for (l = adapters; l != NULL; l = l->next) {
- struct btd_adapter *adapter = l->data;
- const char *path = adapter_get_path(adapter);
-
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_OBJECT_PATH,
- &path);
- }
-
- dbus_message_iter_close_container(iter, &entry);
-
- return TRUE;
-}
-
static gboolean manager_property_get_default_adapter(
const GDBusPropertyTable *property,
DBusMessageIter *iter, void *data)
@@ -172,7 +149,6 @@ static const GDBusMethodTable manager_methods[] = {
};
static const GDBusPropertyTable manager_properties[] = {
- { "Adapters", "ao", manager_property_get_adapters },
{ "DefaultAdapter", "o", manager_property_get_default_adapter, NULL,
manager_property_exists_default_adapter },
{ }
@@ -210,9 +186,6 @@ static void manager_remove_adapter(struct btd_adapter *adapter)
adapters = g_slist_remove(adapters, adapter);
- g_dbus_emit_property_changed(btd_get_dbus_connection(), "/",
- MANAGER_INTERFACE, "Adapters");
-
if (default_adapter_id == dev_id || default_adapter_id < 0) {
int new_default = hci_get_route(NULL);
@@ -319,9 +292,6 @@ struct btd_adapter *btd_manager_register_adapter(int id, gboolean up)
path = adapter_get_path(adapter);
- g_dbus_emit_property_changed(btd_get_dbus_connection(), "/",
- MANAGER_INTERFACE, "Adapters");
-
btd_stop_exit_timer();
if (default_adapter_id < 0)
--
1.7.11.7
^ permalink raw reply related
* [RFC v0 2/7] manager: Remove redundant D-Bus signals
From: Mikel Astiz @ 2012-11-08 14:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz
In-Reply-To: <1352385015-2127-1-git-send-email-mikel.astiz.oss@gmail.com>
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
The Manager interface already reports changes in the adapter list in
form of property changes, so there is no need to keep these two signals
any more.
---
doc/manager-api.txt | 8 --------
src/manager.c | 20 +-------------------
2 files changed, 1 insertion(+), 27 deletions(-)
diff --git a/doc/manager-api.txt b/doc/manager-api.txt
index 1cebb27..b6e4a0f 100644
--- a/doc/manager-api.txt
+++ b/doc/manager-api.txt
@@ -99,14 +99,6 @@ Object path /
Possible errors: org.bluez.Error.DoesNotExist
-Signals AdapterAdded(object adapter)
-
- Parameter is object path of added adapter.
-
- AdapterRemoved(object adapter)
-
- Parameter is object path of removed adapter.
-
Properties array{object} Adapters [readonly]
List of adapter object paths.
diff --git a/src/manager.c b/src/manager.c
index 598c081..f07cefe 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -171,14 +171,6 @@ static const GDBusMethodTable manager_methods[] = {
{ }
};
-static const GDBusSignalTable manager_signals[] = {
- { GDBUS_SIGNAL("AdapterAdded",
- GDBUS_ARGS({ "adapter", "o" })) },
- { GDBUS_SIGNAL("AdapterRemoved",
- GDBUS_ARGS({ "adapter", "o" })) },
- { }
-};
-
static const GDBusPropertyTable manager_properties[] = {
{ "Adapters", "ao", manager_property_get_adapters },
{ "DefaultAdapter", "o", manager_property_get_default_adapter, NULL,
@@ -192,7 +184,7 @@ dbus_bool_t manager_init(const char *path)
return g_dbus_register_interface(btd_get_dbus_connection(),
"/", MANAGER_INTERFACE,
- manager_methods, manager_signals,
+ manager_methods, NULL,
manager_properties, NULL, NULL);
}
@@ -215,7 +207,6 @@ struct btd_adapter *manager_get_default_adapter(void)
static void manager_remove_adapter(struct btd_adapter *adapter)
{
uint16_t dev_id = adapter_get_dev_id(adapter);
- const gchar *path = adapter_get_path(adapter);
adapters = g_slist_remove(adapters, adapter);
@@ -228,11 +219,6 @@ static void manager_remove_adapter(struct btd_adapter *adapter)
manager_set_default_adapter(new_default);
}
- g_dbus_emit_signal(btd_get_dbus_connection(), "/",
- MANAGER_INTERFACE, "AdapterRemoved",
- DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
-
adapter_remove(adapter);
btd_adapter_unref(adapter);
@@ -332,10 +318,6 @@ struct btd_adapter *btd_manager_register_adapter(int id, gboolean up)
}
path = adapter_get_path(adapter);
- g_dbus_emit_signal(btd_get_dbus_connection(), "/",
- MANAGER_INTERFACE, "AdapterAdded",
- DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
g_dbus_emit_property_changed(btd_get_dbus_connection(), "/",
MANAGER_INTERFACE, "Adapters");
--
1.7.11.7
^ permalink raw reply related
* [RFC v0 1/7] manager: Expose default adapter using property
From: Mikel Astiz @ 2012-11-08 14:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz
In-Reply-To: <1352385015-2127-1-git-send-email-mikel.astiz.oss@gmail.com>
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
Replace previous method in the Manager interface with a property. If no
default adapter exists, the property will not be present.
---
doc/manager-api.txt | 20 +++------------
src/manager.c | 71 +++++++++++++++++++++++------------------------------
2 files changed, 35 insertions(+), 56 deletions(-)
diff --git a/doc/manager-api.txt b/doc/manager-api.txt
index fe50556..1cebb27 100644
--- a/doc/manager-api.txt
+++ b/doc/manager-api.txt
@@ -14,13 +14,6 @@ Service org.bluez
Interface org.bluez.Manager
Object path /
- object DefaultAdapter()
-
- Returns object path for the default adapter.
-
- Possible errors: org.bluez.Error.InvalidArguments
- org.bluez.Error.NoSuchAdapter
-
object FindAdapter(string pattern)
Returns object path for the specified adapter. Valid
@@ -114,15 +107,10 @@ Signals AdapterAdded(object adapter)
Parameter is object path of removed adapter.
- DefaultAdapterChanged(object adapter)
-
- Parameter is object path of the new default adapter.
-
- In case all adapters are removed this signal will not
- be emitted. The AdapterRemoved signal has to be used
- to detect that no default adapter is selected or
- available anymore.
-
Properties array{object} Adapters [readonly]
List of adapter object paths.
+
+ object DefaultAdapter [readonly, optional]
+
+ Object path for the default adapter, if any.
diff --git a/src/manager.c b/src/manager.c
index a96115b..598c081 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -64,29 +64,6 @@ const char *manager_get_base_path(void)
return base_path;
}
-static DBusMessage *default_adapter(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- DBusMessage *reply;
- struct btd_adapter *adapter;
- const gchar *path;
-
- adapter = manager_find_adapter_by_id(default_adapter_id);
- if (!adapter)
- return btd_error_no_such_adapter(msg);
-
- reply = dbus_message_new_method_return(msg);
- if (!reply)
- return NULL;
-
- path = adapter_get_path(adapter);
-
- dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
-
- return reply;
-}
-
static DBusMessage *find_adapter(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -155,10 +132,32 @@ static gboolean manager_property_get_adapters(
return TRUE;
}
+static gboolean manager_property_get_default_adapter(
+ const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct btd_adapter *adapter;
+ const char *path;
+
+ adapter = manager_find_adapter_by_id(default_adapter_id);
+ path = adapter_get_path(adapter);
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &path);
+
+ return TRUE;
+}
+
+static gboolean manager_property_exists_default_adapter(
+ const GDBusPropertyTable *property,
+ void *data)
+{
+ if (manager_find_adapter_by_id(default_adapter_id) == NULL)
+ return FALSE;
+ else
+ return TRUE;
+}
+
static const GDBusMethodTable manager_methods[] = {
- { GDBUS_METHOD("DefaultAdapter",
- NULL, GDBUS_ARGS({ "adapter", "o" }),
- default_adapter) },
{ GDBUS_METHOD("FindAdapter",
GDBUS_ARGS({ "pattern", "s" }),
GDBUS_ARGS({ "adapter", "o" }),
@@ -177,13 +176,13 @@ static const GDBusSignalTable manager_signals[] = {
GDBUS_ARGS({ "adapter", "o" })) },
{ GDBUS_SIGNAL("AdapterRemoved",
GDBUS_ARGS({ "adapter", "o" })) },
- { GDBUS_SIGNAL("DefaultAdapterChanged",
- GDBUS_ARGS({ "adapter", "o" })) },
{ }
};
static const GDBusPropertyTable manager_properties[] = {
{ "Adapters", "ao", manager_property_get_adapters },
+ { "DefaultAdapter", "o", manager_property_get_default_adapter, NULL,
+ manager_property_exists_default_adapter },
{ }
};
@@ -199,21 +198,13 @@ dbus_bool_t manager_init(const char *path)
static void manager_set_default_adapter(int id)
{
- struct btd_adapter *adapter;
- const gchar *path;
-
- default_adapter_id = id;
-
- adapter = manager_find_adapter_by_id(id);
- if (!adapter)
+ if (id == default_adapter_id)
return;
- path = adapter_get_path(adapter);
+ default_adapter_id = id;
- g_dbus_emit_signal(btd_get_dbus_connection(), "/",
- MANAGER_INTERFACE, "DefaultAdapterChanged",
- DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
+ g_dbus_emit_property_changed(btd_get_dbus_connection(), "/",
+ MANAGER_INTERFACE, "DefaultAdapter");
}
struct btd_adapter *manager_get_default_adapter(void)
--
1.7.11.7
^ permalink raw reply related
* [RFC v0 0/7] Manager/Adapter transition to ObjectManager
From: Mikel Astiz @ 2012-11-08 14:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mikel Astiz
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
(This is sent as RFC since I haven't done proper testing, and furthermore the test scripts haven't been updated)
While thinking about how profile and their states should be exposed in D-Bus (see previous RFC), I found several potential improvements in the current version of the Manager and Adapter APIs.
Basically, this patchset removes some properties and methods that seem duplicated.
There are other similar methods/properties that could be simplified as well, but for practical reasons I started with the most obvious ones.
Mikel Astiz (7):
manager: Expose default adapter using property
manager: Remove redundant D-Bus signals
manager: Remove redundant Adapters property
adapter: Remove redundant D-Bus signals
adapter: Remove DevicesFound signal
adapter: Remove redundant Devices property
adapter: Remove FindDevice method from D-Bus API
doc/adapter-api.txt | 32 +--------
doc/manager-api.txt | 28 +-------
src/adapter.c | 187 +---------------------------------------------------
src/manager.c | 103 +++++++----------------------
4 files changed, 29 insertions(+), 321 deletions(-)
--
1.7.11.7
^ permalink raw reply
* Re: [PATCH] Bluetooth: Fix memory leak when removing a UUID
From: Marcel Holtmann @ 2012-11-08 13:43 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <1352366726-4308-1-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> When removing a UUID from the list in the remove_uuid() function we must
> also kfree the entry in addition to removing it from the list.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/mgmt.c | 1 +
> 1 file changed, 1 insertion(+)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply
* CSA2: User space aspect
From: Michael Knudsen @ 2012-11-08 13:36 UTC (permalink / raw)
To: linux-bluetooth
I'm currently looking into CSA2 and how it should be exposed to user
space applications, so I want to make sure I am not duplicating any
existing effort in this area.
I've been doing some prestudying and my current thought is to expose
this as socket options for the following parameters:
Transmit_Coding_Format
Receive_Coding_Format
Input_Coding_Format
Output_Coding_Format
Input_Data_Path
Output_Data_Path
If anyone else has an ideas or opinions about this, please speak up,
otherwise I'll try coming up with an interface specification with
more details.
-m.
^ permalink raw reply
* [PATCH obexd v1 3/3] MAP: Reset ap_sent variable
From: Sunil Kumar Behera @ 2012-11-08 11:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sunil Kumar Behera
For multiple subsequent request for message listing
we need to reset this variable to FALSE, so that each
time the get next header function is executed properly.
---
plugins/mas.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/plugins/mas.c b/plugins/mas.c
index bdf2b6b..459df87 100644
--- a/plugins/mas.c
+++ b/plugins/mas.c
@@ -162,6 +162,7 @@ static void reset_request(struct mas_session *mas)
mas->nth_call = FALSE;
mas->finished = FALSE;
+ mas->ap_sent = FALSE;
}
static void mas_clean(struct mas_session *mas)
--
1.7.9.5
^ permalink raw reply related
* [PATCH obexd v1 2/3] MAP: Add MSETime application parameter
From: Sunil Kumar Behera @ 2012-11-08 11:04 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sunil Kumar Behera
MSETime application parameter shall be used in the response
to report the Local Time basis of the MSE.
---
plugins/mas.c | 4 +++-
plugins/messages.h | 1 +
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/plugins/mas.c b/plugins/mas.c
index 319c87f..bdf2b6b 100644
--- a/plugins/mas.c
+++ b/plugins/mas.c
@@ -284,7 +284,7 @@ static const char *yesorno(gboolean a)
}
static void get_messages_listing_cb(void *session, int err, uint16_t size,
- gboolean newmsg,
+ gboolean newmsg, gchar *msetime,
const struct messages_message *entry,
void *user_data)
{
@@ -403,6 +403,8 @@ proceed:
mas->outparams = g_obex_apparam_set_uint8(mas->outparams,
MAP_AP_NEWMESSAGE,
newmsg ? 1 : 0);
+ mas->outparams = g_obex_apparam_set_string(mas->outparams,
+ MAP_AP_MSETIME, msetime);
}
if (err != -EAGAIN)
diff --git a/plugins/messages.h b/plugins/messages.h
index 00a16b1..2ab4ba1 100644
--- a/plugins/messages.h
+++ b/plugins/messages.h
@@ -226,6 +226,7 @@ int messages_get_folder_listing(void *session, const char *name, uint16_t max,
*/
typedef void (*messages_get_messages_listing_cb)(void *session, int err,
uint16_t size, gboolean newmsg,
+ gchar *msetime,
const struct messages_message *message,
void *user_data);
--
1.7.9.5
^ permalink raw reply related
* [PATCH obexd v1 1/3] MAP: Add get_next_header() in message listing
From: Sunil Kumar Behera @ 2012-11-08 11:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sunil Kumar Behera
In case of message listing we need to send application
parameters in response and also it is required for sending
response to message listing size request.
---
plugins/mas.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/plugins/mas.c b/plugins/mas.c
index 186d267..319c87f 100644
--- a/plugins/mas.c
+++ b/plugins/mas.c
@@ -810,6 +810,7 @@ static struct obex_mime_type_driver mime_msg_listing = {
.target = MAS_TARGET,
.target_size = TARGET_SIZE,
.mimetype = "x-bt/MAP-msg-listing",
+ .get_next_header = any_get_next_header,
.open = msg_listing_open,
.close = any_close,
.read = any_read,
--
1.7.9.5
^ permalink raw reply related
* [PATCH obexd 3/3] Reset ap_sent variable
From: Sunil Kumar Behera @ 2012-11-08 10:46 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sunil Kumar Behera
For multiple subsequent request for message listing
we need to reset this variable to FALSE. So that each
time the get next header function is executed properly.
---
plugins/mas.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/plugins/mas.c b/plugins/mas.c
index bdf2b6b..459df87 100644
--- a/plugins/mas.c
+++ b/plugins/mas.c
@@ -162,6 +162,7 @@ static void reset_request(struct mas_session *mas)
mas->nth_call = FALSE;
mas->finished = FALSE;
+ mas->ap_sent = FALSE;
}
static void mas_clean(struct mas_session *mas)
--
1.7.9.5
^ permalink raw reply related
* [PATCH obexd 2/3] Add MSETime application parameter
From: Sunil Kumar Behera @ 2012-11-08 10:44 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sunil Kumar Behera
MSETime application parameter shall be used in the response
to report the Local Time basis of the MSE.
---
plugins/mas.c | 4 +++-
plugins/messages.h | 1 +
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/plugins/mas.c b/plugins/mas.c
index 319c87f..bdf2b6b 100644
--- a/plugins/mas.c
+++ b/plugins/mas.c
@@ -284,7 +284,7 @@ static const char *yesorno(gboolean a)
}
static void get_messages_listing_cb(void *session, int err, uint16_t size,
- gboolean newmsg,
+ gboolean newmsg, gchar *msetime,
const struct messages_message *entry,
void *user_data)
{
@@ -403,6 +403,8 @@ proceed:
mas->outparams = g_obex_apparam_set_uint8(mas->outparams,
MAP_AP_NEWMESSAGE,
newmsg ? 1 : 0);
+ mas->outparams = g_obex_apparam_set_string(mas->outparams,
+ MAP_AP_MSETIME, msetime);
}
if (err != -EAGAIN)
diff --git a/plugins/messages.h b/plugins/messages.h
index 00a16b1..2ab4ba1 100644
--- a/plugins/messages.h
+++ b/plugins/messages.h
@@ -226,6 +226,7 @@ int messages_get_folder_listing(void *session, const char *name, uint16_t max,
*/
typedef void (*messages_get_messages_listing_cb)(void *session, int err,
uint16_t size, gboolean newmsg,
+ gchar *msetime,
const struct messages_message *message,
void *user_data);
--
1.7.9.5
^ permalink raw reply related
* [PATCH obexd 1/3] Add get next header function in message listing.
From: Sunil Kumar Behera @ 2012-11-08 10:42 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sunil Kumar Behera
In case of message listing we need to send application
parameters in response and also it is required for sending
response to message listing size request.
---
plugins/mas.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/plugins/mas.c b/plugins/mas.c
index 186d267..319c87f 100644
--- a/plugins/mas.c
+++ b/plugins/mas.c
@@ -810,6 +810,7 @@ static struct obex_mime_type_driver mime_msg_listing = {
.target = MAS_TARGET,
.target_size = TARGET_SIZE,
.mimetype = "x-bt/MAP-msg-listing",
+ .get_next_header = any_get_next_header,
.open = msg_listing_open,
.close = any_close,
.read = any_read,
--
1.7.9.5
^ permalink raw reply related
* HFP can't work well and sound can't be heard
From: Zheng, Wu @ 2012-11-08 9:41 UTC (permalink / raw)
To: Von Dentz, Luiz; +Cc: linux-bluetooth@vger.kernel.org
Hi Luiz,
The GetProperties methods of "org.bluez.manager", "org.bluez.Adapter" and so on have been converted to some methods of "org.freedesktop.DBus.Properties".
It results in pulseaudio can't communicate with bluez well and sound can't be heard when using HFP.
What do upstream plan for it? Thanks.
Best Regards
Zheng Wu
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox