summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md5
-rw-r--r--binding/bluetooth-api.c10
-rw-r--r--binding/bluetooth-api.h4
3 files changed, 12 insertions, 7 deletions
diff --git a/README.md b/README.md
index fcfd0a1..85150c7 100644
--- a/README.md
+++ b/README.md
@@ -303,8 +303,9 @@ Playing audio reporting event (not all fields will be passed in every event):
"genre": "Dance & DJ/General"
},
"position": 5600,
- "status": "playing"
- "connected": false
+ "status": "playing",
+ "connected": true,
+ "player": "player0"
}
</pre>
diff --git a/binding/bluetooth-api.c b/binding/bluetooth-api.c
index 8fdb0f8..8905c6a 100644
--- a/binding/bluetooth-api.c
+++ b/binding/bluetooth-api.c
@@ -356,13 +356,14 @@ static void bluez_devices_signal_callback(
event = ns->media_event;
}
json_object_object_add(jresp, "properties", jobj);
- } else if (is_mediaplayer1_interface(path) &&
- g_str_has_suffix(path, BLUEZ_DEFAULT_PLAYER)) {
-
+ } else if (is_mediaplayer1_interface(path)) {
+ gchar *player = find_index(path, 5);
json_object_object_add(jresp, "connected",
json_object_new_boolean(TRUE));
json_object_object_add(jresp, "type",
json_object_new_string("playback"));
+ json_object_object_add(jresp, "player",
+ json_object_new_string(player));
mediaplayer1_set_path(ns, path);
event = ns->media_event;
} else {
@@ -390,10 +391,13 @@ static void bluez_devices_signal_callback(
event = ns->media_event;
} else if (is_mediaplayer1_interface(path)) {
+ gchar *player = find_index(path, 5);
json_object_object_add(jresp, "connected",
json_object_new_boolean(FALSE));
json_object_object_add(jresp, "type",
json_object_new_string("playback"));
+ json_object_object_add(jresp, "player",
+ json_object_new_string(player));
event = ns->media_event;
/* adapter removal */
} else if (split_length(path) == 4) {
diff --git a/binding/bluetooth-api.h b/binding/bluetooth-api.h
index 6b24d13..a0b807b 100644
--- a/binding/bluetooth-api.h
+++ b/binding/bluetooth-api.h
@@ -116,9 +116,9 @@ static inline gboolean is_mediaplayer1_interface(const char *path)
if (split_length(path) != 6)
return FALSE;
- // TODO: allow mutiple players per device
+ // Check for 'playerX' suffix, not always player0
data = find_index(path, 5);
- ret = !g_strcmp0(data, BLUEZ_DEFAULT_PLAYER);
+ ret = !strncmp(data, BLUEZ_DEFAULT_PLAYER, sizeof(BLUEZ_DEFAULT_PLAYER) - 1);
g_free(data);
return ret;