]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix resampled file in ringback issue from mailing list
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 11 Aug 2008 20:41:18 +0000 (20:41 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 11 Aug 2008 20:41:18 +0000 (20:41 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9246 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_resample.h
src/switch_ivr_originate.c
src/switch_resample.c

index b14eb99a0896d507d796b7d808a3a45712135470..86c4345be57f7ebe6c3a543e993b68138aa36e69 100644 (file)
@@ -60,6 +60,7 @@ SWITCH_BEGIN_EXTERN_C
        int to_rate;
        /*! the factor to resample by (from / to) */
        double factor;
+       double rfactor;
        /*! a pointer to store a float buffer for data to be resampled */
        float *from;
        /*! the size of the from buffer used */
index 6cc355f5c40de9c246541f06946b3710dbabbb64..ac31b54394164b3ea2b0a87f86cee038a62c579e 100644 (file)
@@ -420,6 +420,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
                                }
 
                                olen = mlen;
+                               if (ringback.fh->resampler) {
+                                       olen *= ringback.fh->resampler->rfactor;
+                               }
                                switch_core_file_read(ringback.fh, write_frame.data, &olen);
 
                                if (olen == 0) {
@@ -1200,6 +1203,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                                        }
 
                                                        olen = mlen;
+                                                       if (ringback.fh->resampler) {
+                                                               olen *= ringback.fh->resampler->rfactor;
+                                                       }
+                                                       
                                                        switch_core_file_read(ringback.fh, write_frame.data, &olen);
 
                                                        if (olen == 0) {
index 3ea4e38e1b7c73871edfbceb1471f64b6ecbf6e0..49efe6413953b83e804c19d77299501210884800 100644 (file)
@@ -72,6 +72,7 @@ SWITCH_DECLARE(switch_status_t) switch_resample_create(switch_audio_resampler_t
        lto_rate = (double) resampler->to_rate;
        lfrom_rate = (double) resampler->from_rate;
        resampler->factor = (lto_rate / lfrom_rate);
+       resampler->rfactor = (lfrom_rate / lto_rate);
 
        resampler->resampler = resample_open(QUALITY, resampler->factor, resampler->factor);
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Activate Resampler %d->%d %f\n", resampler->from_rate, resampler->to_rate,