summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
Diffstat (limited to 'audio')
-rw-r--r--audio/avdtp.c34
-rw-r--r--audio/control.c91
-rw-r--r--audio/main.c26
-rw-r--r--audio/manager.c12
-rw-r--r--audio/manager.h7
5 files changed, 62 insertions, 108 deletions
diff --git a/audio/avdtp.c b/audio/avdtp.c
index b0cd98ba..bda21ac5 100644
--- a/audio/avdtp.c
+++ b/audio/avdtp.c
@@ -1496,13 +1496,6 @@ static gboolean session_cb(GIOChannel *chan, GIOCondition cond,
return TRUE;
failed:
- if (session->pending_auth) {
- manager_cancel_authorize(&session->dst, ADVANCED_AUDIO_UUID,
- session->pending_auth);
- dbus_pending_call_unref(session->pending_auth);
- session->pending_auth = NULL;
- }
-
connection_lost(session, -EIO);
return FALSE;
@@ -2691,10 +2684,7 @@ static void auth_cb(DBusError *derr, void *user_data)
error("Access denied: %s", derr->message);
if (dbus_error_has_name(derr, DBUS_ERROR_NO_REPLY)) {
debug("Canceling authorization request");
- if (service_cancel_auth(&session->dst) < 0)
- manager_cancel_authorize(&session->dst,
- ADVANCED_AUDIO_UUID,
- NULL);
+ service_cancel_auth(&session->src, &session->dst);
}
connection_lost(session, -EACCES);
@@ -2721,23 +2711,6 @@ static void auth_cb(DBusError *derr, void *user_data)
g_io_channel_unref(io);
}
-static void auth_cb_old(DBusPendingCall *call, void *data)
-{
- struct avdtp *session = data;
- DBusMessage *reply = dbus_pending_call_steal_reply(call);
- DBusError err;
-
- dbus_pending_call_unref(session->pending_auth);
- session->pending_auth = NULL;
-
- dbus_error_init(&err);
- dbus_set_error_from_message(&err, reply);
- auth_cb(&err, data);
- dbus_error_free(&err);
-
- dbus_message_unref(reply);
-}
-
static void avdtp_server_cb(GIOChannel *chan, int err, const bdaddr_t *src,
const bdaddr_t *dst, gpointer data)
{
@@ -2785,10 +2758,7 @@ static void avdtp_server_cb(GIOChannel *chan, int err, const bdaddr_t *src,
g_io_channel_unref(chan);
if (service_req_auth(src, dst, ADVANCED_AUDIO_UUID, auth_cb,
- session) == 0)
- return;
- else if (!manager_authorize(dst, ADVANCED_AUDIO_UUID, auth_cb_old,
- session, &session->pending_auth)) {
+ session) < 0) {
avdtp_unref(session);
goto drop;
}
diff --git a/audio/control.c b/audio/control.c
index 6778b268..9139213b 100644
--- a/audio/control.c
+++ b/audio/control.c
@@ -165,8 +165,6 @@ struct avctp {
guint io;
uint16_t mtu;
-
- DBusPendingCall *pending_auth;
};
struct control {
@@ -323,12 +321,8 @@ static struct avctp *avctp_get(const bdaddr_t *src, const bdaddr_t *dst)
assert(dst != NULL);
session = find_session(src, dst);
- if (session) {
- if (session->pending_auth)
- return NULL;
- else
- return session;
- }
+ if (session)
+ return session;
session = g_new0(struct avctp, 1);
@@ -420,13 +414,6 @@ static void avctp_unref(struct avctp *session)
{
sessions = g_slist_remove(sessions, session);
- if (session->pending_auth) {
- manager_cancel_authorize(&session->dst, AVRCP_TARGET_UUID,
- NULL);
- dbus_pending_call_cancel(session->pending_auth);
- dbus_pending_call_unref(session->pending_auth);
- }
-
if (session->state == AVCTP_STATE_CONNECTED)
g_dbus_emit_signal(session->dev->conn,
session->dev->path,
@@ -609,56 +596,47 @@ static void init_uinput(struct avctp *session)
debug("AVRCP: uinput initialized for %s", name);
}
-static void auth_cb(DBusError *derr, void *user_data)
+static void avctp_connect_session(struct avctp *session)
{
- struct avctp *session = user_data;
GIOChannel *io;
- if (derr && dbus_error_is_set(derr)) {
- error("Access denied: %s", derr->message);
- if (dbus_error_has_name(derr, DBUS_ERROR_NO_REPLY)) {
- debug("Canceling authorization request");
- if (service_cancel_auth(&session->dst) < 0)
- manager_cancel_authorize(&session->dst,
- AVRCP_TARGET_UUID,
- NULL);
- }
-
- avctp_unref(session);
- return;
- }
-
session->state = AVCTP_STATE_CONNECTED;
-
session->dev = manager_device_connected(&session->dst,
AVRCP_TARGET_UUID);
session->dev->control->session = session;
+
init_uinput(session);
g_dbus_emit_signal(session->dev->conn, session->dev->path,
AUDIO_CONTROL_INTERFACE, "Connected",
DBUS_TYPE_INVALID);
- g_source_remove(session->io);
+ if (session->io)
+ g_source_remove(session->io);
io = g_io_channel_unix_new(session->sock);
session->io = g_io_add_watch(io,
- G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
- (GIOFunc) session_cb, session);
+ G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+ (GIOFunc) session_cb, session);
g_io_channel_unref(io);
}
-static void auth_cb_old(DBusPendingCall *call, void *data)
+static void auth_cb(DBusError *derr, void *user_data)
{
- DBusMessage *reply = dbus_pending_call_steal_reply(call);
- DBusError err;
+ struct avctp *session = user_data;
- dbus_error_init(&err);
- dbus_set_error_from_message(&err, reply);
- auth_cb(&err, data);
- dbus_error_free(&err);
+ if (derr && dbus_error_is_set(derr)) {
+ error("Access denied: %s", derr->message);
+ if (dbus_error_has_name(derr, DBUS_ERROR_NO_REPLY)) {
+ debug("Canceling authorization request");
+ service_cancel_auth(&session->src, &session->dst);
+ }
- dbus_message_unref(reply);
+ avctp_unref(session);
+ return;
+ }
+
+ avctp_connect_session(session);
}
static void avctp_server_cb(GIOChannel *chan, int err, const bdaddr_t *src,
@@ -701,6 +679,7 @@ static void avctp_server_cb(GIOChannel *chan, int err, const bdaddr_t *src,
}
session->mtu = l2o.imtu;
+
session->io = g_io_add_watch(chan, flags, (GIOFunc) session_cb,
session);
g_io_channel_unref(chan);
@@ -708,34 +687,18 @@ static void avctp_server_cb(GIOChannel *chan, int err, const bdaddr_t *src,
if (avdtp_is_connected(src, dst))
goto proceed;
- if (service_req_auth(src, dst, AVRCP_TARGET_UUID, auth_cb, session) == 0)
- goto proceed;
- else if (!manager_authorize(dst, AVRCP_TARGET_UUID, auth_cb_old, session,
- &session->pending_auth)) {
- avctp_unref(session);
+ if (service_req_auth(src, dst, AVRCP_TARGET_UUID, auth_cb, session) < 0)
goto drop;
- }
+
+ return;
proceed:
- if (!session->pending_auth) {
- session->state = AVCTP_STATE_CONNECTED;
- session->dev = manager_device_connected(dst,
- AVRCP_TARGET_UUID);
- session->dev->control->session = session;
- init_uinput(session);
- flags |= G_IO_IN;
- g_dbus_emit_signal(session->dev->conn,
- session->dev->path,
- AUDIO_CONTROL_INTERFACE,
- "Connected",
- DBUS_TYPE_INVALID);
- }
+ avctp_connect_session(session);
return;
drop:
- g_io_channel_close(chan);
- g_io_channel_unref(chan);
+ close(session->sock);
}
static GIOChannel *avctp_server_socket(gboolean master)
diff --git a/audio/main.c b/audio/main.c
index 86efce27..bbe06e05 100644
--- a/audio/main.c
+++ b/audio/main.c
@@ -80,6 +80,28 @@ static struct btd_device_driver a2dp_driver = {
.remove = a2dp_remove,
};
+static int audio_probe(struct btd_device *device)
+{
+ DBG("path %s", device->path);
+
+ return 0;
+}
+
+static void audio_remove(struct btd_device *device)
+{
+ DBG("path %s", device->path);
+}
+
+static struct btd_device_driver audio_driver = {
+ .name = "audio",
+ .uuids = BTD_UUIDS(HSP_HS_UUID, HFP_HS_UUID, HSP_AG_UUID, HFP_AG_UUID,
+ ADVANCED_AUDIO_UUID, A2DP_SOURCE_UUID, A2DP_SINK_UUID,
+ AVRCP_TARGET_UUID, AVRCP_REMOTE_UUID),
+ .probe = audio_probe,
+ .remove = audio_remove,
+};
+
+
static GKeyFile *load_config_file(const char *file)
{
GError *err = NULL;
@@ -124,11 +146,15 @@ static int audio_init(void)
btd_register_device_driver(&a2dp_driver);
+ btd_register_device_driver(&audio_driver);
+
return 0;
}
static void audio_exit(void)
{
+ btd_unregister_device_driver(&audio_driver);
+
btd_unregister_device_driver(&a2dp_driver);
btd_unregister_device_driver(&headset_driver);
diff --git a/audio/manager.c b/audio/manager.c
index 242f16bb..18ef9eb4 100644
--- a/audio/manager.c
+++ b/audio/manager.c
@@ -1164,9 +1164,7 @@ static void auth_cb(DBusError *derr, void *user_data)
error("Access denied: %s", derr->message);
if (dbus_error_has_name(derr, DBUS_ERROR_NO_REPLY)) {
debug("Canceling authorization request");
- if (service_cancel_auth(&device->dst) < 0)
- manager_cancel_authorize(&device->dst, uuid,
- NULL);
+ service_cancel_auth(&device->src, &device->dst);
}
headset_set_state(device, HEADSET_STATE_DISCONNECTED);
@@ -1219,9 +1217,13 @@ static void ag_io_cb(GIOChannel *chan, int err, const bdaddr_t *src,
goto drop;
}
- if (!service_req_auth(&device->src, &device->dst, uuid, auth_cb,
- device) == 0)
+ err = service_req_auth(&device->src, &device->dst, uuid, auth_cb,
+ device);
+ if (err < 0) {
+ debug("Authorization denied: %s", strerror(-err));
headset_close_rfcomm(device);
+ return;
+ }
headset_set_state(device, HEADSET_STATE_CONNECT_IN_PROGRESS);
diff --git a/audio/manager.h b/audio/manager.h
index 6b2b90d8..8f7f6be3 100644
--- a/audio/manager.h
+++ b/audio/manager.h
@@ -48,10 +48,3 @@ struct audio_device *manager_device_connected(const bdaddr_t *bda, const char *u
gboolean manager_create_device(bdaddr_t *bda, create_dev_cb_t cb,
void *user_data);
-
-gboolean manager_authorize(const bdaddr_t *dba, const char *uuid,
- DBusPendingCallNotifyFunction cb,
- void *user_data,
- DBusPendingCall **pending);
-void manager_cancel_authorize(bdaddr_t *dba, const char *uuid,
- DBusPendingCall *pending);