All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 01/14] AVRCP: Update constants
@ 2012-06-27 13:27 Michal Labedzki
  2012-06-27 13:27 ` [PATCH v2 02/14] doc: Fix typo Michal Labedzki
                   ` (13 more replies)
  0 siblings, 14 replies; 18+ messages in thread
From: Michal Labedzki @ 2012-06-27 13:27 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, lucas.demarchi, johan.hedberg, Michal Labedzki

Change all specification constants to enum type.
Also add constants for addressed player feature.
---
 audio/avrcp.c |  151 ++++++++++++++++++++++++++++++++-------------------------
 audio/avrcp.h |  107 ++++++++++++++++++++++------------------
 audio/media.c |    2 +-
 3 files changed, 146 insertions(+), 114 deletions(-)

diff --git a/audio/avrcp.c b/audio/avrcp.c
index 89ee112..da102b2 100644
--- a/audio/avrcp.c
+++ b/audio/avrcp.c
@@ -58,56 +58,73 @@
 #include "sdpd.h"
 #include "dbus-common.h"
 
-/* Company IDs for vendor dependent commands */
-#define IEEEID_BTSIG		0x001958
-
-/* Error codes for metadata transfer */
-#define E_INVALID_COMMAND	0x00
-#define E_INVALID_PARAM		0x01
-#define E_PARAM_NOT_FOUND	0x02
-#define E_INTERNAL		0x03
-
-/* Packet types */
-#define AVRCP_PACKET_TYPE_SINGLE	0x00
-#define AVRCP_PACKET_TYPE_START		0x01
-#define AVRCP_PACKET_TYPE_CONTINUING	0x02
-#define AVRCP_PACKET_TYPE_END		0x03
-
-/* PDU types for metadata transfer */
-#define AVRCP_GET_CAPABILITIES		0x10
-#define AVRCP_LIST_PLAYER_ATTRIBUTES	0X11
-#define AVRCP_LIST_PLAYER_VALUES	0x12
-#define AVRCP_GET_CURRENT_PLAYER_VALUE	0x13
-#define AVRCP_SET_PLAYER_VALUE		0x14
-#define AVRCP_GET_PLAYER_ATTRIBUTE_TEXT	0x15
-#define AVRCP_GET_PLAYER_VALUE_TEXT	0x16
-#define AVRCP_DISPLAYABLE_CHARSET	0x17
-#define AVRCP_CT_BATTERY_STATUS		0x18
-#define AVRCP_GET_ELEMENT_ATTRIBUTES	0x20
-#define AVRCP_GET_PLAY_STATUS		0x30
-#define AVRCP_REGISTER_NOTIFICATION	0x31
-#define AVRCP_REQUEST_CONTINUING	0x40
-#define AVRCP_ABORT_CONTINUING		0x41
-#define AVRCP_SET_ABSOLUTE_VOLUME	0x50
-
-/* Capabilities for AVRCP_GET_CAPABILITIES pdu */
-#define CAP_COMPANY_ID		0x02
-#define CAP_EVENTS_SUPPORTED	0x03
-
 #define AVRCP_REGISTER_NOTIFICATION_PARAM_LENGTH 5
 
