linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/4] audio/player: Fix checking wrong flag
@ 2016-08-18 12:45 Luiz Augusto von Dentz
  2016-08-18 12:45 ` [PATCH BlueZ 2/4] audio/avrcp: Fix not setting player id Luiz Augusto von Dentz
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2016-08-18 12:45 UTC (permalink / raw)
  To: linux-bluetooth

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

media_player_set_searchable should check searchable flag not browsable.
---
 profiles/audio/player.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/profiles/audio/player.c b/profiles/audio/player.c
index 465bff5..9d638fc 100644
--- a/profiles/audio/player.c
+++ b/profiles/audio/player.c
@@ -1406,7 +1406,7 @@ void media_player_set_browsable(struct media_player *mp, bool enabled)
 
 void media_player_set_searchable(struct media_player *mp, bool enabled)
 {
-	if (mp->browsable == enabled)
+	if (mp->searchable == enabled)
 		return;
 
 	DBG("%s", enabled ? "true" : "false");
-- 
2.7.4


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

* [PATCH BlueZ 2/4] audio/avrcp: Fix not setting player id
  2016-08-18 12:45 [PATCH BlueZ 1/4] audio/player: Fix checking wrong flag Luiz Augusto von Dentz
@ 2016-08-18 12:45 ` Luiz Augusto von Dentz
  2016-08-18 12:45 ` [PATCH BlueZ 3/4] audio/avrcp: Don't send SetBrowsedPlayer if player is not browsable Luiz Augusto von Dentz
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2016-08-18 12:45 UTC (permalink / raw)
  To: linux-bluetooth

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

The id shall be initialized properly otherwise it maybe reused by
another player since its id will be 0 which is reserved as placeholder
when discovering the player list.
---
 profiles/audio/avrcp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index c100149..90faa1d 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -3212,6 +3212,7 @@ static struct avrcp_player *create_ct_player(struct avrcp *session,
 	const char *path;
 
 	player = g_new0(struct avrcp_player, 1);
+	player->id = id;
 	player->sessions = g_slist_prepend(player->sessions, session);
 
 	path = device_get_path(session->dev);
-- 
2.7.4


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

* [PATCH BlueZ 3/4] audio/avrcp: Don't send SetBrowsedPlayer if player is not browsable
  2016-08-18 12:45 [PATCH BlueZ 1/4] audio/player: Fix checking wrong flag Luiz Augusto von Dentz
  2016-08-18 12:45 ` [PATCH BlueZ 2/4] audio/avrcp: Fix not setting player id Luiz Augusto von Dentz
