fix resampled file in ringback issue from mailing list

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9246 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-08-11 20:41:18 +00:00
parent 320a541822
commit 468a3c6fe9
3 changed files with 9 additions and 0 deletions

View 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 */

View 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) {

View 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,