From: Simon Mikuda <simon.mikuda@streamunlimited.com>
To: linux-bluetooth@vger.kernel.org
Cc: Simon Mikuda <simon.mikuda@streamunlimited.com>
Subject: [PATCH BlueZ 8/8] player: Fix NumberOfItems of Now Playing after its content changed
Date: Sun, 22 Nov 2026 11:57:31 +0100 [thread overview]
Message-ID: <20261122105731.799090-9-simon.mikuda@streamunlimited.com> (raw)
In-Reply-To: <20261122105731.799090-1-simon.mikuda@streamunlimited.com>
NOW_PLAYING_CONTENT_CHANGED clears the Now Playing items but keeps the
number of items, which is requested again only when the scope changes,
and ListItems does not list past it. So a controller that stays in Now
Playing lists a grown list cut at its old length.
To reproduce, list the 2 items of Now Playing, let the target add 3
items, and list Now Playing again:
btmon: EventID: 0x09 (EVENT_NOW_PLAYING_CONTENT_CHANGED)
avrcp_now_playing_changed() NowPlaying changed
bluetoothd: profiles/audio/player.c:get_items() 2
btmon: AVRCP: GetFolderItems: len 0x0022
btmon: Scope: 0x03 (Now Playing)
btmon: StartItem: 0x00000000 (0)
btmon: EndItem: 0x00000001 (1)
avrcp_list_items_rsp() start 0 end 1 items 2 total 2
Only the 2 items listed before are listed again.
Reset the number of items, so that ListItems leaves the end of the list
to the target until it is known again, and request it again when Now
Playing is the current folder.
Fixes: 671f370a8e34 ("audio/player: Clear playlist on Now Playing Changed AVRCP event")
Assisted-by: Claude:claude-opus-5-5
---
profiles/audio/player.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/profiles/audio/player.c b/profiles/audio/player.c
index d4dbe1b59..a24c51952 100644
--- a/profiles/audio/player.c
+++ b/profiles/audio/player.c
@@ -2067,9 +2067,28 @@ struct media_item *media_player_set_playlist_item(struct media_player *mp,
void media_player_clear_playlist(struct media_player *mp)
{
+ struct player_callback *cb = mp->cb;
+
if (mp->playlist) {
g_slist_free_full(mp->playlist->items, media_item_destroy);
mp->playlist->items = NULL;
+
+ /*
+ * The number of items may have changed: leave the end of the
+ * list to the target until it is known again.
+ */
+ mp->playlist->number_of_items = 0;
+ }
+
+ if (mp->playlist && mp->scope == mp->playlist) {
+ g_dbus_emit_property_changed(btd_get_dbus_connection(),
+ mp->path,
+ MEDIA_FOLDER_INTERFACE,
+ "NumberOfItems");
+
+ if (cb->cbs->total_items)
+ cb->cbs->total_items(mp, mp->scope->item->name,
+ cb->user_data);
}
g_dbus_emit_property_changed(btd_get_dbus_connection(), mp->path,
--
2.43.0
prev parent reply other threads:[~2026-11-22 10:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 10:57 [PATCH BlueZ 0/8] AVRCP browsing fixes, and browsing and cover art in the target role Simon Mikuda
2026-11-22 10:57 ` [PATCH BlueZ 1/8] avrcp: Fix not checking browsing PDU parameter length Simon Mikuda
2026-11-22 18:57 ` AVRCP browsing fixes, and browsing and cover art in the target role bluez.test.bot
2026-11-22 10:57 ` [PATCH BlueZ 2/8] avrcp: Fix listing media players up to item 0xffffffff Simon Mikuda
2026-11-22 10:57 ` [PATCH BlueZ 3/8] avrcp: Fix byte order of ADDRESSED_PLAYER_CHANGED notification Simon Mikuda
2026-11-22 10:57 ` [PATCH BlueZ 4/8] avrcp: Fix byte order of TRACK_CHANGED identifier Simon Mikuda
2026-11-22 10:57 ` [PATCH BlueZ 5/8] avrcp: Fix not browsing a player addressed before it was listed Simon Mikuda
2026-11-22 10:57 ` [PATCH BlueZ 6/8] player: Fix crash on Search in a folder with a space in its name Simon Mikuda
2026-11-22 10:57 ` [PATCH BlueZ 7/8] player: Fix missing Name of listed Now Playing items Simon Mikuda
2026-11-22 10:57 ` Simon Mikuda [this message]
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=20261122105731.799090-9-simon.mikuda@streamunlimited.com \
--to=simon.mikuda@streamunlimited.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