Merge pull request #1507 in FS/freeswitch from ~DRAGOS_OANCEA_NX/freeswitch-dragos-nx:bugfix/FS-11105/multichannel_prebuf_datalen to master

* commit '6bc59b3b5ad681c1c9e71758d5602e72b05f7c76':
  FS-11105: core: fix in switch_core_file_write() for audio channels > 2 ( eg: for when the prebuffer size does not divide by the number of wanted channels)
This commit is contained in:
Christopher Rienzo 2019-02-15 16:19:06 +00:00
commit 7e67dc3c4d
1 changed files with 7 additions and 2 deletions

View File

@ -639,6 +639,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_write(switch_file_handle_t *fh,
if (fh->pre_buffer) {
switch_size_t rlen, blen;
switch_size_t datalen_adj = fh->pre_buffer_datalen;
switch_status_t status = SWITCH_STATUS_SUCCESS;
int asis = switch_test_flag(fh, SWITCH_FILE_NATIVE);
@ -646,8 +647,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_write(switch_file_handle_t *fh,
rlen = switch_buffer_inuse(fh->pre_buffer);
if (rlen >= fh->pre_buffer_datalen) {
if ((blen = switch_buffer_read(fh->pre_buffer, fh->pre_buffer_data, fh->pre_buffer_datalen))) {
if (fh->pre_buffer_datalen % fh->channels) {
datalen_adj = fh->pre_buffer_datalen - (fh->pre_buffer_datalen % fh->channels);
}
if (rlen >= datalen_adj) {
if ((blen = switch_buffer_read(fh->pre_buffer, fh->pre_buffer_data, datalen_adj))) {
if (!asis)
blen /= 2;
if (fh->channels > 1)