diff mbox series

[BlueZ] player: Fix Track being emitted with empty metadata

Message ID 20220215205012.2130772-1-luiz.dentz@gmail.com
State New
Headers show
Series [BlueZ] player: Fix Track being emitted with empty metadata | expand

Commit Message

Luiz Augusto von Dentz Feb. 15, 2022, 8:50 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This sometimes causes the Track to be schedule while some metadata are
still pending.

Fixes: https://github.com/bluez/bluez/issues/291
---
 profiles/audio/player.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/profiles/audio/player.c b/profiles/audio/player.c
index d34b39168..687614b49 100644
--- a/profiles/audio/player.c
+++ b/profiles/audio/player.c
@@ -1308,9 +1308,14 @@  void media_player_set_duration(struct media_player *mp, uint32_t duration)
 
 	g_hash_table_replace(mp->track, g_strdup("Duration"), value);
 
-	g_dbus_emit_property_changed(btd_get_dbus_connection(),
+	/* If metadata is pending wait for it */
+	if (mp->process_id)
+		return;
+
+	g_dbus_emit_property_changed_full(btd_get_dbus_connection(),
 					mp->path, MEDIA_PLAYER_INTERFACE,
-					"Track");
+					"Track",
+					G_DBUS_PROPERTY_CHANGED_FLAG_FLUSH);
 }
 
 void media_player_set_position(struct media_player *mp, uint32_t position)