diff options
| author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2015-05-07 16:55:19 +0300 |
|---|---|---|
| committer | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2017-02-02 14:51:59 +0000 |
| commit | c758d900fd09190bfec93efd0dc6c6afcc20a373 (patch) | |
| tree | ce2dcedd7a82c6355af819a1ee003f4d375519f0 | |
| parent | 2cc3810bb62c43d8bf22ed4406617a1c304cb041 (diff) | |
| download | bluez-c758d900fd09190bfec93efd0dc6c6afcc20a373.tar.gz | |
audio/player: Resync if Position property is read
Request position to be resync if status is playing and position is
supported.
| -rw-r--r-- | profiles/audio/avrcp.c | 18 | ||||
| -rw-r--r-- | profiles/audio/player.c | 5 | ||||
| -rw-r--r-- | profiles/audio/player.h | 1 |
3 files changed, 24 insertions, 0 deletions
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index a7f395ecf..0941e049d 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -2870,6 +2870,23 @@ done: set_browsed_player(session, player); } +static bool ct_get_position(struct media_player *mp, void *user_data) +{ + struct avrcp_player *player = user_data; + struct avrcp *session; + + session = player->sessions->data; + if (session == NULL) + return false; + + if (session->controller->version < 0x0103) + return false; + + avrcp_get_play_status(session); + + return true; +} + static bool ct_set_setting(struct media_player *mp, const char *key, const char *value, void *user_data) { @@ -3268,6 +3285,7 @@ static int ct_get_total_numberofitems(struct media_player *mp, const char *name, } static const struct media_player_callback ct_cbs = { + .get_position = ct_get_position, .set_setting = ct_set_setting, .play = ct_play, .pause = ct_pause, diff --git a/profiles/audio/player.c b/profiles/audio/player.c index 7944b493e..2c8aa75e6 100644 --- a/profiles/audio/player.c +++ b/profiles/audio/player.c @@ -169,12 +169,17 @@ static gboolean get_position(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { struct media_player *mp = data; + struct player_callback *cb = mp->cb; uint32_t position; position = media_player_get_position(mp); dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &position); + /* Trigger a resync if position has drifted more than a sec */ + if (abs(position - mp->position) > 1000) + cb->cbs->get_position(mp, cb->user_data); + return TRUE; } diff --git a/profiles/audio/player.h b/profiles/audio/player.h index 54e395a13..bd5e3a00f 100644 --- a/profiles/audio/player.h +++ b/profiles/audio/player.h @@ -45,6 +45,7 @@ struct media_player; struct media_item; struct media_player_callback { + bool (*get_position) (struct media_player *mp, void *user_data); bool (*set_setting) (struct media_player *mp, const char *key, const char *value, void *user_data); int (*play) (struct media_player *mp, void *user_data); |
