linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] audio/sink: Fix not notifying service about connection state
@ 2013-07-04 12:00 Luiz Augusto von Dentz
  2013-07-04 12:00 ` [PATCH BlueZ 2/2] audio/source: " Luiz Augusto von Dentz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2013-07-04 12:00 UTC (permalink / raw)
  To: linux-bluetooth

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

btd_service_connecting_complete should be called whenever the service
is connected otherwise the service state will not be consistent.
---
 profiles/audio/sink.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/profiles/audio/sink.c b/profiles/audio/sink.c
index 3969417..f55efe8 100644
--- a/profiles/audio/sink.c
+++ b/profiles/audio/sink.c
@@ -164,6 +164,7 @@ static void stream_state_changed(struct avdtp_stream *stream,
 		sink->cb_id = 0;
 		break;
 	case AVDTP_STATE_OPEN:
+		btd_service_connecting_complete(sink->service, 0);
 		sink_set_state(dev, SINK_STATE_CONNECTED);
 		break;
 	case AVDTP_STATE_STREAMING:
@@ -182,20 +183,14 @@ static void stream_state_changed(struct avdtp_stream *stream,
 static gboolean stream_setup_retry(gpointer user_data)
 {
 	struct sink *sink = user_data;
-	int err;
 
 	sink->retry_id = 0;
 
-	if (sink->stream_state >= AVDTP_STATE_OPEN) {
-		DBG("Stream successfully created, after XCASE connect:connect");
-		err = 0;
-	} else {
+	if (sink->stream_state < AVDTP_STATE_OPEN) {
 		DBG("Stream setup failed, after XCASE connect:connect");
-		err = -EIO;
+		btd_service_connecting_complete(sink->service, -EIO);
 	}
 
-	btd_service_connecting_complete(sink->service, err);
-
 	if (sink->connect_id > 0) {
 		a2dp_cancel(sink->dev, sink->connect_id);
 		sink->connect_id = 0;
@@ -212,11 +207,8 @@ static void stream_setup_complete(struct avdtp *session, struct a2dp_sep *sep,
 
 	sink->connect_id = 0;
 
-	if (stream) {
-		DBG("Stream successfully created");
-		btd_service_connecting_complete(sink->service, 0);
+	if (stream)
 		return;
-	}
 
 	avdtp_unref(sink->session);
 	sink->session = NULL;
-- 
1.8.1.4


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

* [PATCH BlueZ 2/2] audio/source: Fix not notifying service about connection state
  2013-07-04 12:00 [PATCH BlueZ 1/2] audio/sink: Fix not notifying service about connection state Luiz Augusto von Dentz
@ 2013-07-04 12:00 ` Luiz Augusto von Dentz
  2013-07-04 12:19 ` [PATCH BlueZ 1/2] audio/sink: " Mikel Astiz
  2013-07-05 10:20 ` Johan Hedberg
  2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2013-07-04 12:00 UTC (permalink / raw)
  To: linux-bluetooth

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

btd_service_connecting_complete should be called whenever the service
is connected otherwise the service state will not be consistent.
---
 profiles/audio/source.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/profiles/audio/source.c b/profiles/audio/source.c
