mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-02 11:19:28 +00:00
FS-7479 #resolve
This commit is contained in:
parent
1f25952008
commit
6209d91f9c
@ -175,6 +175,9 @@ 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)
|
||||||
|
|
||||||
|
|
||||||
SWITCH_END_EXTERN_C
|
SWITCH_END_EXTERN_C
|
||||||
#endif
|
#endif
|
||||||
/* For Emacs:
|
/* For Emacs:
|
||||||
|
@ -1245,6 +1245,17 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
|
|||||||
switch_mutex_lock(session->resample_mutex);
|
switch_mutex_lock(session->resample_mutex);
|
||||||
if (session->write_resampler) {
|
if (session->write_resampler) {
|
||||||
|
|
||||||
|
if (switch_resample_calc_buffer_size(session->write_resampler->to_rate, session->write_resampler->from_rate,
|
||||||
|
write_frame->datalen / 2 / session->write_resampler->channels) > SWITCH_RECOMMENDED_BUFFER_SIZE) {
|
||||||
|
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "%s not enough buffer space for required resample operation!\n",
|
||||||
|
switch_channel_get_name(session->channel));
|
||||||
|
switch_channel_hangup(session->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||||
|
switch_mutex_unlock(session->resample_mutex);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
switch_resample_process(session->write_resampler, data, write_frame->datalen / 2 / session->write_resampler->channels);
|
switch_resample_process(session->write_resampler, data, write_frame->datalen / 2 / session->write_resampler->channels);
|
||||||
|
|
||||||
memcpy(data, session->write_resampler->to, session->write_resampler->to_len * 2 * session->write_resampler->channels);
|
memcpy(data, session->write_resampler->to, session->write_resampler->to_len * 2 * session->write_resampler->channels);
|
||||||
|
@ -84,9 +84,13 @@ SWITCH_DECLARE(switch_status_t) switch_resample_perform_create(switch_audio_resa
|
|||||||
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) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Out of Buffer SPACE!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
resampler->to_len = resampler->to_size;
|
resampler->to_len = resampler->to_size;
|
||||||
speex_resampler_process_interleaved_int(resampler->resampler, src, &srclen, resampler->to, &resampler->to_len);
|
speex_resampler_process_interleaved_int(resampler->resampler, src, &srclen, resampler->to, &resampler->to_len);
|
||||||
return resampler->to_len;
|
return resampler->to_len;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user