From: raghu447 <raghavendra.rao@collabora.com>
To: linux-bluetooth@vger.kernel.org
Cc: raghavendra <raghavendra.rao@collabora.com>
Subject: [PATCH 1/4] profiles/audio: Support MCS track position writes
Date: Fri, 4 Sep 2026 22:23:29 +0530 [thread overview]
Message-ID: <20260904165332.42046-2-raghavendra.rao@collabora.com> (raw)
In-Reply-To: <20260904165332.42046-1-raghavendra.rao@collabora.com>
From: raghavendra <raghavendra.rao@collabora.com>
Use MPRIS Seek to handle MCS Track Position writes.
This is required by PTS GMCS/SR/SP/BV-02-C test.
---
profiles/audio/mcp.c | 22 ++++++++++++++++++++--
profiles/audio/media.c | 32 ++++++++++++++++++++++++++++++++
profiles/audio/media.h | 1 +
3 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/profiles/audio/mcp.c b/profiles/audio/mcp.c
index 8adf814e8..2d239ac4b 100644
--- a/profiles/audio/mcp.c
+++ b/profiles/audio/mcp.c
@@ -795,8 +795,26 @@ static uint16_t mcs_playing_order_supported(void *data)
static bool mcs_set_track_position(void *data, int32_t value)
{
- /* TODO: add support to setting position in org.bluez.MediaPlayer */
- return false;
+ struct mcs_instance *mcs = data;
+ struct player_link *p = mcs_get_active(mcs);
+ int64_t position_centisec = value;
+
+ if (!p)
+ return false;
+
+ if (value < 0) {
+ int32_t duration_centisec = mcs_track_duration(mcs);
+
+ if (duration_centisec == BT_MCS_DURATION_UNAVAILABLE)
+ return false;
+
+ position_centisec += duration_centisec;
+ }
+
+ /* Convert MCS centiseconds to a relative MPRIS microsecond offset. */
+ return local_player_seek(p->lp, (position_centisec * 10 -
+ local_player_get_position(p->lp)) *
+ G_TIME_SPAN_MILLISECOND);
}
static bool mcs_set_playing_order(void *data, uint8_t value)
diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index 95f9580b0..82117a2ed 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
@@ -157,6 +157,7 @@ struct local_player {
GTimer *timer;
bool play;
bool pause;
+ bool seek;
bool next;
bool previous;
bool control;
@@ -2296,6 +2297,29 @@ bool local_player_pause(struct local_player *mp)
return local_player_send(mp, "Pause");
}
+bool local_player_seek(struct local_player *mp, int64_t offset_usec)
+{
+ DBusMessage *msg;
+
+ DBG("");
+
+ if (!mp->seek || !mp->control)
+ return false;
+
+ msg = dbus_message_new_method_call(mp->sender, mp->path,
+ MEDIA_PLAYER_INTERFACE, "Seek");
+ if (msg == NULL) {
+ error("Couldn't allocate D-Bus message");
+ return false;
+ }
+
+ dbus_message_append_args(msg, DBUS_TYPE_INT64, &offset_usec,
+ DBUS_TYPE_INVALID);
+ g_dbus_send_message(btd_get_dbus_connection(), msg);
+
+ return true;
+}
+
bool local_player_next(struct local_player *mp)
{
DBG("");
@@ -2673,6 +2697,9 @@ static gboolean set_player_property(struct local_player *mp, const char *key,
if (strcasecmp(key, "CanPause") == 0)
return set_flag(mp, &var, &mp->pause);
+ if (strcasecmp(key, "CanSeek") == 0)
+ return set_flag(mp, &var, &mp->seek);
+
if (strcasecmp(key, "CanGoNext") == 0)
return set_flag(mp, &var, &mp->next);
@@ -3247,6 +3274,11 @@ static void app_register_player(void *data, void *user_data)
goto fail;
}
+ if (g_dbus_proxy_get_property(proxy, "CanSeek", &iter)) {
+ if (!set_flag(player, &iter, &player->seek))
+ goto fail;
+ }
+
if (g_dbus_proxy_get_property(proxy, "CanGoNext", &iter)) {
if (!set_flag(player, &iter, &player->next))
goto fail;
diff --git a/profiles/audio/media.h b/profiles/audio/media.h
index 1c43075ba..43a85b1d6 100644
--- a/profiles/audio/media.h
+++ b/profiles/audio/media.h
@@ -73,6 +73,7 @@ bool local_player_have_track(struct local_player *lp);
bool local_player_play(struct local_player *lp);
bool local_player_stop(struct local_player *lp);
bool local_player_pause(struct local_player *lp);
+bool local_player_seek(struct local_player *lp, int64_t offset_usec);
bool local_player_next(struct local_player *lp);
bool local_player_previous(struct local_player *lp);
--
2.43.0
next prev parent reply other threads:[~2026-09-04 16:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 6:11 [BlueZ PATCH 0/3] Add MCS fast seek and track position write raghu447
2026-08-31 6:11 ` [BlueZ PATCH 1/3] profiles/audio: Support MCS fast seeking raghu447
2026-09-02 15:31 ` Luiz Augusto von Dentz
2026-08-31 6:11 ` [BlueZ PATCH 2/3] profiles/audio: Support MCS track position writes raghu447
2026-09-02 15:35 ` Luiz Augusto von Dentz
2026-09-03 8:19 ` Bastien Nocera
2026-09-04 16:53 ` [PATCH 0/4] Add MCS fast seek and track position write support raghu447
2026-09-04 16:53 ` raghu447 [this message]
2026-09-04 17:51 ` bluez.test.bot
2026-09-04 16:53 ` [PATCH 2/4] profiles/audio: Support MCS fast seeking raghu447
2026-09-04 16:53 ` [PATCH 3/4] shared/mcp: Notify unsupported RFU opcodes raghu447
2026-09-04 16:53 ` [PATCH 4/4] unit/test-mcp: Test unsupported RFU opcode raghu447
2026-09-04 20:20 ` [PATCH 0/4] Add MCS fast seek and track position write support patchwork-bot+bluetooth
2026-08-31 6:11 ` [BlueZ PATCH 3/3] shared/mcp: Notify unsupported RFU opcodes raghu447
2026-09-02 15:36 ` Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260904165332.42046-2-raghavendra.rao@collabora.com \
--to=raghavendra.rao@collabora.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox