From: Mike Brady Date: Sun, 8 Sep 2019 14:53:52 +0000 (+0100) Subject: Only send shuffle commands if a change is necessary X-Git-Tag: 3.3.3~2^2~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=839c778a7c999bf7b8bdd7ca54b5c9df98e7fcb2;p=thirdparty%2Fshairport-sync.git Only send shuffle commands if a change is necessary --- diff --git a/dbus-service.c b/dbus-service.c index 2294a706..2393675b 100644 --- a/dbus-service.c +++ b/dbus-service.c @@ -25,6 +25,8 @@ guint ownerID = 0; void dbus_metadata_watcher(struct metadata_bundle *argc, __attribute__((unused)) void *userdata) { char response[100]; + gboolean current_status, new_status; + const char *th; shairport_sync_advanced_remote_control_set_volume(shairportSyncAdvancedRemoteControlSkeleton, argc->speaker_volume); @@ -129,21 +131,30 @@ void dbus_metadata_watcher(struct metadata_bundle *argc, __attribute__((unused)) shairportSyncAdvancedRemoteControlSkeleton, response); } + switch (argc->shuffle_status) { case SS_NOT_AVAILABLE: - shairport_sync_advanced_remote_control_set_shuffle(shairportSyncAdvancedRemoteControlSkeleton, - FALSE); + new_status = FALSE; break; case SS_OFF: - shairport_sync_advanced_remote_control_set_shuffle(shairportSyncAdvancedRemoteControlSkeleton, - FALSE); + new_status = FALSE; break; case SS_ON: - shairport_sync_advanced_remote_control_set_shuffle(shairportSyncAdvancedRemoteControlSkeleton, - TRUE); + new_status = TRUE; break; default: - debug(1, "This should never happen."); + new_status = FALSE; + debug(1, "Unknown shuffle status -- this should never happen."); + } + + current_status = shairport_sync_advanced_remote_control_get_shuffle( + shairportSyncAdvancedRemoteControlSkeleton); + + // only set this if it's different + if (current_status != new_status) { + debug(3, "Shuffle State should be changed"); + shairport_sync_advanced_remote_control_set_shuffle( + shairportSyncAdvancedRemoteControlSkeleton, new_status); } // Build the metadata array