-#define AVRCP_FEATURE_CATEGORY_1	0x0001
-#define AVRCP_FEATURE_CATEGORY_2	0x0002
-#define AVRCP_FEATURE_CATEGORY_3	0x0004
-#define AVRCP_FEATURE_CATEGORY_4	0x0008
-#define AVRCP_FEATURE_PLAYER_SETTINGS	0x0010
+enum company_id {
+	IEEEID_BTSIG	 = 0x001958
+};
+
+enum status_code {
+	STATUS_INVALID_COMMAND		= 0x00,
+	STATUS_INVALID_PARAMETER	= 0x01,
+	STATUS_INTERNAL_ERROR		= 0x03,
+	STATUS_OK			= 0x04,
+	STATUS_INVALID_PLAYER_ID	= 0x11,
+	STATUS_NO_AVAILABLE_PLAYERS	= 0x15,
+	STATUS_ADDRESSED_PLAYER_CHANGED	= 0x16
+};
+
+enum packet_type {
+	AVRCP_PACKET_TYPE_SINGLE	= 0x00,
+	AVRCP_PACKET_TYPE_START		= 0x01,
+	AVRCP_PACKET_TYPE_CONTINUING	= 0x02,
+	AVRCP_PACKET_TYPE_END		= 0x03
+};
+
+enum control_pdu_ieeeid_btsig {
+	AVRCP_GET_CAPABILITIES		= 0x10,
+	AVRCP_LIST_PLAYER_ATTRIBUTES	= 0X11,
+	AVRCP_LIST_PLAYER_VALUES	= 0x12,
+	AVRCP_GET_CURRENT_PLAYER_VALUE	= 0x13,
+	AVRCP_SET_PLAYER_VALUE		= 0x14,
+	AVRCP_GET_PLAYER_ATTRIBUTE_TEXT	= 0x15,
+	AVRCP_GET_PLAYER_VALUE_TEXT	= 0x16,
+	AVRCP_DISPLAYABLE_CHARSET	= 0x17,
+	AVRCP_CT_BATTERY_STATUS		= 0x18,
+	AVRCP_GET_ELEMENT_ATTRIBUTES	= 0x20,
+	AVRCP_GET_PLAY_STATUS		= 0x30,
+	AVRCP_REGISTER_NOTIFICATION	= 0x31,
+	AVRCP_REQUEST_CONTINUING	= 0x40,
+	AVRCP_ABORT_CONTINUING		= 0x41,
+	AVRCP_SET_ABSOLUTE_VOLUME	= 0x50,
+	AVRCP_SET_ADDRESSED_PLAYER	= 0x60,
+};
+
+enum capability {
+	CAP_COMPANY_ID		= 0x02,
+	CAP_EVENTS_SUPPORTED	= 0x03
+};
+
+enum sdp_feature {
+	AVRCP_FEATURE_CATEGORY_1	= 0x0001,
+	AVRCP_FEATURE_CATEGORY_2	= 0x0002,
+	AVRCP_FEATURE_CATEGORY_3	= 0x0004,
+	AVRCP_FEATURE_CATEGORY_4	= 0x0008,
+	AVRCP_FEATURE_PLAYER_SETTINGS	= 0x0010,
+};
 
 enum battery_status {
-	BATTERY_STATUS_NORMAL =		0,
-	BATTERY_STATUS_WARNING =	1,
-	BATTERY_STATUS_CRITICAL =	2,
-	BATTERY_STATUS_EXTERNAL =	3,
-	BATTERY_STATUS_FULL_CHARGE =	4,
+	BATTERY_STATUS_NORMAL		= 0,
+	BATTERY_STATUS_WARNING		= 1,
+	BATTERY_STATUS_CRITICAL		= 2,
+	BATTERY_STATUS_EXTERNAL		= 3,
+	BATTERY_STATUS_FULL_CHARGE	= 4
+};
+
+enum avrcp_version {
+	AVRCP_VERSION_UNKNOWN	= 0x0000,
+	AVRCP_VERSION_1_3	= 0x0103,
+	AVRCP_VERSION_1_4	= 0x0104
 };
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
@@ -396,7 +413,7 @@ int avrcp_player_event(struct avrcp_player *player, uint8_t id, void *data)
 	DBG("id=%u", id);
 
 	switch (id) {
-	case AVRCP_EVENT_STATUS_CHANGED:
+	case AVRCP_EVENT_PLAYBACK_STATUS_CHANGED:
 		size = 2;
 		pdu->params[1] = *((uint8_t *)data);
 
@@ -581,7 +598,7 @@ static uint8_t avrcp_handle_get_capabilities(struct avrcp_player *player,
 		return AVC_CTYPE_STABLE;
 	case CAP_EVENTS_SUPPORTED:
 		pdu->params[1] = 4;
-		pdu->params[2] = AVRCP_EVENT_STATUS_CHANGED;
+		pdu->params[2] = AVRCP_EVENT_PLAYBACK_STATUS_CHANGED;
 		pdu->params[3] = AVRCP_EVENT_TRACK_CHANGED;
 		pdu->params[4] = AVRCP_EVENT_TRACK_REACHED_START;
 		pdu->params[5] = AVRCP_EVENT_TRACK_REACHED_END;
@@ -592,7 +609,7 @@ static uint8_t avrcp_handle_get_capabilities(struct avrcp_player *player,
 
 err:
 	pdu->params_len = htons(1);
-	pdu->params[0] = E_INVALID_PARAM;
+	pdu->params[0] = STATUS_INVALID_PARAMETER;
 
 	return AVC_CTYPE_REJECTED;
 }
@@ -606,7 +623,7 @@ static uint8_t avrcp_handle_list_player_attributes(struct avrcp_player *player,
 
 	if (len != 0) {
 		pdu->params_len = htons(1);
-		pdu->params[0] = E_INVALID_PARAM;
+		pdu->params[0] = STATUS_INVALID_PARAMETER;
 		return AVC_CTYPE_REJECTED;
 	}
 
@@ -653,7 +670,7 @@ static uint8_t avrcp_handle_list_player_values(struct avrcp_player *player,
 
 err:
 	pdu->params_len = htons(1);
-	pdu->params[0] = E_INVALID_PARAM;
+	pdu->params[0] = STATUS_INVALID_PARAMETER;
 	return AVC_CTYPE_REJECTED;
 }
 
@@ -724,7 +741,7 @@ static uint8_t avrcp_handle_get_element_attributes(struct avrcp_player *player,
 	return AVC_CTYPE_STABLE;
 err:
 	pdu->params_len = htons(1);
-	pdu->params[0] = E_INVALID_PARAM;
+	pdu->params[0] = STATUS_INVALID_PARAMETER;
 	return AVC_CTYPE_REJECTED;
 }
 
@@ -781,7 +798,7 @@ static uint8_t avrcp_handle_get_current_player_value(struct avrcp_player *player
 
 err:
 	pdu->params_len = htons(1);
-	pdu->params[0] = E_INVALID_PARAM;
+	pdu->params[0] = STATUS_INVALID_PARAMETER;
 
 	return AVC_CTYPE_REJECTED;
 }
@@ -802,7 +819,7 @@ static uint8_t avrcp_handle_set_player_value(struct avrcp_player *player,
 	 * and set the existent ones. Sec. 5.2.4 is not clear however how to
 	 * indicate that a certain ID was not accepted. If at least one
 	 * attribute is valid, we respond with no parameters. Otherwise an
-	 * E_INVALID_PARAM is sent.
+	 * STATUS_INVALID_PARAMETER is sent.
 	 */
 	for (len = 0, i = 0, param = &pdu->params[1]; i < pdu->params[0];
 							i++, param += 2) {
@@ -820,7 +837,7 @@ static uint8_t avrcp_handle_set_player_value(struct avrcp_player *player,
 
 err:
 	pdu->params_len = htons(1);
-	pdu->params[0] = E_INVALID_PARAM;
+	pdu->params[0] = STATUS_INVALID_PARAMETER;
 	return AVC_CTYPE_REJECTED;
 }
 
@@ -832,7 +849,7 @@ static uint8_t avrcp_handle_displayable_charset(struct avrcp_player *player,
 
 	if (len < 3) {
 		pdu->params_len = htons(1);
-		pdu->params[0] = E_INVALID_PARAM;
+		pdu->params[0] = STATUS_INVALID_PARAMETER;
 		return AVC_CTYPE_REJECTED;
 	}
 
@@ -864,7 +881,7 @@ static uint8_t avrcp_handle_ct_battery_status(struct avrcp_player *player,
 
 err:
 	pdu->params_len = htons(1);
-	pdu->params[0] = E_INVALID_PARAM;
+	pdu->params[0] = STATUS_INVALID_PARAMETER;
 	return AVC_CTYPE_REJECTED;
 }
 
@@ -879,7 +896,7 @@ static uint8_t avrcp_handle_get_play_status(struct avrcp_player *player,
 
 	if (len != 0) {
 		pdu->params_len = htons(1);
-		pdu->params[0] = E_INVALID_PARAM;
+		pdu->params[0] = STATUS_INVALID_PARAMETER;
 		return AVC_CTYPE_REJECTED;
 	}
 
@@ -918,7 +935,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp_player *player,
 		goto err;
 
 	switch (pdu->params[0]) {
-	case AVRCP_EVENT_STATUS_CHANGED:
+	case AVRCP_EVENT_PLAYBACK_STATUS_CHANGED:
 		len = 2;
 		pdu->params[1] = player->cb->get_status(player->user_data);
 
@@ -948,7 +965,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp_player *player,
 
 err:
 	pdu->params_len = htons(1);
-	pdu->params[0] = E_INVALID_PARAM;
+	pdu->params[0] = STATUS_INVALID_PARAMETER;
 	return AVC_CTYPE_REJECTED;
 }
 
@@ -988,7 +1005,7 @@ static uint8_t avrcp_handle_request_continuing(struct avrcp_player *player,
 	return AVC_CTYPE_STABLE;
 err:
 	pdu->params_len = htons(1);
-	pdu->params[0] = E_INVALID_PARAM;
+	pdu->params[0] = STATUS_INVALID_PARAMETER;
 	return AVC_CTYPE_REJECTED;
 }
 
@@ -1014,7 +1031,7 @@ static uint8_t avrcp_handle_abort_continuing(struct avrcp_player *player,
 
 err:
 	pdu->params_len = htons(1);
-	pdu->params[0] = E_INVALID_PARAM;
+	pdu->params[0] = STATUS_INVALID_PARAMETER;
 	return AVC_CTYPE_REJECTED;
 }
 
@@ -1079,7 +1096,7 @@ static size_t handle_vendordep_pdu(struct avctp *session, uint8_t transaction,
 	pdu->rsvd = 0;
 
 	if (operand_count < AVRCP_HEADER_LENGTH) {
-		pdu->params[0] = E_INVALID_COMMAND;
+		pdu->params[0] = STATUS_INVALID_COMMAND;
 		goto err_metadata;
 	}
 
@@ -1089,12 +1106,12 @@ static size_t handle_vendordep_pdu(struct avctp *session, uint8_t transaction,
 	}
 
 	if (!handler || handler->code != *code) {
-		pdu->params[0] = E_INVALID_COMMAND;
+		pdu->params[0] = STATUS_INVALID_COMMAND;
 		goto err_metadata;
 	}
 
 	if (!handler->func) {
-		pdu->params[0] = E_INVALID_PARAM;
+		pdu->params[0] = STATUS_INVALID_PARAMETER;
 		goto err_metadata;
 	}
 
@@ -1122,7 +1139,7 @@ size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands)
 
     *code = AVC_CTYPE_REJECTED;
     pdu->params_len = htons(1);
-    pdu->params[0] = E_INTERNAL;
+    pdu->params[0] = STATUS_INTERNAL_ERROR;
 
     DBG("rejecting AVRCP PDU 0x%02X, company 0x%06X len 0x%04X",
             pdu->pdu_id, company_id, pdu->params_len);
@@ -1236,7 +1253,7 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
 
 		desc = list->data;
 
-		if (desc && desc->version >= 0x0104)
+		if (desc && desc->version >= AVRCP_VERSION_1_4)
 			register_volume_notification(player);
 
 		sdp_list_free(list, free);
diff --git a/audio/avrcp.h b/audio/avrcp.h
index bf11a6c..dcc67f6 100644
--- a/audio/avrcp.h
+++ b/audio/avrcp.h
@@ -22,59 +22,74 @@
  *
  */
 
-/* player attributes */
-#define AVRCP_ATTRIBUTE_ILEGAL		0x00
-#define AVRCP_ATTRIBUTE_EQUALIZER	0x01
-#define AVRCP_ATTRIBUTE_REPEAT_MODE	0x02
-#define AVRCP_ATTRIBUTE_SHUFFLE		0x03
-#define AVRCP_ATTRIBUTE_SCAN		0x04
+enum player_attribute {
+	AVRCP_ATTRIBUTE_ILEGAL		= 0x00,
+	AVRCP_ATTRIBUTE_EQUALIZER	= 0x01,
+	AVRCP_ATTRIBUTE_REPEAT_MODE	= 0x02,
+	AVRCP_ATTRIBUTE_SHUFFLE		= 0x03,
+	AVRCP_ATTRIBUTE_SCAN		= 0x04
+};
 
-/* equalizer values */
-#define AVRCP_EQUALIZER_OFF		0x01
-#define AVRCP_EQUALIZER_ON		0x02
+enum equalizer_value {
+	AVRCP_EQUALIZER_OFF		= 0x01,
+	AVRCP_EQUALIZER_ON		= 0x02
+};
 
-/* repeat mode values */
-#define AVRCP_REPEAT_MODE_OFF		0x01
-#define AVRCP_REPEAT_MODE_SINGLE	0x02
-#define AVRCP_REPEAT_MODE_ALL		0x03
-#define AVRCP_REPEAT_MODE_GROUP		0x04
+enum repeat_mode_value {
+	AVRCP_REPEAT_MODE_OFF		= 0x01,
+	AVRCP_REPEAT_MODE_SINGLE	= 0x02,
+	AVRCP_REPEAT_MODE_ALL		= 0x03,
+	AVRCP_REPEAT_MODE_GROUP		= 0x04
+};
 
-/* shuffle values */
-#define AVRCP_SHUFFLE_OFF		0x01
-#define AVRCP_SHUFFLE_ALL		0x02
-#define AVRCP_SHUFFLE_GROUP		0x03
+enum shuffle_value {
+	AVRCP_SHUFFLE_OFF		= 0x01,
+	AVRCP_SHUFFLE_ALL		= 0x02,
+	AVRCP_SHUFFLE_GROUP		= 0x03
+};
 
-/* scan values */
-#define AVRCP_SCAN_OFF			0x01
-#define AVRCP_SCAN_ALL			0x02
-#define AVRCP_SCAN_GROUP		0x03
+enum scan_value {
+	AVRCP_SCAN_OFF			= 0x01,
+	AVRCP_SCAN_ALL			= 0x02,
+	AVRCP_SCAN_GROUP		= 0x03
+};
 
-/* media attributes */
-#define AVRCP_MEDIA_ATTRIBUTE_ILLEGAL	0x00
-#define AVRCP_MEDIA_ATTRIBUTE_TITLE	0x01
-#define AVRCP_MEDIA_ATTRIBUTE_ARTIST	0x02
-#define AVRCP_MEDIA_ATTRIBUTE_ALBUM	0x03
-#define AVRCP_MEDIA_ATTRIBUTE_TRACK	0x04
-#define AVRCP_MEDIA_ATTRIBUTE_N_TRACKS	0x05
-#define AVRCP_MEDIA_ATTRIBUTE_GENRE	0x06
-#define AVRCP_MEDIA_ATTRIBUTE_DURATION	0x07
-#define AVRCP_MEDIA_ATTRIBUTE_LAST	AVRCP_MEDIA_ATTRIBUTE_DURATION
+enum media_attribute {
+	AVRCP_MEDIA_ATTRIBUTE_ILLEGAL	= 0x00,
+	AVRCP_MEDIA_ATTRIBUTE_TITLE	= 0x01,
+	AVRCP_MEDIA_ATTRIBUTE_ARTIST	= 0x02,
+	AVRCP_MEDIA_ATTRIBUTE_ALBUM	= 0x03,
+	AVRCP_MEDIA_ATTRIBUTE_TRACK	= 0x04,
+	AVRCP_MEDIA_ATTRIBUTE_N_TRACKS	= 0x05,
+	AVRCP_MEDIA_ATTRIBUTE_GENRE	= 0x06,
+	AVRCP_MEDIA_ATTRIBUTE_DURATION	= 0x07,
+	AVRCP_MEDIA_ATTRIBUTE_LAST	= AVRCP_MEDIA_ATTRIBUTE_DURATION
+};
 
-/* play status */
-#define AVRCP_PLAY_STATUS_STOPPED	0x00
-#define AVRCP_PLAY_STATUS_PLAYING	0x01
-#define AVRCP_PLAY_STATUS_PAUSED	0x02
-#define AVRCP_PLAY_STATUS_FWD_SEEK	0x03
-#define AVRCP_PLAY_STATUS_REV_SEEK	0x04
-#define AVRCP_PLAY_STATUS_ERROR		0xFF
+enum play_status {
+	AVRCP_PLAY_STATUS_STOPPED	= 0x00,
+	AVRCP_PLAY_STATUS_PLAYING	= 0x01,
+	AVRCP_PLAY_STATUS_PAUSED	= 0x02,
+	AVRCP_PLAY_STATUS_FWD_SEEK	= 0x03,
+	AVRCP_PLAY_STATUS_REV_SEEK	= 0x04,
+	AVRCP_PLAY_STATUS_ERROR		= 0xFF
+};
 
-/* Notification events */
-#define AVRCP_EVENT_STATUS_CHANGED	0x01
-#define AVRCP_EVENT_TRACK_CHANGED	0x02
-#define AVRCP_EVENT_TRACK_REACHED_END	0x03
-#define AVRCP_EVENT_TRACK_REACHED_START	0x04
-#define AVRCP_EVENT_VOLUME_CHANGED	0x0d
-#define AVRCP_EVENT_LAST		AVRCP_EVENT_VOLUME_CHANGED
+enum notification_event {
+	AVRCP_EVENT_PLAYBACK_STATUS_CHANGED		= 0x01,
+	AVRCP_EVENT_TRACK_CHANGED			= 0x02,
+	AVRCP_EVENT_TRACK_REACHED_END			= 0x03,
+	AVRCP_EVENT_TRACK_REACHED_START			= 0x04,
+	AVRCP_EVENT_PLAYBACK_POS_CHANGED		= 0x05,
+	AVRCP_EVENT_BATT_STATUS_CHANGED			= 0x06,
+	AVRCP_EVENT_SYSTEM_STATUS_CHANGED		= 0x07,
+	AVRCP_EVENT_PLAYER_APPLICATION_SETTING_CHANGED	= 0x08,
+	AVRCP_EVENT_NOW_PLAYING_CONTENT_CHANGED		= 0x09,
+	AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED		= 0x0A,
+	AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED		= 0x0B,
+	AVRCP_EVENT_VOLUME_CHANGED			= 0x0D,
+	AVRCP_EVENT_LAST				= AVRCP_EVENT_VOLUME_CHANGED
+};
 
 struct avrcp_player_cb {
 	int (*get_setting) (uint8_t attr, void *user_data);
diff --git a/audio/media.c b/audio/media.c
index 1956653..4e23273 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -1414,7 +1414,7 @@ static gboolean set_status(struct media_player *mp, DBusMessageIter *iter)
 
 	mp->status = val;
 
-	avrcp_player_event(mp->player, AVRCP_EVENT_STATUS_CHANGED, &val);
+	avrcp_player_event(mp->player, AVRCP_EVENT_PLAYBACK_STATUS_CHANGED, &val);
 
 	return TRUE;
 }
-- 
on behalf of ST-Ericsson


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

* [PATCH v2 02/14] doc: Fix typo
  2012-06-27 13:27 [PATCH v2 01/14] AVRCP: Update constants Michal Labedzki
@ 2012-06-27 13:27 ` Michal Labedzki
  2012-06-27 13:27 ` [PATCH v2 03/14] media: Rename set_property to set_player_property Michal Labedzki
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michal Labedzki @ 2012-06-27 13:27 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, lucas.demarchi, johan.hedberg, Michal Labedzki

This patch fix simple typo in documentation of API.
---
 doc/adapter-api.txt   |    2 +-
 doc/audio-api.txt     |    2 +-
 doc/device-api.txt    |    2 +-
 doc/media-api.txt     |    2 +-
 doc/proximity-api.txt |    2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
index dccb6bf..916e941 100644
--- a/doc/adapter-api.txt
+++ b/doc/adapter-api.txt
@@ -24,7 +24,7 @@ Methods		dict GetProperties()
 		void SetProperty(string name, variant value)
 
 			Changes the value of the specified property. Only
-			properties that are listed a read-write are changeable.
+			properties that are listed as read-write are changeable.
 			On success this will emit a PropertyChanged signal.
 
 			Possible Errors: org.bluez.Error.InvalidArguments
diff --git a/doc/audio-api.txt b/doc/audio-api.txt
index 02291fd..9b1737d 100644
--- a/doc/audio-api.txt
+++ b/doc/audio-api.txt
@@ -122,7 +122,7 @@ Methods		void Connect()
 		void SetProperty(string name, variant value)
 
 			Changes the value of the specified property. Only
-			properties that are listed a read-write are changeable.
+			properties that are listed as read-write are changeable.
 			On success this will emit a PropertyChanged signal.
 
 			Possible Errors: org.bluez.Error.DoesNotExist
diff --git a/doc/device-api.txt b/doc/device-api.txt
index 4a170e4..0f34210 100644
--- a/doc/device-api.txt
+++ b/doc/device-api.txt
@@ -25,7 +25,7 @@ Methods		dict GetProperties()
 		void SetProperty(string name, variant value)
 
 			Changes the value of the specified property. Only
-			properties that are listed a read-write are changeable.
+			properties that are listed as read-write are changeable.
 			On success this will emit a PropertyChanged signal.
 
 			Possible Errors: org.bluez.Error.DoesNotExist
diff --git a/doc/media-api.txt b/doc/media-api.txt
index 4446439..e5eeaa0 100644
--- a/doc/media-api.txt
+++ b/doc/media-api.txt
@@ -289,7 +289,7 @@ Methods		dict GetProperties()
 		void SetProperty(string name, variant value)
 
 			Changes the value of the specified property. Only
-			properties that are listed a read-write can be changed.
+			properties that are listed as read-write can be changed.
 
 			On success this will emit a PropertyChanged signal.
 
diff --git a/doc/proximity-api.txt b/doc/proximity-api.txt
index 0c60d47..c8eae50 100644
--- a/doc/proximity-api.txt
+++ b/doc/proximity-api.txt
@@ -19,7 +19,7 @@ Methods		dict GetProperties()
 		void SetProperty(string name, variant value)
 
 			Changes the value of the specified property. Only
-			properties that are listed a read-write are changeable.
+			properties that are listed as read-write are changeable.
 			On success this will emit a PropertyChanged signal.
 
 			Possible Errors: org.bluez.Error.InvalidArguments
-- 
on behalf of ST-Ericsson


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

* [PATCH v2 03/14] media: Rename set_property to set_player_property
  2012-06-27 13:27 [PATCH v2 01/14] AVRCP: Update constants Michal Labedzki
  2012-06-27 13:27 ` [PATCH v2 02/14] doc: Fix typo Michal Labedzki
@ 2012-06-27 13:27 ` Michal Labedzki
  2012-06-27 13:27 ` [PATCH v2 04/14] AVRCP: Use name "addressed" instead of "active" Michal Labedzki
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michal Labedzki @ 2012-06-27 13:27 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, lucas.demarchi, johan.hedberg, Michal Labedzki

This is to avoid conflicts with DBus interface convention
used in BlueZ.
---
 audio/media.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/audio/media.c b/audio/media.c
index 4e23273..cc8ac37 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -1454,7 +1454,7 @@ static gboolean set_position(struct media_player *mp, DBusMessageIter *iter)
 	return TRUE;
 }
 
-static gboolean set_property(struct media_player *mp, const char *key,
+static gboolean set_player_property(struct media_player *mp, const char *key,
 							DBusMessageIter *entry)
 {
 	DBusMessageIter var;
@@ -1515,7 +1515,7 @@ static gboolean property_changed(DBusConnection *connection, DBusMessage *msg,
 
 	dbus_message_iter_next(&iter);
 
-	set_property(mp, property, &iter);
+	set_player_property(mp, property, &iter);
 
 	return TRUE;
 }
@@ -1747,7 +1747,7 @@ static gboolean parse_player_properties(struct media_player *mp,
 		dbus_message_iter_get_basic(&entry, &key);
 		dbus_message_iter_next(&entry);
 
-		if (set_property(mp, key, &entry) == FALSE)
+		if (set_player_property(mp, key, &entry) == FALSE)
 			return FALSE;
 
 		dbus_message_iter_next(&dict);
-- 
on behalf of ST-Ericsson


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

* [PATCH v2 04/14] AVRCP: Use name "addressed" instead of "active"
  2012-06-27 13:27 [PATCH v2 01/14] AVRCP: Update constants Michal Labedzki
  2012-06-27 13:27 ` [PATCH v2 02/14] doc: Fix typo Michal Labedzki
  2012-06-27 13:27 ` [PATCH v2 03/14] media: Rename set_property to set_player_property Michal Labedzki
@ 2012-06-27 13:27 ` Michal Labedzki
  2012-06-27 13:27 ` [PATCH v2 05/14] AVRCP: Convert spaces to tabs Michal Labedzki
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michal Labedzki @ 2012-06-27 13:27 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, lucas.demarchi, johan.hedberg, Michal Labedzki

AVRCP 1.4 named currently controlled player as "addressed", so use
this name instead of "active". In future there where be more "browsing"
player that will be active, but not addressed.
---
 audio/avrcp.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/audio/avrcp.c b/audio/avrcp.c
index da102b2..adcf30d 100644
--- a/audio/avrcp.c
+++ b/audio/avrcp.c
@@ -163,7 +163,7 @@ struct avrcp_server {
 	uint32_t tg_record_id;
 	uint32_t ct_record_id;
 	GSList *players;
-	struct avrcp_player *active_player;
+	struct avrcp_player *addressed_player;
 };
 
 struct pending_pdu {
@@ -1217,7 +1217,7 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
 	if (!server)
 		return;
 
-	player = server->active_player;
+	player = server->addressed_player;
 	if (!player)
 		return;
 
@@ -1410,7 +1410,7 @@ struct avrcp_player *avrcp_register_player(const bdaddr_t *src,
 	player->destroy = destroy;
 
 	if (!server->players)
-		server->active_player = player;
+		server->addressed_player = player;
 
 	if (!avctp_id)
 		avctp_id = avctp_add_state_cb(state_changed, NULL);
@@ -1426,8 +1426,8 @@ void avrcp_unregister_player(struct avrcp_player *player)
 
 	server->players = g_slist_remove(server->players, player);
 
-	if (server->active_player == player)
-		server->active_player = g_slist_nth_data(server->players, 0);
+	if (server->addressed_player == player)
+		server->addressed_player = g_slist_nth_data(server->players, 0);
 
 	player_destroy(player);
 }
@@ -1462,7 +1462,7 @@ int avrcp_set_volume(struct audio_device *dev, uint8_t volume)
 	if (server == NULL)
 		return -EINVAL;
 
-	player = server->active_player;
+	player = server->addressed_player;
 	if (player == NULL)
 		return -ENOTSUP;
 
-- 
on behalf of ST-Ericsson


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

* [PATCH v2 05/14] AVRCP: Convert spaces to tabs
  2012-06-27 13:27 [PATCH v2 01/14] AVRCP: Update constants Michal Labedzki
                   ` (2 preceding siblings ...)
  2012-06-27 13:27 ` [PATCH v2 04/14] AVRCP: Use name "addressed" instead of "active" Michal Labedzki
@ 2012-06-27 13:27 ` Michal Labedzki
  2012-06-27 13:27 ` [PATCH v2 06/14] AVRCP: Keep AVRCP version of connected device in session Michal Labedzki
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michal Labedzki @ 2012-06-27 13:27 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, lucas.demarchi, johan.hedberg, Michal Labedzki

Fix coding style issue.
---
 audio/avrcp.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/audio/avrcp.c b/audio/avrcp.c
index adcf30d..64f6086 100644
--- a/audio/avrcp.c
+++ b/audio/avrcp.c
@@ -1134,17 +1134,17 @@ err_metadata:
 
 size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands)
 {
-    struct avrcp_header *pdu = (void *) operands;
-    uint32_t company_id = get_company_id(pdu->company_id);
+	struct avrcp_header *pdu = (void *) operands;
+	uint32_t company_id = get_company_id(pdu->company_id);
 
-    *code = AVC_CTYPE_REJECTED;
-    pdu->params_len = htons(1);
-    pdu->params[0] = STATUS_INTERNAL_ERROR;
+	*code = AVC_CTYPE_REJECTED;
+	pdu->params_len = htons(1);
+	pdu->params[0] = STATUS_INTERNAL_ERROR;
 
-    DBG("rejecting AVRCP PDU 0x%02X, company 0x%06X len 0x%04X",
-            pdu->pdu_id, company_id, pdu->params_len);
+	DBG("rejecting AVRCP PDU 0x%02X, company 0x%06X len 0x%04X",
+		pdu->pdu_id, company_id, pdu->params_len);
 
-    return AVRCP_HEADER_LENGTH + 1;
+	return AVRCP_HEADER_LENGTH + 1;
 }
 
 static struct avrcp_server *find_server(GSList *list, const bdaddr_t *src)
-- 
on behalf of ST-Ericsson


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

* [PATCH v2 06/14] AVRCP: Keep AVRCP version of connected device in session
  2012-06-27 13:27 [PATCH v2 01/14] AVRCP: Update constants Michal Labedzki
                   ` (3 preceding siblings ...)
  2012-06-27 13:27 ` [PATCH v2 05/14] AVRCP: Convert spaces to tabs Michal Labedzki
@ 2012-06-27 13:27 ` Michal Labedzki
  2012-06-27 13:27 ` [PATCH v2 07/14] AVRCP: Move profile specific fields from players Michal Labedzki
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michal Labedzki @ 2012-06-27 13:27 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, lucas.demarchi, johan.hedberg, Michal Labedzki

This can be used to improve compatibility between
AVRCP 1.3 vs AVRCP 1.4 devices and implementation in stack.
---
 audio/avrcp.c |   42 ++++++++++++++++++++++++++++++++----------
 1 file changed, 32 insertions(+), 10 deletions(-)

diff --git a/audio/avrcp.c b/audio/avrcp.c
index 64f6086..4e3b641 100644
--- a/audio/avrcp.c
+++ b/audio/avrcp.c
@@ -158,12 +158,18 @@ struct avrcp_header {
 #define AVRCP_MTU	(AVC_MTU - AVC_HEADER_LENGTH)
 #define AVRCP_PDU_MTU	(AVRCP_MTU - AVRCP_HEADER_LENGTH)
 
+struct avrcp_session {
+	uint16_t version_tg;
+	uint16_t version_ct;
+};
+
 struct avrcp_server {
 	bdaddr_t src;
 	uint32_t tg_record_id;
 	uint32_t ct_record_id;
 	GSList *players;
 	struct avrcp_player *addressed_player;
+	struct avrcp_session session;
 };
 
 struct pending_pdu {
@@ -1209,7 +1215,7 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
 {
 	struct avrcp_server *server;
 	struct avrcp_player *player;
-	const sdp_record_t *rec;
+	const sdp_record_t *rec_tg, *rec_ct;
 	sdp_list_t *list;
 	sdp_profile_desc_t *desc;
 
@@ -1244,19 +1250,32 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
 							player);
 		break;
 	case AVCTP_STATE_CONNECTED:
-		rec = btd_device_get_record(dev->btd_dev, AVRCP_TARGET_UUID);
-		if (rec == NULL)
-			return;
+		rec_tg = btd_device_get_record(dev->btd_dev, AVRCP_TARGET_UUID);
+		rec_ct = btd_device_get_record(dev->btd_dev, AVRCP_REMOTE_UUID);
+
+		if (rec_tg && sdp_get_profile_descs(rec_tg, &list) >= 0) {
+			desc = list->data;
+			if (desc)
+				server->session.version_tg = desc->version;
+			else
+				server->session.version_tg = AVRCP_VERSION_UNKNOWN;
+			sdp_list_free(list, free);
+		}
 
-		if (sdp_get_profile_descs(rec, &list) < 0)
-			return;
+		if (rec_ct && sdp_get_profile_descs(rec_ct, &list) >= 0) {
+			desc = list->data;
+			if (desc)
+				server->session.version_ct = desc->version;
+			else
+				server->session.version_ct = AVRCP_VERSION_UNKNOWN;
+			sdp_list_free(list, free);
+		}
 
-		desc = list->data;
+		DBG("Remote Controller TG version: 0x%03x", server->session.version_tg);
+		DBG("Remote Controller CT version: 0x%03x", server->session.version_ct);
 
-		if (desc && desc->version >= AVRCP_VERSION_1_4)
+		if (server->session.version_tg >= AVRCP_VERSION_1_4)
 			register_volume_notification(player);
-
-		sdp_list_free(list, free);
 	default:
 		return;
 	}
@@ -1344,6 +1363,9 @@ int avrcp_register(DBusConnection *conn, const bdaddr_t *src, GKeyFile *config)
 
 	bacpy(&server->src, src);
 
+	server->session.version_tg = AVRCP_VERSION_UNKNOWN;
+	server->session.version_ct = AVRCP_VERSION_UNKNOWN;
+
 	servers = g_slist_append(servers, server);
 
 	return 0;
-- 
on behalf of ST-Ericsson


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

* [PATCH v2 07/14] AVRCP: Move profile specific fields from players
  2012-06-27 13:27 [PATCH v2 01/14] AVRCP: Update constants Michal Labedzki
                   ` (4 preceding siblings ...)
  2012-06-27 13:27 ` [PATCH v2 06/14] AVRCP: Keep AVRCP version of connected device in session Michal Labedzki
@ 2012-06-27 13:27 ` Michal Labedzki
  2012-06-27 13:27 ` [PATCH v2 08/14] AVRCP: Register AVRCP before MEDIA interface Michal Labedzki
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michal Labedzki @ 2012-06-27 13:27 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, lucas.demarchi, johan.hedberg, Michal Labedzki

Transactions, events and fragmentation are not specified to
every player. Those fields are specific to profile, so
move them to new AVRCP session structure.
---
 audio/avrcp.c |   83 ++++++++++++++++++++++++++++++++-------------------------
 audio/avrcp.h |    5 +++-
 audio/media.c |   10 +++----
 3 files changed, 56 insertions(+), 42 deletions(-)

diff --git a/audio/avrcp.c b/audio/avrcp.c
index 4e3b641..430f216 100644
--- a/audio/avrcp.c
+++ b/audio/avrcp.c
@@ -159,8 +159,12 @@ struct avrcp_header {
 #define AVRCP_PDU_MTU	(AVRCP_MTU - AVRCP_HEADER_LENGTH)
 
 struct avrcp_session {
+	struct avctp *avctp_session;
 	uint16_t version_tg;
 	uint16_t version_ct;
+	uint16_t registered_events;
+	uint8_t transaction[16];
+	struct pending_pdu *pending_pdu;
 };
 
 struct avrcp_server {
@@ -180,14 +184,8 @@ struct pending_pdu {
 
 struct avrcp_player {
 	struct avrcp_server *server;
-	struct avctp *session;
 	struct audio_device *dev;
-
 	unsigned int handler;
-	uint16_t registered_events;
-	uint8_t transaction_events[AVRCP_EVENT_LAST + 1];
-	struct pending_pdu *pending_pdu;
-
 	struct avrcp_player_cb *cb;
 	void *user_data;
 	GDestroyNotify destroy;
@@ -396,17 +394,17 @@ static void set_company_id(uint8_t cid[3], const uint32_t cid_in)
 	cid[2] = cid_in;
 }
 
-int avrcp_player_event(struct avrcp_player *player, uint8_t id, void *data)
+int avrcp_event(struct avrcp_session *session, uint8_t id, void *data)
 {
 	uint8_t buf[AVRCP_HEADER_LENGTH + 9];
 	struct avrcp_header *pdu = (void *) buf;
 	uint16_t size;
 	int err;
 
-	if (player->session == NULL)
+	if (session->avctp_session == NULL)
 		return -ENOTCONN;
 
-	if (!(player->registered_events & (1 << id)))
+	if (!(session->registered_events & (1 << id)))
 		return 0;
 
 	memset(buf, 0, sizeof(buf));
@@ -439,15 +437,14 @@ int avrcp_player_event(struct avrcp_player *player, uint8_t id, void *data)
 	}
 
 	pdu->params_len = htons(size);
-
-	err = avctp_send_vendordep(player->session, player->transaction_events[id],
+	err = avctp_send_vendordep(session->avctp_session, session->transaction[id],
 					AVC_CTYPE_CHANGED, AVC_SUBUNIT_PANEL,
 					buf, size + AVRCP_HEADER_LENGTH);
 	if (err < 0)
 		return err;
 
 	/* Unregister event as per AVRCP 1.3 spec, section 5.4.2 */
-	player->registered_events ^= 1 << id;
+	session->registered_events ^= 1 << id;
 
 	return 0;
 }
@@ -546,14 +543,14 @@ static struct pending_pdu *pending_pdu_new(uint8_t pdu_id, GList *attr_ids,
 	return pending;
 }
 
-static gboolean player_abort_pending_pdu(struct avrcp_player *player)
+static gboolean pending_pdu_abort(struct avrcp_session *session)
 {
-	if (player->pending_pdu == NULL)
+	if (session->pending_pdu == NULL)
 		return FALSE;
 
-	g_list_free(player->pending_pdu->attr_ids);
-	g_free(player->pending_pdu);
-	player->pending_pdu = NULL;
+	g_list_free(session->pending_pdu->attr_ids);
+	g_free(session->pending_pdu);
+	session->pending_pdu = NULL;
 
 	return TRUE;
 }
@@ -684,6 +681,7 @@ static uint8_t avrcp_handle_get_element_attributes(struct avrcp_player *player,
 						struct avrcp_header *pdu,
 						uint8_t transaction)
 {
+	struct avrcp_session *session = &player->server->session;
 	uint16_t len = ntohs(pdu->params_len);
 	uint64_t *identifier = (uint64_t *) &pdu->params[0];
 	uint16_t pos;
@@ -729,14 +727,14 @@ static uint8_t avrcp_handle_get_element_attributes(struct avrcp_player *player,
 	if (!len)
 		goto err;
 
-	player_abort_pending_pdu(player);
+	pending_pdu_abort(session);
 	pos = 1;
 	offset = 0;
 	attr_ids = player_fill_media_attribute(player, attr_ids, pdu->params,
 								&pos, &offset);
 
 	if (attr_ids != NULL) {
-		player->pending_pdu = pending_pdu_new(pdu->pdu_id, attr_ids,
+		session->pending_pdu = pending_pdu_new(pdu->pdu_id, attr_ids,
 								offset);
 		pdu->packet_type = AVRCP_PACKET_TYPE_START;
 	}
@@ -929,6 +927,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp_player *player,
 						struct avrcp_header *pdu,
 						uint8_t transaction)
 {
+	struct avrcp_session *session = &player->server->session;
 	uint16_t len = ntohs(pdu->params_len);
 	uint64_t uid;
 
@@ -962,8 +961,8 @@ static uint8_t avrcp_handle_register_notification(struct avrcp_player *player,
 	}
 
 	/* Register event and save the transaction used */
-	player->registered_events |= (1 << pdu->params[0]);
-	player->transaction_events[pdu->params[0]] = transaction;
+	session->registered_events |= (1 << pdu->params[0]);
+	session->transaction[pdu->params[0]] = transaction;
 
 	pdu->params_len = htons(len);
 
@@ -979,13 +978,14 @@ static uint8_t avrcp_handle_request_continuing(struct avrcp_player *player,
 						struct avrcp_header *pdu,
 						uint8_t transaction)
 {
+	struct avrcp_session *session = &player->server->session;
 	uint16_t len = ntohs(pdu->params_len);
 	struct pending_pdu *pending;
 
-	if (len != 1 || player->pending_pdu == NULL)
+	if (len != 1 || session->pending_pdu == NULL)
 		goto err;
 
-	pending = player->pending_pdu;
+	pending = session->pending_pdu;
 
 	if (pending->pdu_id != pdu->params[0])
 		goto err;
@@ -999,8 +999,8 @@ static uint8_t avrcp_handle_request_continuing(struct avrcp_player *player,
 	pdu->pdu_id = pending->pdu_id;
 
 	if (pending->attr_ids == NULL) {
-		g_free(player->pending_pdu);
-		player->pending_pdu = NULL;
+		g_free(session->pending_pdu);
+		session->pending_pdu = NULL;
 		pdu->packet_type = AVRCP_PACKET_TYPE_END;
 	} else {
 		pdu->packet_type = AVRCP_PACKET_TYPE_CONTINUING;
@@ -1019,18 +1019,19 @@ static uint8_t avrcp_handle_abort_continuing(struct avrcp_player *player,
 						struct avrcp_header *pdu,
 						uint8_t transaction)
 {
+	struct avrcp_session *session = &player->server->session;
 	uint16_t len = ntohs(pdu->params_len);
 	struct pending_pdu *pending;
 
-	if (len != 1 || player->pending_pdu == NULL)
+	if (len != 1 || session->pending_pdu == NULL)
 		goto err;
 
-	pending = player->pending_pdu;
+	pending = session->pending_pdu;
 
 	if (pending->pdu_id != pdu->params[0])
 		goto err;
 
-	player_abort_pending_pdu(player);
+	pending_pdu_abort(session);
 	pdu->params_len = 0;
 
 	return AVC_CTYPE_ACCEPTED;
@@ -1127,7 +1128,7 @@ static size_t handle_vendordep_pdu(struct avctp *session, uint8_t transaction,
 				pdu->pdu_id != AVRCP_GET_ELEMENT_ATTRIBUTES &&
 				pdu->pdu_id != AVRCP_REQUEST_CONTINUING &&
 				pdu->pdu_id != AVRCP_ABORT_CONTINUING)
-		player_abort_pending_pdu(player);
+		pending_pdu_abort(&player->server->session);
 
 	return AVRCP_HEADER_LENGTH + ntohs(pdu->params_len);
 
@@ -1205,7 +1206,7 @@ static void register_volume_notification(struct avrcp_player *player)
 
 	length = AVRCP_HEADER_LENGTH + ntohs(pdu->params_len);
 
-	avctp_send_vendordep_req(player->session, AVC_CTYPE_NOTIFY,
+	avctp_send_vendordep_req(player->server->session.avctp_session, AVC_CTYPE_NOTIFY,
 					AVC_SUBUNIT_PANEL, buf, length,
 					avrcp_handle_volume_changed, player);
 }
@@ -1214,6 +1215,7 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
 				avctp_state_t new_state, void *user_data)
 {
 	struct avrcp_server *server;
+	struct avrcp_session *session;
 	struct avrcp_player *player;
 	const sdp_record_t *rec_tg, *rec_ct;
 	sdp_list_t *list;
@@ -1223,15 +1225,18 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
 	if (!server)
 		return;
 
+	session = &server->session;
+
 	player = server->addressed_player;
 	if (!player)
 		return;
 
 	switch (new_state) {
 	case AVCTP_STATE_DISCONNECTED:
-		player->session = NULL;
+		session->avctp_session = NULL;
+
 		player->dev = NULL;
-		player->registered_events = 0;
+		session->registered_events = 0;
 
 		if (player->handler) {
 			avctp_unregister_pdu_handler(player->handler);
@@ -1240,7 +1245,8 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
 
 		break;
 	case AVCTP_STATE_CONNECTING:
-		player->session = avctp_connect(&dev->src, &dev->dst);
+		session->avctp_session = avctp_connect(&dev->src, &dev->dst);
+
 		player->dev = dev;
 
 		if (!player->handler)
@@ -1303,6 +1309,11 @@ void avrcp_disconnect(struct audio_device *dev)
 	avctp_disconnect(session);
 }
 
+struct avrcp_session *avrcp_get_session(struct avrcp_player *player)
+{
+	return &player->server->session;
+}
+
 int avrcp_register(DBusConnection *conn, const bdaddr_t *src, GKeyFile *config)
 {
 	sdp_record_t *record;
@@ -1378,7 +1389,7 @@ static void player_destroy(gpointer data)
 	if (player->destroy)
 		player->destroy(player->user_data);
 
-	player_abort_pending_pdu(player);
+	pending_pdu_abort(&player->server->session);
 
 	if (player->handler)
 		avctp_unregister_pdu_handler(player->handler);
@@ -1488,7 +1499,7 @@ int avrcp_set_volume(struct audio_device *dev, uint8_t volume)
 	if (player == NULL)
 		return -ENOTSUP;
 
-	if (player->session == NULL)
+	if (server->session.avctp_session == NULL)
 		return -ENOTCONN;
 
 	memset(buf, 0, sizeof(buf));
@@ -1501,7 +1512,7 @@ int avrcp_set_volume(struct audio_device *dev, uint8_t volume)
 
 	DBG("volume=%u", volume);
 
-	return avctp_send_vendordep_req(player->session, AVC_CTYPE_CONTROL,
+	return avctp_send_vendordep_req(server->session.avctp_session, AVC_CTYPE_CONTROL,
 					AVC_SUBUNIT_PANEL, buf, sizeof(buf),
 					avrcp_handle_set_volume, player);
 }
diff --git a/audio/avrcp.h b/audio/avrcp.h
index dcc67f6..1b4a887 100644
--- a/audio/avrcp.h
+++ b/audio/avrcp.h
@@ -103,11 +103,14 @@ struct avrcp_player_cb {
 							void *user_data);
 };
 
+struct avrcp_player *player;
+
 int avrcp_register(DBusConnection *conn, const bdaddr_t *src, GKeyFile *config);
 void avrcp_unregister(const bdaddr_t *src);
 
 gboolean avrcp_connect(struct audio_device *dev);
 void avrcp_disconnect(struct audio_device *dev);
+struct avrcp_session *avrcp_get_session(struct avrcp_player *player);
 int avrcp_set_volume(struct audio_device *dev, uint8_t volume);
 
 struct avrcp_player *avrcp_register_player(const bdaddr_t *src,
@@ -116,7 +119,7 @@ struct avrcp_player *avrcp_register_player(const bdaddr_t *src,
 						GDestroyNotify destroy);
 void avrcp_unregister_player(struct avrcp_player *player);
 
-int avrcp_player_event(struct avrcp_player *player, uint8_t id, void *data);
+int avrcp_event(struct avrcp_session *session, uint8_t id, void *data);
 
 
 size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands);
diff --git a/audio/media.c b/audio/media.c
index cc8ac37..5c958c6 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -1414,7 +1414,7 @@ static gboolean set_status(struct media_player *mp, DBusMessageIter *iter)
 
 	mp->status = val;
 
-	avrcp_player_event(mp->player, AVRCP_EVENT_PLAYBACK_STATUS_CHANGED, &val);
+	avrcp_event(avrcp_get_session(mp->player), AVRCP_EVENT_PLAYBACK_STATUS_CHANGED, &val);
 
 	return TRUE;
 }
@@ -1434,7 +1434,7 @@ static gboolean set_position(struct media_player *mp, DBusMessageIter *iter)
 	g_timer_start(mp->timer);
 
 	if (!mp->position) {
-		avrcp_player_event(mp->player,
+		avrcp_event(avrcp_get_session(mp->player),
 					AVRCP_EVENT_TRACK_REACHED_START, NULL);
 		return TRUE;
 	}
@@ -1448,7 +1448,7 @@ static gboolean set_position(struct media_player *mp, DBusMessageIter *iter)
 	 */
 	if (mp->position == UINT32_MAX ||
 			(duration && mp->position >= duration->value.num))
-		avrcp_player_event(mp->player, AVRCP_EVENT_TRACK_REACHED_END,
+		avrcp_event(avrcp_get_session(mp->player), AVRCP_EVENT_TRACK_REACHED_END,
 									NULL);
 
 	return TRUE;
@@ -1641,8 +1641,8 @@ static gboolean parse_player_metadata(struct media_player *mp,
 	g_timer_start(mp->timer);
 	uid = get_uid(mp);
 
-	avrcp_player_event(mp->player, AVRCP_EVENT_TRACK_CHANGED, &uid);
-	avrcp_player_event(mp->player, AVRCP_EVENT_TRACK_REACHED_START,
+	avrcp_event(avrcp_get_session(mp->player), AVRCP_EVENT_TRACK_CHANGED, &uid);
+	avrcp_event(avrcp_get_session(mp->player), AVRCP_EVENT_TRACK_REACHED_START,
 								NULL);
 
 	return TRUE;
-- 
on behalf of ST-Ericsson


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

* [PATCH v2 08/14] AVRCP: Register AVRCP before MEDIA interface
  2012-06-27 13:27 [PATCH v2 01/14] AVRCP: Update constants Michal Labedzki
                   ` (5 preceding siblings ...)
  2012-06-27 13:27 ` [PATCH v2 07/14] AVRCP: Move profile specific fields from players Michal Labedzki
@ 2012-06-27 13:27 ` Michal Labedzki
  2012-06-27 13:27 ` [PATCH v2 09/14] AVRCP: Implement notification AVAILABLE_PLAYERS_CHANGED Michal Labedzki
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michal Labedzki @ 2012-06-27 13:27 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, lucas.demarchi, johan.hedberg, Michal Labedzki

Register AVRCP before MEDIA interface to avoid searching for or
accessing non-existent AVRCP server.
---
 audio/manager.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/audio/manager.c b/audio/manager.c
index d442d1d..076346a 100644
--- a/audio/manager.c
+++ b/audio/manager.c
@@ -1238,6 +1238,9 @@ proceed:
 	if (enabled.socket)
 		unix_init();
 
+	if (enabled.control)
+		btd_register_adapter_driver(&avrcp_server_driver);
+
 	if (enabled.media)
 		btd_register_adapter_driver(&media_server_driver);
 
@@ -1250,9 +1253,6 @@ proceed:
 	if (enabled.source || enabled.sink)
 		btd_register_adapter_driver(&a2dp_server_driver);
 
-	if (enabled.control)
-		btd_register_adapter_driver(&avrcp_server_driver);
-
 	btd_register_device_driver(&audio_driver);
 
 	*enable_sco = (enabled.gateway || enabled.headset);
-- 
on behalf of ST-Ericsson


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

* [PATCH v2 09/14] AVRCP: Implement notification AVAILABLE_PLAYERS_CHANGED
  2012-06-27 13:27 [PATCH v2 01/14] AVRCP: Update constants Michal Labedzki
                   ` (6 preceding siblings ...)
  2012-06-27 13:27 ` [PATCH v2 08/14] AVRCP: Register AVRCP before MEDIA interface Michal Labedzki
@ 2012-06-27 13:27 ` Michal Labedzki
  2012-06-27 13:27 ` [PATCH v2 10/14] media: Add support for changing addressed player Michal Labedzki
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michal Labedzki @ 2012-06-27 13:27 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, lucas.demarchi, johan.hedberg, Michal Labedzki

Notify remote controller about change in available players
when player is being registered or unregistered.
---
 audio/avrcp.c |    5 ++++-
 audio/media.c |    3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/audio/avrcp.c b/audio/avrcp.c
index 430f216..d011b2e 100644
--- a/audio/avrcp.c
+++ b/audio/avrcp.c
@@ -429,6 +429,7 @@ int avrcp_event(struct avrcp_session *session, uint8_t id, void *data)
 		break;
 	case AVRCP_EVENT_TRACK_REACHED_END:
 	case AVRCP_EVENT_TRACK_REACHED_START:
+	case AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED:
 		size = 1;
 		break;
 	default:
@@ -600,11 +601,12 @@ static uint8_t avrcp_handle_get_capabilities(struct avrcp_player *player,
 
 		return AVC_CTYPE_STABLE;
 	case CAP_EVENTS_SUPPORTED:
-		pdu->params[1] = 4;
+		pdu->params[1] = 5;
 		pdu->params[2] = AVRCP_EVENT_PLAYBACK_STATUS_CHANGED;
 		pdu->params[3] = AVRCP_EVENT_TRACK_CHANGED;
 		pdu->params[4] = AVRCP_EVENT_TRACK_REACHED_START;
 		pdu->params[5] = AVRCP_EVENT_TRACK_REACHED_END;
+		pdu->params[6] = AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED;
 
 		pdu->params_len = htons(2 + pdu->params[1]);
 		return AVC_CTYPE_STABLE;
@@ -953,6 +955,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp_player *player,
 		break;
 	case AVRCP_EVENT_TRACK_REACHED_END:
 	case AVRCP_EVENT_TRACK_REACHED_START:
+	case AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED:
 		len = 1;
 		break;
 	default:
diff --git a/audio/media.c b/audio/media.c
index 5c958c6..f3cca25 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -1795,6 +1795,8 @@ static DBusMessage *register_player(DBusConnection *conn, DBusMessage *msg,
 		return btd_error_invalid_args(msg);
 	}
 
+	avrcp_event(avrcp_get_session(mp->player), AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED, NULL);
+
 	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
 }
 
@@ -1816,6 +1818,7 @@ static DBusMessage *unregister_player(DBusConnection *conn, DBusMessage *msg,
 	if (player == NULL)
 		return btd_error_does_not_exist(msg);
 
+	avrcp_event(avrcp_get_session(player->player), AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED, NULL);
 	media_player_remove(player);
 
 	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
-- 
on behalf of ST-Ericsson


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

* [PATCH v2 10/14] media: Add support for changing addressed player
  2012-06-27 13:27 [PATCH v2 01/14] AVRCP: Update constants Michal Labedzki
                   ` (7 preceding siblings ...)
  2012-06-27 13:27 ` [PATCH v2 09/14] AVRCP: Implement notification AVAILABLE_PLAYERS_CHANGED Michal Labedzki
@ 2012-06-27 13:27 ` Michal Labedzki
  2012-06-27 13:27 ` [PATCH v2 11/14] AVRCP: Implement setting AddressedPlayer with notifications completion Michal Labedzki
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michal Labedzki @ 2012-06-27 13:27 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, lucas.demarchi, johan.hedberg, Michal Labedzki

There is possibility to register more than one player. This patch
allows to change currently selected player to one the list of
previously registered players. If there are no any registered players
add Dummy Player for compatibility with AVRCP 1.3 device or
AVRCP 1.4 without MultiplePlayer feature.
---
 audio/media.c |  109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 107 insertions(+), 2 deletions(-)

diff --git a/audio/media.c b/audio/media.c
index f3cca25..ce5822a 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -54,6 +54,8 @@
 #define MEDIA_ENDPOINT_INTERFACE "org.bluez.MediaEndpoint"
 #define MEDIA_PLAYER_INTERFACE "org.bluez.MediaPlayer"
 
+#define DUMMY_PLAYER "/dummy"
+
 #define REQUEST_TIMEOUT (3 * 1000)		/* 3 seconds */
 
 struct media_adapter {
@@ -62,6 +64,7 @@ struct media_adapter {
 	DBusConnection		*conn;		/* Adapter connection */
 	GSList			*endpoints;	/* Endpoints list */
 	GSList			*players;	/* Players list */
+	struct media_player	*addressed;	/* Addressed Player */
 };
 
 struct endpoint_request {
@@ -102,6 +105,7 @@ struct media_player {
 	uint8_t			status;
 	uint32_t		position;
 	uint8_t			volume;
+	uint16_t		id;
 	GTimer			*timer;
 };
 
@@ -961,6 +965,25 @@ static struct media_player *media_adapter_find_player(
 	return NULL;
 }
 
+static struct media_player *media_adapter_find_player_by_id(
+						struct media_adapter *adapter,
+						const char *sender,
+						uint16_t player_id) {
+	GSList *l;
+
+	for (l = adapter->players; l; l = l->next) {
+		struct media_player *mp = l->data;
+
+		if (sender && g_strcmp0(mp->sender, sender) != 0)
+			continue;
+
+		if (player_id == mp->id)
+			return mp;
+	}
+
+	return NULL;
+}
+
 static void release_player(struct media_player *mp)
 {
 	DBusMessage *msg;
@@ -1673,6 +1696,17 @@ static gboolean track_changed(DBusConnection *connection, DBusMessage *msg,
 	return TRUE;
 }
 
+/* Need at least one free id to avoid infinite loop */
+static uint16_t get_free_player_id(struct media_adapter *adapter,
+						const char *sender)
+{
+	static uint16_t last_id = 0;
+
+	while (media_adapter_find_player_by_id(adapter, sender, last_id++));
+
+	return last_id - 1;
+}
+
 static struct media_player *media_player_create(struct media_adapter *adapter,
 						const char *sender,
 						const char *path,
@@ -1680,6 +1714,12 @@ static struct media_player *media_player_create(struct media_adapter *adapter,
 {
 	struct media_player *mp;
 
+	if (g_slist_length(adapter->players) >= UINT16_MAX) {
+		if (err)
+			*err = -EINVAL;
+		return NULL;
+	}
+
 	mp = g_new0(struct media_player, 1);
 	mp->adapter = adapter;
 	mp->sender = g_strdup(sender);
@@ -1709,10 +1749,11 @@ static struct media_player *media_player_create(struct media_adapter *adapter,
 	}
 
 	mp->settings = g_hash_table_new(g_direct_hash, g_direct_equal);
+	mp->id = get_free_player_id(adapter, sender);
 
 	adapter->players = g_slist_append(adapter->players, mp);
 
-	info("Player registered: sender=%s path=%s", sender, path);
+	info("Player registered: sender=%s path=%s id=%d", sender, path, mp->id);
 
 	if (err)
 		*err = 0;
@@ -1720,6 +1761,57 @@ static struct media_player *media_player_create(struct media_adapter *adapter,
 	return mp;
 }
 
+static gboolean media_set_addressed_player(struct media_adapter *adapter,
+					    const char *sender, const char *path,
+					    gboolean local)
+{
+	struct media_player *mp;
+	struct metadata_value *value;
+
+	if (adapter->addressed &&
+		g_strcmp0(path, adapter->addressed->path) == 0)
+		return FALSE;
+
+	mp = media_adapter_find_player(adapter, NULL, path);
+	if (!mp && g_strcmp0(path, DUMMY_PLAYER) == 0) {
+		mp = media_player_create(adapter, NULL, DUMMY_PLAYER, NULL);
+		if (!mp)
+			return FALSE;
+
+		mp->position = 0;
+		mp->track = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL,
+							metadata_value_free);
+		value = g_new0(struct metadata_value, 1);
+		value->type = DBUS_TYPE_STRING;
+		value->value.str = g_strdup("no player");
+		g_hash_table_replace(mp->track, GUINT_TO_POINTER(AVRCP_MEDIA_ATTRIBUTE_TITLE), value);
+
+		g_hash_table_replace(mp->settings,
+					GUINT_TO_POINTER(AVRCP_ATTRIBUTE_EQUALIZER),
+					GUINT_TO_POINTER(AVRCP_EQUALIZER_OFF));
+		g_hash_table_replace(mp->settings,
+					GUINT_TO_POINTER(AVRCP_ATTRIBUTE_REPEAT_MODE),
+					GUINT_TO_POINTER(AVRCP_REPEAT_MODE_OFF));
+		g_hash_table_replace(mp->settings,
+					GUINT_TO_POINTER(AVRCP_ATTRIBUTE_SHUFFLE),
+					GUINT_TO_POINTER(AVRCP_SHUFFLE_OFF));
+		g_hash_table_replace(mp->settings,
+					GUINT_TO_POINTER(AVRCP_ATTRIBUTE_SCAN),
+					GUINT_TO_POINTER(AVRCP_SCAN_OFF));
+	}
+
+	if (!mp)
+		return FALSE;
+
+	if (adapter->addressed &&
+		g_strcmp0(adapter->addressed->path, DUMMY_PLAYER) == 0)
+		media_player_remove(adapter->addressed);
+
+	adapter->addressed = mp;
+
+	return TRUE;
+}
+
 static gboolean parse_player_properties(struct media_player *mp,
 							DBusMessageIter *iter)
 {
@@ -1762,7 +1854,8 @@ static DBusMessage *register_player(DBusConnection *conn, DBusMessage *msg,
 	struct media_adapter *adapter = data;
 	struct media_player *mp;
 	DBusMessageIter args;
-	const char *sender, *path;
+	const char *sender;
+	char *path;
 	int err;
 
 	sender = dbus_message_get_sender(msg);
@@ -1772,6 +1865,8 @@ static DBusMessage *register_player(DBusConnection *conn, DBusMessage *msg,
 	dbus_message_iter_get_basic(&args, &path);
 	dbus_message_iter_next(&args);
 
+	DBG("Registering player sender=%s path=%s", sender, path);
+
 	if (media_adapter_find_player(adapter, sender, path) != NULL)
 		return btd_error_already_exists(msg);
 
@@ -1797,6 +1892,9 @@ static DBusMessage *register_player(DBusConnection *conn, DBusMessage *msg,
 
 	avrcp_event(avrcp_get_session(mp->player), AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED, NULL);
 
+	if (g_strcmp0(adapter->addressed->path, DUMMY_PLAYER) == 0)
+		media_set_addressed_player(adapter, sender, path, TRUE);
+
 	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
 }
 
@@ -1814,6 +1912,8 @@ static DBusMessage *unregister_player(DBusConnection *conn, DBusMessage *msg,
 
 	sender = dbus_message_get_sender(msg);
 
+	DBG("Unregistering player sender=%s path=%s", sender, path);
+
 	player = media_adapter_find_player(adapter, sender, path);
 	if (player == NULL)
 		return btd_error_does_not_exist(msg);
@@ -1821,6 +1921,9 @@ static DBusMessage *unregister_player(DBusConnection *conn, DBusMessage *msg,
 	avrcp_event(avrcp_get_session(player->player), AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED, NULL);
 	media_player_remove(player);
 
+	if (g_strcmp0(adapter->addressed->path, path) == 0)
+		media_set_addressed_player(adapter, sender, DUMMY_PLAYER, TRUE);
+
 	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
 }
 
@@ -1862,6 +1965,8 @@ int media_register(DBusConnection *conn, const char *path, const bdaddr_t *src)
 	adapter->conn = dbus_connection_ref(conn);
 	bacpy(&adapter->src, src);
 	adapter->path = g_strdup(path);
+	adapter->addressed = NULL;
+	media_set_addressed_player(adapter, NULL, DUMMY_PLAYER, TRUE);
 
 	if (!g_dbus_register_interface(conn, path, MEDIA_INTERFACE,
 					media_methods, NULL, NULL,
-- 
on behalf of ST-Ericsson


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

* [PATCH v2 11/14] AVRCP: Implement setting AddressedPlayer with notifications completion
  2012-06-27 13:27 [PATCH v2 01/14] AVRCP: Update constants Michal Labedzki
                   ` (8 preceding siblings ...)
  2012-06-27 13:27 ` [PATCH v2 10/14] media: Add support for changing addressed player Michal Labedzki
@ 2012-06-27 13:27 ` Michal Labedzki
  2012-06-27 13:27 ` [PATCH v2 12/14] AVRCP: Use NoAvailablePlayers status code for AVRCP 1.4 devices Michal Labedzki
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michal Labedzki @ 2012-06-27 13:27 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, lucas.demarchi, johan.hedberg, Michal Labedzki

For AVRCP 1.4 complete notifications according to the specification
by rejecting all registered notifications with coresponding
transaction id.

For AVRCP 1.3 complete events by reusing already registered events.
This allows to change media player and notify remote controller
about metadata changed.
---
 audio/avrcp.c |   99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 audio/avrcp.h |    1 +
 audio/media.c |    5 +++
 3 files changed, 105 insertions(+)

diff --git a/audio/avrcp.c b/audio/avrcp.c
index d011b2e..baf9de5 100644
--- a/audio/avrcp.c
+++ b/audio/avrcp.c
@@ -58,6 +58,8 @@
 #include "sdpd.h"
 #include "dbus-common.h"
 
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
 #define AVRCP_REGISTER_NOTIFICATION_PARAM_LENGTH 5
 
 enum company_id {
@@ -191,6 +193,21 @@ struct avrcp_player {
 	GDestroyNotify destroy;
 };
 
+struct status_reply {
+	struct avrcp_header pdu;
+	uint8_t status;
+} __attribute__ ((packed));
+
+static const uint8_t events_to_complete[] = {
+	AVRCP_EVENT_PLAYBACK_STATUS_CHANGED,
+	AVRCP_EVENT_TRACK_CHANGED,
+	AVRCP_EVENT_TRACK_REACHED_END,
+	AVRCP_EVENT_TRACK_REACHED_START,
+	AVRCP_EVENT_PLAYBACK_POS_CHANGED,
+	AVRCP_EVENT_PLAYER_APPLICATION_SETTING_CHANGED,
+	AVRCP_EVENT_NOW_PLAYING_CONTENT_CHANGED
+};
+
 static GSList *servers = NULL;
 static unsigned int avctp_id = 0;
 
@@ -1519,3 +1536,85 @@ int avrcp_set_volume(struct audio_device *dev, uint8_t volume)
 					AVC_SUBUNIT_PANEL, buf, sizeof(buf),
 					avrcp_handle_set_volume, player);
 }
+
+static void avrcp_events_completion(struct avrcp_session *session)
+{
+	struct status_reply event;
+	unsigned int i;
+	uint8_t id;
+	int err;
+
+	memset(&event, 0, sizeof(event));
+	set_company_id(event.pdu.company_id, IEEEID_BTSIG);
+	event.pdu.pdu_id = AVRCP_REGISTER_NOTIFICATION;
+	event.pdu.params_len = htons(1);
+	event.status = STATUS_ADDRESSED_PLAYER_CHANGED;
+
+	for (i = 0; i < ARRAY_SIZE(events_to_complete); i++) {
+		id = 1 << events_to_complete[i];
+
+		if (!(session->registered_events & id))
+			continue;
+
+		err = avctp_send_vendordep(session->avctp_session,
+						session->transaction[events_to_complete[i]],
+						AVC_CTYPE_REJECTED, AVC_SUBUNIT_PANEL,
+						(uint8_t *) &event, sizeof(event));
+		if (err < 0)
+			DBG("Cannot complete event %u: %s (%d)",
+				events_to_complete[i], strerror(-err), err);
+
+		session->registered_events ^= id;
+	}
+}
+
+static void avrcp_events_reusing(struct avrcp_player *player)
+{
+	struct avrcp_player *addressed = player->server->addressed_player;
+	struct avrcp_session *session = &player->server->session;
+	uint8_t play_status;
+	uint64_t uid;
+
+	/* Reusing previously registered events for AVRCP 1.3 devices */
+
+	play_status = player->cb->get_status(player->user_data);
+	uid = player->cb->get_uid(player->user_data);
+
+	if (play_status != addressed->cb->get_status(addressed->user_data))
+		avrcp_event(session, AVRCP_EVENT_PLAYBACK_STATUS_CHANGED,
+				&play_status);
+
+	avrcp_event(session, AVRCP_EVENT_TRACK_CHANGED, &uid);
+}
+
+gboolean avrcp_set_addressed_player(struct avrcp_player *player, gboolean local)
+{
+	struct avrcp_server *server = player->server;
+	struct avrcp_session *session = &server->session;
+
+	if (player == server->addressed_player)
+		return TRUE;
+
+	/* if triggered from remote, try to complete events */
+	if (local) {
+		if (session->version_ct == AVRCP_VERSION_1_3)
+			avrcp_events_reusing(player);
+		else
+			avrcp_events_completion(session);
+	}
+
+	pending_pdu_abort(session);
+
+	player->dev = server->addressed_player->dev;
+
+	if (server->addressed_player->handler) {
+		avctp_unregister_pdu_handler(server->addressed_player->handler);
+		server->addressed_player->handler = 0;
+	}
+	player->handler = avctp_register_pdu_handler(AVC_OP_VENDORDEP,
+							handle_vendordep_pdu, player);
+
+	server->addressed_player = player;
+
+	return TRUE;
+}
diff --git a/audio/avrcp.h b/audio/avrcp.h
index 1b4a887..68e3098 100644
--- a/audio/avrcp.h
+++ b/audio/avrcp.h
@@ -121,5 +121,6 @@ void avrcp_unregister_player(struct avrcp_player *player);
 
 int avrcp_event(struct avrcp_session *session, uint8_t id, void *data);
 
+gboolean avrcp_set_addressed_player(struct avrcp_player *player, gboolean local);
 
 size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands);
diff --git a/audio/media.c b/audio/media.c
index ce5822a..97bf7df 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -1803,12 +1803,17 @@ static gboolean media_set_addressed_player(struct media_adapter *adapter,
 	if (!mp)
 		return FALSE;
 
+	if (!avrcp_set_addressed_player(mp->player, local))
+		return FALSE;
+
 	if (adapter->addressed &&
 		g_strcmp0(adapter->addressed->path, DUMMY_PLAYER) == 0)
 		media_player_remove(adapter->addressed);
 
 	adapter->addressed = mp;
 
+	DBG("Set addressed player id=%u to %s", mp->id, path);
+
 	return TRUE;
 }
 
-- 
on behalf of ST-Ericsson


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

* [PATCH v2 12/14] AVRCP: Use NoAvailablePlayers status code for AVRCP 1.4 devices
  2012-06-27 13:27 [PATCH v2 01/14] AVRCP: Update constants Michal Labedzki
                   ` (9 preceding siblings ...)
  2012-06-27 13:27 ` [PATCH v2 11/14] AVRCP: Implement setting AddressedPlayer with notifications completion Michal Labedzki
@ 2012-06-27 13:27 ` Michal Labedzki
  2012-06-27 13:27 ` [PATCH v2 13/14] AVRCP: Implement notification ADDRESSED_PLAYER_CHANGED Michal Labedzki
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michal Labedzki @ 2012-06-27 13:27 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, lucas.demarchi, johan.hedberg, Michal Labedzki

DummyPlayer indicate there is no available players. For AVRCP 1.4
devices use NoAvailblePlayers status code, on the other side, for
AVRCP 1.3 devices use InternalError.
---
 audio/avrcp.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
 audio/avrcp.h |    1 +
 audio/media.c |   13 ++++++++++++-
 3 files changed, 66 insertions(+), 5 deletions(-)

diff --git a/audio/avrcp.c b/audio/avrcp.c
index baf9de5..a725142 100644
--- a/audio/avrcp.c
+++ b/audio/avrcp.c
@@ -1159,6 +1159,41 @@ err_metadata:
 	return AVRCP_HEADER_LENGTH + 1;
 }
 
+static size_t handle_dummy_player(struct avctp *session, uint8_t transaction,
+					uint8_t *code, uint8_t *subunit,
+					uint8_t *operands, size_t operand_count,
+					void *user_data)
+{
+	struct avrcp_player *player = user_data;
+	struct avrcp_header *pdu = (void *) operands;
+	uint32_t company_id = get_company_id(pdu->company_id);
+
+	if (player->server->session.version_ct < AVRCP_VERSION_1_4)
+		goto ignoring;
+
+	if (pdu->pdu_id == AVRCP_GET_CAPABILITIES ||
+		pdu->pdu_id == AVRCP_REGISTER_NOTIFICATION)
+		goto pass;
+
+	*code = AVC_CTYPE_REJECTED;
+	pdu->params_len = htons(1);
+
+	pdu->params[0] = STATUS_NO_AVAILABLE_PLAYERS;
+
+	DBG("cannot handle regard to no available players "
+		"AVRCP PDU 0x%02X, company 0x%06X len 0x%04X",
+		pdu->pdu_id, company_id, pdu->params_len);
+
+	return AVRCP_HEADER_LENGTH + 1;
+
+ignoring:
+	DBG("ignoring AVRCP PDU 0x%02X, company 0x%06X len 0x%04X",
+		pdu->pdu_id, company_id, pdu->params_len);
+pass:
+	return handle_vendordep_pdu(session, transaction, code, subunit,
+					operands, operand_count, user_data);
+}
+
 size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands)
 {
 	struct avrcp_header *pdu = (void *) operands;
@@ -1166,6 +1201,7 @@ size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands)
 
 	*code = AVC_CTYPE_REJECTED;
 	pdu->params_len = htons(1);
+
 	pdu->params[0] = STATUS_INTERNAL_ERROR;
 
 	DBG("rejecting AVRCP PDU 0x%02X, company 0x%06X len 0x%04X",
@@ -1269,11 +1305,19 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
 
 		player->dev = dev;
 
-		if (!player->handler)
-			player->handler = avctp_register_pdu_handler(
+		if (!player->handler) {
+			if (player->cb->is_dummy_player(player->user_data))
+				player->handler = avctp_register_pdu_handler(
+							AVC_OP_VENDORDEP,
+							handle_dummy_player,
+							player);
+			else
+				player->handler = avctp_register_pdu_handler(
 							AVC_OP_VENDORDEP,
 							handle_vendordep_pdu,
 							player);
+		}
+
 		break;
 	case AVCTP_STATE_CONNECTED:
 		rec_tg = btd_device_get_record(dev->btd_dev, AVRCP_TARGET_UUID);
@@ -1611,8 +1655,13 @@ gboolean avrcp_set_addressed_player(struct avrcp_player *player, gboolean local)
 		avctp_unregister_pdu_handler(server->addressed_player->handler);
 		server->addressed_player->handler = 0;
 	}
-	player->handler = avctp_register_pdu_handler(AVC_OP_VENDORDEP,
-							handle_vendordep_pdu, player);
+
+	if (player->cb->is_dummy_player(player->user_data))
+		player->handler = avctp_register_pdu_handler(AVC_OP_VENDORDEP,
+						handle_dummy_player, player);
+	else
+		player->handler = avctp_register_pdu_handler(AVC_OP_VENDORDEP,
+						handle_vendordep_pdu, player);
 
 	server->addressed_player = player;
 
diff --git a/audio/avrcp.h b/audio/avrcp.h
index 68e3098..148dc0e 100644
--- a/audio/avrcp.h
+++ b/audio/avrcp.h
@@ -101,6 +101,7 @@ struct avrcp_player_cb {
 	uint32_t (*get_position) (void *user_data);
 	void (*set_volume) (uint8_t volume, struct audio_device *dev,
 							void *user_data);
+	gboolean (*is_dummy_player) (void *user_data);
 };
 
 struct avrcp_player *player;
diff --git a/audio/media.c b/audio/media.c
index 97bf7df..0c11cf0 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -1393,6 +1393,16 @@ static void set_volume(uint8_t volume, struct audio_device *dev, void *user_data
 	}
 }
 
+static gboolean is_dummy_player(void *user_data)
+{
+	struct media_player *mp = user_data;
+
+	if (strcmp(mp->path, DUMMY_PLAYER) == 0)
+	    return TRUE;
+
+	return FALSE;
+}
+
 static struct avrcp_player_cb player_cb = {
 	.get_setting = get_setting,
 	.set_setting = set_setting,
@@ -1401,7 +1411,8 @@ static struct avrcp_player_cb player_cb = {
 	.get_metadata = get_metadata,
 	.get_position = get_position,
 	.get_status = get_status,
-	.set_volume = set_volume
+	.set_volume = set_volume,
+	.is_dummy_player = is_dummy_player
 };
 
 static void media_player_exit(DBusConnection *connection, void *user_data)
-- 
on behalf of ST-Ericsson


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

* [PATCH v2 13/14] AVRCP: Implement notification ADDRESSED_PLAYER_CHANGED
  2012-06-27 13:27 [PATCH v2 01/14] AVRCP: Update constants Michal Labedzki
                   ` (10 preceding siblings ...)
  2012-06-27 13:27 ` [PATCH v2 12/14] AVRCP: Use NoAvailablePlayers status code for AVRCP 1.4 devices Michal Labedzki
@ 2012-06-27 13:27 ` Michal Labedzki
  2012-06-27 13:27 ` [PATCH v2 14/14] AVRCP: Handle SetAddressedPlayer command from remote controller Michal Labedzki
  2012-06-27 13:32 ` [PATCH v2 01/14] AVRCP: Update constants Luiz Augusto von Dentz
  13 siblings, 0 replies; 18+ messages in thread
From: Michal Labedzki @ 2012-06-27 13:27 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, lucas.demarchi, johan.hedberg, Michal Labedzki

It is triggered by local change of addressed player on TG while
unregistering currently addressed player.
---
 audio/avrcp.c |   35 ++++++++++++++++++++++++++++++++++-
 audio/avrcp.h |    2 ++
 audio/media.c |   19 ++++++++++++++++++-
 3 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/audio/avrcp.c b/audio/avrcp.c
index a725142..7b2d6e0 100644
--- a/audio/avrcp.c
+++ b/audio/avrcp.c
@@ -208,6 +208,11 @@ static const uint8_t events_to_complete[] = {
 	AVRCP_EVENT_NOW_PLAYING_CONTENT_CHANGED
 };
 
+struct addressed_param {
+	uint16_t player_id;
+	uint16_t uid_counter;
+} __attribute__ ((packed));
+
 static GSList *servers = NULL;
 static unsigned int avctp_id = 0;
 
@@ -444,6 +449,14 @@ int avrcp_event(struct avrcp_session *session, uint8_t id, void *data)
 		memcpy(&pdu->params[1], data, sizeof(uint64_t));
 
 		break;
+	case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED:
+		size = 5;
+		/* player id */
+		memcpy(&pdu->params[1], data, sizeof(uint16_t));
+		/* uid counter */
+		memcpy(&pdu->params[3], data + 2, sizeof(uint16_t));
+
+		break;
 	case AVRCP_EVENT_TRACK_REACHED_END:
 	case AVRCP_EVENT_TRACK_REACHED_START:
 	case AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED:
@@ -618,12 +631,13 @@ static uint8_t avrcp_handle_get_capabilities(struct avrcp_player *player,
 
 		return AVC_CTYPE_STABLE;
 	case CAP_EVENTS_SUPPORTED:
-		pdu->params[1] = 5;
+		pdu->params[1] = 6;
 		pdu->params[2] = AVRCP_EVENT_PLAYBACK_STATUS_CHANGED;
 		pdu->params[3] = AVRCP_EVENT_TRACK_CHANGED;
 		pdu->params[4] = AVRCP_EVENT_TRACK_REACHED_START;
 		pdu->params[5] = AVRCP_EVENT_TRACK_REACHED_END;
 		pdu->params[6] = AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED;
+		pdu->params[7] = AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED;
 
 		pdu->params_len = htons(2 + pdu->params[1]);
 		return AVC_CTYPE_STABLE;
@@ -949,6 +963,8 @@ static uint8_t avrcp_handle_register_notification(struct avrcp_player *player,
 	struct avrcp_session *session = &player->server->session;
 	uint16_t len = ntohs(pdu->params_len);
 	uint64_t uid;
+	uint16_t uid_counter;
+	uint16_t player_id;
 
 	/*
 	 * 1 byte for EventID, 4 bytes for Playback interval but the latest
@@ -970,6 +986,16 @@ static uint8_t avrcp_handle_register_notification(struct avrcp_player *player,
 		memcpy(&pdu->params[1], &uid, sizeof(uint64_t));
 
 		break;
+	case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED:
+		len = 5;
+
+		player_id = htons(player->cb->get_player_id(player->user_data));
+		memcpy(&pdu->params[1], &player_id, sizeof(player_id));
+
+		uid_counter = htons(player->cb->get_uid_counter(player->user_data));
+		memcpy(&pdu->params[3], &uid_counter, sizeof(uid_counter));
+
+		break;
 	case AVRCP_EVENT_TRACK_REACHED_END:
 	case AVRCP_EVENT_TRACK_REACHED_START:
 	case AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED:
@@ -1635,12 +1661,19 @@ gboolean avrcp_set_addressed_player(struct avrcp_player *player, gboolean local)
 {
 	struct avrcp_server *server = player->server;
 	struct avrcp_session *session = &server->session;
+	struct addressed_param parameters;
 
 	if (player == server->addressed_player)
 		return TRUE;
 
 	/* if triggered from remote, try to complete events */
 	if (local) {
+		parameters.player_id = htons(player->cb->get_player_id(player->user_data));
+		parameters.uid_counter = htons(player->cb->get_uid_counter(player->user_data));
+
+		avrcp_event(session, AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED,
+				&parameters);
+
 		if (session->version_ct == AVRCP_VERSION_1_3)
 			avrcp_events_reusing(player);
 		else
diff --git a/audio/avrcp.h b/audio/avrcp.h
index 148dc0e..83e8563 100644
--- a/audio/avrcp.h
+++ b/audio/avrcp.h
@@ -102,6 +102,8 @@ struct avrcp_player_cb {
 	void (*set_volume) (uint8_t volume, struct audio_device *dev,
 							void *user_data);
 	gboolean (*is_dummy_player) (void *user_data);
+	uint16_t (*get_player_id) (void *user_data);
+	uint16_t (*get_uid_counter) (void *user_data);
 };
 
 struct avrcp_player *player;
diff --git a/audio/media.c b/audio/media.c
index 0c11cf0..c99cde6 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -106,6 +106,7 @@ struct media_player {
 	uint32_t		position;
 	uint8_t			volume;
 	uint16_t		id;
+	uint16_t		uid_counter;
 	GTimer			*timer;
 };
 
@@ -1403,6 +1404,20 @@ static gboolean is_dummy_player(void *user_data)
 	return FALSE;
 }
 
+static uint16_t get_player_id(void *user_data)
+{
+	struct media_player *mp = user_data;
+
+	return mp->id;
+}
+
+static uint16_t get_uid_counter(void *user_data)
+{
+	struct media_player *mp = user_data;
+
+	return mp->uid_counter;
+}
+
 static struct avrcp_player_cb player_cb = {
 	.get_setting = get_setting,
 	.set_setting = set_setting,
@@ -1412,7 +1427,9 @@ static struct avrcp_player_cb player_cb = {
 	.get_position = get_position,
 	.get_status = get_status,
 	.set_volume = set_volume,
-	.is_dummy_player = is_dummy_player
+	.is_dummy_player = is_dummy_player,
+	.get_player_id = get_player_id,
+	.get_uid_counter = get_uid_counter
 };
 
 static void media_player_exit(DBusConnection *connection, void *user_data)
-- 
on behalf of ST-Ericsson


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

* [PATCH v2 14/14] AVRCP: Handle SetAddressedPlayer command from remote controller
  2012-06-27 13:27 [PATCH v2 01/14] AVRCP: Update constants Michal Labedzki
                   ` (11 preceding siblings ...)
  2012-06-27 13:27 ` [PATCH v2 13/14] AVRCP: Implement notification ADDRESSED_PLAYER_CHANGED Michal Labedzki
@ 2012-06-27 13:27 ` Michal Labedzki
  2012-06-27 13:32 ` [PATCH v2 01/14] AVRCP: Update constants Luiz Augusto von Dentz
  13 siblings, 0 replies; 18+ messages in thread
From: Michal Labedzki @ 2012-06-27 13:27 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, lucas.demarchi, johan.hedberg, Michal Labedzki

Set player selected by controller as addressed player.
---
 audio/avrcp.c |   33 +++++++++++++++++++++++++++++++++
 audio/avrcp.h |    1 +
 audio/media.c |   19 ++++++++++++++++++-
 3 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/audio/avrcp.c b/audio/avrcp.c
index 7b2d6e0..9a1c8e1 100644
--- a/audio/avrcp.c
+++ b/audio/avrcp.c
@@ -1088,6 +1088,37 @@ err:
 	return AVC_CTYPE_REJECTED;
 }
 
+static uint8_t avrcp_handle_set_addressed_player(struct avrcp_player *player,
+							struct avrcp_header *pdu,
+							uint8_t transaction)
+{
+	uint16_t len = ntohs(pdu->params_len);
+	uint16_t player_id;
+
+	if (len != sizeof(player_id)) {
+		pdu->params[0] = STATUS_INVALID_PARAMETER;
+		return AVC_CTYPE_REJECTED;
+	}
+
+	player_id = bt_get_be16(pdu->params);
+
+	DBG("Remote controller set addressed player id=%u", player_id);
+
+	pdu->params_len = htons(1);
+
+	if (!player->cb->set_addressed_player(player_id, player->user_data)) {
+		if (g_slist_length(player->server->players) == 0)
+			pdu->params[0] = STATUS_NO_AVAILABLE_PLAYERS;
+		else
+			pdu->params[0] = STATUS_INVALID_PLAYER_ID;
+
+		return AVC_CTYPE_REJECTED;
+	}
+
+	pdu->params[0] = STATUS_OK;
+	return AVC_CTYPE_ACCEPTED;
+}
+
 static struct pdu_handler {
 	uint8_t pdu_id;
 	uint8_t code;
@@ -1123,6 +1154,8 @@ static struct pdu_handler {
 					avrcp_handle_request_continuing },
 		{ AVRCP_ABORT_CONTINUING, AVC_CTYPE_CONTROL,
 					avrcp_handle_abort_continuing },
+		{ AVRCP_SET_ADDRESSED_PLAYER, AVC_CTYPE_CONTROL,
+					avrcp_handle_set_addressed_player },
 		{ },
 };
 
diff --git a/audio/avrcp.h b/audio/avrcp.h
index 83e8563..04fbe5a 100644
--- a/audio/avrcp.h
+++ b/audio/avrcp.h
@@ -104,6 +104,7 @@ struct avrcp_player_cb {
 	gboolean (*is_dummy_player) (void *user_data);
 	uint16_t (*get_player_id) (void *user_data);
 	uint16_t (*get_uid_counter) (void *user_data);
+	gboolean (*set_addressed_player) (uint16_t player_id, void *user_data);
 };
 
 struct avrcp_player *player;
diff --git a/audio/media.c b/audio/media.c
index c99cde6..ee55a6b 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -120,6 +120,10 @@ struct metadata_value {
 
 static GSList *adapters = NULL;
 
+static gboolean media_set_addressed_player(struct media_adapter *adapter,
+					   const char *sender, const char *path,
+					   gboolean local);
+
 static void endpoint_request_free(struct endpoint_request *request)
 {
 	if (request->call)
@@ -1418,6 +1422,18 @@ static uint16_t get_uid_counter(void *user_data)
 	return mp->uid_counter;
 }
 
+static gboolean set_addressed_player(uint16_t player_id, void *user_data)
+{
+	struct media_player *player = user_data;
+	struct media_player *mp;
+
+	mp = media_adapter_find_player_by_id(player->adapter, NULL, player_id);
+	if (!mp)
+		return FALSE;
+
+	return media_set_addressed_player(player->adapter, player->sender, mp->path, FALSE);
+}
+
 static struct avrcp_player_cb player_cb = {
 	.get_setting = get_setting,
 	.set_setting = set_setting,
@@ -1429,7 +1445,8 @@ static struct avrcp_player_cb player_cb = {
 	.set_volume = set_volume,
 	.is_dummy_player = is_dummy_player,
 	.get_player_id = get_player_id,
-	.get_uid_counter = get_uid_counter
+	.get_uid_counter = get_uid_counter,
+	.set_addressed_player = set_addressed_player
 };
 
 static void media_player_exit(DBusConnection *connection, void *user_data)
-- 
on behalf of ST-Ericsson


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

* Re: [PATCH v2 01/14] AVRCP: Update constants
  2012-06-27 13:27 [PATCH v2 01/14] AVRCP: Update constants Michal Labedzki
                   ` (12 preceding siblings ...)
  2012-06-27 13:27 ` [PATCH v2 14/14] AVRCP: Handle SetAddressedPlayer command from remote controller Michal Labedzki
@ 2012-06-27 13:32 ` Luiz Augusto von Dentz
  2012-06-27 14:25   ` Michal.Labedzki
  13 siblings, 1 reply; 18+ messages in thread
From: Luiz Augusto von Dentz @ 2012-06-27 13:32 UTC (permalink / raw)
  To: Michal Labedzki; +Cc: linux-bluetooth, lucas.demarchi, johan.hedberg

Hi Michal,

On Wed, Jun 27, 2012 at 4:27 PM, Michal Labedzki
<michal.labedzki@tieto.com> wrote:
> Change all specification constants to enum type.
> Also add constants for addressed player feature.
> ---
>  audio/avrcp.c |  151 ++++++++++++++++++++++++++++++++-------------------------
>  audio/avrcp.h |  107 ++++++++++++++++++++++------------------
>  audio/media.c |    2 +-
>  3 files changed, 146 insertions(+), 114 deletions(-)
>
> diff --git a/audio/avrcp.c b/audio/avrcp.c
> index 89ee112..da102b2 100644
> --- a/audio/avrcp.c
> +++ b/audio/avrcp.c
> @@ -58,56 +58,73 @@
>  #include "sdpd.h"
>  #include "dbus-common.h"
>
> -/* Company IDs for vendor dependent commands */
> -#define IEEEID_BTSIG           0x001958
> -
> -/* Error codes for metadata transfer */
> -#define E_INVALID_COMMAND      0x00
> -#define E_INVALID_PARAM                0x01
> -#define E_PARAM_NOT_FOUND      0x02
> -#define E_INTERNAL             0x03
> -
> -/* Packet types */
> -#define AVRCP_PACKET_TYPE_SINGLE       0x00
> -#define AVRCP_PACKET_TYPE_START                0x01
> -#define AVRCP_PACKET_TYPE_CONTINUING   0x02
> -#define AVRCP_PACKET_TYPE_END          0x03
> -
> -/* PDU types for metadata transfer */
> -#define AVRCP_GET_CAPABILITIES         0x10
> -#define AVRCP_LIST_PLAYER_ATTRIBUTES   0X11
> -#define AVRCP_LIST_PLAYER_VALUES       0x12
> -#define AVRCP_GET_CURRENT_PLAYER_VALUE 0x13
> -#define AVRCP_SET_PLAYER_VALUE         0x14
> -#define AVRCP_GET_PLAYER_ATTRIBUTE_TEXT        0x15
> -#define AVRCP_GET_PLAYER_VALUE_TEXT    0x16
> -#define AVRCP_DISPLAYABLE_CHARSET      0x17
> -#define AVRCP_CT_BATTERY_STATUS                0x18
> -#define AVRCP_GET_ELEMENT_ATTRIBUTES   0x20
> -#define AVRCP_GET_PLAY_STATUS          0x30
> -#define AVRCP_REGISTER_NOTIFICATION    0x31
> -#define AVRCP_REQUEST_CONTINUING       0x40
> -#define AVRCP_ABORT_CONTINUING         0x41
> -#define AVRCP_SET_ABSOLUTE_VOLUME      0x50
> -
> -/* Capabilities for AVRCP_GET_CAPABILITIES pdu */
> -#define CAP_COMPANY_ID         0x02
> -#define CAP_EVENTS_SUPPORTED   0x03
> -
>  #define AVRCP_REGISTER_NOTIFICATION_PARAM_LENGTH 5
>
> -#define AVRCP_FEATURE_CATEGORY_1       0x0001
> -#define AVRCP_FEATURE_CATEGORY_2       0x0002
> -#define AVRCP_FEATURE_CATEGORY_3       0x0004
> -#define AVRCP_FEATURE_CATEGORY_4       0x0008
> -#define AVRCP_FEATURE_PLAYER_SETTINGS  0x0010
> +enum company_id {
> +       IEEEID_BTSIG     = 0x001958
> +};
> +
> +enum status_code {
> +       STATUS_INVALID_COMMAND          = 0x00,
> +       STATUS_INVALID_PARAMETER        = 0x01,
> +       STATUS_INTERNAL_ERROR           = 0x03,
> +       STATUS_OK                       = 0x04,
> +       STATUS_INVALID_PLAYER_ID        = 0x11,
> +       STATUS_NO_AVAILABLE_PLAYERS     = 0x15,
> +       STATUS_ADDRESSED_PLAYER_CHANGED = 0x16
> +};
> +
> +enum packet_type {
> +       AVRCP_PACKET_TYPE_SINGLE        = 0x00,
> +       AVRCP_PACKET_TYPE_START         = 0x01,
> +       AVRCP_PACKET_TYPE_CONTINUING    = 0x02,
> +       AVRCP_PACKET_TYPE_END           = 0x03
> +};
> +
> +enum control_pdu_ieeeid_btsig {
> +       AVRCP_GET_CAPABILITIES          = 0x10,
> +       AVRCP_LIST_PLAYER_ATTRIBUTES    = 0X11,
> +       AVRCP_LIST_PLAYER_VALUES        = 0x12,
> +       AVRCP_GET_CURRENT_PLAYER_VALUE  = 0x13,
> +       AVRCP_SET_PLAYER_VALUE          = 0x14,
> +       AVRCP_GET_PLAYER_ATTRIBUTE_TEXT = 0x15,
> +       AVRCP_GET_PLAYER_VALUE_TEXT     = 0x16,
> +       AVRCP_DISPLAYABLE_CHARSET       = 0x17,
> +       AVRCP_CT_BATTERY_STATUS         = 0x18,
> +       AVRCP_GET_ELEMENT_ATTRIBUTES    = 0x20,
> +       AVRCP_GET_PLAY_STATUS           = 0x30,
> +       AVRCP_REGISTER_NOTIFICATION     = 0x31,
> +       AVRCP_REQUEST_CONTINUING        = 0x40,
> +       AVRCP_ABORT_CONTINUING          = 0x41,
> +       AVRCP_SET_ABSOLUTE_VOLUME       = 0x50,
> +       AVRCP_SET_ADDRESSED_PLAYER      = 0x60,
> +};
> +
> +enum capability {
> +       CAP_COMPANY_ID          = 0x02,
> +       CAP_EVENTS_SUPPORTED    = 0x03
> +};
> +
> +enum sdp_feature {
> +       AVRCP_FEATURE_CATEGORY_1        = 0x0001,
> +       AVRCP_FEATURE_CATEGORY_2        = 0x0002,
> +       AVRCP_FEATURE_CATEGORY_3        = 0x0004,
> +       AVRCP_FEATURE_CATEGORY_4        = 0x0008,
> +       AVRCP_FEATURE_PLAYER_SETTINGS   = 0x0010,
> +};
>
>  enum battery_status {
> -       BATTERY_STATUS_NORMAL =         0,
> -       BATTERY_STATUS_WARNING =        1,
> -       BATTERY_STATUS_CRITICAL =       2,
> -       BATTERY_STATUS_EXTERNAL =       3,
> -       BATTERY_STATUS_FULL_CHARGE =    4,
> +       BATTERY_STATUS_NORMAL           = 0,
> +       BATTERY_STATUS_WARNING          = 1,
> +       BATTERY_STATUS_CRITICAL         = 2,
> +       BATTERY_STATUS_EXTERNAL         = 3,
> +       BATTERY_STATUS_FULL_CHARGE      = 4
> +};
> +
> +enum avrcp_version {
> +       AVRCP_VERSION_UNKNOWN   = 0x0000,
> +       AVRCP_VERSION_1_3       = 0x0103,
> +       AVRCP_VERSION_1_4       = 0x0104
>  };
>
>  #if __BYTE_ORDER == __LITTLE_ENDIAN
> @@ -396,7 +413,7 @@ int avrcp_player_event(struct avrcp_player *player, uint8_t id, void *data)
>        DBG("id=%u", id);
>
>        switch (id) {
> -       case AVRCP_EVENT_STATUS_CHANGED:
> +       case AVRCP_EVENT_PLAYBACK_STATUS_CHANGED:
>                size = 2;
>                pdu->params[1] = *((uint8_t *)data);
>
> @@ -581,7 +598,7 @@ static uint8_t avrcp_handle_get_capabilities(struct avrcp_player *player,
>                return AVC_CTYPE_STABLE;
>        case CAP_EVENTS_SUPPORTED:
>                pdu->params[1] = 4;
> -               pdu->params[2] = AVRCP_EVENT_STATUS_CHANGED;
> +               pdu->params[2] = AVRCP_EVENT_PLAYBACK_STATUS_CHANGED;
>                pdu->params[3] = AVRCP_EVENT_TRACK_CHANGED;
>                pdu->params[4] = AVRCP_EVENT_TRACK_REACHED_START;
>                pdu->params[5] = AVRCP_EVENT_TRACK_REACHED_END;
> @@ -592,7 +609,7 @@ static uint8_t avrcp_handle_get_capabilities(struct avrcp_player *player,
>
>  err:
>        pdu->params_len = htons(1);
> -       pdu->params[0] = E_INVALID_PARAM;
> +       pdu->params[0] = STATUS_INVALID_PARAMETER;
>
>        return AVC_CTYPE_REJECTED;
>  }
> @@ -606,7 +623,7 @@ static uint8_t avrcp_handle_list_player_attributes(struct avrcp_player *player,
>
>        if (len != 0) {
>                pdu->params_len = htons(1);
> -               pdu->params[0] = E_INVALID_PARAM;
> +               pdu->params[0] = STATUS_INVALID_PARAMETER;
>                return AVC_CTYPE_REJECTED;
>        }
>
> @@ -653,7 +670,7 @@ static uint8_t avrcp_handle_list_player_values(struct avrcp_player *player,
>
>  err:
>        pdu->params_len = htons(1);
> -       pdu->params[0] = E_INVALID_PARAM;
> +       pdu->params[0] = STATUS_INVALID_PARAMETER;
>        return AVC_CTYPE_REJECTED;
>  }
>
> @@ -724,7 +741,7 @@ static uint8_t avrcp_handle_get_element_attributes(struct avrcp_player *player,
>        return AVC_CTYPE_STABLE;
>  err:
>        pdu->params_len = htons(1);
> -       pdu->params[0] = E_INVALID_PARAM;
> +       pdu->params[0] = STATUS_INVALID_PARAMETER;
>        return AVC_CTYPE_REJECTED;
>  }
>
> @@ -781,7 +798,7 @@ static uint8_t avrcp_handle_get_current_player_value(struct avrcp_player *player
>
>  err:
>        pdu->params_len = htons(1);
> -       pdu->params[0] = E_INVALID_PARAM;
> +       pdu->params[0] = STATUS_INVALID_PARAMETER;
>
>        return AVC_CTYPE_REJECTED;
>  }
> @@ -802,7 +819,7 @@ static uint8_t avrcp_handle_set_player_value(struct avrcp_player *player,
>         * and set the existent ones. Sec. 5.2.4 is not clear however how to
>         * indicate that a certain ID was not accepted. If at least one
>         * attribute is valid, we respond with no parameters. Otherwise an
> -        * E_INVALID_PARAM is sent.
> +        * STATUS_INVALID_PARAMETER is sent.
>         */
>        for (len = 0, i = 0, param = &pdu->params[1]; i < pdu->params[0];
>                                                        i++, param += 2) {
> @@ -820,7 +837,7 @@ static uint8_t avrcp_handle_set_player_value(struct avrcp_player *player,
>
>  err:
>        pdu->params_len = htons(1);
> -       pdu->params[0] = E_INVALID_PARAM;
> +       pdu->params[0] = STATUS_INVALID_PARAMETER;
>        return AVC_CTYPE_REJECTED;
>  }
>
> @@ -832,7 +849,7 @@ static uint8_t avrcp_handle_displayable_charset(struct avrcp_player *player,
>
>        if (len < 3) {
>                pdu->params_len = htons(1);
> -               pdu->params[0] = E_INVALID_PARAM;
> +               pdu->params[0] = STATUS_INVALID_PARAMETER;
>                return AVC_CTYPE_REJECTED;
>        }
>
> @@ -864,7 +881,7 @@ static uint8_t avrcp_handle_ct_battery_status(struct avrcp_player *player,
>
>  err:
>        pdu->params_len = htons(1);
> -       pdu->params[0] = E_INVALID_PARAM;
> +       pdu->params[0] = STATUS_INVALID_PARAMETER;
>        return AVC_CTYPE_REJECTED;
>  }
>
> @@ -879,7 +896,7 @@ static uint8_t avrcp_handle_get_play_status(struct avrcp_player *player,
>
>        if (len != 0) {
>                pdu->params_len = htons(1);
> -               pdu->params[0] = E_INVALID_PARAM;
> +               pdu->params[0] = STATUS_INVALID_PARAMETER;
>                return AVC_CTYPE_REJECTED;
>        }
>
> @@ -918,7 +935,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp_player *player,
>                goto err;
>
>        switch (pdu->params[0]) {
> -       case AVRCP_EVENT_STATUS_CHANGED:
> +       case AVRCP_EVENT_PLAYBACK_STATUS_CHANGED:
>                len = 2;
>                pdu->params[1] = player->cb->get_status(player->user_data);
>
> @@ -948,7 +965,7 @@ static uint8_t avrcp_handle_register_notification(struct avrcp_player *player,
>
>  err:
>        pdu->params_len = htons(1);
> -       pdu->params[0] = E_INVALID_PARAM;
> +       pdu->params[0] = STATUS_INVALID_PARAMETER;
>        return AVC_CTYPE_REJECTED;
>  }
>
> @@ -988,7 +1005,7 @@ static uint8_t avrcp_handle_request_continuing(struct avrcp_player *player,
>        return AVC_CTYPE_STABLE;
>  err:
>        pdu->params_len = htons(1);
> -       pdu->params[0] = E_INVALID_PARAM;
> +       pdu->params[0] = STATUS_INVALID_PARAMETER;
>        return AVC_CTYPE_REJECTED;
>  }
>
> @@ -1014,7 +1031,7 @@ static uint8_t avrcp_handle_abort_continuing(struct avrcp_player *player,
>
>  err:
>        pdu->params_len = htons(1);
> -       pdu->params[0] = E_INVALID_PARAM;
> +       pdu->params[0] = STATUS_INVALID_PARAMETER;
>        return AVC_CTYPE_REJECTED;
>  }
>
> @@ -1079,7 +1096,7 @@ static size_t handle_vendordep_pdu(struct avctp *session, uint8_t transaction,
>        pdu->rsvd = 0;
>
>        if (operand_count < AVRCP_HEADER_LENGTH) {
> -               pdu->params[0] = E_INVALID_COMMAND;
> +               pdu->params[0] = STATUS_INVALID_COMMAND;
>                goto err_metadata;
>        }
>
> @@ -1089,12 +1106,12 @@ static size_t handle_vendordep_pdu(struct avctp *session, uint8_t transaction,
>        }
>
>        if (!handler || handler->code != *code) {
> -               pdu->params[0] = E_INVALID_COMMAND;
> +               pdu->params[0] = STATUS_INVALID_COMMAND;
>                goto err_metadata;
>        }
>
>        if (!handler->func) {
> -               pdu->params[0] = E_INVALID_PARAM;
> +               pdu->params[0] = STATUS_INVALID_PARAMETER;
>                goto err_metadata;
>        }
>
> @@ -1122,7 +1139,7 @@ size_t avrcp_handle_vendor_reject(uint8_t *code, uint8_t *operands)
>
>     *code = AVC_CTYPE_REJECTED;
>     pdu->params_len = htons(1);
> -    pdu->params[0] = E_INTERNAL;
> +    pdu->params[0] = STATUS_INTERNAL_ERROR;
>
>     DBG("rejecting AVRCP PDU 0x%02X, company 0x%06X len 0x%04X",
>             pdu->pdu_id, company_id, pdu->params_len);
> @@ -1236,7 +1253,7 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
>
>                desc = list->data;
>
> -               if (desc && desc->version >= 0x0104)
> +               if (desc && desc->version >= AVRCP_VERSION_1_4)
>                        register_volume_notification(player);
>
>                sdp_list_free(list, free);
> diff --git a/audio/avrcp.h b/audio/avrcp.h
> index bf11a6c..dcc67f6 100644
> --- a/audio/avrcp.h
> +++ b/audio/avrcp.h
> @@ -22,59 +22,74 @@
>  *
>  */
>
> -/* player attributes */
> -#define AVRCP_ATTRIBUTE_ILEGAL         0x00
> -#define AVRCP_ATTRIBUTE_EQUALIZER      0x01
> -#define AVRCP_ATTRIBUTE_REPEAT_MODE    0x02
> -#define AVRCP_ATTRIBUTE_SHUFFLE                0x03
> -#define AVRCP_ATTRIBUTE_SCAN           0x04
> +enum player_attribute {
> +       AVRCP_ATTRIBUTE_ILEGAL          = 0x00,
> +       AVRCP_ATTRIBUTE_EQUALIZER       = 0x01,
> +       AVRCP_ATTRIBUTE_REPEAT_MODE     = 0x02,
> +       AVRCP_ATTRIBUTE_SHUFFLE         = 0x03,
> +       AVRCP_ATTRIBUTE_SCAN            = 0x04
> +};
>
> -/* equalizer values */
> -#define AVRCP_EQUALIZER_OFF            0x01
> -#define AVRCP_EQUALIZER_ON             0x02
> +enum equalizer_value {
> +       AVRCP_EQUALIZER_OFF             = 0x01,
> +       AVRCP_EQUALIZER_ON              = 0x02
> +};
>
> -/* repeat mode values */
> -#define AVRCP_REPEAT_MODE_OFF          0x01
> -#define AVRCP_REPEAT_MODE_SINGLE       0x02
> -#define AVRCP_REPEAT_MODE_ALL          0x03
> -#define AVRCP_REPEAT_MODE_GROUP                0x04
> +enum repeat_mode_value {
> +       AVRCP_REPEAT_MODE_OFF           = 0x01,
> +       AVRCP_REPEAT_MODE_SINGLE        = 0x02,
> +       AVRCP_REPEAT_MODE_ALL           = 0x03,
> +       AVRCP_REPEAT_MODE_GROUP         = 0x04
> +};
>
> -/* shuffle values */
> -#define AVRCP_SHUFFLE_OFF              0x01
> -#define AVRCP_SHUFFLE_ALL              0x02
> -#define AVRCP_SHUFFLE_GROUP            0x03
> +enum shuffle_value {
> +       AVRCP_SHUFFLE_OFF               = 0x01,
> +       AVRCP_SHUFFLE_ALL               = 0x02,
> +       AVRCP_SHUFFLE_GROUP             = 0x03
> +};
>
> -/* scan values */
> -#define AVRCP_SCAN_OFF                 0x01
> -#define AVRCP_SCAN_ALL                 0x02
> -#define AVRCP_SCAN_GROUP               0x03
> +enum scan_value {
> +       AVRCP_SCAN_OFF                  = 0x01,
> +       AVRCP_SCAN_ALL                  = 0x02,
> +       AVRCP_SCAN_GROUP                = 0x03
> +};
>
> -/* media attributes */
> -#define AVRCP_MEDIA_ATTRIBUTE_ILLEGAL  0x00
> -#define AVRCP_MEDIA_ATTRIBUTE_TITLE    0x01
> -#define AVRCP_MEDIA_ATTRIBUTE_ARTIST   0x02
> -#define AVRCP_MEDIA_ATTRIBUTE_ALBUM    0x03
> -#define AVRCP_MEDIA_ATTRIBUTE_TRACK    0x04
> -#define AVRCP_MEDIA_ATTRIBUTE_N_TRACKS 0x05
> -#define AVRCP_MEDIA_ATTRIBUTE_GENRE    0x06
> -#define AVRCP_MEDIA_ATTRIBUTE_DURATION 0x07
> -#define AVRCP_MEDIA_ATTRIBUTE_LAST     AVRCP_MEDIA_ATTRIBUTE_DURATION
> +enum media_attribute {
> +       AVRCP_MEDIA_ATTRIBUTE_ILLEGAL   = 0x00,
> +       AVRCP_MEDIA_ATTRIBUTE_TITLE     = 0x01,
> +       AVRCP_MEDIA_ATTRIBUTE_ARTIST    = 0x02,
> +       AVRCP_MEDIA_ATTRIBUTE_ALBUM     = 0x03,
> +       AVRCP_MEDIA_ATTRIBUTE_TRACK     = 0x04,
> +       AVRCP_MEDIA_ATTRIBUTE_N_TRACKS  = 0x05,
> +       AVRCP_MEDIA_ATTRIBUTE_GENRE     = 0x06,
> +       AVRCP_MEDIA_ATTRIBUTE_DURATION  = 0x07,
> +       AVRCP_MEDIA_ATTRIBUTE_LAST      = AVRCP_MEDIA_ATTRIBUTE_DURATION
> +};
>
> -/* play status */
> -#define AVRCP_PLAY_STATUS_STOPPED      0x00
> -#define AVRCP_PLAY_STATUS_PLAYING      0x01
> -#define AVRCP_PLAY_STATUS_PAUSED       0x02
> -#define AVRCP_PLAY_STATUS_FWD_SEEK     0x03
> -#define AVRCP_PLAY_STATUS_REV_SEEK     0x04
> -#define AVRCP_PLAY_STATUS_ERROR                0xFF
> +enum play_status {
> +       AVRCP_PLAY_STATUS_STOPPED       = 0x00,
> +       AVRCP_PLAY_STATUS_PLAYING       = 0x01,
> +       AVRCP_PLAY_STATUS_PAUSED        = 0x02,
> +       AVRCP_PLAY_STATUS_FWD_SEEK      = 0x03,
> +       AVRCP_PLAY_STATUS_REV_SEEK      = 0x04,
> +       AVRCP_PLAY_STATUS_ERROR         = 0xFF
> +};
>
> -/* Notification events */
> -#define AVRCP_EVENT_STATUS_CHANGED     0x01
> -#define AVRCP_EVENT_TRACK_CHANGED      0x02
> -#define AVRCP_EVENT_TRACK_REACHED_END  0x03
> -#define AVRCP_EVENT_TRACK_REACHED_START        0x04
> -#define AVRCP_EVENT_VOLUME_CHANGED     0x0d
> -#define AVRCP_EVENT_LAST               AVRCP_EVENT_VOLUME_CHANGED
> +enum notification_event {
> +       AVRCP_EVENT_PLAYBACK_STATUS_CHANGED             = 0x01,
> +       AVRCP_EVENT_TRACK_CHANGED                       = 0x02,
> +       AVRCP_EVENT_TRACK_REACHED_END                   = 0x03,
> +       AVRCP_EVENT_TRACK_REACHED_START                 = 0x04,
> +       AVRCP_EVENT_PLAYBACK_POS_CHANGED                = 0x05,
> +       AVRCP_EVENT_BATT_STATUS_CHANGED                 = 0x06,
> +       AVRCP_EVENT_SYSTEM_STATUS_CHANGED               = 0x07,
> +       AVRCP_EVENT_PLAYER_APPLICATION_SETTING_CHANGED  = 0x08,
> +       AVRCP_EVENT_NOW_PLAYING_CONTENT_CHANGED         = 0x09,
> +       AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED           = 0x0A,
> +       AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED            = 0x0B,
> +       AVRCP_EVENT_VOLUME_CHANGED                      = 0x0D,
> +       AVRCP_EVENT_LAST                                = AVRCP_EVENT_VOLUME_CHANGED
> +};
>
>  struct avrcp_player_cb {
>        int (*get_setting) (uint8_t attr, void *user_data);
> diff --git a/audio/media.c b/audio/media.c
> index 1956653..4e23273 100644
> --- a/audio/media.c
> +++ b/audio/media.c
> @@ -1414,7 +1414,7 @@ static gboolean set_status(struct media_player *mp, DBusMessageIter *iter)
>
>        mp->status = val;
>
> -       avrcp_player_event(mp->player, AVRCP_EVENT_STATUS_CHANGED, &val);
> +       avrcp_player_event(mp->player, AVRCP_EVENT_PLAYBACK_STATUS_CHANGED, &val);
>
>        return TRUE;
>  }
> --
> on behalf of ST-Ericsson
>

Haven't I nak the changes to enum before? What have you changed in v2?

-- 
Luiz Augusto von Dentz

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

* RE: [PATCH v2 01/14] AVRCP: Update constants
  2012-06-27 13:32 ` [PATCH v2 01/14] AVRCP: Update constants Luiz Augusto von Dentz
@ 2012-06-27 14:25   ` Michal.Labedzki
  2012-06-27 16:22     ` Lucas De Marchi
  0 siblings, 1 reply; 18+ messages in thread
From: Michal.Labedzki @ 2012-06-27 14:25 UTC (permalink / raw)
  To: luiz.dentz; +Cc: linux-bluetooth, lucas.demarchi, johan.hedberg

Hi Luiz,


> Haven't I nak the changes to enum before? What have you changed in v2?
>
>--
> Luiz Augusto von Dentz

No. According to Lucas I removed unused constants.
What wrong with enum? Look into sap.h, vhci.h, reporter.h, parser.h, cups.h and... avrcp.c ("enum battery_status" is here)

I have idea to make enum new convention in BlueZ. See sap.h - it looks very clearly for me. Pros for used enum is that enum can be thread as group of constants, mostly constants defined in specification. But "magic constants" should stay define - mostly defined by developer. 
Disadvantage for "define" is that as you can see in BlueZ AVRCP - you must use additional comment to describe group of constants.

Luiz, why "nak"? Could you present your point of view?

Regards / Pozdrawiam
-------------------------------------------------------------------------------------------------------------
Michał Łabędzki
ASCII: Michal Labedzki
e-mail: michal.labedzki@tieto.com
office communicator: michal.labedzki@tieto.com
location: Poland, Wrocław, Legnicka 55F
room: 315
phone: +48 717 740 340
---
Tieto Corporation / Tieto Poland
http://www.tieto.com / http://www.tieto.pl
---
Tieto Poland spółka z ograniczoną odpowiedzialnością z siedzibą w Szczecinie, ul. Malczewskiego 26. Zarejestrowana w Sądzie Rejonowym Szczecin-Centrum w Szczecinie, XIII Wydział Gospodarczy Krajowego Rejestru Sądowego pod numerem 0000124858. NIP: 8542085557. REGON: 812023656. Kapitał zakładowy: 4 271500 PLN

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

* Re: [PATCH v2 01/14] AVRCP: Update constants
  2012-06-27 14:25   ` Michal.Labedzki
@ 2012-06-27 16:22     ` Lucas De Marchi
  2012-06-28 10:10       ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 18+ messages in thread
From: Lucas De Marchi @ 2012-06-27 16:22 UTC (permalink / raw)
  To: Michal.Labedzki
  Cc: luiz.dentz, linux-bluetooth, lucas.demarchi, johan.hedberg

Hi Michal,

On Wed, Jun 27, 2012 at 11:25 AM,  <Michal.Labedzki@tieto.com> wrote:
> Hi Luiz,
>
>
>> Haven't I nak the changes to enum before? What have you changed in v2?
>>
>>--
>> Luiz Augusto von Dentz
>
> No. According to Lucas I removed unused constants.
> What wrong with enum? Look into sap.h, vhci.h, reporter.h, parser.h, cups.h and... avrcp.c ("enum battery_status" is here)

I strongly NACKed this before. Not only because of the unused constants.

>
> I have idea to make enum new convention in BlueZ. See sap.h - it looks very clearly for me. Pros for used enum is that enum can be thread as group of constants, mostly constants defined in specification. But "magic constants" should stay define - mostly defined by developer.
> Disadvantage for "define" is that as you can see in BlueZ AVRCP - you must use additional comment to describe group of constants.

I don't see any advantage in being able to group them. You still have
to define the name by prefixing it with the namespace. If it was
already enum, fine - changing for the sake of change only is not good.

>
> Luiz, why "nak"? Could you present your point of view?

IMO this change doesn't give us anything

Lucas De Marchi

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

* Re: [PATCH v2 01/14] AVRCP: Update constants
  2012-06-27 16:22     ` Lucas De Marchi
@ 2012-06-28 10:10       ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 18+ messages in thread
From: Luiz Augusto von Dentz @ 2012-06-28 10:10 UTC (permalink / raw)
  To: Lucas De Marchi
  Cc: Michal.Labedzki, linux-bluetooth, lucas.demarchi, johan.hedberg

Hi Lucas,

On Wed, Jun 27, 2012 at 7:22 PM, Lucas De Marchi
<lucas.demarchi@profusion.mobi> wrote:
>> No. According to Lucas I removed unused constants.
>> What wrong with enum? Look into sap.h, vhci.h, reporter.h, parser.h, cups.h and... avrcp.c ("enum battery_status" is here)
>
> I strongly NACKed this before. Not only because of the unused constants.
>
>>
>> I have idea to make enum new convention in BlueZ. See sap.h - it looks very clearly for me. Pros for used enum is that enum can be thread as group of constants, mostly constants defined in specification. But "magic constants" should stay define - mostly defined by developer.
>> Disadvantage for "define" is that as you can see in BlueZ AVRCP - you must use additional comment to describe group of constants.
>
> I don't see any advantage in being able to group them. You still have
> to define the name by prefixing it with the namespace. If it was
> already enum, fine - changing for the sake of change only is not good.
>
>>
>> Luiz, why "nak"? Could you present your point of view?
>
> IMO this change doesn't give us anything

Exactly, enum gives us nothing, no type checking or anything, so why bother.

@Michal: As for the rest of the patches, I will apply the typo and
code style fixes that are straightforward, the rest will probably need
rebasing. I specially liked the idea of avrcp_session, it will be
really useful, I guess we can even store the avctp_session on it. As
for the dummy player, my initial take was that it was necessary, but
you are actually not using it as a place holder, instead it just
return errors so in that I would just check if there is no player
available send the proper errors.

-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2012-06-28 10:10 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-27 13:27 [PATCH v2 01/14] AVRCP: Update constants Michal Labedzki
2012-06-27 13:27 ` [PATCH v2 02/14] doc: Fix typo Michal Labedzki
2012-06-27 13:27 ` [PATCH v2 03/14] media: Rename set_property to set_player_property Michal Labedzki
2012-06-27 13:27 ` [PATCH v2 04/14] AVRCP: Use name "addressed" instead of "active" Michal Labedzki
2012-06-27 13:27 ` [PATCH v2 05/14] AVRCP: Convert spaces to tabs Michal Labedzki
2012-06-27 13:27 ` [PATCH v2 06/14] AVRCP: Keep AVRCP version of connected device in session Michal Labedzki
2012-06-27 13:27 ` [PATCH v2 07/14] AVRCP: Move profile specific fields from players Michal Labedzki
2012-06-27 13:27 ` [PATCH v2 08/14] AVRCP: Register AVRCP before MEDIA interface Michal Labedzki
2012-06-27 13:27 ` [PATCH v2 09/14] AVRCP: Implement notification AVAILABLE_PLAYERS_CHANGED Michal Labedzki
2012-06-27 13:27 ` [PATCH v2 10/14] media: Add support for changing addressed player Michal Labedzki
2012-06-27 13:27 ` [PATCH v2 11/14] AVRCP: Implement setting AddressedPlayer with notifications completion Michal Labedzki
2012-06-27 13:27 ` [PATCH v2 12/14] AVRCP: Use NoAvailablePlayers status code for AVRCP 1.4 devices Michal Labedzki
2012-06-27 13:27 ` [PATCH v2 13/14] AVRCP: Implement notification ADDRESSED_PLAYER_CHANGED Michal Labedzki
2012-06-27 13:27 ` [PATCH v2 14/14] AVRCP: Handle SetAddressedPlayer command from remote controller Michal Labedzki
2012-06-27 13:32 ` [PATCH v2 01/14] AVRCP: Update constants Luiz Augusto von Dentz
2012-06-27 14:25   ` Michal.Labedzki
2012-06-27 16:22     ` Lucas De Marchi
2012-06-28 10:10       ` Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.