]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[core] fix: don't terminate file before max_samples returned 216/head
authorrucc <harangoz@gmail.com>
Thu, 9 Jan 2020 14:32:24 +0000 (15:32 +0100)
committerrucc <harangoz@gmail.com>
Thu, 9 Jan 2020 14:54:42 +0000 (15:54 +0100)
if file buffer is considerably bigger than max_samples than keeping track of samples read instead of samples returned might result in a significantly shorter play

src/switch_core_file.c

index 717233ce55f6ce0024067e9da76ca8bfb3595e88..2d6680c74b09be00c2a3506df6b9469059e76037 100644 (file)
@@ -482,7 +482,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_read(switch_file_handle_t *fh,
                                if (status != SWITCH_STATUS_SUCCESS || !rlen) {
                                        switch_set_flag_locked(fh, SWITCH_FILE_BUFFER_DONE);
                                } else {
-                                       fh->samples_in += rlen;
                                        if (fh->real_channels != fh->channels && !switch_test_flag(fh, SWITCH_FILE_NOMUX)) {
                                                switch_mux_channels((int16_t *) fh->pre_buffer_data, rlen, fh->real_channels, fh->channels);
                                        }
@@ -492,6 +491,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_read(switch_file_handle_t *fh,
                }
 
                rlen = switch_buffer_read(fh->pre_buffer, data, asis ? *len : *len * 2 * fh->channels);
+               fh->samples_in += rlen;
                *len = asis ? rlen : rlen / 2 / fh->channels;
 
                if (*len == 0) {