aboutsummaryrefslogtreecommitdiffstats
path: root/codecs
diff options
context:
space:
mode:
Diffstat (limited to 'codecs')
-rw-r--r--codecs/codec_g726.c5
-rw-r--r--codecs/codec_gsm.c6
-rw-r--r--codecs/codec_ilbc.c10
-rw-r--r--codecs/codec_lpc10.c12
-rw-r--r--codecs/codec_speex.c15
-rw-r--r--codecs/codec_zap.c16
6 files changed, 31 insertions, 33 deletions
diff --git a/codecs/codec_g726.c b/codecs/codec_g726.c
index f4cfdd749..1634ae5d2 100644
--- a/codecs/codec_g726.c
+++ b/codecs/codec_g726.c
@@ -700,12 +700,13 @@ struct g726_coder_pvt {
};
/*! \brief init a new instance of g726_coder_pvt. */
-static void *lintog726_new(struct ast_trans_pvt *pvt)
+static int lintog726_new(struct ast_trans_pvt *pvt)
{
struct g726_coder_pvt *tmp = pvt->pvt;
g726_init_state(&tmp->g726);
- return tmp;
+
+ return 0;
}
/*! \brief decode packed 4-bit G726 values and store in buffer. */
diff --git a/codecs/codec_gsm.c b/codecs/codec_gsm.c
index c7b0b100c..a23306e57 100644
--- a/codecs/codec_gsm.c
+++ b/codecs/codec_gsm.c
@@ -68,13 +68,11 @@ struct gsm_translator_pvt { /* both gsm2lin and lin2gsm */
int16_t buf[BUFFER_SAMPLES]; /* lin2gsm, temporary storage */
};
-static void *gsm_new(struct ast_trans_pvt *pvt)
+static int gsm_new(struct ast_trans_pvt *pvt)
{
struct gsm_translator_pvt *tmp = pvt->pvt;
- if (!(tmp->gsm = gsm_create()))
- return NULL;
- return tmp;
+ return (tmp->gsm = gsm_create()) ? 0 : -1;
}
static struct ast_frame *lintogsm_sample(void)
diff --git a/codecs/codec_ilbc.c b/codecs/codec_ilbc.c
index e41e4776f..883a385c8 100644
--- a/codecs/codec_ilbc.c
+++ b/codecs/codec_ilbc.c
@@ -67,20 +67,22 @@ struct ilbc_coder_pvt {
int16_t buf[BUFFER_SAMPLES];
};
-static void *lintoilbc_new(struct ast_trans_pvt *pvt)
+static int lintoilbc_new(struct ast_trans_pvt *pvt)
{
struct ilbc_coder_pvt *tmp = pvt->pvt;
initEncode(&tmp->enc, ILBC_MS);
- return tmp;
+
+ return 0;
}
-static void *ilbctolin_new(struct ast_trans_pvt *pvt)
+static int ilbctolin_new(struct ast_trans_pvt *pvt)
{
struct ilbc_coder_pvt *tmp = pvt->pvt;
initDecode(&tmp->dec, ILBC_MS, USE_ILBC_ENHANCER);
- return tmp;
+
+ return 0;
}
static struct ast_frame *lintoilbc_sample(void)
diff --git a/codecs/codec_lpc10.c b/codecs/codec_lpc10.c
index 8f1c81a43..e41137de1 100644
--- a/codecs/codec_lpc10.c
+++ b/codecs/codec_lpc10.c
@@ -72,22 +72,18 @@ struct lpc10_coder_pvt {
int longer;
};
-static void *lpc10_enc_new(struct ast_trans_pvt *pvt)
+static int lpc10_enc_new(struct ast_trans_pvt *pvt)
{
struct lpc10_coder_pvt *tmp = pvt->pvt;
- if (!(tmp->lpc10.enc = create_lpc10_encoder_state()))
- return NULL;
- return tmp;
+ return (tmp->lpc10.enc = create_lpc10_encoder_state()) ? 0 : -1;
}
-static void *lpc10_dec_new(struct ast_trans_pvt *pvt)
+static int lpc10_dec_new(struct ast_trans_pvt *pvt)
{
struct lpc10_coder_pvt *tmp = pvt->pvt;
- if (!(tmp->lpc10.dec = create_lpc10_decoder_state()))
- return NULL;
- return tmp;
+ return (tmp->lpc10.dec = create_lpc10_decoder_state()) ? 0 : -1;
}
static struct ast_frame *lintolpc10_sample(void)
diff --git a/codecs/codec_speex.c b/codecs/codec_speex.c
index 81808f9fd..ebc1ed566 100644
--- a/codecs/codec_speex.c
+++ b/codecs/codec_speex.c
@@ -103,17 +103,16 @@ struct speex_coder_pvt {
};
-static void *lintospeex_new(struct ast_trans_pvt *pvt)
+static int lintospeex_new(struct ast_trans_pvt *pvt)
{
struct speex_coder_pvt *tmp = pvt->pvt;
if (!(tmp->speex = speex_encoder_init(&speex_nb_mode)))
- return NULL;
+ return -1;
speex_bits_init(&tmp->bits);
speex_bits_reset(&tmp->bits);
speex_encoder_ctl(tmp->speex, SPEEX_GET_FRAME_SIZE, &tmp->framesize);
- ast_log(LOG_WARNING, "speex framesize is %d\n", tmp->framesize);
speex_encoder_ctl(tmp->speex, SPEEX_SET_COMPLEXITY, &complexity);
#ifdef _SPEEX_TYPES_H
if (preproc) {
@@ -142,20 +141,22 @@ static void *lintospeex_new(struct ast_trans_pvt *pvt)
speex_encoder_ctl(tmp->speex, SPEEX_SET_DTX, &dtx);
tmp->silent_state = 0;
- return tmp;
+ return 0;
}
-static void *speextolin_new(struct ast_trans_pvt *pvt)
+static int speextolin_new(struct ast_trans_pvt *pvt)
{
struct speex_coder_pvt *tmp = pvt->pvt;
if (!(tmp->speex = speex_decoder_init(&speex_nb_mode)))
- return NULL;
+ return -1;
+
speex_bits_init(&tmp->bits);
speex_decoder_ctl(tmp->speex, SPEEX_GET_FRAME_SIZE, &tmp->framesize);
if (enhancement)
speex_decoder_ctl(tmp->speex, SPEEX_SET_ENH, &enhancement);
- return tmp;
+
+ return 0;
}
static struct ast_frame *lintospeex_sample(void)
diff --git a/codecs/codec_zap.c b/codecs/codec_zap.c
index cad97c475..e7ece201d 100644
--- a/codecs/codec_zap.c
+++ b/codecs/codec_zap.c
@@ -43,7 +43,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <sys/ioctl.h>
#include <errno.h>
#include <sys/mman.h>
-#include <linux/zaptel.h>
+#include <zaptel.h>
#include "asterisk/lock.h"
#include "asterisk/translate.h"
@@ -162,7 +162,7 @@ static void zap_destroy(struct ast_trans_pvt *pvt)
close(ztp->fd);
}
-static struct ast_trans_pvt *zap_translate(struct ast_trans_pvt *pvt, int dest, int source)
+static int zap_translate(struct ast_trans_pvt *pvt, int dest, int source)
{
/* Request translation through zap if possible */
int fd;
@@ -171,13 +171,13 @@ static struct ast_trans_pvt *zap_translate(struct ast_trans_pvt *pvt, int dest,
struct zt_transcode_header *hdr;
if ((fd = open("/dev/zap/transcode", O_RDWR)) < 0)
- return NULL;
+ return -1;
if ((hdr = mmap(NULL, sizeof(*hdr), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) {
ast_log(LOG_ERROR, "Memory Map failed for transcoding (%s)\n", strerror(errno));
close(fd);
- return NULL;
+ return -1;
}
if (hdr->magic != ZT_TRANSCODE_MAGIC) {
@@ -185,7 +185,7 @@ static struct ast_trans_pvt *zap_translate(struct ast_trans_pvt *pvt, int dest,
munmap(hdr, sizeof(*hdr));
close(fd);
- return NULL;
+ return -1;
}
hdr->srcfmt = (1 << source);
@@ -195,17 +195,17 @@ static struct ast_trans_pvt *zap_translate(struct ast_trans_pvt *pvt, int dest,
munmap(hdr, sizeof(*hdr));
close(fd);
- return NULL;
+ return -1;
}
ztp = pvt->pvt;
ztp->fd = fd;
ztp->hdr = hdr;
- return pvt;
+ return 0;
}
-static void *zap_new(struct ast_trans_pvt *pvt)
+static int zap_new(struct ast_trans_pvt *pvt)
{
return zap_translate(pvt, pvt->t->dstfmt, pvt->t->srcfmt);
}