@ 2016-08-18 12:45 ` Luiz Augusto von Dentz
  2016-08-18 12:45 ` [PATCH BlueZ 4/4] audio/avrcp: Use SetAddressedPlayer when player changes Luiz Augusto von Dentz
  2016-08-23 10:19 ` [PATCH BlueZ 1/4] audio/player: Fix checking wrong flag Luiz Augusto von Dentz
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2016-08-18 12:45 UTC (permalink / raw)
  To: linux-bluetooth

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

If player is not browsable the code should skip sending SetBrowsedPlayer.
---
 profiles/audio/avrcp.c  | 20 ++++++++++++++++++--
 profiles/audio/player.c |  5 +++++
 profiles/audio/player.h |  1 +
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 90faa1d..21acee3 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -3194,14 +3194,30 @@ static const struct media_player_callback ct_cbs = {
 	.total_items = ct_get_total_numberofitems,
 };
 
+static void set_browsed_player(struct avrcp *session,
+					struct avrcp_player *player)
+{
+	if (!player || !player->id || player->browsed)
+		return;
+
+	if (media_player_get_browsable(player->user_data))
+		avrcp_set_browsed_player(session, player);
+}
+
 static void set_ct_player(struct avrcp *session, struct avrcp_player *player)
 {
 	struct btd_service *service;
 
+	if (session->controller->player == player)
+		goto done;
+
 	session->controller->player = player;
 	service = btd_device_get_service(session->dev, AVRCP_TARGET_UUID);
 	control_set_player(service, player ?
 			media_player_get_path(player->user_data) : NULL);
+
+done:
+	set_browsed_player(session, player);
 }
 
 static struct avrcp_player *create_ct_player(struct avrcp *session,
@@ -3304,8 +3320,8 @@ avrcp_parse_media_player_item(struct avrcp *session, uint8_t *operands,
 		media_player_set_name(mp, name);
 	}
 
-	if (session->controller->player == player && !player->browsed)
-		avrcp_set_browsed_player(session, player);
+	if (player->addressed)
+		set_browsed_player(session, player);
 
 	return player;
 }
diff --git a/profiles/audio/player.c b/profiles/audio/player.c
index 9d638fc..f1bd9de 100644
--- a/profiles/audio/player.c
+++ b/profiles/audio/player.c
@@ -1404,6 +1404,11 @@ void media_player_set_browsable(struct media_player *mp, bool enabled)
 					"Browsable");
 }
 
+bool media_player_get_browsable(struct media_player *mp)
+{
+	return mp->browsable;
+}
+
 void media_player_set_searchable(struct media_player *mp, bool enabled)
 {
 	if (mp->searchable == enabled)
diff --git a/profiles/audio/player.h b/profiles/audio/player.h
index 4ad8bfe..54e395a 100644
--- a/profiles/audio/player.h
+++ b/profiles/audio/player.h
@@ -85,6 +85,7 @@ void media_player_set_type(struct media_player *mp, const char *type);
 void media_player_set_subtype(struct media_player *mp, const char *subtype);
 void media_player_set_name(struct media_player *mp, const char *name);
 void media_player_set_browsable(struct media_player *mp, bool enabled);
+bool media_player_get_browsable(struct media_player *mp);
 void media_player_set_searchable(struct media_player *mp, bool enabled);
 void media_player_set_folder(struct media_player *mp, const char *path,
 								uint32_t items);
-- 
2.7.4


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

* [PATCH BlueZ 4/4] audio/avrcp: Use SetAddressedPlayer when player changes
  2016-08-18 12:45 [PATCH BlueZ 1/4] audio/player: Fix checking wrong flag Luiz Augusto von Dentz
  2016-08-18 12:45 ` [PATCH BlueZ 2/4] audio/avrcp: Fix not setting player id Luiz Augusto von Dentz
  2016-08-18 12:45 ` [PATCH BlueZ 3/4] audio/avrcp: Don't send SetBrowsedPlayer if player is not browsable Luiz Augusto von Dentz
@ 2016-08-18 12:45 ` Luiz Augusto von Dentz
  2016-08-23 10:19 ` [PATCH BlueZ 1/4] audio/player: Fix checking wrong flag Luiz Augusto von Dentz
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2016-08-18 12:45 UTC (permalink / raw)
  To: linux-bluetooth

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

This ensures the right player id is addressed before sending commands as
a different player maybe have been set as addressed.
---
 profiles/audio/avrcp.c | 115 ++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 89 insertions(+), 26 deletions(-)

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 21acee3..e20515d 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -2793,6 +2793,83 @@ static void avrcp_set_player_value(struct avrcp *session, uint8_t attr,
 					avrcp_player_value_rsp, session);
 }
 
+static gboolean avrcp_set_addressed_player_rsp(struct avctp *conn, uint8_t code,
+					uint8_t subunit, uint8_t transaction,
+					uint8_t *operands, size_t operand_count,
+					void *user_data)
+{
+	struct avrcp *session = user_data;
+	struct avrcp_player *player = session->controller->player;
+	struct avrcp_header *pdu = (void *) operands;
+
+	if (!pdu || code != AVC_CTYPE_ACCEPTED)
+		return FALSE;
+
+	player->addressed = true;
+
+	return FALSE;
+}
+
+static void avrcp_set_addressed_player(struct avrcp *session,
+						struct avrcp_player *player)
+{
+	uint8_t buf[AVRCP_HEADER_LENGTH + 2];
+	struct avrcp_header *pdu = (void *) buf;
+	uint16_t id;
+
+	memset(buf, 0, sizeof(buf));
+
+	set_company_id(pdu->company_id, IEEEID_BTSIG);
+	pdu->pdu_id = AVRCP_SET_ADDRESSED_PLAYER;
+	pdu->packet_type = AVRCP_PACKET_TYPE_SINGLE;
+	id = htons(player->id);
+	memcpy(pdu->params, &id, 2);
+	pdu->params_len = htons(2);
+
+	avctp_send_vendordep_req(session->conn, AVC_CTYPE_CONTROL,
+					AVC_SUBUNIT_PANEL, buf, sizeof(buf),
+					avrcp_set_addressed_player_rsp,
+					session);
+}
+
+static void set_addressed_player(struct avrcp *session,
+					struct avrcp_player *player)
+{
+	if (!player || !player->id || player->addressed ||
+				session->controller->version < 0x0104)
+		return;
+
+	/* Set player as addressed */
+	avrcp_set_addressed_player(session, player);
+}
+
+static void set_browsed_player(struct avrcp *session,
+					struct avrcp_player *player)
+{
+	if (!player || !player->id || player->browsed)
+		return;
+
+	if (media_player_get_browsable(player->user_data))
+		avrcp_set_browsed_player(session, player);
+}
+
+static void set_ct_player(struct avrcp *session, struct avrcp_player *player)
+{
+	struct btd_service *service;
+
+	if (session->controller->player == player)
+		goto done;
+
+	session->controller->player = player;
+	service = btd_device_get_service(session->dev, AVRCP_TARGET_UUID);
+	control_set_player(service, player ?
+			media_player_get_path(player->user_data) : NULL);
+
+done:
+	set_addressed_player(session, player);
+	set_browsed_player(session, player);
+}
+
 static bool ct_set_setting(struct media_player *mp, const char *key,
 					const char *value, void *user_data)
 {
@@ -2808,6 +2885,8 @@ static bool ct_set_setting(struct media_player *mp, const char *key,
 	if (session->controller->version < 0x0103)
 		return false;
 
+	set_ct_player(session, player);
+
 	attr = attr_to_val(key);
 	if (attr < 0)
 		return false;
@@ -2830,6 +2909,8 @@ static int ct_press(struct avrcp_player *player, uint8_t op)
 	if (session == NULL)
 		return -ENOTCONN;
 
+	set_ct_player(session, player);
+
 	err = avctp_send_passthrough(session->conn, op);
 	if (err < 0)
 		return err;
@@ -2898,6 +2979,8 @@ static int ct_list_items(struct media_player *mp, const char *name,
 
 	session = player->sessions->data;
 
+	set_ct_player(session, player);
+
 	if (g_str_has_prefix(name, "/NowPlaying"))
 		player->scope = 0x03;
 	else if (g_str_has_suffix(name, "/search"))
@@ -2942,6 +3025,7 @@ static int ct_change_folder(struct media_player *mp, const char *path,
 	uint8_t direction;
 
 	session = player->sessions->data;
+	set_ct_player(session, player);
 	player->change_path = g_strdup(path);
 
 	direction = g_str_has_prefix(path, player->path) ? 0x01 : 0x00;
@@ -3008,6 +3092,7 @@ static int ct_search(struct media_player *mp, const char *string,
 
 	session = player->sessions->data;
 
+	set_ct_player(session, player);
 	avrcp_search(session, string);
 
 	return 0;
@@ -3048,6 +3133,7 @@ static int ct_play_item(struct media_player *mp, const char *name,
 		return -EBUSY;
 
 	session = player->sessions->data;
+	set_ct_player(session, player);
 
 	if (g_strrstr(name, "/NowPlaying"))
 		player->scope = 0x03;
@@ -3100,6 +3186,7 @@ static int ct_add_to_nowplaying(struct media_player *mp, const char *name,
 	else
 		player->scope = 0x01;
 
+	set_ct_player(session, player);
 	avrcp_add_to_nowplaying(session, uid);
 
 	return 0;
@@ -3159,6 +3246,7 @@ static int ct_get_total_numberofitems(struct media_player *mp, const char *name,
 	struct avrcp *session;
 
 	session = player->sessions->data;
+	set_ct_player(session, player);
 
 	if (session->controller->version != 0x0106) {
 		error("version not supported");
@@ -3194,32 +3282,6 @@ static const struct media_player_callback ct_cbs = {
 	.total_items = ct_get_total_numberofitems,
 };
 
-static void set_browsed_player(struct avrcp *session,
-					struct avrcp_player *player)
-{
-	if (!player || !player->id || player->browsed)
-		return;
-
-	if (media_player_get_browsable(player->user_data))
-		avrcp_set_browsed_player(session, player);
-}
-
-static void set_ct_player(struct avrcp *session, struct avrcp_player *player)
-{
-	struct btd_service *service;
-
-	if (session->controller->player == player)
-		goto done;
-
-	session->controller->player = player;
-	service = btd_device_get_service(session->dev, AVRCP_TARGET_UUID);
-	control_set_player(service, player ?
-			media_player_get_path(player->user_data) : NULL);
-
-done:
-	set_browsed_player(session, player);
-}
-
 static struct avrcp_player *create_ct_player(struct avrcp *session,
 								uint16_t id)
 {
@@ -3540,6 +3602,7 @@ static void avrcp_addressed_player_changed(struct avrcp *session,
 			return;
 	}
 
+	player->addressed = true;
 	player->uid_counter = get_be16(&pdu->params[3]);
 	set_ct_player(session, player);
 
-- 
2.7.4


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

* Re: [PATCH BlueZ 1/4] audio/player: Fix checking wrong flag
  2016-08-18 12:45 [PATCH BlueZ 1/4] audio/player: Fix checking wrong flag Luiz Augusto von Dentz
                   ` (2 preceding siblings ...)
  2016-08-18 12:45 ` [PATCH BlueZ 4/4] audio/avrcp: Use SetAddressedPlayer when player changes Luiz Augusto von Dentz
@ 2016-08-23 10:19 ` Luiz Augusto von Dentz
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2016-08-23 10:19 UTC (permalink / raw)
  To: linux-bluetooth@vger.kernel.org

