linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/4] core: Print profile name in device_profile_connected
@ 2012-12-19 11:26 Luiz Augusto von Dentz
  2012-12-19 11:26 ` [PATCH BlueZ 2/4] audio: Fix not cleaning up player when device is removed Luiz Augusto von Dentz
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2012-12-19 11:26 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 src/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/device.c b/src/device.c
index 6a98645..ba8790e 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1112,7 +1112,7 @@ static int connect_next(struct btd_device *dev)
 void device_profile_connected(struct btd_device *dev,
 					struct btd_profile *profile, int err)
 {
-	DBG("%s (%d)", strerror(-err), -err);
+	DBG("%s %s (%d)", profile->name, strerror(-err), -err);
 
 	dev->pending = g_slist_remove(dev->pending, profile);
 
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH BlueZ 2/4] audio: Fix not cleaning up player when device is removed
  2012-12-19 11:26 [PATCH BlueZ 1/4] core: Print profile name in device_profile_connected Luiz Augusto von Dentz
@ 2012-12-19 11:26 ` Luiz Augusto von Dentz
  2012-12-19 11:27 ` [PATCH BlueZ 3/4] audio: Remove unused parameters from sink_connect/sink_disconnect Luiz Augusto von Dentz
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2012-12-19 11:26 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

All profile connections need to be reported to the core otherwise it
won't be able to disconnect them properly.
---
 profiles/audio/control.c | 58 ++++++------------------------------------------
 profiles/audio/control.h |  5 ++---
 profiles/audio/manager.c | 14 ++++++++++--
 profiles/audio/manager.h |  2 ++
 4 files changed, 23 insertions(+), 56 deletions(-)

diff --git a/profiles/audio/control.c b/profiles/audio/control.c
index 1600fce..642fdd5 100644
--- a/profiles/audio/control.c
+++ b/profiles/audio/control.c
@@ -61,28 +61,11 @@
 
 static unsigned int avctp_id = 0;
 
-struct pending_request {
-	audio_device_cb cb;
-	void *data;
-	unsigned int id;
-};
-
 struct control {
 	struct avctp *session;
 	gboolean target;
-	struct pending_request *connect;
 };
 
-static void pending_request_free(struct audio_device *dev,
-					struct pending_request *pending,
-					int err)
-{
-	if (pending->cb)
-		pending->cb(dev, err, pending->data);
-
-	g_free(pending);
-}
-
 static void state_changed(struct audio_device *dev, avctp_state_t old_state,
 				avctp_state_t new_state, void *user_data)
 {
@@ -94,13 +77,12 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
 	case AVCTP_STATE_DISCONNECTED:
 		control->session = NULL;
 
-		if (control->connect) {
-			pending_request_free(dev, control->connect, -EIO);
-			control->connect = NULL;
+		if (old_state != AVCTP_STATE_CONNECTED) {
+			audio_control_connected(dev->btd_dev, -EIO);
+			break;
 		}
 
-		if (old_state != AVCTP_STATE_CONNECTED)
-			break;
+		audio_control_disconnected(dev->btd_dev, 0);
 
 		g_dbus_emit_property_changed(conn, path,
 					AUDIO_CONTROL_INTERFACE, "Connected");
@@ -114,10 +96,7 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
 
 		break;
 	case AVCTP_STATE_CONNECTED:
-		if (control->connect) {
-			pending_request_free(dev, control->connect, 0);
-			control->connect = NULL;
-		}
+		audio_control_connected(dev->btd_dev, 0);
 
 		g_dbus_emit_property_changed(conn, path,
 					AUDIO_CONTROL_INTERFACE, "Connected");
@@ -127,10 +106,9 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
 	}
 }
 
-int control_connect(struct audio_device *dev, audio_device_cb cb, void *data)
+int control_connect(struct audio_device *dev)
 {
 	struct control *control = dev->control;
-	struct pending_request *pending;
 
 	if (control->session)
 		return -EALREADY;
@@ -138,42 +116,23 @@ int control_connect(struct audio_device *dev, audio_device_cb cb, void *data)
 	if (!control->target)
 		return -ENOTSUP;
 
-	if (control->connect)
-		return -EINPROGRESS;
-
 	control->session = avctp_connect(dev);
 	if (!control->session)
 		return -EIO;
 
-	pending = g_new0(struct pending_request, 1);
-	pending->cb = cb;
-	pending->data = data;
-	control->connect = pending;
-
 	return 0;
 }
 
-int control_disconnect(struct audio_device *dev, audio_device_cb cb,
-								void *data)
+int control_disconnect(struct audio_device *dev)
 {
 	struct control *control = dev->control;
 
 	if (!control->session)
 		return -ENOTCONN;
 
-	/* cancel pending connect */
-	if (control->connect) {
-		pending_request_free(dev, control->connect, -ECANCELED);
-		control->connect = NULL;
-	}
-
 	avctp_disconnect(control->session);
 
-	if (cb)
-		cb(dev, 0, data);
-
 	return 0;
-
 }
 
 static DBusMessage *key_pressed(DBusConnection *conn, DBusMessage *msg,
@@ -291,9 +250,6 @@ static void path_unregister(void *data)
 	if (control->session)
 		avctp_disconnect(control->session);
 
-	if (control->connect)
-		pending_request_free(dev, control->connect, -ECANCELED);
-
 	g_free(control);
 	dev->control = NULL;
 }
diff --git a/profiles/audio/control.h b/profiles/audio/control.h
index 878dd1e..001b564 100644
--- a/profiles/audio/control.h
+++ b/profiles/audio/control.h
@@ -29,6 +29,5 @@ void control_update(struct control *control, GSList *uuids);
 void control_unregister(struct audio_device *dev);
 gboolean control_is_active(struct audio_device *dev);
 
-int control_connect(struct audio_device *dev, audio_device_cb cb, void *data);
-int control_disconnect(struct audio_device *dev, audio_device_cb cb,
-								void *data);
+int control_connect(struct audio_device *dev);
+int control_disconnect(struct audio_device *dev);
diff --git a/profiles/audio/manager.c b/profiles/audio/manager.c
index 422316e..620127c 100644
--- a/profiles/audio/manager.c
+++ b/profiles/audio/manager.c
@@ -270,7 +270,7 @@ static int avrcp_control_connect(struct btd_device *dev,
 		return -1;
 	}
 
-	return control_connect(audio_dev, connect_cb, profile);
+	return control_connect(audio_dev);
 }
 
 static int avrcp_control_disconnect(struct btd_device *dev,
@@ -287,7 +287,7 @@ static int avrcp_control_disconnect(struct btd_device *dev,
 		return -1;
 	}
 
-	return control_disconnect(audio_dev, disconnect_cb, profile);
+	return control_disconnect(audio_dev);
 }
 
 static struct audio_adapter *audio_adapter_ref(struct audio_adapter *adp)
@@ -512,6 +512,16 @@ void audio_source_disconnected(struct btd_device *dev, int err)
 	device_profile_connected(dev, &a2dp_source_profile, err);
 }
 
+void audio_control_connected(struct btd_device *dev, int err)
+{
+	device_profile_connected(dev, &avrcp_profile, err);
+}
+
+void audio_control_disconnected(struct btd_device *dev, int err)
+{
+	device_profile_disconnected(dev, &avrcp_profile, err);
+}
+
 int audio_manager_init(GKeyFile *conf)
 {
 	char **list;
diff --git a/profiles/audio/manager.h b/profiles/audio/manager.h
index 2b924dc..e70d795 100644
--- a/profiles/audio/manager.h
+++ b/profiles/audio/manager.h
@@ -33,6 +33,8 @@ void audio_sink_connected(struct btd_device *dev, int err);
 void audio_sink_disconnected(struct btd_device *dev, int err);
 void audio_source_connected(struct btd_device *dev, int err);
 void audio_source_disconnected(struct btd_device *dev, int err);
+void audio_control_connected(struct btd_device *dev, int err);
+void audio_control_disconnected(struct btd_device *dev, int err);
 
 int audio_manager_init(GKeyFile *config);
 void audio_manager_exit(void);
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH BlueZ 3/4] audio: Remove unused parameters from sink_connect/sink_disconnect
  2012-12-19 11:26 [PATCH BlueZ 1/4] core: Print profile name in device_profile_connected Luiz Augusto von Dentz
  2012-12-19 11:26 ` [PATCH BlueZ 2/4] audio: Fix not cleaning up player when device is removed Luiz Augusto von Dentz
