linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/4] audio/avrcp: Fix possible crash when current player is removed
@ 2015-09-29 13:45 Luiz Augusto von Dentz
  2015-09-29 13:45 ` [PATCH BlueZ 2/4] doc/media-api: Add Player property to MediaControl1 Luiz Augusto von Dentz
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2015-09-29 13:45 UTC (permalink / raw)
  To: linux-bluetooth

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

If current player is removed a new player should be assigned.

Note: In normal condition this should never happen since player 0 works
as a place holder but there have been some cases where addressed player
changed don't match with any player returned by GetFolderList which
cause a new player to be created and the old one to be destroyed.
---
 profiles/audio/avrcp.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

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;
-- 
2.4.3


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

end of thread, other threads:[~2015-10-01 14:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-29 13:45 [PATCH BlueZ 1/4] audio/avrcp: Fix possible crash when current player is removed Luiz Augusto von Dentz
2015-09-29 13:45 ` [PATCH BlueZ 2/4] doc/media-api: Add Player property to MediaControl1 Luiz Augusto von Dentz
2015-09-29 13:45 ` [PATCH BlueZ 3/4] audio/control: Mark all methods of MediaControl1 as deprecated Luiz Augusto von Dentz
2015-09-29 13:45 ` [PATCH BlueZ 4/4] audio/control: Add Player property to MediaControl1 Luiz Augusto von Dentz
2015-10-01 14:37 ` [PATCH BlueZ 1/4] audio/avrcp: Fix possible crash when current player is removed Luiz Augusto von Dentz

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).