Diff between 6de5a954d46663ef72a3e0ecf4f1add038568110 and 05790fa731e8387ee3e3808c9e1ffb8058ebd3df

Changed Files

File Additions Deletions Status
profiles/audio/avrcp.c +8 -6 modified

Full Patch

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 24deac5..a3ed16a 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -3320,10 +3320,15 @@ static void player_remove(gpointer data)
 
 	for (l = player->sessions; l; l = l->next) {
 		struct avrcp *session = l->data;
+		struct avrcp_data *controller = session->controller;
 
-		session->controller->players = g_slist_remove(
-						session->controller->players,
-						player);
+		controller->players = g_slist_remove(controller->players,
+								player);
+
+		/* Check if current player is being removed */
+		if (controller->player == player)
+			controller->player = g_slist_nth_data(
+							controller->players, 0);
 	}
 
 	player_destroy(player);
@@ -3374,9 +3379,6 @@ static gboolean avrcp_get_media_player_list_rsp(struct avctp *conn,
 		i += len;
 	}
 
-	if (g_slist_find(removed, session->controller->player))
-		session->controller->player = NULL;
-
 	g_slist_free_full(removed, player_remove);
 
 	return FALSE;