]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
interval tweaks
authorBrian West <brian@freeswitch.org>
Fri, 15 Feb 2008 20:11:44 +0000 (20:11 +0000)
committerBrian West <brian@freeswitch.org>
Fri, 15 Feb 2008 20:11:44 +0000 (20:11 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7626 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_loadable_module.h
src/include/switch_types.h
src/mod/applications/mod_conference/mod_conference.c
src/mod/codecs/mod_voipcodecs/mod_voipcodecs.c
src/mod/endpoints/mod_alsa/mod_alsa.c
src/mod/endpoints/mod_portaudio/mod_portaudio.c
src/mod/formats/mod_local_stream/mod_local_stream.c

index 1cc0108d2ed402a36bb8e7f380db6f636ed65878..d2c9e24c5202ef2d9b7989caafcf48504cceea95 100644 (file)
@@ -353,30 +353,30 @@ static inline void switch_core_codec_add_implementation(switch_memory_pool_t *po
                                                         /*! deinitalize a codec handle using this implementation */
                                                         switch_core_codec_destroy_func_t destroy)
 {
-
-    switch_codec_implementation_t *impl = (switch_codec_implementation_t *) switch_core_alloc(pool, sizeof(*impl));
-    impl->codec_type = codec_type;
-    impl->ianacode = ianacode;
-    impl->iananame = iananame;
-    impl->fmtp = fmtp;
-    impl->samples_per_second = samples_per_second;
-    impl->actual_samples_per_second = actual_samples_per_second;
-    impl->bits_per_second = bits_per_second;
-    impl->microseconds_per_frame = microseconds_per_frame;
-    impl->samples_per_frame = samples_per_frame;
-    impl->bytes_per_frame = bytes_per_frame;
-    impl->encoded_bytes_per_frame = encoded_bytes_per_frame;
-    impl->number_of_channels = number_of_channels;
-    impl->pref_frames_per_packet = pref_frames_per_packet;
-    impl->max_frames_per_packet = max_frames_per_packet;
-    impl->init = init;
-    impl->encode = encode;
-    impl->decode = decode;
-    impl->destroy = destroy;
-    
-    impl->next = codec_interface->implementations;
-    codec_interface->implementations = impl;
-
+       if (SWITCH_ACCEPTABLE_INTERVAL(microseconds_per_frame / 1000)) {
+               switch_codec_implementation_t *impl = (switch_codec_implementation_t *) switch_core_alloc(pool, sizeof(*impl));
+               impl->codec_type = codec_type;
+               impl->ianacode = ianacode;
+               impl->iananame = iananame;
+               impl->fmtp = fmtp;
+               impl->samples_per_second = samples_per_second;
+               impl->actual_samples_per_second = actual_samples_per_second;
+               impl->bits_per_second = bits_per_second;
+               impl->microseconds_per_frame = microseconds_per_frame;
+               impl->samples_per_frame = samples_per_frame;
+               impl->bytes_per_frame = bytes_per_frame;
+               impl->encoded_bytes_per_frame = encoded_bytes_per_frame;
+               impl->number_of_channels = number_of_channels;
+               impl->pref_frames_per_packet = pref_frames_per_packet;
+               impl->max_frames_per_packet = max_frames_per_packet;
+               impl->init = init;
+               impl->encode = encode;
+               impl->decode = decode;
+               impl->destroy = destroy;
+               
+               impl->next = codec_interface->implementations;
+               codec_interface->implementations = impl;
+       }
 }
 
 ///\}
index 9bc955ba157e5a1e8e74435f29a51289eb3f20f9..17f55cf2b18ef4139fdbdd8dff082d55e752e8b1 100644 (file)
@@ -306,7 +306,7 @@ SWITCH_DECLARE_DATA extern switch_directories SWITCH_GLOBAL_dirs;
 #define SWITCH_CORE_QUEUE_LEN 100000
 #define SWITCH_MAX_MANAGEMENT_BUFFER_LEN 1024 * 8
 
-#define SWITCH_ACCEPTABLE_INTERVAL(_i) (_i <= SWITCH_MAX_INTERVAL && (_i % 10) == 0)
+#define SWITCH_ACCEPTABLE_INTERVAL(_i) (_i && _i <= SWITCH_MAX_INTERVAL && (_i % 10) == 0)
 
 typedef enum {
        SWITCH_CPF_SCREEN = (1 << 0),
index bbbadcffa42dc5eaab23f5634ae5eddbf0976eec..3079e768a5263ee2f186ba193f3997be2a3c3ff9 100644 (file)
@@ -4618,8 +4618,6 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m
 {
        conference_obj_t *conference;
        switch_xml_t xml_kvp;
-       char *rate_name = NULL;
-       char *interval_name = NULL;
        char *timer_name = NULL;
        char *domain = NULL;
        char *tts_engine = NULL;
@@ -4679,12 +4677,18 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m
                if (!strcasecmp(var, "rate") && !switch_strlen_zero(val)) {
             uint32_t tmp = atoi(val);
             if (tmp == 8000 || tmp == 16000 || tmp == 32000) {
-                rate_name = val;
+                rate = tmp;
             }
                } else if (!strcasecmp(var, "domain") && !switch_strlen_zero(val)) {
                        domain = val;
                } else if (!strcasecmp(var, "interval") && !switch_strlen_zero(val)) {
-                       interval_name = val;
+                       uint32_t tmp = atoi(val);
+                       if (SWITCH_ACCEPTABLE_INTERVAL(tmp)) {
+                               interval = tmp;
+                       } else {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                 "Interval must be multipe of 10 and less than %d, Using default of 20\n", SWITCH_MAX_INTERVAL); 
+                       }
                } else if (!strcasecmp(var, "timer-name") && !switch_strlen_zero(val)) {
                        timer_name = val;
                } else if (!strcasecmp(var, "tts-engine") && !switch_strlen_zero(val)) {
@@ -4766,22 +4770,6 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m
 
        /* Set defaults and various paramaters */
 
-       /* Speed in hertz */
-       if (!switch_strlen_zero(rate_name)) {
-               uint32_t r = atoi(rate_name);
-               if (r) {
-                       rate = r;
-               }
-       }
-
-       /* Packet Interval in milliseconds */
-       if (!switch_strlen_zero(interval_name)) {
-               uint32_t i = atoi(interval_name);
-               if (i) {
-                       interval = i;
-               }
-       }
-
        /* Timer module to use */
        if (switch_strlen_zero(timer_name)) {
                timer_name = "soft";
index 55c3e5743df54601e5f7a54d75bc41f570107b81..9805f135cba8fee2294618f98f1f32479da40ae1 100644 (file)
@@ -684,12 +684,13 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_voipcodecs_load)
                                              switch_gsm_init, switch_gsm_encode, switch_gsm_decode, switch_gsm_destroy);
     }
        /* LPC10 */
-       SWITCH_ADD_CODEC(codec_interface, "LPC-10");
-    switch_core_codec_add_implementation(pool, codec_interface,
-                                         SWITCH_CODEC_TYPE_AUDIO, 7, "LPC", NULL, 8000, 8000, 2400,
-                                                                                90000, 720, 1440, 28, 1, 1, 1,
-                                         switch_lpc10_init, switch_lpc10_encode, switch_lpc10_decode, switch_lpc10_destroy);
-       
+       if (SWITCH_MAX_INTERVAL >= 90) {
+               SWITCH_ADD_CODEC(codec_interface, "LPC-10");
+               switch_core_codec_add_implementation(pool, codec_interface,
+                                                                                        SWITCH_CODEC_TYPE_AUDIO, 7, "LPC", NULL, 8000, 8000, 2400,
+                                                                                        90000, 720, 1440, 28, 1, 1, 1,
+                                                                                        switch_lpc10_init, switch_lpc10_encode, switch_lpc10_decode, switch_lpc10_destroy);
+       }
        /* indicate that the module should continue to be loaded */
        return SWITCH_STATUS_SUCCESS;
 }
