a2dp: Update last used on open indication
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 3 May 2019 08:24:57 +0000 (11:24 +0300)
committerhimanshu <h.himanshu@samsung.com>
Tue, 11 Feb 2020 08:57:47 +0000 (14:27 +0530)
This updates the last used endpoint also when receiving an open
request from the remote end.

Change-Id: Ie586bda139c2d24c1f5bf18d16a30e5ba10db261
Signed-off-by: himanshu <h.himanshu@samsung.com>
profiles/audio/a2dp.c

index 997ac8b..7ed98d4 100644 (file)
@@ -892,32 +892,6 @@ static void getconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
                DBG("Source %p: Set_Configuration_Cfm", sep);
 }
 
-static gboolean open_ind(struct avdtp *session, struct avdtp_local_sep *sep,
-                               struct avdtp_stream *stream, uint8_t *err,
-                               void *user_data)
-{
-       struct a2dp_sep *a2dp_sep = user_data;
-       struct a2dp_setup *setup;
-
-       if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-               DBG("Sink %p: Open_Ind", sep);
-       else
-               DBG("Source %p: Open_Ind", sep);
-
-       setup = a2dp_setup_get(session);
-       if (!setup)
-               return FALSE;
-
-       setup->stream = stream;
-
-       if (setup->reconfigure)
-               setup->reconfigure = FALSE;
-
-       finalize_config(setup);
-
-       return TRUE;
-}
-
 static bool match_remote_sep(const void *data, const void *user_data)
 {
        const struct a2dp_remote_sep *sep = data;
@@ -972,6 +946,35 @@ static void update_last_used(struct a2dp_channel *chan,
        store_last_used(chan, rsep);
 }
 
+static gboolean open_ind(struct avdtp *session, struct avdtp_local_sep *sep,
+                               struct avdtp_stream *stream, uint8_t *err,
+                               void *user_data)
+{
+       struct a2dp_sep *a2dp_sep = user_data;
+       struct a2dp_setup *setup;
+
+       if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
+               DBG("Sink %p: Open_Ind", sep);
+       else
+               DBG("Source %p: Open_Ind", sep);
+
+       setup = a2dp_setup_get(session);
+       if (!setup)
+               return FALSE;
+
+       setup->stream = stream;
+
+       if (!err && setup->chan)
+               update_last_used(setup->chan, stream);
+
+       if (setup->reconfigure)
+               setup->reconfigure = FALSE;
+
+       finalize_config(setup);
+
+       return TRUE;
+}
+
 static void open_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
                        struct avdtp_stream *stream, struct avdtp_error *err,
                        void *user_data)