diff --git a/src/include/switch_resample.h b/src/include/switch_resample.h index b14eb99a08..86c4345be5 100644 --- a/src/include/switch_resample.h +++ b/src/include/switch_resample.h @@ -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 */ diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index 6cc355f5c4..ac31b54394 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -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) { diff --git a/src/switch_resample.c b/src/switch_resample.c index 3ea4e38e1b..49efe64139 100644 --- a/src/switch_resample.c +++ b/src/switch_resample.c @@ -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,