mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-18 17:41:53 +00:00
FS-7479 fix regression
This commit is contained in:
parent
6bb8ee321a
commit
31a7c446e6
@ -175,7 +175,7 @@ SWITCH_DECLARE(uint32_t) switch_merge_sln(int16_t *data, uint32_t samples, int16
|
|||||||
SWITCH_DECLARE(uint32_t) switch_unmerge_sln(int16_t *data, uint32_t samples, int16_t *other_data, uint32_t other_samples);
|
SWITCH_DECLARE(uint32_t) switch_unmerge_sln(int16_t *data, uint32_t samples, int16_t *other_data, uint32_t other_samples);
|
||||||
SWITCH_DECLARE(void) switch_mux_channels(int16_t *data, switch_size_t samples, uint32_t orig_channels, uint32_t channels);
|
SWITCH_DECLARE(void) switch_mux_channels(int16_t *data, switch_size_t samples, uint32_t orig_channels, uint32_t channels);
|
||||||
|
|
||||||
#define switch_resample_calc_buffer_size(_to, _from, _srclen) (uint32_t)((float)(_to / _from) * (float)_srclen * 2)
|
#define switch_resample_calc_buffer_size(_to, _from, _srclen) ((uint32_t)(((float)_to / (float)_from) * (float)_srclen) * 2)
|
||||||
|
|
||||||
|
|
||||||
SWITCH_END_EXTERN_C
|
SWITCH_END_EXTERN_C
|
||||||
|
@ -63,7 +63,9 @@ SWITCH_DECLARE(switch_status_t) switch_resample_perform_create(switch_audio_resa
|
|||||||
|
|
||||||
switch_zmalloc(resampler, sizeof(*resampler));
|
switch_zmalloc(resampler, sizeof(*resampler));
|
||||||
|
|
||||||
resampler->resampler = speex_resampler_init(channels ? channels : 1, from_rate, to_rate, quality, &err);
|
if (!channels) channels = 1;
|
||||||
|
|
||||||
|
resampler->resampler = speex_resampler_init(channels, from_rate, to_rate, quality, &err);
|
||||||
|
|
||||||
if (!resampler->resampler) {
|
if (!resampler->resampler) {
|
||||||
free(resampler);
|
free(resampler);
|
||||||
@ -77,18 +79,25 @@ SWITCH_DECLARE(switch_status_t) switch_resample_perform_create(switch_audio_resa
|
|||||||
resampler->to_rate = to_rate;
|
resampler->to_rate = to_rate;
|
||||||
resampler->factor = (lto_rate / lfrom_rate);
|
resampler->factor = (lto_rate / lfrom_rate);
|
||||||
resampler->rfactor = (lfrom_rate / lto_rate);
|
resampler->rfactor = (lfrom_rate / lto_rate);
|
||||||
resampler->to_size = resample_buffer(to_rate, from_rate, (uint32_t) to_size);
|
|
||||||
resampler->to = malloc(resampler->to_size * sizeof(int16_t) * (channels ? channels : 1));
|
|
||||||
resampler->channels = channels;
|
resampler->channels = channels;
|
||||||
|
|
||||||
|
//resampler->to_size = resample_buffer(to_rate, from_rate, (uint32_t) to_size);
|
||||||
|
|
||||||
|
resampler->to_size = switch_resample_calc_buffer_size(resampler->to_rate, resampler->from_rate, to_size) / 2;
|
||||||
|
resampler->to = malloc(resampler->to_size * sizeof(int16_t) * resampler->channels);
|
||||||
|
switch_assert(resampler->to);
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(uint32_t) switch_resample_process(switch_audio_resampler_t *resampler, int16_t *src, uint32_t srclen)
|
SWITCH_DECLARE(uint32_t) switch_resample_process(switch_audio_resampler_t *resampler, int16_t *src, uint32_t srclen)
|
||||||
{
|
{
|
||||||
if (switch_resample_calc_buffer_size(resampler->to_rate, resampler->from_rate, srclen) > SWITCH_RECOMMENDED_BUFFER_SIZE) {
|
int to_size = switch_resample_calc_buffer_size(resampler->to_rate, resampler->from_rate, srclen) / 2;
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Out of Buffer SPACE!\n");
|
|
||||||
return 0;
|
if (to_size > resampler->to_size) {
|
||||||
|
resampler->to_size = to_size;
|
||||||
|
resampler->to = realloc(resampler->to, resampler->to_size * sizeof(int16_t) * resampler->channels);
|
||||||
|
switch_assert(resampler->to);
|
||||||
}
|
}
|
||||||
|
|
||||||
resampler->to_len = resampler->to_size;
|
resampler->to_len = resampler->to_size;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user