Reverted back track_id as hex string

This commit is contained in:
zutroy97
2026-07-05 17:45:24 -05:00
parent 0c946ea040
commit 0e37b5adcf
+9 -8
View File
@@ -85,9 +85,9 @@ void on_message(__attribute__((unused)) struct mosquitto *mosq,
debug(2, "[MQTT]: Disconnect Command: %s\n", commands[it]);
stop_play(); // stop any current session and don't replace it
} else if (strcmp(commands[it], "queue_next") == 0) {
// payload is "queue_next <track_id>", where <track_id> is the decimal track_id
// payload is "queue_next <track_id>", where <track_id> is the hex track_id
// string as published by shairport-sync itself (see the "mper"/"track_id" handling
// above), e.g. "queue_next 123456789012345"
// above), e.g. "queue_next 1A2B3C4D5E6F7"
char *track_id = payload + strlen(commands[it]);
while (*track_id == ' ' || *track_id == '\t')
track_id++;
@@ -99,7 +99,7 @@ void on_message(__attribute__((unused)) struct mosquitto *mosq,
} else {
char dacp_command[256];
snprintf(dacp_command, sizeof(dacp_command),
"cue?command=add&query='dmap.persistentid:%s'&mode=3", track_id);
"cue?command=add&query='dmap.persistentid:0x%s'&mode=3", track_id);
debug(2, "[MQTT]: Queue Next Command: %s\n", dacp_command);
send_simple_dacp_command(dacp_command);
}
@@ -322,7 +322,6 @@ void mqtt_process_metadata(uint32_t type, uint32_t code, char *data, uint32_t le
if (config.mqtt_publish_parsed) {
if (type == 'core') {
int32_t r;
uint64_t trackid;
char trackidstring[32];
switch (code) {
@@ -342,10 +341,12 @@ void mqtt_process_metadata(uint32_t type, uint32_t code, char *data, uint32_t le
mqtt_publish("title", data, length);
break;
case 'mper':
trackid = ntohl(*(uint32_t *)data);
trackid = trackid << 32;
trackid += ntohl(*(uint32_t *)(data + sizeof(uint32_t)));
r = snprintf(trackidstring, sizeof(trackidstring), "%" PRIu64 "", trackid);
// publish the raw persistent-id bytes as hex, in the order received --
// no byte-order or integer conversion, so this can't reverse the value.
r = 0;
for (uint32_t i = 0; i < length && r < (int32_t)sizeof(trackidstring) - 2; i++)
r += snprintf(trackidstring + r, sizeof(trackidstring) - (size_t)r, "%02X",
(unsigned char)data[i]);
mqtt_publish("track_id", trackidstring, r);
}
} else if (type == 'ssnc') {