From: Anthony Minessale Date: Mon, 19 May 2014 23:07:47 +0000 (+0500) Subject: add heartbeat_fire_on_set variable to fire heartbeat instantly when its first enabled... X-Git-Tag: v1.4.4~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55f8f556faf606bb7f067cb4d07c3024c16540aa;p=thirdparty%2Ffreeswitch.git add heartbeat_fire_on_set variable to fire heartbeat instantly when its first enabled (legacy behavior) --- diff --git a/src/switch_core_session.c b/src/switch_core_session.c index f774d6349f..15f18c5ab0 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -1524,9 +1524,16 @@ SWITCH_DECLARE(void) switch_core_session_unsched_heartbeat(switch_core_session_t SWITCH_DECLARE(void) switch_core_session_sched_heartbeat(switch_core_session_t *session, uint32_t seconds) { + time_t when; switch_core_session_unsched_heartbeat(session); - session->track_id = switch_scheduler_add_task(switch_epoch_time_now(NULL) + session->track_duration, sch_heartbeat_callback, (char *) __SWITCH_FUNC__, + if (switch_true(switch_channel_get_variable(session->channel, "heartbeat_fire_on_set"))) { + when = switch_epoch_time_now(NULL); + } else { + when = switch_epoch_time_now(NULL) + session->track_duration; + } + + session->track_id = switch_scheduler_add_task(when, sch_heartbeat_callback, (char *) __SWITCH_FUNC__, switch_core_session_get_uuid(session), 0, strdup(switch_core_session_get_uuid(session)), SSHF_FREE_ARG); } @@ -1550,8 +1557,11 @@ SWITCH_DECLARE(void) switch_core_session_enable_heartbeat(switch_core_session_t return; } - session->read_frame_count = (session->read_impl.samples_per_second / session->read_impl.samples_per_packet) * seconds; - + if (switch_true(switch_channel_get_variable(session->channel, "heartbeat_fire_on_set"))) { + session->read_frame_count = 0; + } else { + session->read_frame_count = (session->read_impl.samples_per_second / session->read_impl.samples_per_packet) * seconds; + } switch_core_session_unsched_heartbeat(session);