index 1c43d1cc8b80fe7a62537448340bea430ff7c39a..792671a3fc9047f1606a3f998834a2a9fd07b686 100644 (file)
@@ -905,7 +905,13 @@ static switch_status_t load_config(void)
                        } else if (!strcmp(var, "sample-rate")) {
                                globals.sample_rate = atoi(val);
                        } else if (!strcmp(var, "codec-ms")) {
-                               globals.codec_ms = atoi(val);
+                               int tmp = atoi(val);
+                               if (SWITCH_ACCEPTABLE_INTERVAL(tmp)) {
+                                       globals.codec_ms = tmp;
+                               } else {
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                         "codec-ms must be multipe of 10 and less than %d, Using default of 20\n", SWITCH_MAX_INTERVAL); 
+                               }
                        } else if (!strcmp(var, "dialplan")) {
                                set_global_dialplan(val);
                        } else if (!strcmp(var, "cid-name")) {
index fe51bdadb67c6f9b9bbc1fb047971f72d8121cda..be68b2a40d29c60421346087e1942dcb07d04561 100644 (file)
@@ -782,7 +782,13 @@ static switch_status_t load_config(void)
                        } else if (!strcmp(var, "sample-rate")) {
                                globals.sample_rate = atoi(val);
                        } else if (!strcmp(var, "codec-ms")) {
-                               globals.codec_ms = atoi(val);
+                               int tmp = atoi(val);
+                               if (SWITCH_ACCEPTABLE_INTERVAL(tmp)) {
+                                       globals.codec_ms = tmp;
+                               } else {
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                         "codec-ms must be multipe of 10 and less than %d, Using default of 20\n", SWITCH_MAX_INTERVAL); 
+                               }
                        } else if (!strcmp(var, "dialplan")) {
                                set_global_dialplan(val);
                        } else if (!strcmp(var, "cid-name")) {
index d08fda60a1001e175684a482210933699a4d9294..cd36e1e513660813b716c4b9659112afdc3f9fc5 100644 (file)
@@ -414,10 +414,11 @@ static void launch_threads(void)
                                }
                        } else if (!strcasecmp(var, "interval")) {
                                int tmp = atoi(val);
-                               if (tmp >= 10) {
+                               if (SWITCH_ACCEPTABLE_INTERVAL(tmp)) {
                                        source->interval = tmp;
                                } else {
-                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't set interval to less than 10\n");
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                 "Interval must be multipe of 10 and less than %d, Using default of 20\n", SWITCH_MAX_INTERVAL); 
                                }
                        } else if (!strcasecmp(var, "timer-name")) {
                                source->timer_name = switch_core_strdup(source->pool, val);