* [PATCH BlueZ 1/2] audio/avrcp: Use position changed event to resync
@ 2015-05-06 14:08 Luiz Augusto von Dentz
2015-05-06 14:08 ` [PATCH BlueZ 2/2] policy: Fix not incrementing attempts Luiz Augusto von Dentz
2015-05-07 8:26 ` [PATCH BlueZ 1/2] audio/avrcp: Use position changed event to resync Luiz Augusto von Dentz
0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2015-05-06 14:08 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Some player do not change state when backward is pressed only once,
instead it will just start the track from the beginning.
To fix this subscribe to playback position changed event since it is
mandatory to be sent in the following conditions:
- TG has reached the registered playback Interval time.
- Changed PLAY STATUS.
- Changed Current Track.
- Reached end or beginning of track.
---
profiles/audio/avrcp.c | 23 +++++++++++++++++++++++
profiles/audio/avrcp.h | 1 +
2 files changed, 24 insertions(+)
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index cc26eed..245b3fc 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -3084,6 +3084,17 @@ static void avrcp_track_changed(struct avrcp *session,
avrcp_get_element_attributes(session);
}
+static void avrcp_playback_pos_changed(struct avrcp *session,
+ struct avrcp_header *pdu)
+{
+ struct avrcp_player *player = session->controller->player;
+ struct media_player *mp = player->user_data;
+ uint32_t position;
+
+ position = get_be32(&pdu->params[1]);
+ media_player_set_position(mp, position);
+}
+
static void avrcp_setting_changed(struct avrcp *session,
struct avrcp_header *pdu)
{
@@ -3177,6 +3188,9 @@ static gboolean avrcp_handle_event(struct avctp *conn,
case AVRCP_EVENT_TRACK_CHANGED:
avrcp_track_changed(session, pdu);
break;
+ case AVRCP_EVENT_PLAYBACK_POS_CHANGED:
+ avrcp_playback_pos_changed(session, pdu);
+ break;
case AVRCP_EVENT_SETTINGS_CHANGED:
avrcp_setting_changed(session, pdu);
break;
@@ -3208,6 +3222,14 @@ static void avrcp_register_notification(struct avrcp *session, uint8_t event)
pdu->pdu_id = AVRCP_REGISTER_NOTIFICATION;
pdu->packet_type = AVRCP_PACKET_TYPE_SINGLE;
pdu->params[0] = event;
+
+ /*
+ * Set maximum interval possible for position changed as we only
+ * use it to resync.
+ */
+ if (event == AVRCP_EVENT_PLAYBACK_POS_CHANGED)
+ bt_put_be32(UINT32_MAX, &pdu->params[1]);
+
pdu->params_len = htons(AVRCP_REGISTER_NOTIFICATION_PARAM_LENGTH);
length = AVRCP_HEADER_LENGTH + ntohs(pdu->params_len);
@@ -3248,6 +3270,7 @@ static gboolean avrcp_get_capabilities_resp(struct avctp *conn,
switch (event) {
case AVRCP_EVENT_STATUS_CHANGED:
case AVRCP_EVENT_TRACK_CHANGED:
+ case AVRCP_EVENT_PLAYBACK_POS_CHANGED:
case AVRCP_EVENT_SETTINGS_CHANGED:
case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED:
case AVRCP_EVENT_UIDS_CHANGED:
diff --git a/profiles/audio/avrcp.h b/profiles/audio/avrcp.h
index 6ac5294..a9aeb1a 100644
--- a/profiles/audio/avrcp.h
+++ b/profiles/audio/avrcp.h
@@ -74,6 +74,7 @@
#define AVRCP_EVENT_TRACK_CHANGED 0x02
#define AVRCP_EVENT_TRACK_REACHED_END 0x03
#define AVRCP_EVENT_TRACK_REACHED_START 0x04
+#define AVRCP_EVENT_PLAYBACK_POS_CHANGED 0x05
#define AVRCP_EVENT_SETTINGS_CHANGED 0x08
#define AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED 0x0a
#define AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED 0x0b
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH BlueZ 2/2] policy: Fix not incrementing attempts
2015-05-06 14:08 [PATCH BlueZ 1/2] audio/avrcp: Use position changed event to resync Luiz Augusto von Dentz
@ 2015-05-06 14:08 ` Luiz Augusto von Dentz
2015-05-07 8:26 ` [PATCH BlueZ 1/2] audio/avrcp: Use position changed event to resync Luiz Augusto von Dentz
1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2015-05-06 14:08 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The number of attempts and intervals maybe different causing the attempts
to not be incremented properly.
---
plugins/policy.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/plugins/policy.c b/plugins/policy.c
index 7687203..6bb8268 100644
--- a/plugins/policy.c
+++ b/plugins/policy.c
@@ -683,6 +683,8 @@ static void reconnect_set_timer(struct reconnect_data *reconnect)
{
static int timeout = 0;
+ reconnect->attempt++;
+
if (reconnect->attempt < reconnect_intervals_len)
timeout = reconnect_intervals[reconnect->attempt];
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH BlueZ 1/2] audio/avrcp: Use position changed event to resync
2015-05-06 14:08 [PATCH BlueZ 1/2] audio/avrcp: Use position changed event to resync Luiz Augusto von Dentz
2015-05-06 14:08 ` [PATCH BlueZ 2/2] policy: Fix not incrementing attempts Luiz Augusto von Dentz
@ 2015-05-07 8:26 ` Luiz Augusto von Dentz
1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2015-05-07 8:26 UTC (permalink / raw)
To: linux-bluetooth
Hi,
On Wed, May 6, 2015 at 5:08 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> Some player do not change state when backward is pressed only once,
> instead it will just start the track from the beginning.
>
> To fix this subscribe to playback position changed event since it is
> mandatory to be sent in the following conditions:
>
> - TG has reached the registered playback Interval time.
> - Changed PLAY STATUS.
> - Changed Current Track.
> - Reached end or beginning of track.
> ---
> profiles/audio/avrcp.c | 23 +++++++++++++++++++++++
> profiles/audio/avrcp.h | 1 +
> 2 files changed, 24 insertions(+)
>
> diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
> index cc26eed..245b3fc 100644
> --- a/profiles/audio/avrcp.c
> +++ b/profiles/audio/avrcp.c
> @@ -3084,6 +3084,17 @@ static void avrcp_track_changed(struct avrcp *session,
> avrcp_get_element_attributes(session);
> }
>
> +static void avrcp_playback_pos_changed(struct avrcp *session,
> + struct avrcp_header *pdu)
> +{
> + struct avrcp_player *player = session->controller->player;
> + struct media_player *mp = player->user_data;
> + uint32_t position;
> +
> + position = get_be32(&pdu->params[1]);
> + media_player_set_position(mp, position);
> +}
> +
> static void avrcp_setting_changed(struct avrcp *session,
> struct avrcp_header *pdu)
> {
> @@ -3177,6 +3188,9 @@ static gboolean avrcp_handle_event(struct avctp *conn,
> case AVRCP_EVENT_TRACK_CHANGED:
> avrcp_track_changed(session, pdu);
> break;
> + case AVRCP_EVENT_PLAYBACK_POS_CHANGED:
> + avrcp_playback_pos_changed(session, pdu);
> + break;
> case AVRCP_EVENT_SETTINGS_CHANGED:
> avrcp_setting_changed(session, pdu);
> break;
> @@ -3208,6 +3222,14 @@ static void avrcp_register_notification(struct avrcp *session, uint8_t event)
> pdu->pdu_id = AVRCP_REGISTER_NOTIFICATION;
> pdu->packet_type = AVRCP_PACKET_TYPE_SINGLE;
> pdu->params[0] = event;
> +
> + /*
> + * Set maximum interval possible for position changed as we only
> + * use it to resync.
> + */
> + if (event == AVRCP_EVENT_PLAYBACK_POS_CHANGED)
> + bt_put_be32(UINT32_MAX, &pdu->params[1]);
> +
> pdu->params_len = htons(AVRCP_REGISTER_NOTIFICATION_PARAM_LENGTH);
>
> length = AVRCP_HEADER_LENGTH + ntohs(pdu->params_len);
> @@ -3248,6 +3270,7 @@ static gboolean avrcp_get_capabilities_resp(struct avctp *conn,
> switch (event) {
> case AVRCP_EVENT_STATUS_CHANGED:
> case AVRCP_EVENT_TRACK_CHANGED:
> + case AVRCP_EVENT_PLAYBACK_POS_CHANGED:
> case AVRCP_EVENT_SETTINGS_CHANGED:
> case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED:
> case AVRCP_EVENT_UIDS_CHANGED:
> diff --git a/profiles/audio/avrcp.h b/profiles/audio/avrcp.h
> index 6ac5294..a9aeb1a 100644
> --- a/profiles/audio/avrcp.h
> +++ b/profiles/audio/avrcp.h
> @@ -74,6 +74,7 @@
> #define AVRCP_EVENT_TRACK_CHANGED 0x02
> #define AVRCP_EVENT_TRACK_REACHED_END 0x03
> #define AVRCP_EVENT_TRACK_REACHED_START 0x04
> +#define AVRCP_EVENT_PLAYBACK_POS_CHANGED 0x05
> #define AVRCP_EVENT_SETTINGS_CHANGED 0x08
> #define AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED 0x0a
> #define AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED 0x0b
> --
> 2.1.0
Applied,
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-05-07 8:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-06 14:08 [PATCH BlueZ 1/2] audio/avrcp: Use position changed event to resync Luiz Augusto von Dentz
2015-05-06 14:08 ` [PATCH BlueZ 2/2] policy: Fix not incrementing attempts Luiz Augusto von Dentz
2015-05-07 8:26 ` [PATCH BlueZ 1/2] audio/avrcp: Use position changed event to resync 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.