Merge "app_agent_spool: Fix typo in dtmf features usage desctiption"
[asterisk/asterisk.git] / codecs / codec_resample.c
index 26b1f0e..e0d530d 100644 (file)
 #include "asterisk.h"
 #include "speex/speex_resampler.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
 #include "asterisk/module.h"
 #include "asterisk/translate.h"
 #include "asterisk/slin.h"
 
-#define OUTBUF_SIZE   8096
+#define OUTBUF_SAMPLES   11520
 
 static struct ast_translator *translators;
 static int trans_size;
@@ -114,7 +112,7 @@ static void resamp_destroy(struct ast_trans_pvt *pvt)
 static int resamp_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
 {
        SpeexResamplerState *resamp_pvt = pvt->pvt;
-       unsigned int out_samples = (OUTBUF_SIZE / sizeof(int16_t)) - pvt->samples;
+       unsigned int out_samples = OUTBUF_SAMPLES - pvt->samples;
        unsigned int in_samples;
 
        if (!f->datalen) {
@@ -155,7 +153,7 @@ static int load_module(void)
 
        trans_size = ARRAY_LEN(codec_list) * (ARRAY_LEN(codec_list) - 1);
        if (!(translators = ast_calloc(1, sizeof(struct ast_translator) * trans_size))) {
-               return AST_MODULE_LOAD_FAILURE;
+               return AST_MODULE_LOAD_DECLINE;
        }
 
        for (x = 0; x < ARRAY_LEN(codec_list); x++) {
@@ -167,8 +165,8 @@ static int load_module(void)
                        translators[idx].destroy = resamp_destroy;
                        translators[idx].framein = resamp_framein;
                        translators[idx].desc_size = 0;
-                       translators[idx].buffer_samples = (OUTBUF_SIZE / sizeof(int16_t));
-                       translators[idx].buf_size = OUTBUF_SIZE;
+                       translators[idx].buffer_samples = OUTBUF_SAMPLES;
+                       translators[idx].buf_size = (OUTBUF_SAMPLES * sizeof(int16_t));
                        memcpy(&translators[idx].src_codec, &codec_list[x], sizeof(struct ast_codec));
                        memcpy(&translators[idx].dst_codec, &codec_list[y], sizeof(struct ast_codec));
                        snprintf(translators[idx].name, sizeof(translators[idx].name), "slin %ukhz -> %ukhz",
@@ -182,7 +180,7 @@ static int load_module(void)
        ast_unregister_translator won't fail.*/
        if (res) {
                unload_module();
-               return AST_MODULE_LOAD_FAILURE;
+               return AST_MODULE_LOAD_DECLINE;
        }
 
        return AST_MODULE_LOAD_SUCCESS;