]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
adjust buffering sizes to allow resampling of high defination audio codecs so they...
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 12 Jan 2009 19:12:09 +0000 (19:12 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 12 Jan 2009 19:12:09 +0000 (19:12 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11145 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_core_file.c

index a5042cea647f9f65b14243ba08ec5a15c2f5ef83..e810297a2181a831a27540c47ef16b6a07b20a13 100644 (file)
@@ -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;