]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix inaccurate sample count in file handle, buffered samples were being double tallied
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 21 Sep 2011 16:05:33 +0000 (11:05 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 21 Sep 2011 16:05:33 +0000 (11:05 -0500)
src/switch_core_file.c
src/switch_ivr_play_say.c

index 28f1172ff8acd26c80287201ba79466527ce937c..6beaa83584532f730d404ebba63204c4e39cd5d3 100644 (file)
@@ -395,7 +395,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_write(switch_file_handle_t *fh,
                                }
                        }
                }
-
                fh->samples_out += orig_len;
                return status;
        } else {
@@ -550,7 +549,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_close(switch_file_handle_t *fh)
                                        if (fh->file_interface->file_write(fh, fh->pre_buffer_data, &blen) != SWITCH_STATUS_SUCCESS) {
                                                break;
                                        }
-                                       fh->samples_out += blen;
                                }
                        }
                }
index f941ff85c834fbb2b303b0fab961cf4537657974..f3d554faeba435e17ae3da25f08da673d3386e2a 100644 (file)
@@ -779,9 +779,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
                
        }
 
-       if (read_impl.samples_per_second) {
-               switch_channel_set_variable_printf(channel, "record_seconds", "%d", fh->samples_out / read_impl.samples_per_second);
-               switch_channel_set_variable_printf(channel, "record_ms", "%d", fh->samples_out / (read_impl.samples_per_second / 1000));
+       if (read_impl.actual_samples_per_second) {
+               switch_channel_set_variable_printf(channel, "record_seconds", "%d", fh->samples_out / read_impl.actual_samples_per_second);
+               switch_channel_set_variable_printf(channel, "record_ms", "%d", fh->samples_out / (read_impl.actual_samples_per_second / 1000));
 
        }