index 226c372..73c3185 100644
--- a/profiles/audio/source.c
+++ b/profiles/audio/source.c
@@ -165,6 +165,7 @@ static void stream_state_changed(struct avdtp_stream *stream,
 		source->cb_id = 0;
 		break;
 	case AVDTP_STATE_OPEN:
+		btd_service_connecting_complete(source->service, 0);
 		source_set_state(dev, SOURCE_STATE_CONNECTED);
 		break;
 	case AVDTP_STATE_STREAMING:
@@ -183,20 +184,14 @@ static void stream_state_changed(struct avdtp_stream *stream,
 static gboolean stream_setup_retry(gpointer user_data)
 {
 	struct source *source = user_data;
-	int err;
 
 	source->retry_id = 0;
 
-	if (source->stream_state >= AVDTP_STATE_OPEN) {
-		DBG("Stream successfully created, after XCASE connect:connect");
-		err = 0;
-	} else {
+	if (source->stream_state < AVDTP_STATE_OPEN) {
 		DBG("Stream setup failed, after XCASE connect:connect");
-		err = -EIO;
+		btd_service_connecting_complete(source->service, -EIO);
 	}
 
-	btd_service_connecting_complete(source->service, err);
-
 	if (source->connect_id > 0) {
 		a2dp_cancel(source->dev, source->connect_id);
 		source->connect_id = 0;
@@ -213,11 +208,8 @@ static void stream_setup_complete(struct avdtp *session, struct a2dp_sep *sep,
 
 	source->connect_id = 0;
 
-	if (stream) {
-		DBG("Stream successfully created");
-		btd_service_connecting_complete(source->service, 0);
+	if (stream)
 		return;
-	}
 
 	avdtp_unref(source->session);
 	source->session = NULL;
-- 
1.8.1.4


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

* Re: [PATCH BlueZ 1/2] audio/sink: Fix not notifying service about connection state
  2013-07-04 12:00 [PATCH BlueZ 1/2] audio/sink: Fix not notifying service about connection state Luiz Augusto von Dentz
  2013-07-04 12:00 ` [PATCH BlueZ 2/2] audio/source: " Luiz Augusto von Dentz
@ 2013-07-04 12:19 ` Mikel Astiz
  2013-07-05 10:20 ` Johan Hedberg
  2 siblings, 0 replies; 4+ messages in thread
From: Mikel Astiz @ 2013-07-04 12:19 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Thu, Jul 4, 2013 at 2:00 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> btd_service_connecting_complete should be called whenever the service
> is connected otherwise the service state will not be consistent.
> ---
>  profiles/audio/sink.c | 16 ++++------------
>  1 file changed, 4 insertions(+), 12 deletions(-)
>
> diff --git a/profiles/audio/sink.c b/profiles/audio/sink.c
> index 3969417..f55efe8 100644
> --- a/profiles/audio/sink.c
> +++ b/profiles/audio/sink.c
> @@ -164,6 +164,7 @@ static void stream_state_changed(struct avdtp_stream *stream,
>                 sink->cb_id = 0;
>                 break;
>         case AVDTP_STATE_OPEN:
> +               btd_service_connecting_complete(sink->service, 0);

I guess it's impossible to enter AVDTP_STATE_STREAMING without being OPEN first?

If this is guaranteed, the patch looks good to me.

Cheers,
Mikel

>                 sink_set_state(dev, SINK_STATE_CONNECTED);
>                 break;
>         case AVDTP_STATE_STREAMING:
> @@ -182,20 +183,14 @@ static void stream_state_changed(struct avdtp_stream *stream,
>  static gboolean stream_setup_retry(gpointer user_data)
>  {
>         struct sink *sink = user_data;
> -       int err;
>
>         sink->retry_id = 0;
>
> -       if (sink->stream_state >= AVDTP_STATE_OPEN) {
> -               DBG("Stream successfully created, after XCASE connect:connect");
> -               err = 0;
> -       } else {
> +       if (sink->stream_state < AVDTP_STATE_OPEN) {
>                 DBG("Stream setup failed, after XCASE connect:connect");
> -               err = -EIO;
> +               btd_service_connecting_complete(sink->service, -EIO);
>         }
>
> -       btd_service_connecting_complete(sink->service, err);
> -
>         if (sink->connect_id > 0) {
>                 a2dp_cancel(sink->dev, sink->connect_id);
>                 sink->connect_id = 0;
> @@ -212,11 +207,8 @@ static void stream_setup_complete(struct avdtp *session, struct a2dp_sep *sep,
>
>         sink->connect_id = 0;
>
> -       if (stream) {
> -               DBG("Stream successfully created");
> -               btd_service_connecting_complete(sink->service, 0);
> +       if (stream)
>                 return;
> -       }
>
>         avdtp_unref(sink->session);
>         sink->session = NULL;
> --
> 1.8.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH BlueZ 1/2] audio/sink: Fix not notifying service about connection state
  2013-07-04 12:00 [PATCH BlueZ 1/2] audio/sink: Fix not notifying service about connection state Luiz Augusto von Dentz
  2013-07-04 12:00 ` [PATCH BlueZ 2/2] audio/source: " Luiz Augusto von Dentz
  2013-07-04 12:19 ` [PATCH BlueZ 1/2] audio/sink: " Mikel Astiz
@ 2013-07-05 10:20 ` Johan Hedberg
  2 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2013-07-05 10:20 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Thu, Jul 04, 2013, Luiz Augusto von Dentz wrote:
> btd_service_connecting_complete should be called whenever the service
> is connected otherwise the service state will not be consistent.
> ---
>  profiles/audio/sink.c | 16 ++++------------
>  1 file changed, 4 insertions(+), 12 deletions(-)

Both patches have been applied. Thanks.

Johan

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

end of thread, other threads:[~2013-07-05 10:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-04 12:00 [PATCH BlueZ 1/2] audio/sink: Fix not notifying service about connection state Luiz Augusto von Dentz
2013-07-04 12:00 ` [PATCH BlueZ 2/2] audio/source: " Luiz Augusto von Dentz
2013-07-04 12:19 ` [PATCH BlueZ 1/2] audio/sink: " Mikel Astiz
2013-07-05 10:20 ` 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).