public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] Remove IMTU and OMTU properties and return its values on Acquire reply
@ 2011-01-18 10:00 Luiz Augusto von Dentz
  2011-01-18 10:00 ` [PATCH 2/4] Updade a2dpsink to use new Acquire API Luiz Augusto von Dentz
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Luiz Augusto von Dentz @ 2011-01-18 10:00 UTC (permalink / raw)
  To: linux-bluetooth

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

This should make Acquire blocking friendly since the client no longer has
to call GetProperties to discover how much it can write/read when using
the acquired file descriptor.
---
 audio/transport.c |   56 +++++++++++++++++++++++++++++++---------------------
 doc/media-api.txt |   13 ++---------
 2 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/audio/transport.c b/audio/transport.c
index bdec157..d575590 100644
--- a/audio/transport.c
+++ b/audio/transport.c
@@ -181,14 +181,6 @@ static gboolean media_transport_set_fd(struct media_transport *transport,
 
 	info("%s: fd(%d) ready", transport->path, fd);
 
-	emit_property_changed(transport->conn, transport->path,
-				MEDIA_TRANSPORT_INTERFACE, "IMTU",
-				DBUS_TYPE_UINT16, &transport->imtu);
-
-	emit_property_changed(transport->conn, transport->path,
-				MEDIA_TRANSPORT_INTERFACE, "OMTU",
-				DBUS_TYPE_UINT16, &transport->omtu);
-
 	return TRUE;
 }
 
@@ -209,6 +201,7 @@ static void a2dp_resume_complete(struct avdtp *session,
 	struct avdtp_stream *stream;
 	int fd;
 	uint16_t imtu, omtu;
+	gboolean ret;
 
 	req->id = 0;
 
@@ -219,15 +212,24 @@ static void a2dp_resume_complete(struct avdtp *session,
 	if (stream == NULL)
 		goto fail;
 
-	if (avdtp_stream_get_transport(stream, &fd, &imtu, &omtu, NULL) ==
-			FALSE)
+	ret = avdtp_stream_get_transport(stream, &fd, &imtu, &omtu, NULL);
+	if (ret == FALSE)
 		goto fail;
 
 	media_transport_set_fd(transport, fd, imtu, omtu);
 
-	if (g_dbus_send_reply(transport->conn, req->msg,
-				DBUS_TYPE_UNIX_FD, &fd,
-				DBUS_TYPE_INVALID) == FALSE)
+	if (g_strstr_len(owner->accesstype, -1, "r") == NULL)
+		imtu = 0;
+
+	if (g_strstr_len(owner->accesstype, -1, "w") == NULL)
+		omtu = 0;
+
+	ret = g_dbus_send_reply(transport->conn, req->msg,
+						DBUS_TYPE_UNIX_FD, &fd,
+						DBUS_TYPE_UINT16, &imtu,
+						DBUS_TYPE_UINT16, &omtu,
+						DBUS_TYPE_INVALID);
+	if (ret == FALSE)
 		goto fail;
 
 	return;
@@ -282,6 +284,8 @@ static void headset_resume_complete(struct audio_device *dev, void *user_data)
 	struct acquire_request *req = owner->request;
 	struct media_transport *transport = owner->transport;
 	int fd;
+	uint16_t imtu, omtu;
+	gboolean ret;
 
 	req->id = 0;
 
@@ -292,11 +296,23 @@ static void headset_resume_complete(struct audio_device *dev, void *user_data)
 	if (fd < 0)
 		goto fail;
 
-	media_transport_set_fd(transport, fd, 48, 48);
+	imtu = 48;
+	omtu = 48;
 
-	if (g_dbus_send_reply(transport->conn, req->msg,
-				DBUS_TYPE_UNIX_FD, &fd,
-				DBUS_TYPE_INVALID) == FALSE)
+	media_transport_set_fd(transport, fd, imtu, omtu);
+
+	if (g_strstr_len(owner->accesstype, -1, "r") == NULL)
+		imtu = 0;
+
+	if (g_strstr_len(owner->accesstype, -1, "w") == NULL)
+		omtu = 0;
+
+	ret = g_dbus_send_reply(transport->conn, req->msg,
+						DBUS_TYPE_UNIX_FD, &fd,
+						DBUS_TYPE_UINT16, &imtu,
+						DBUS_TYPE_UINT16, &omtu,
+						DBUS_TYPE_INVALID);
+	if (ret == FALSE)
 		goto fail;
 
 	return;
@@ -607,12 +623,6 @@ void transport_get_properties(struct media_transport *transport,
 	dict_append_entry(&dict, "Device", DBUS_TYPE_OBJECT_PATH,
 						&transport->device->path);
 
-	dict_append_entry(&dict, "IMTU", DBUS_TYPE_UINT16,
-						&transport->imtu);
-
-	dict_append_entry(&dict, "OMTU", DBUS_TYPE_UINT16,
-						&transport->omtu);
-
 	uuid = media_endpoint_get_uuid(transport->endpoint);
 	dict_append_entry(&dict, "UUID", DBUS_TYPE_STRING, &uuid);
 
diff --git a/doc/media-api.txt b/doc/media-api.txt
index 5338974..92b8b3f 100644
--- a/doc/media-api.txt
+++ b/doc/media-api.txt
@@ -86,9 +86,10 @@ Methods		dict GetProperties()
 			Returns all properties for the interface. See the
 			properties section for available properties.
 
-		fd Acquire(string accesstype)
+		fd, uint16, uint16 Acquire(string accesstype)
 
-			Acquire transport file descriptor.
+			Acquire transport file descriptor and the MTU for read
+			and write respectively.
 
 			possible accesstype:
 
@@ -118,14 +119,6 @@ Properties	object Device [readonly]
 
 			Device object which the transport is connected to.
 
-		uint16 IMTU [readonly]
-
-			Transport input MTU.
-
-		uint16 OMTU [readonly]
-
-			Transport output MTU.
-
 		string UUID [readonly]
 
 			UUID of the profile which the transport is for.
-- 
1.7.1


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

end of thread, other threads:[~2011-01-19 15:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-18 10:00 [PATCH 1/4] Remove IMTU and OMTU properties and return its values on Acquire reply Luiz Augusto von Dentz
2011-01-18 10:00 ` [PATCH 2/4] Updade a2dpsink to use new Acquire API Luiz Augusto von Dentz
2011-01-19 15:16   ` Johan Hedberg
2011-01-18 10:00 ` [PATCH 3/4] Add Routing property to MediaTransport interface Luiz Augusto von Dentz
2011-01-19 15:20   ` Johan Hedberg
2011-01-18 10:00 ` [PATCH 4/4] Add proper tracking mechanism to NREC Luiz Augusto von Dentz
2011-01-19 15:22   ` Johan Hedberg
2011-01-19 15:14 ` [PATCH 1/4] Remove IMTU and OMTU properties and return its values on Acquire reply Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox