Treat the "mper" attribute as the 64-bit item that it is rather than a 32-bit item as hithereto. Output it as a hexadecimal number to correspond with the format of the track id obtained from AppleScript
This commit is contained in:
+3
-2
@@ -27,6 +27,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@@ -204,7 +205,7 @@ void dbus_metadata_watcher(struct metadata_bundle *argc, __attribute__((unused))
|
||||
// Add in the Track ID based on the 'mper' metadata if it is non-zero
|
||||
if (argc->item_id != 0) {
|
||||
char trackidstring[128];
|
||||
snprintf(trackidstring, sizeof(trackidstring), "/org/gnome/ShairportSync/mper_%u",
|
||||
snprintf(trackidstring, sizeof(trackidstring), "/org/gnome/ShairportSync/%" PRIX64 "",
|
||||
argc->item_id);
|
||||
GVariant *trackid = g_variant_new("o", trackidstring);
|
||||
g_variant_builder_add(dict_builder, "{sv}", "mpris:trackid", trackid);
|
||||
@@ -517,7 +518,7 @@ gboolean notify_convolution_impulse_response_file_callback(ShairportSync *skelet
|
||||
#else
|
||||
gboolean notify_convolution_impulse_response_file_callback(__attribute__((unused)) ShairportSync *skeleton,
|
||||
__attribute__((unused)) gpointer user_data) {
|
||||
char *th = (char *)shairport_sync_get_convolution_impulse_response_file(skeleton);
|
||||
__attribute__((unused)) char *th = (char *)shairport_sync_get_convolution_impulse_response_file(skeleton);
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
+24
-18
@@ -5,7 +5,7 @@
|
||||
* then you need a metadata hub,
|
||||
* where everything is stored
|
||||
* This file is part of Shairport Sync.
|
||||
* Copyright (c) Mike Brady 2017--2019
|
||||
* Copyright (c) Mike Brady 2017--2020
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@@ -303,28 +304,33 @@ void metadata_hub_process_metadata(uint32_t type, uint32_t code, char *data, uin
|
||||
// all the following items of metadata are contained in one metadata packet
|
||||
// they are preceded by an 'ssnc' 'mdst' item and followed by an 'ssnc 'mden' item.
|
||||
|
||||
uint32_t ui;
|
||||
char *cs;
|
||||
int changed = 0;
|
||||
if (type == 'core') {
|
||||
switch (code) {
|
||||
case 'mper':
|
||||
ui = ntohl(*(uint32_t *)data);
|
||||
debug(2, "MH Item ID seen: \"%u\" of length %u.", ui, length);
|
||||
if (ui != metadata_store.item_id) {
|
||||
metadata_store.item_id = ui;
|
||||
metadata_store.item_id_changed = 1;
|
||||
metadata_store.item_id_received = 1;
|
||||
debug(2, "MH Item ID set to: \"%u\"", metadata_store.item_id);
|
||||
}
|
||||
case 'mper': {
|
||||
// get the 64-bit number as a uint64_t by reading two uint32_t s and combining them
|
||||
uint64_t vl = ntohl(*(uint32_t*)data); // get the high order 32 bits
|
||||
vl = vl << 32; // shift them into the correct location
|
||||
uint64_t ul = ntohl(*(uint32_t*)(data+sizeof(uint32_t))); // and the low order 32 bits
|
||||
vl = vl + ul;
|
||||
debug(2, "MH Item ID seen: \"%" PRIx64 "\" of length %u.", vl, length);
|
||||
if (vl != metadata_store.item_id) {
|
||||
metadata_store.item_id = vl;
|
||||
metadata_store.item_id_changed = 1;
|
||||
metadata_store.item_id_received = 1;
|
||||
debug(2, "MH Item ID set to: \"%" PRIx64 "\"", metadata_store.item_id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'astm':
|
||||
ui = ntohl(*(uint32_t *)data);
|
||||
debug(2, "MH Song Time seen: \"%u\" of length %u.", ui, length);
|
||||
if (ui != metadata_store.songtime_in_milliseconds) {
|
||||
metadata_store.songtime_in_milliseconds = ui;
|
||||
metadata_store.songtime_in_milliseconds_changed = 1;
|
||||
debug(2, "MH Song Time set to: \"%u\"", metadata_store.songtime_in_milliseconds);
|
||||
case 'astm': {
|
||||
uint32_t ui = ntohl(*(uint32_t *)data);
|
||||
debug(2, "MH Song Time seen: \"%u\" of length %u.", ui, length);
|
||||
if (ui != metadata_store.songtime_in_milliseconds) {
|
||||
metadata_store.songtime_in_milliseconds = ui;
|
||||
metadata_store.songtime_in_milliseconds_changed = 1;
|
||||
debug(2, "MH Song Time set to: \"%u\"", metadata_store.songtime_in_milliseconds);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'asal':
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ typedef struct metadata_bundle {
|
||||
char *cover_art_pathname;
|
||||
int cover_art_pathname_changed;
|
||||
|
||||
uint32_t item_id; // seems to be a track ID -- see itemid in DACP.c
|
||||
uint64_t item_id; // seems to be a track ID -- see itemid in DACP.c
|
||||
int item_id_changed;
|
||||
int item_id_received; // important for deciding if the track information should be ignored.
|
||||
|
||||
|
||||
+2
-2
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@@ -174,8 +175,7 @@ void mpris_metadata_watcher(struct metadata_bundle *argc, __attribute__((unused)
|
||||
// Add in the Track ID based on the 'mper' metadata if it is non-zero
|
||||
if (argc->item_id != 0) {
|
||||
char trackidstring[128];
|
||||
snprintf(trackidstring, sizeof(trackidstring), "/org/gnome/ShairportSync/mper_%u",
|
||||
argc->item_id);
|
||||
snprintf(trackidstring, sizeof(trackidstring), "/org/gnome/ShairportSync/%" PRIX64 "", argc->item_id);
|
||||
GVariant *trackid = g_variant_new("o", trackidstring);
|
||||
g_variant_builder_add(dict_builder, "{sv}", "mpris:trackid", trackid);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user