audio: Fix cancelling disconnect timeout
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 11 Oct 2019 12:40:04 +0000 (15:40 +0300)
committerhimanshu <h.himanshu@samsung.com>
Tue, 11 Feb 2020 08:57:59 +0000 (14:27 +0530)
If AVDTP session has been connected but no stream has been setup calls
to service->connect would return -EBUSY to avoid stream setup collision
but it also takes a reference to the session cancelling the disconnect
timeout and disabling the stream_setup logic that would attempt to
estabilish a stream.

Change-Id: I47a87aeb77429441b7470ff26ef9a9a2d0c54b43
Signed-off-by: himanshu <h.himanshu@samsung.com>
profiles/audio/sink.c
profiles/audio/source.c

index 332d127..01cd461 100755 (executable)
@@ -266,11 +266,18 @@ gboolean sink_setup_stream(struct btd_service *service, struct avdtp *session)
        if (sink->connect_id > 0 || sink->disconnect_id > 0)
                return FALSE;
 
-       if (session && !sink->session)
-               sink->session = avdtp_ref(session);
-
-       if (!sink->session)
-               return FALSE;
+       if (!sink->session) {
+               if (session)
+                       sink->session = avdtp_ref(session);
+               else
+                       sink->session = a2dp_avdtp_get(
+                                       btd_service_get_device(service));
+
+               if (!sink->session) {
+                       DBG("Unable to get a session");
+                       return FALSE;
+               }
+       }
 
        sink->connect_id = a2dp_discover(sink->session, discovery_complete,
                                                                sink);
@@ -284,16 +291,6 @@ int sink_connect(struct btd_service *service)
 {
        struct sink *sink = btd_service_get_user_data(service);
 
-#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
-       if (!sink->session)
-               sink->session = a2dp_avdtp_get(btd_service_get_device(service));
-
-       if (!sink->session) {
-               DBG("Unable to get a session");
-               return -EIO;
-       }
-#endif
-
        if (sink->connect_id > 0 || sink->disconnect_id > 0)
                return -EBUSY;
 
index 4081e19..0ac20fe 100755 (executable)
@@ -257,11 +257,18 @@ gboolean source_setup_stream(struct btd_service *service,
        if (source->connect_id > 0 || source->disconnect_id > 0)
                return FALSE;
 
-       if (session && !source->session)
-               source->session = avdtp_ref(session);
-
-       if (!source->session)
-               return FALSE;
+       if (!source->session) {
+               if (session)
+                       source->session = avdtp_ref(session);
+               else
+                       source->session = a2dp_avdtp_get(
+                                       btd_service_get_device(service));
+
+               if (!source->session) {
+                       DBG("Unable to get a session");
+                       return FALSE;
+               }
+       }
 
        source->connect_id = a2dp_discover(source->session, discovery_complete,
                                                                source);
@@ -275,14 +282,6 @@ int source_connect(struct btd_service *service)
 {
        struct source *source = btd_service_get_user_data(service);
 
-       if (!source->session)
-               source->session = a2dp_avdtp_get(btd_service_get_device(service));
-
-       if (!source->session) {
-               DBG("Unable to get a session");
-               return -EIO;
-       }
-
        if (source->connect_id > 0 || source->disconnect_id > 0)
                return -EBUSY;