]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6980 #resolve don't crash when using native recording on recordstop
authorBrian West <brian@freeswitch.org>
Tue, 11 Nov 2014 13:45:50 +0000 (07:45 -0600)
committerBrian West <brian@freeswitch.org>
Tue, 11 Nov 2014 13:45:50 +0000 (07:45 -0600)
src/switch_ivr_async.c

index dcea776c83afc52dd4515f32e16784cbdace1c28..1b209ae1960133c05978a7642dcf62f128611ffa 100644 (file)
@@ -1088,17 +1088,17 @@ static void send_record_stop_event(switch_channel_t *channel, switch_codec_imple
 {
        switch_event_t *event;
 
-       if (read_impl->actual_samples_per_second) {
-               switch_channel_set_variable_printf(channel, "record_seconds", "%d", rh->fh->samples_out / read_impl->actual_samples_per_second);
-               switch_channel_set_variable_printf(channel, "record_ms", "%d", rh->fh->samples_out / (read_impl->actual_samples_per_second / 1000));
+       if (rh->fh) {
+               switch_channel_set_variable_printf(channel, "record_samples", "%d", rh->fh->samples_out);
+               if (read_impl->actual_samples_per_second) {
+                       switch_channel_set_variable_printf(channel, "record_seconds", "%d", rh->fh->samples_out / read_impl->actual_samples_per_second);
+                       switch_channel_set_variable_printf(channel, "record_ms", "%d", rh->fh->samples_out / (read_impl->actual_samples_per_second / 1000));
+               }
        }
-
        if (!zstr(rh->completion_cause)) {
                switch_channel_set_variable_printf(channel, "record_completion_cause", "%s", rh->completion_cause);
        }
 
-       switch_channel_set_variable_printf(channel, "record_samples", "%d", rh->fh->samples_out);
-
        if (switch_event_create(&event, SWITCH_EVENT_RECORD_STOP) == SWITCH_STATUS_SUCCESS) {
                switch_channel_event_set_data(channel, event);
                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Record-File-Path", rh->file);