@ 2012-12-19 11:27 ` Luiz Augusto von Dentz
  2012-12-19 11:27 ` [PATCH BlueZ 4/4] audio: Fix calling device_profile_connected on disconnected cases Luiz Augusto von Dentz
  2012-12-19 11:41 ` [PATCH BlueZ 1/4] core: Print profile name in device_profile_connected Johan Hedberg
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2012-12-19 11:27 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Profile .connect and .disconnect no longer use callbacks so there is no
reason to keep these parameters around.
---
 profiles/audio/device.c  |  2 +-
 profiles/audio/manager.c | 18 ++----------------
 profiles/audio/sink.c    |  5 ++---
 profiles/audio/sink.h    |  5 ++---
 4 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/profiles/audio/device.c b/profiles/audio/device.c
index 080ebc9..d4ba6d2 100644
--- a/profiles/audio/device.c
+++ b/profiles/audio/device.c
@@ -184,7 +184,7 @@ static void disconnect_cb(struct btd_device *btd_dev, gboolean removal,
 		avrcp_disconnect(dev);
 
 	if (dev->sink && priv->sink_state != SINK_STATE_DISCONNECTED)
-		sink_disconnect(dev, TRUE, NULL, NULL);
+		sink_disconnect(dev, TRUE);
 	else
 		priv->disconnecting = FALSE;
 }
diff --git a/profiles/audio/manager.c b/profiles/audio/manager.c
index 620127c..1f49aa3 100644
--- a/profiles/audio/manager.c
+++ b/profiles/audio/manager.c
@@ -174,20 +174,6 @@ static int avrcp_probe(struct btd_profile *p, struct btd_device *device,
 	return 0;
 }
 
-static void connect_cb(struct audio_device *dev, int err, void *data)
-{
-	struct btd_profile *profile = data;
-
-	device_profile_connected(dev->btd_dev, profile, err);
-}
-
-static void disconnect_cb(struct audio_device *dev, int err, void *data)
-{
-	struct btd_profile *profile = data;
-
-	device_profile_disconnected(dev->btd_dev, profile, err);
-}
-
 static int a2dp_source_connect(struct btd_device *dev,
 						struct btd_profile *profile)
 {
@@ -236,7 +222,7 @@ static int a2dp_sink_connect(struct btd_device *dev,
 		return -1;
 	}
 
-	return sink_connect(audio_dev, connect_cb, profile);
+	return sink_connect(audio_dev);
 }
 
 static int a2dp_sink_disconnect(struct btd_device *dev,
@@ -253,7 +239,7 @@ static int a2dp_sink_disconnect(struct btd_device *dev,
 		return -1;
 	}
 
-	return sink_disconnect(audio_dev, FALSE, disconnect_cb, profile);
+	return sink_disconnect(audio_dev, FALSE);
 }
 
 static int avrcp_control_connect(struct btd_device *dev,
diff --git a/profiles/audio/sink.c b/profiles/audio/sink.c
index b12c913..02e1a65 100644
--- a/profiles/audio/sink.c
+++ b/profiles/audio/sink.c
@@ -305,7 +305,7 @@ gboolean sink_setup_stream(struct sink *sink, struct avdtp *session)
 	return TRUE;
 }
 
-int sink_connect(struct audio_device *dev, audio_device_cb cb, void *data)
+int sink_connect(struct audio_device *dev)
 {
 	struct sink *sink = dev->sink;
 
@@ -415,8 +415,7 @@ gboolean sink_new_stream(struct audio_device *dev, struct avdtp *session,
 	return TRUE;
 }
 
-int sink_disconnect(struct audio_device *dev, gboolean shutdown,
-						audio_device_cb cb, void *data)
+int sink_disconnect(struct audio_device *dev, gboolean shutdown)
 {
 	struct sink *sink = dev->sink;
 
diff --git a/profiles/audio/sink.h b/profiles/audio/sink.h
index b9e97e3..fc7ed92 100644
--- a/profiles/audio/sink.h
+++ b/profiles/audio/sink.h
@@ -42,9 +42,8 @@ gboolean sink_remove_state_cb(unsigned int id);
 struct sink *sink_init(struct audio_device *dev);
 void sink_unregister(struct audio_device *dev);
 gboolean sink_is_active(struct audio_device *dev);
-int sink_connect(struct audio_device *dev, audio_device_cb cb, void *data);
+int sink_connect(struct audio_device *dev);
 gboolean sink_new_stream(struct audio_device *dev, struct avdtp *session,
 				struct avdtp_stream *stream);
 gboolean sink_setup_stream(struct sink *sink, struct avdtp *session);
-int sink_disconnect(struct audio_device *dev, gboolean shutdown,
-						audio_device_cb cb, void *data);
+int sink_disconnect(struct audio_device *dev, gboolean shutdown);
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH BlueZ 4/4] audio: Fix calling device_profile_connected on disconnected cases
  2012-12-19 11:26 [PATCH BlueZ 1/4] core: Print profile name in device_profile_connected Luiz Augusto von Dentz
  2012-12-19 11:26 ` [PATCH BlueZ 2/4] audio: Fix not cleaning up player when device is removed Luiz Augusto von Dentz
  2012-12-19 11:27 ` [PATCH BlueZ 3/4] audio: Remove unused parameters from sink_connect/sink_disconnect Luiz Augusto von Dentz
@ 2012-12-19 11:27 ` Luiz Augusto von Dentz
  2012-12-19 11:41 ` [PATCH BlueZ 1/4] core: Print profile name in device_profile_connected Johan Hedberg
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2012-12-19 11:27 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 profiles/audio/manager.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/profiles/audio/manager.c b/profiles/audio/manager.c
index 1f49aa3..0f6a4f7 100644
--- a/profiles/audio/manager.c
+++ b/profiles/audio/manager.c
@@ -485,7 +485,7 @@ void audio_sink_connected(struct btd_device *dev, int err)
 
 void audio_sink_disconnected(struct btd_device *dev, int err)
 {
-	device_profile_connected(dev, &a2dp_sink_profile, err);
+	device_profile_disconnected(dev, &a2dp_sink_profile, err);
 }
 
 void audio_source_connected(struct btd_device *dev, int err)
@@ -495,7 +495,7 @@ void audio_source_connected(struct btd_device *dev, int err)
 
 void audio_source_disconnected(struct btd_device *dev, int err)
 {
-	device_profile_connected(dev, &a2dp_source_profile, err);
+	device_profile_disconnected(dev, &a2dp_source_profile, err);
 }
 
 void audio_control_connected(struct btd_device *dev, int err)
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH BlueZ 1/4] core: Print profile name in device_profile_connected
  2012-12-19 11:26 [PATCH BlueZ 1/4] core: Print profile name in device_profile_connected Luiz Augusto von Dentz
                   ` (2 preceding siblings ...)
  2012-12-19 11:27 ` [PATCH BlueZ 4/4] audio: Fix calling device_profile_connected on disconnected cases Luiz Augusto von Dentz
@ 2012-12-19 11:41 ` Johan Hedberg
  3 siblings, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2012-12-19 11:41 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Wed, Dec 19, 2012, Luiz Augusto von Dentz wrote:
> ---
>  src/device.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

All patches in this set have been applied. Thanks.

Johan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-12-19 11:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-19 11:26 [PATCH BlueZ 1/4] core: Print profile name in device_profile_connected Luiz Augusto von Dentz
2012-12-19 11:26 ` [PATCH BlueZ 2/4] audio: Fix not cleaning up player when device is removed Luiz Augusto von Dentz
2012-12-19 11:27 ` [PATCH BlueZ 3/4] audio: Remove unused parameters from sink_connect/sink_disconnect Luiz Augusto von Dentz
2012-12-19 11:27 ` [PATCH BlueZ 4/4] audio: Fix calling device_profile_connected on disconnected cases Luiz Augusto von Dentz
2012-12-19 11:41 ` [PATCH BlueZ 1/4] core: Print profile name in device_profile_connected Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).