OSDN Git Service

audio/source: Fix not notifying service about connection state
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 4 Jul 2013 12:00:45 +0000 (15:00 +0300)
committerJohan Hedberg <johan.hedberg@intel.com>
Fri, 5 Jul 2013 10:19:48 +0000 (13:19 +0300)
btd_service_connecting_complete should be called whenever the service
is connected otherwise the service state will not be consistent.

profiles/audio/source.c

index 226c372..73c3185 100644 (file)
@@ -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;