Hi,

On Thu, Aug 18, 2016 at 3:45 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> media_player_set_searchable should check searchable flag not browsable.
> ---
>  profiles/audio/player.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/profiles/audio/player.c b/profiles/audio/player.c
> index 465bff5..9d638fc 100644
> --- a/profiles/audio/player.c
> +++ b/profiles/audio/player.c
> @@ -1406,7 +1406,7 @@ void media_player_set_browsable(struct media_player *mp, bool enabled)
>
>  void media_player_set_searchable(struct media_player *mp, bool enabled)
>  {
> -       if (mp->browsable == enabled)
> +       if (mp->searchable == enabled)
>                 return;
>
>         DBG("%s", enabled ? "true" : "false");
> --
> 2.7.4

Applied.


-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2016-08-23 10:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-18 12:45 [PATCH BlueZ 1/4] audio/player: Fix checking wrong flag Luiz Augusto von Dentz
2016-08-18 12:45 ` [PATCH BlueZ 2/4] audio/avrcp: Fix not setting player id Luiz Augusto von Dentz
2016-08-18 12:45 ` [PATCH BlueZ 3/4] audio/avrcp: Don't send SetBrowsedPlayer if player is not browsable Luiz Augusto von Dentz
2016-08-18 12:45 ` [PATCH BlueZ 4/4] audio/avrcp: Use SetAddressedPlayer when player changes Luiz Augusto von Dentz
2016-08-23 10:19 ` [PATCH BlueZ 1/4] audio/player: Fix checking wrong flag 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).