From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Wed, 21 Jun 2023 18:24:18 +0000 (+0100) Subject: activity monitor should send an active_end on shutdown, provided it was in the active... X-Git-Tag: 4.3~1^2~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46a215b630e43ec97448971f516c9b7e1fadbbd3;p=thirdparty%2Fshairport-sync.git activity monitor should send an active_end on shutdown, provided it was in the active state. --- diff --git a/activity_monitor.c b/activity_monitor.c index 49f99d13..361bf517 100644 --- a/activity_monitor.c +++ b/activity_monitor.c @@ -50,6 +50,7 @@ enum am_state state; enum ps_state { ps_inactive, ps_active } player_state; int activity_monitor_running = 0; +int activity_monitor_is_shutting_down = 0; pthread_t activity_monitor_thread; pthread_mutex_t activity_monitor_mutex; @@ -120,7 +121,7 @@ void activity_monitor_signify_activity(int active) { pthread_mutex_unlock(&activity_monitor_mutex); going_active(config.cmd_blocking); } else if ((state == am_active) && (player_state == ps_inactive) && - (config.active_state_timeout == 0.0)) { + ((config.active_state_timeout == 0.0) || (activity_monitor_is_shutting_down != 0))) { state = am_inactive; pthread_mutex_unlock(&activity_monitor_mutex); going_inactive(config.cmd_blocking); @@ -240,7 +241,9 @@ void activity_monitor_start() { void activity_monitor_stop() { if (activity_monitor_running) { + activity_monitor_is_shutting_down = 1; debug(3, "activity_monitor_stop start..."); + activity_monitor_signify_activity(0); // tell it to go inactive... pthread_cancel(activity_monitor_thread); pthread_join(activity_monitor_thread, NULL); debug(2, "activity_monitor_stop complete");