]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11312 [core] prevent double firing record_start event
authorlazedo <luis.azedo@factorlusitano.com>
Sat, 4 Aug 2018 10:09:22 +0000 (10:09 +0000)
committerlazedo <luis.azedo@factorlusitano.com>
Tue, 16 Oct 2018 07:27:40 +0000 (07:27 +0000)
src/switch_ivr_async.c

index 67223717763aa949db7455e3904fea628f6e866b..d80426f3477edeea5551fefed9527642bfcb2f3b 100644 (file)
@@ -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();