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:
parent
192a232c23
commit
6bc59b3b5a
|
@ -608,6 +608,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);
|
||||
|
||||
|
@ -615,8 +616,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)
|
||||
|
|
Loading…
Reference in New Issue