提交 468a3c6f authored 作者: Anthony Minessale's avatar Anthony Minessale

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
上级 320a5418
...@@ -60,6 +60,7 @@ SWITCH_BEGIN_EXTERN_C ...@@ -60,6 +60,7 @@ SWITCH_BEGIN_EXTERN_C
int to_rate; int to_rate;
/*! the factor to resample by (from / to) */ /*! the factor to resample by (from / to) */
double factor; double factor;
double rfactor;
/*! a pointer to store a float buffer for data to be resampled */ /*! a pointer to store a float buffer for data to be resampled */
float *from; float *from;
/*! the size of the from buffer used */ /*! the size of the from buffer used */
......
...@@ -420,6 +420,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t ...@@ -420,6 +420,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
} }
olen = mlen; olen = mlen;
if (ringback.fh->resampler) {
olen *= ringback.fh->resampler->rfactor;
}
switch_core_file_read(ringback.fh, write_frame.data, &olen); switch_core_file_read(ringback.fh, write_frame.data, &olen);
if (olen == 0) { if (olen == 0) {
...@@ -1200,6 +1203,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess ...@@ -1200,6 +1203,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
} }
olen = mlen; olen = mlen;
if (ringback.fh->resampler) {
olen *= ringback.fh->resampler->rfactor;
}
switch_core_file_read(ringback.fh, write_frame.data, &olen); switch_core_file_read(ringback.fh, write_frame.data, &olen);
if (olen == 0) { if (olen == 0) {
......
...@@ -72,6 +72,7 @@ SWITCH_DECLARE(switch_status_t) switch_resample_create(switch_audio_resampler_t ...@@ -72,6 +72,7 @@ SWITCH_DECLARE(switch_status_t) switch_resample_create(switch_audio_resampler_t
lto_rate = (double) resampler->to_rate; lto_rate = (double) resampler->to_rate;
lfrom_rate = (double) resampler->from_rate; lfrom_rate = (double) resampler->from_rate;
resampler->factor = (lto_rate / lfrom_rate); resampler->factor = (lto_rate / lfrom_rate);
resampler->rfactor = (lfrom_rate / lto_rate);
resampler->resampler = resample_open(QUALITY, resampler->factor, resampler->factor); 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, switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Activate Resampler %d->%d %f\n", resampler->from_rate, resampler->to_rate,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论