[asterisk-commits] russell: branch group/asterisk-cpp r168404 - /team/group/asterisk-cpp/main/dsp.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jan 10 19:09:45 CST 2009


Author: russell
Date: Sat Jan 10 19:09:45 2009
New Revision: 168404

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=168404
Log:
dsp.c compiles except for the usage of offsetof() which it doesn't like

Modified:
    team/group/asterisk-cpp/main/dsp.c

Modified: team/group/asterisk-cpp/main/dsp.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/main/dsp.c?view=diff&rev=168404&r1=168403&r2=168404
==============================================================================
--- team/group/asterisk-cpp/main/dsp.c (original)
+++ team/group/asterisk-cpp/main/dsp.c Sat Jan 10 19:09:45 2009
@@ -88,7 +88,7 @@
 };
 
 static struct progalias {
-	char *name;
+	const char *name;
 	enum prog_mode mode;
 } aliases[] = {
 	{ "us", PROG_MODE_NA },
@@ -403,7 +403,7 @@
 
 static void mute_fragment(struct ast_dsp *dsp, fragment_t *fragment)
 {
-	if (dsp->mute_fragments >= ARRAY_LEN(dsp->mute_data)) {
+	if (dsp->mute_fragments >= (int) ARRAY_LEN(dsp->mute_data)) {
 		ast_log(LOG_ERROR, "Too many fragments to mute. Ignoring\n");
 		return;
 	}
@@ -1104,7 +1104,7 @@
 		ast_log(LOG_WARNING, "Can only check call progress in signed-linear frames\n");
 		return 0;
 	}
-	return __ast_dsp_call_progress(dsp, inf->data.ptr, inf->datalen / 2);
+	return __ast_dsp_call_progress(dsp, (short *) inf->data.ptr, inf->datalen / 2);
 }
 
 static int __ast_dsp_silence_noise(struct ast_dsp *dsp, short *s, int len, int *totalsilence, int *totalnoise)
@@ -1278,7 +1278,7 @@
 		ast_log(LOG_WARNING, "Can only calculate silence on signed-linear frames :(\n");
 		return 0;
 	}
-	s = f->data.ptr;
+	s = (short *) f->data.ptr;
 	len = f->datalen/2;
 	return __ast_dsp_silence_noise(dsp, s, len, totalsilence, NULL);
 }
@@ -1296,7 +1296,7 @@
                ast_log(LOG_WARNING, "Can only calculate noise on signed-linear frames :(\n");
                return 0;
        }
-       s = f->data.ptr;
+       s = (short *) f->data.ptr;
        len = f->datalen/2;
        return __ast_dsp_silence_noise(dsp, s, len, NULL, totalnoise);
 }
@@ -1320,22 +1320,22 @@
 		return af;
 	}
 
-	odata = af->data.ptr;
+	odata = (unsigned char *) af->data.ptr;
 	len = af->datalen;
 	/* Make sure we have short data */
 	switch (af->subclass) {
 	case AST_FORMAT_SLINEAR:
-		shortdata = af->data.ptr;
+		shortdata = (short *) af->data.ptr;
 		len = af->datalen / 2;
 		break;
 	case AST_FORMAT_ULAW:
-		shortdata = alloca(af->datalen * 2);
+		shortdata = (short *) alloca(af->datalen * 2);
 		for (x = 0;x < len; x++) {
 			shortdata[x] = AST_MULAW(odata[x]);
 		}
 		break;
 	case AST_FORMAT_ALAW:
-		shortdata = alloca(af->datalen * 2);
+		shortdata = (short *) alloca(af->datalen * 2);
 		for (x = 0; x < len; x++) {
 			shortdata[x] = AST_ALAW(odata[x]);
 		}
@@ -1410,7 +1410,7 @@
 
 			if (event) {
 				memset(&dsp->f, 0, sizeof(dsp->f));
-				dsp->f.frametype = event;
+				dsp->f.frametype = (ast_frame_type) event;
 				dsp->f.subclass = event_digit;
 				outf = &dsp->f;
 				goto done;
@@ -1488,11 +1488,10 @@
 static void ast_dsp_prog_reset(struct ast_dsp *dsp)
 {
 	int max = 0;
-	int x;
 	
 	dsp->gsamp_size = modes[dsp->progmode].size;
 	dsp->gsamps = 0;
-	for (x = 0; x < ARRAY_LEN(modes[dsp->progmode].freqs); x++) {
+	for (unsigned int x = 0; x < ARRAY_LEN(modes[dsp->progmode].freqs); x++) {
 		if (modes[dsp->progmode].freqs[x]) {
 			goertzel_init(&dsp->freqs[x], (float)modes[dsp->progmode].freqs[x], dsp->gsamp_size);
 			max = x + 1;
@@ -1506,7 +1505,7 @@
 {
 	struct ast_dsp *dsp;
 	
-	if ((dsp = ast_calloc(1, sizeof(*dsp)))) {		
+	if ((dsp = (struct ast_dsp *) ast_calloc(1, sizeof(*dsp)))) {		
 		dsp->threshold = DEFAULT_THRESHOLD;
 		dsp->features = DSP_FEATURE_SILENCE_SUPPRESS;
 		dsp->busycount = DSP_HISTORY;
@@ -1612,14 +1611,14 @@
 
 int ast_dsp_set_digitmode(struct ast_dsp *dsp, int digitmode)
 {
-	int new;
+	int newmode;
 	int old;
 	
 	old = dsp->digitmode & (DSP_DIGITMODE_DTMF | DSP_DIGITMODE_MF | DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_MUTEMAX);
-	new = digitmode & (DSP_DIGITMODE_DTMF | DSP_DIGITMODE_MF | DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_MUTEMAX);
-	if (old != new) {
+	newmode = digitmode & (DSP_DIGITMODE_DTMF | DSP_DIGITMODE_MF | DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_MUTEMAX);
+	if (old != newmode) {
 		/* Must initialize structures if switching from MF to DTMF or vice-versa */
-		ast_digit_detect_init(&dsp->digit_state, new & DSP_DIGITMODE_MF);
+		ast_digit_detect_init(&dsp->digit_state, newmode & DSP_DIGITMODE_MF);
 	}
 	dsp->digitmode = digitmode;
 	return 0;
@@ -1636,9 +1635,7 @@
 
 int ast_dsp_set_call_progress_zone(struct ast_dsp *dsp, char *zone)
 {
-	int x;
-	
-	for (x = 0; x < ARRAY_LEN(aliases); x++) {
+	for (unsigned int x = 0; x < ARRAY_LEN(aliases); x++) {
 		if (!strcasecmp(aliases[x].name, zone)) {
 			dsp->progmode = aliases[x].mode;
 			ast_dsp_prog_reset(dsp);




More information about the asterisk-commits mailing list