From d6c105efe031478344a1d7539fd48bb66b7ce585 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Fri, 15 Feb 2008 23:02:06 +0000 Subject: [PATCH] switch_bytes_per_frame -> switch_samples_per_frame rename git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7639 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_utils.h | 2 +- src/mod/applications/mod_conference/mod_conference.c | 8 ++++---- src/mod/endpoints/mod_portaudio/mod_portaudio.c | 2 +- src/mod/formats/mod_local_stream/mod_local_stream.c | 4 ++-- src/switch_core_speech.c | 2 +- src/switch_ivr.c | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 1e3bd76b30..52c20937e6 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -41,7 +41,7 @@ #include SWITCH_BEGIN_EXTERN_C -#define switch_bytes_per_frame(rate, interval) ((uint32_t)((float)rate / (1000.0f / (float)interval))) +#define switch_samples_per_frame(rate, interval) ((uint32_t)((float)rate / (1000.0f / (float)interval))) #define SWITCH_SMAX 32767 #define SWITCH_SMIN -32768 #define switch_normalize_to_16bit(n) if (n > SWITCH_SMAX) n = SWITCH_SMAX / 2; else if (n < SWITCH_SMIN) n = SWITCH_SMIN / 2; diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index e426838df9..024db02a6d 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -817,7 +817,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t * thread, { conference_obj_t *conference = (conference_obj_t *) obj; conference_member_t *imember, *omember; - uint32_t samples = switch_bytes_per_frame(conference->rate, conference->interval); + uint32_t samples = switch_samples_per_frame(conference->rate, conference->interval); uint32_t bytes = samples * 2; uint8_t ready = 0, total = 0; switch_timer_t timer = { 0 }; @@ -1647,7 +1647,7 @@ static void conference_loop_output(conference_member_t * member) switch_timer_t timer = { 0 }; switch_codec_t *read_codec = switch_core_session_get_read_codec(member->session); uint32_t interval = read_codec->implementation->microseconds_per_frame / 1000; - uint32_t samples = switch_bytes_per_frame(member->conference->rate, interval); + uint32_t samples = switch_samples_per_frame(member->conference->rate, interval); uint32_t csamples = samples; uint32_t tsamples = member->orig_read_codec->implementation->samples_per_frame; uint32_t flush_len = 0; @@ -1656,7 +1656,7 @@ static void conference_loop_output(conference_member_t * member) switch_assert(member->conference != NULL); - flush_len = switch_bytes_per_frame(member->conference->rate, member->conference->interval) * 10; + flush_len = switch_samples_per_frame(member->conference->rate, member->conference->interval) * 10; if (switch_core_timer_init(&timer, member->conference->timer_name, interval, tsamples, NULL) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timer Setup Failed. Conference Cannot Start\n"); @@ -1952,7 +1952,7 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t * t conference_member_t smember = { 0 }, *member; conference_record_t *rec = (conference_record_t *) obj; conference_obj_t *conference = rec->conference; - uint32_t samples = switch_bytes_per_frame(conference->rate, conference->interval); + uint32_t samples = switch_samples_per_frame(conference->rate, conference->interval); uint32_t low_count = 0, mux_used; char *vval; switch_timer_t timer = { 0 }; diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index be68b2a40d..0328490d36 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -733,7 +733,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_portaudio_load) globals.read_frame.buflen = sizeof(globals.databuf); globals.cng_frame.data = globals.cngbuf; globals.cng_frame.buflen = sizeof(globals.cngbuf); - globals.cng_frame.datalen = switch_bytes_per_frame(globals.sample_rate, globals.codec_ms) * 2; + globals.cng_frame.datalen = switch_samples_per_frame(globals.sample_rate, globals.codec_ms) * 2; switch_set_flag((&globals.cng_frame), SFF_CNG); /* connect my internal structure to the blank pointer passed to me */ diff --git a/src/mod/formats/mod_local_stream/mod_local_stream.c b/src/mod/formats/mod_local_stream/mod_local_stream.c index cd36e1e513..f65188653a 100644 --- a/src/mod/formats/mod_local_stream/mod_local_stream.c +++ b/src/mod/formats/mod_local_stream/mod_local_stream.c @@ -176,7 +176,7 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void } source->rate = fh.samplerate; - source->samples = switch_bytes_per_frame(fh.native_rate, source->interval); + source->samples = switch_samples_per_frame(fh.native_rate, source->interval); if (switch_core_timer_init(&timer, source->timer_name, source->interval, source->samples, source->pool) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can't start timer.\n"); @@ -425,7 +425,7 @@ static void launch_threads(void) } } - source->samples = switch_bytes_per_frame(source->rate, source->interval); + source->samples = switch_samples_per_frame(source->rate, source->interval); switch_core_hash_insert(globals.source_hash, source->name, source); diff --git a/src/switch_core_speech.c b/src/switch_core_speech.c index 1d07e0f880..8c738c13bc 100644 --- a/src/switch_core_speech.c +++ b/src/switch_core_speech.c @@ -81,7 +81,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_speech_open(switch_speech_handle_t * sh->rate = rate; sh->name = switch_core_strdup(pool, module_name); - sh->samples = switch_bytes_per_frame(rate, interval); + sh->samples = switch_samples_per_frame(rate, interval); return sh->speech_interface->speech_open(sh, voice_name, rate, flags); } diff --git a/src/switch_ivr.c b/src/switch_ivr.c index aed7e310c4..2d48d04e02 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -1518,7 +1518,7 @@ SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint3 read_codec = switch_core_session_get_read_codec(session); interval = read_codec->implementation->microseconds_per_frame / 1000; - samples = switch_bytes_per_frame(read_codec->implementation->samples_per_second, interval); + samples = switch_samples_per_frame(read_codec->implementation->samples_per_second, interval); qlen = delay_ms / (interval); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting delay to %dms (%d frames)\n", delay_ms, qlen);