[Freeswitch-svn] [commit] r4782 - in freeswitch/trunk/src: . mod/applications/mod_conference
Freeswitch SVN
mikej at freeswitch.org
Wed Mar 28 14:21:00 EDT 2007
Author: mikej
Date: Wed Mar 28 14:21:00 2007
New Revision: 4782
Modified:
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
freeswitch/trunk/src/switch_core.c
freeswitch/trunk/src/switch_resample.c
Log:
add checking for successful re-sampler allocation. Add ifdefs to disable build with re-sampler.
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Wed Mar 28 14:21:00 2007
@@ -4070,12 +4070,15 @@
switch_audio_resampler_t **resampler = read_codec->implementation->samples_per_second > conference->rate ?
&member.read_resampler : &member.mux_resampler;
- switch_resample_create(resampler,
+ if (switch_resample_create(resampler,
read_codec->implementation->samples_per_second,
read_codec->implementation->samples_per_second * 20,
conference->rate,
conference->rate * 20,
- member.pool);
+ member.pool) != SWITCH_STATUS_SUCCESS){
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to crete resampler!\n");
+ goto done;
+ }
/* Setup an audio buffer for the resampled audio */
if (switch_buffer_create_dynamic(&member.resample_buffer, CONF_DBLOCK_SIZE, CONF_DBUFFER_SIZE, CONF_DBUFFER_MAX) != SWITCH_STATUS_SUCCESS) {
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Wed Mar 28 14:21:00 2007
@@ -2174,11 +2174,15 @@
switch (status) {
case SWITCH_STATUS_RESAMPLE:
if (!session->read_resampler) {
- switch_resample_create(&session->read_resampler,
+ if (switch_resample_create(&session->read_resampler,
read_frame->codec->implementation->samples_per_second,
read_frame->codec->implementation->bytes_per_frame * 20,
session->read_codec->implementation->samples_per_second,
- session->read_codec->implementation->bytes_per_frame * 20, session->pool);
+ session->read_codec->implementation->bytes_per_frame * 20, session->pool) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to allocate resampler\n");
+ status = SWITCH_STATUS_FALSE;
+ goto done;
+ }
}
case SWITCH_STATUS_SUCCESS:
session->raw_read_frame.samples = session->raw_read_frame.datalen / sizeof(int16_t);
@@ -2448,6 +2452,9 @@
session->write_codec->implementation->samples_per_second,
session->write_codec->implementation->bytes_per_frame * 20,
session->pool);
+ if (status != SWITCH_STATUS_SUCCESS) {
+ goto done;
+ }
}
break;
case SWITCH_STATUS_SUCCESS:
@@ -2652,6 +2659,9 @@
session->write_codec->implementation->samples_per_second,
session->write_codec->implementation->bytes_per_frame * 20,
session->pool);
+ if (status != SWITCH_STATUS_SUCCESS) {
+ goto done;
+ }
}
break;
case SWITCH_STATUS_SUCCESS:
Modified: freeswitch/trunk/src/switch_resample.c
==============================================================================
--- freeswitch/trunk/src/switch_resample.c (original)
+++ freeswitch/trunk/src/switch_resample.c Wed Mar 28 14:21:00 2007
@@ -31,7 +31,12 @@
*/
#include <switch.h>
#include <switch_resample.h>
+#ifndef WIN32
+#include <switch_private.h>
+#endif
+#ifndef DISABLE_RESAMPLE
#include <libresample.h>
+#endif
#define NORMFACT (float)0x8000
#define MAXSAMPLE (float)0x7FFF
#define MAXSAMPLEC (char)0x7F
@@ -52,6 +57,10 @@
switch_size_t from_size,
int to_rate, uint32_t to_size, switch_memory_pool_t *pool)
{
+#ifdef DISABLE_RESAMPLE
+ *new_resampler = NULL;
+ return SWITCH_STATUS_NOTIMPL;
+#else
switch_audio_resampler_t *resampler;
double lto_rate, lfrom_rate;
@@ -75,12 +84,16 @@
*new_resampler = resampler;
return SWITCH_STATUS_SUCCESS;
+#endif
}
SWITCH_DECLARE(uint32_t) switch_resample_process(switch_audio_resampler_t *resampler, float *src, int srclen, float *dst,
uint32_t dstlen, int last)
{
+#ifdef DISABLE_RESAMPLE
+ return 0;
+#else
int o = 0, srcused = 0, srcpos = 0, out = 0;
for (;;) {
@@ -99,11 +112,14 @@
}
}
return out;
+#endif
}
SWITCH_DECLARE(void) switch_resample_destroy(switch_audio_resampler_t *resampler)
{
+#ifndef DISABLE_RESAMPLE
resample_close(resampler->resampler);
+#endif
}
More information about the Freeswitch-svn
mailing list