From: Anthony Minessale Date: Mon, 12 Jan 2009 19:12:09 +0000 (+0000) Subject: adjust buffering sizes to allow resampling of high defination audio codecs so they... X-Git-Tag: v1.0.3~785 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4997507dfedf7d2bbfbe96f1cc970518c4541a53;p=thirdparty%2Ffreeswitch.git adjust buffering sizes to allow resampling of high defination audio codecs so they can be transcoded to lower and higher levels git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11145 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- diff --git a/src/switch_core_file.c b/src/switch_core_file.c index a5042cea64..e810297a21 100644 --- a/src/switch_core_file.c +++ b/src/switch_core_file.c @@ -204,11 +204,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_read(switch_file_handle_t *fh, if (fh->resampler->to_len < want || fh->resampler->to_len > orig_len) { if (!fh->buffer) { - switch_buffer_create_dynamic(&fh->buffer, fh->resampler->to_len * 4, fh->resampler->to_len * 8, fh->resampler->to_len * 32); + int factor = fh->resampler->to_len * fh->samplerate / 1000; + switch_buffer_create_dynamic(&fh->buffer, factor, factor, 0); switch_assert(fh->buffer); } if (!fh->dbuf) { - fh->dbuflen = fh->resampler->to_len * 10; + fh->dbuflen = want * 2; fh->dbuf = switch_core_alloc(fh->memory_pool, fh->dbuflen); } switch_assert(fh->resampler->to_len <= fh->dbuflen); @@ -217,7 +218,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_read(switch_file_handle_t *fh, switch_buffer_write(fh->buffer, fh->dbuf, fh->resampler->to_len * 2); if (switch_buffer_inuse(fh->buffer) < want * 2) { - *len = want - fh->resampler->to_len; + *len = want; goto more; } *len = switch_buffer_read(fh->buffer, data, orig_len * 2) / 2;