From 0e0d5881444fa7af0730c56dc24ef7fc730870a1 Mon Sep 17 00:00:00 2001 From: lazedo Date: Sat, 4 Aug 2018 10:09:22 +0000 Subject: [PATCH] FS-11312 [core] prevent double firing record_start event --- src/switch_ivr_async.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index 6722371776..d80426f347 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -1145,6 +1145,7 @@ struct record_helper { uint32_t writes; uint32_t vwrites; const char *completion_cause; + int start_event_sent; }; /** @@ -1188,6 +1189,7 @@ static void send_record_stop_event(switch_channel_t *channel, switch_codec_imple { switch_event_t *event; + rh->start_event_sent = 0; if (rh->fh) { switch_channel_set_variable_printf(channel, "record_samples", "%d", rh->fh->samples_out); if (read_impl->actual_samples_per_second) { @@ -1304,10 +1306,13 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s } } - if (switch_event_create(&event, SWITCH_EVENT_RECORD_START) == SWITCH_STATUS_SUCCESS) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Record-File-Path", rh->file); - switch_channel_event_set_data(channel, event); - switch_event_fire(&event); + if(rh->start_event_sent == 0) { + rh->start_event_sent = 1; + if (switch_event_create(&event, SWITCH_EVENT_RECORD_START) == SWITCH_STATUS_SUCCESS) { + switch_channel_event_set_data(channel, event); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Record-File-Path", rh->file); + switch_event_fire(&event); + } } rh->silence_time = switch_micro_time_now();