Linux bluetooth development
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 05/13 v2] AVRCP: Always create a controller player even for version 1.0
Date: Thu, 10 Jan 2013 15:37:10 +0200	[thread overview]
Message-ID: <1357825038-21970-5-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1357825038-21970-1-git-send-email-luiz.dentz@gmail.com>

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

Since the buttons controls are now part of the MediaPlayer1 it can be used
even with AVRCP version 1.0.
---
 profiles/audio/avrcp.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 3366b48..d0cc346 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -1952,6 +1952,9 @@ static bool ct_set_setting(struct media_player *mp, const char *key,
 	if (session == NULL)
 		return false;
 
+	if (session->version < 0x0103)
+		return false;
+
 	attr = attr_to_val(key);
 	if (attr < 0)
 		return false;
@@ -2047,24 +2050,15 @@ static gboolean avrcp_get_capabilities_resp(struct avctp *conn,
 					void *user_data)
 {
 	struct avrcp *session = user_data;
-	struct avrcp_player *player = session->player;
-	struct media_player *mp;
 	struct avrcp_header *pdu = (void *) operands;
 	uint16_t events = 0;
 	uint8_t count;
-	const char *path;
 
 	if (pdu->params[0] != CAP_EVENTS_SUPPORTED)
 		return FALSE;
 
 	count = pdu->params[1];
 
-	path = device_get_path(session->dev->btd_dev);
-
-	mp = media_player_controller_create(path);
-	if (mp == NULL)
-		return FALSE;
-
 	for (; count > 0; count--) {
 		uint8_t event = pdu->params[1 + count];
 
@@ -2079,10 +2073,6 @@ static gboolean avrcp_get_capabilities_resp(struct avctp *conn,
 		}
 	}
 
-	media_player_set_callbacks(mp, &ct_cbs, player);
-	player->user_data = mp;
-	player->destroy = (GDestroyNotify) media_player_destroy;
-
 	if (!(events & (1 << AVRCP_EVENT_SETTINGS_CHANGED)))
 		avrcp_list_player_attributes(session);
 
@@ -2169,6 +2159,8 @@ static void session_tg_init(struct avrcp *session)
 static void session_ct_init(struct avrcp *session)
 {
 	struct avrcp_player *player;
+	struct media_player *mp;
+	const char *path;
 
 	session->control_handlers = ct_control_handlers;
 
@@ -2179,13 +2171,22 @@ static void session_ct_init(struct avrcp *session)
 							handle_vendordep_pdu,
 							session);
 
-	if (session->version < 0x0103)
-		return;
-
 	player = g_new0(struct avrcp_player, 1);
 	player->sessions = g_slist_prepend(player->sessions, session);
 	session->player = player;
 
+	path = device_get_path(session->dev->btd_dev);
+
+	mp = media_player_controller_create(path);
+	if (mp != NULL) {
+		media_player_set_callbacks(mp, &ct_cbs, player);
+		player->user_data = mp;
+		player->destroy = (GDestroyNotify) media_player_destroy;
+	}
+
+	if (session->version < 0x0103)
+		return;
+
 	avrcp_get_capabilities(session);
 }
 
-- 
1.8.0.1


  parent reply	other threads:[~2013-01-10 13:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-10 13:37 [PATCH BlueZ 01/13 v2] media-api: Add playback control methods to MediaPlayer1 Luiz Augusto von Dentz
2013-01-10 13:37 ` [PATCH BlueZ 02/13 v2] player: Remove GetTrack and TrackChanged Luiz Augusto von Dentz
2013-01-10 13:37 ` [PATCH BlueZ 03/13 v2] player: Add support for button controls Luiz Augusto von Dentz
2013-01-10 13:37 ` [PATCH BlueZ 04/13 v2] player: Fix documentation to use TrackNumber in track metadata Luiz Augusto von Dentz
2013-01-10 13:37 ` Luiz Augusto von Dentz [this message]
2013-01-10 13:37 ` [PATCH BlueZ 06/13 v2] player: Add Device property Luiz Augusto von Dentz
2013-01-10 13:37 ` [PATCH BlueZ 07/13 v2] media: Adapt RegisterPlayer to changes in MediaPlayer1 Luiz Augusto von Dentz
2013-01-10 13:37 ` [PATCH BlueZ 08/13 v2] test: Adapt simple-player to the new API of MediaPlayer1 Luiz Augusto von Dentz
2013-01-10 13:37 ` [PATCH BlueZ 09/13 v2] tools: Adapt mpris-player to " Luiz Augusto von Dentz
2013-01-10 13:37 ` [PATCH BlueZ 10/13 v2] media-api: Change RegisterPlayer to use MPRIS spec Luiz Augusto von Dentz
2013-01-10 13:37 ` [PATCH BlueZ 11/13 v2] test: Update test-player to register using MPRIS interface Luiz Augusto von Dentz
2013-01-10 13:37 ` [PATCH BlueZ 12/13 v2] media: Implement new RegisterPlayer API Luiz Augusto von Dentz
2013-01-10 13:37 ` [PATCH BlueZ 13/13 v2] tools: Update mpris-player to register using MPRIS interface Luiz Augusto von Dentz
2013-01-10 16:02   ` Anderson Lizardo
2013-01-10 16:56     ` Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1357825038-21970-5-git-send-email-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox