[asterisk-commits] tilghman: trunk r90993 - /trunk/channels/chan_usbradio.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Dec 4 15:46:28 CST 2007


Author: tilghman
Date: Tue Dec  4 15:46:27 2007
New Revision: 90993

URL: http://svn.digium.com/view/asterisk?view=rev&rev=90993
Log:
Coding guidelines fixups
(Closes issue #11412)

Modified:
    trunk/channels/chan_usbradio.c

Modified: trunk/channels/chan_usbradio.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_usbradio.c?view=diff&rev=90993&r1=90992&r2=90993
==============================================================================
--- trunk/channels/chan_usbradio.c (original)
+++ trunk/channels/chan_usbradio.c Tue Dec  4 15:46:27 2007
@@ -79,15 +79,15 @@
 #include "./xpmr/xpmr.h"
 
 #if 0
-#define traceusb1(a) {printf a;}
+#define traceusb1(a, ...) ast_debug(4, a __VA_ARGS__)
 #else
-#define traceusb1(a)
+#define traceusb1(a, ...)
 #endif
 
 #if 0
-#define traceusb2(a) {printf a;}
+#define traceusb2(a, ...) ast_debug(4, a __VA_ARGS__)
 #else
-#define traceusb2(a)
+#define traceusb2(a, ...)
 #endif
 
 #ifdef __linux
@@ -300,7 +300,7 @@
 static FILE *ftxcapraw = NULL, *ftxcaptrace = NULL, *ftxoutraw = NULL;
 
 static int usbradio_debug;
-#if 0 //maw asdf sph
+#if 0 /* maw asdf sph */
 static int usbradio_debug_level = 0;
 #endif
 
@@ -356,12 +356,12 @@
 	 * nosound is set to disable the audio data from the channel
 	 * (so we can play the tones etc.).
 	 */
-	int sndcmd[2];				/* Sound command pipe */
-	int cursound;				/* index of sound to send */
-	int sampsent;				/* # of sound samples sent  */
-	int nosound;				/* set to block audio from the PBX */
-
-	int total_blocks;			/* total blocks in the output device */
+	int sndcmd[2];              /* Sound command pipe */
+	int cursound;               /* index of sound to send */
+	int sampsent;               /* # of sound samples sent  */
+	int nosound;                /* set to block audio from the PBX */
+
+	int total_blocks;           /* total blocks in the output device */
 	int sounddev;
 	enum { M_UNSET, M_FULL, M_READ, M_WRITE } duplex;
 	i16 cdMethod;
@@ -371,11 +371,11 @@
 	unsigned int queuesize;		/* max fragments in queue */
 	unsigned int frags;			/* parameter for SETFRAGMENT */
 
-	int warned;					/* various flags used for warnings */
+	int warned;                 /* various flags used for warnings */
 #define WARN_used_blocks	1
 #define WARN_speed		2
 #define WARN_frag		4
-	int w_errors;				/* overfull in the write path */
+	int w_errors;               /* overfull in the write path */
 	struct timeval lastopen;
 
 	int overridecontext;
@@ -385,8 +385,8 @@
 	 * be representable in 16 bits to avoid overflows.
 	 */
 #define	BOOST_SCALE	(1<<9)
-#define	BOOST_MAX	40			/* slightly less than 7 bits */
-	int boost;					/* input boost, scaled by BOOST_SCALE */
+#define	BOOST_MAX	40          /* slightly less than 7 bits */
+	int boost;                  /* input boost, scaled by BOOST_SCALE */
 	char devicenum;
 	int spkrmax;
 	int micmax;
@@ -394,96 +394,96 @@
 	pthread_t sthread;
 	pthread_t hidthread;
 
-	int stophid;
+	int     stophid;
 	struct ast_channel *owner;
-	char ext[AST_MAX_EXTENSION];
-	char ctx[AST_MAX_CONTEXT];
-	char language[MAX_LANGUAGE];
-	char cid_name[256];			/*XXX */
-	char cid_num[256];			/*XXX */
-	char mohinterpret[MAX_MUSICCLASS];
+	char    ext[AST_MAX_EXTENSION];
+	char    ctx[AST_MAX_CONTEXT];
+	char    language[MAX_LANGUAGE];
+	char    cid_name[256];          /* XXX */
+	char    cid_num[256];           /* XXX */
+	char    mohinterpret[MAX_MUSICCLASS];
 
 	/* buffers used in usbradio_write, 2 per int by 2 channels by 6 times oversampling (48KS/s) */
-	char usbradio_write_buf[FRAME_SIZE * 2 * 2 * 6];    
-	char usbradio_write_buf_1[FRAME_SIZE * 2 * 2* 6];
-
-	int usbradio_write_dst;
+	char    usbradio_write_buf[FRAME_SIZE * 2 * 2 * 6];
+	char    usbradio_write_buf_1[FRAME_SIZE * 2 * 2 * 6];
+
+	int     usbradio_write_dst;
 	/* buffers used in usbradio_read - AST_FRIENDLY_OFFSET space for headers
 	 * plus enough room for a full frame
 	 */
-	char usbradio_read_buf[FRAME_SIZE * (2 * 12) + AST_FRIENDLY_OFFSET];
-	char usbradio_read_buf_8k[FRAME_SIZE * 2 + AST_FRIENDLY_OFFSET];
-	int readpos;				/* read position above */
-	struct ast_frame read_f;	/* returned by usbradio_read */
+	char    usbradio_read_buf[FRAME_SIZE * (2 * 12) + AST_FRIENDLY_OFFSET];
+	char    usbradio_read_buf_8k[FRAME_SIZE * 2 + AST_FRIENDLY_OFFSET];
+	int     readpos;         /* read position above */
+	struct ast_frame read_f; /* returned by usbradio_read */
 	
 
-	char debuglevel;
-	char radioduplex;			
-
-	char lastrx;
-	char rxhidsq;
-	char rxcarrierdetect;		/*!< status from pmr channel */
-	char rxctcssdecode;			/*!< status from pmr channel */
-
-	char rxkeytype;
-	char rxkeyed;	  			/*!< indicates rx signal present */
-
-	char lasttx;
-	char txkeyed;				/*! tx key request from upper layers  */
-	char txchankey;
-	char txtestkey;
-
-	time_t lasthidtime;
+	char    debuglevel;
+	char    radioduplex;
+
+	char    lastrx;
+	char    rxhidsq;
+	char    rxcarrierdetect; /*!< status from pmr channel */
+	char    rxctcssdecode;   /*!< status from pmr channel */
+
+	char    rxkeytype;
+	char    rxkeyed;         /*!< indicates rx signal present */
+
+	char    lasttx;
+	char    txkeyed;         /*! tx key request from upper layers  */
+	char    txchankey;
+	char    txtestkey;
+
+	time_t  lasthidtime;
     struct ast_dsp *dsp;
 
-	t_pmr_chan	*pmrChan;
+	t_pmr_chan *pmrChan;
 
 	char    rxcpusaver;
 	char    txcpusaver;
 
-	char	rxdemod;
-	float	rxgain;
-	char 	rxcdtype;
-	char 	rxsdtype;
-	int	rxsquelchadj;   /*!< this copy needs to be here for initialization */
-	char	txtoctype;
+	char    rxdemod;
+	float   rxgain;
+	char    rxcdtype;
+	char    rxsdtype;
+	int     rxsquelchadj;    /*!< this copy needs to be here for initialization */
+	char    txtoctype;
 
 	char    txprelim;
-	float	txctcssgain;
-	char 	txmixa;
-	char 	txmixb;
-
-	char	invertptt;
-
-	char	rxctcssrelax;
-	float	rxctcssgain;
-	float 	rxctcssfreq;
-	float 	txctcssfreq;
-
-	int	rxmixerset;	   	
-	int 	rxboostset;
-	float	rxvoiceadj;
-	float	rxctcssadj;
-	int 	txmixaset;
-	int 	txmixbset;
+	float   txctcssgain;
+	char    txmixa;
+	char    txmixb;
+
+	char    invertptt;
+
+	char    rxctcssrelax;
+	float   rxctcssgain;
+	float   rxctcssfreq;
+	float   txctcssfreq;
+
+	int     rxmixerset;
+	int     rxboostset;
+	float   rxvoiceadj;
+	float   rxctcssadj;
+	int     txmixaset;
+	int     txmixbset;
 	int     txctcssadj;
 
 	int    	hdwtype;
-	int	hid_gpio_ctl;		
-	int	hid_gpio_ctl_loc;	
-	int	hid_io_cor; 		
-	int	hid_io_cor_loc; 	
-	int	hid_io_ctcss;		
-	int	hid_io_ctcss_loc; 	
-	int	hid_io_ptt; 		
-	int	hid_gpio_loc; 		
+	int     hid_gpio_ctl;
+	int     hid_gpio_ctl_loc;
+	int     hid_io_cor;
+	int     hid_io_cor_loc;
+	int     hid_io_ctcss;
+	int     hid_io_ctcss_loc;
+	int     hid_io_ptt;
+	int     hid_gpio_loc;
 
 	struct {
-	    	unsigned rxcapraw:1;
+		unsigned rxcapraw:1;
 		unsigned txcapraw:1;
 		unsigned txcap2:1;
 		unsigned rxcap2:1;
-	}b;
+	} b;
 };
 
 /* maw add additional defaults !!! */
@@ -505,8 +505,8 @@
 /*	DECLARE FUNCTION PROTOTYPES	*/
 
 static void store_txtoctype(struct chan_usbradio_pvt *o, const char *s);
-static int	hidhdwconfig(struct chan_usbradio_pvt *o);
-static int set_txctcss_level(struct chan_usbradio_pvt *o);
+static int  hidhdwconfig(struct chan_usbradio_pvt *o);
+static int  set_txctcss_level(struct chan_usbradio_pvt *o);
 static void pmrdump(struct chan_usbradio_pvt *o);
 static void mult_set(struct chan_usbradio_pvt *o);
 static int  mult_calc(int value);
@@ -519,7 +519,7 @@
 
 static char *usbradio_active;	 /* the active device */
 
-static int setformat(struct chan_usbradio_pvt *o, int mode);
+static int  setformat(struct chan_usbradio_pvt *o, int mode);
 
 static struct ast_channel *usbradio_request(const char *type, int format, void *data
 , int *cause);
@@ -566,15 +566,15 @@
 static int amixer_max(int devnum,char *param)
 {
 	int	rv,type;
-	char	str[100];
+	char str[15];
 	snd_hctl_t *hctl;
 	snd_ctl_elem_id_t *id;
 	snd_hctl_elem_t *elem;
 	snd_ctl_elem_info_t *info;
 
-	sprintf(str,"hw:%d",devnum);
+	snprintf(str, sizeof(str), "hw:%d", devnum);
 	if (snd_hctl_open(&hctl, str, 0))
-		return(-1);
+		return -1;
 	snd_hctl_load(hctl);
 	id = alloca(snd_ctl_elem_id_sizeof());
 	memset(id, 0, snd_ctl_elem_id_sizeof());
@@ -583,18 +583,18 @@
 	elem = snd_hctl_find_elem(hctl, id);
 	if (!elem) {
 		snd_hctl_close(hctl);
-		return(-1);
+		return -1;
 	}
 	info = alloca(snd_ctl_elem_info_sizeof());
 	memset(info, 0, snd_ctl_elem_info_sizeof());
 	snd_hctl_elem_info(elem,info);
 	type = snd_ctl_elem_info_get_type(info);
 	rv = 0;
-	switch(type) {
-	    case SND_CTL_ELEM_TYPE_INTEGER:
+	switch (type) {
+	case SND_CTL_ELEM_TYPE_INTEGER:
 		rv = snd_ctl_elem_info_get_max(info);
 		break;
-	    case SND_CTL_ELEM_TYPE_BOOLEAN:
+	case SND_CTL_ELEM_TYPE_BOOLEAN:
 		rv = 1;
 		break;
 	}
@@ -608,19 +608,19 @@
 
 Note: must add -lasound to end of linkage */
 
-static int setamixer(int devnum,char *param, int v1, int v2)
+static int setamixer(int devnum, char *param, int v1, int v2)
 {
 	int	type;
-	char	str[100];
+	char str[15];
 	snd_hctl_t *hctl;
 	snd_ctl_elem_id_t *id;
 	snd_ctl_elem_value_t *control;
 	snd_hctl_elem_t *elem;
 	snd_ctl_elem_info_t *info;
 
-	sprintf(str,"hw:%d",devnum);
+	snprintf(str, sizeof(str), "hw:%d", devnum);
 	if (snd_hctl_open(&hctl, str, 0))
-		return(-1);
+		return -1;
 	snd_hctl_load(hctl);
 	id = alloca(snd_ctl_elem_id_sizeof());
 	memset(id, 0, snd_ctl_elem_id_sizeof());
@@ -629,7 +629,7 @@
 	elem = snd_hctl_find_elem(hctl, id);
 	if (!elem) {
 		snd_hctl_close(hctl);
-		return(-1);
+		return -1;
 	}
 	info = alloca(snd_ctl_elem_info_sizeof());
 	memset(info, 0, snd_ctl_elem_info_sizeof());
@@ -638,12 +638,12 @@
 	control = alloca(snd_ctl_elem_value_sizeof());
 	memset(control, 0, snd_ctl_elem_value_sizeof());
 	snd_ctl_elem_value_set_id(control, id);    
-	switch(type) {
-	    case SND_CTL_ELEM_TYPE_INTEGER:
+	switch (type) {
+	case SND_CTL_ELEM_TYPE_INTEGER:
 		snd_ctl_elem_value_set_integer(control, 0, v1);
 		if (v2 > 0) snd_ctl_elem_value_set_integer(control, 1, v2);
 		break;
-	    case SND_CTL_ELEM_TYPE_BOOLEAN:
+	case SND_CTL_ELEM_TYPE_BOOLEAN:
 		snd_ctl_elem_value_set_integer(control, 0, (v1 != 0));
 		break;
 	}
@@ -652,29 +652,29 @@
 		return(-1);
 	}
 	snd_hctl_close(hctl);
-	return(0);
+	return 0;
 }
 
 static void hid_set_outputs(struct usb_dev_handle *handle,
          unsigned char *outputs)
 {
 	usb_control_msg(handle,
-	      USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE,
-	      HID_REPORT_SET,
-	      0 + (HID_RT_OUTPUT << 8),
-	      C108_HID_INTERFACE,
-	      (char*)outputs, 4, 5000);
+		USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE,
+		HID_REPORT_SET,
+		0 + (HID_RT_OUTPUT << 8),
+		C108_HID_INTERFACE,
+		(char *)outputs, 4, 5000);
 }
 
 static void hid_get_inputs(struct usb_dev_handle *handle,
          unsigned char *inputs)
 {
 	usb_control_msg(handle,
-	      USB_ENDPOINT_IN + USB_TYPE_CLASS + USB_RECIP_INTERFACE,
-	      HID_REPORT_GET,
-	      0 + (HID_RT_INPUT << 8),
-	      C108_HID_INTERFACE,
-	      (char*)inputs, 4, 5000);
+		USB_ENDPOINT_IN + USB_TYPE_CLASS + USB_RECIP_INTERFACE,
+		HID_REPORT_GET,
+		0 + (HID_RT_INPUT << 8),
+		C108_HID_INTERFACE,
+		(char *)inputs, 4, 5000);
 }
 
 static struct usb_device *hid_device_init(void)
@@ -696,38 +696,33 @@
 
 static int hidhdwconfig(struct chan_usbradio_pvt *o)
 {
-	if(o->hdwtype==1)	  /*sphusb */
-	{
-		o->hid_gpio_ctl		=  0x08;	/* set GPIO4 to output mode */
-		o->hid_gpio_ctl_loc	=  2; 	/* For CTL of GPIO */
-		o->hid_io_cor		=  4;	/* GPIO3 is COR */
-		o->hid_io_cor_loc	=  1;	/* GPIO3 is COR */
-		o->hid_io_ctcss		=  2;  	/* GPIO 2 is External CTCSS */
-		o->hid_io_ctcss_loc =  1;	/* is GPIO 2 */
-		o->hid_io_ptt 		=  8;  	/* GPIO 4 is PTT */
-		o->hid_gpio_loc 	=  1;  	/* For ALL GPIO */
-	}
-	else if(o->hdwtype==0)	/* dudeusb */
-	{
-		o->hid_gpio_ctl		=  0x0c;	/* set GPIO 3 & 4 to output mode */
-		o->hid_gpio_ctl_loc	=  2; 	/* For CTL of GPIO */
-		o->hid_io_cor		=  2;	/* VOLD DN is COR */
-		o->hid_io_cor_loc	=  0;	/* VOL DN COR */
-		o->hid_io_ctcss		=  2;  	/* GPIO 2 is External CTCSS */
-		o->hid_io_ctcss_loc =  1;	/* is GPIO 2 */
-		o->hid_io_ptt 		=  4;  	/* GPIO 3 is PTT */
-		o->hid_gpio_loc 	=  1;  	/* For ALL GPIO */
-	}
-	else if(o->hdwtype==3)	/* custom version */
-	{
-		o->hid_gpio_ctl		=  0x0c;	/* set GPIO 3 & 4 to output mode */
-		o->hid_gpio_ctl_loc	=  2; 	/* For CTL of GPIO */
-		o->hid_io_cor		=  2;	/* VOLD DN is COR */
-		o->hid_io_cor_loc	=  0;	/* VOL DN COR */
-		o->hid_io_ctcss		=  2;  	/* GPIO 2 is External CTCSS */
-		o->hid_io_ctcss_loc =  1;	/* is GPIO 2 */
-		o->hid_io_ptt 		=  4;  	/* GPIO 3 is PTT */
-		o->hid_gpio_loc 	=  1;  	/* For ALL GPIO */
+	if (o->hdwtype == 1) {         /*sphusb */
+		o->hid_gpio_ctl     =  0x08; /* set GPIO4 to output mode */
+		o->hid_gpio_ctl_loc =  2;    /* For CTL of GPIO */
+		o->hid_io_cor       =  4;    /* GPIO3 is COR */
+		o->hid_io_cor_loc   =  1;    /* GPIO3 is COR */
+		o->hid_io_ctcss     =  2;    /* GPIO 2 is External CTCSS */
+		o->hid_io_ctcss_loc =  1;    /* is GPIO 2 */
+		o->hid_io_ptt       =  8;    /* GPIO 4 is PTT */
+		o->hid_gpio_loc     =  1;    /* For ALL GPIO */
+	} else if (o->hdwtype == 0) {  /* dudeusb */
+		o->hid_gpio_ctl     =  0x0c;/* set GPIO 3 & 4 to output mode */
+		o->hid_gpio_ctl_loc =  2;    /* For CTL of GPIO */
+		o->hid_io_cor       =  2;    /* VOLD DN is COR */
+		o->hid_io_cor_loc   =  0;    /* VOL DN COR */
+		o->hid_io_ctcss     =  2;    /* GPIO 2 is External CTCSS */
+		o->hid_io_ctcss_loc =  1;    /* is GPIO 2 */
+		o->hid_io_ptt       =  4;    /* GPIO 3 is PTT */
+		o->hid_gpio_loc     =  1;    /* For ALL GPIO */
+	} else if (o->hdwtype == 3) {  /* custom version */
+		o->hid_gpio_ctl     =  0x0c; /* set GPIO 3 & 4 to output mode */
+		o->hid_gpio_ctl_loc =  2;    /* For CTL of GPIO */
+		o->hid_io_cor       =  2;    /* VOLD DN is COR */
+		o->hid_io_cor_loc   =  0;    /* VOL DN COR */
+		o->hid_io_ctcss     =  2;    /* GPIO 2 is External CTCSS */
+		o->hid_io_ctcss_loc =  1;    /* is GPIO 2 */
+		o->hid_io_ptt       =  4;    /* GPIO 3 is PTT */
+		o->hid_gpio_loc     =  1;    /* For ALL GPIO */
 	}
 
 	return 0;
@@ -736,70 +731,72 @@
 
 static void *hidthread(void *arg)
 {
-	unsigned char buf[4],keyed;
+	unsigned char buf[4], keyed;
 	char lastrx, txtmp;
 	struct usb_device *usb_dev;
 	struct usb_dev_handle *usb_handle;
-	struct chan_usbradio_pvt *o = (struct chan_usbradio_pvt *) arg;
+	struct chan_usbradio_pvt *o = arg;
 
 	usb_dev = hid_device_init();
 	if (usb_dev == NULL) {
-		ast_log(LOG_ERROR,"USB HID device not found\n");
+		ast_log(LOG_ERROR, "USB HID device not found\n");
 		pthread_exit(NULL);
 	}
 	usb_handle = usb_open(usb_dev);
 	if (usb_handle == NULL) {
-	        ast_log(LOG_ERROR,"Not able to open USB device\n");
+		ast_log(LOG_ERROR, "Not able to open USB device\n");
 		pthread_exit(NULL);
 	}
-	if (usb_claim_interface(usb_handle,C108_HID_INTERFACE) < 0) {
-	        if (usb_detach_kernel_driver_np(usb_handle,C108_HID_INTERFACE) < 0) {
-		        ast_log(LOG_ERROR,"Not able to detach the USB device\n");
+	if (usb_claim_interface(usb_handle, C108_HID_INTERFACE) < 0) {
+	        if (usb_detach_kernel_driver_np(usb_handle, C108_HID_INTERFACE) < 0) {
+			ast_log(LOG_ERROR, "Not able to detach the USB device\n");
 			pthread_exit(NULL);
 		}
-		if (usb_claim_interface(usb_handle,C108_HID_INTERFACE) < 0) {
-		        ast_log(LOG_ERROR,"Not able to claim the USB device\n");
+		if (usb_claim_interface(usb_handle, C108_HID_INTERFACE) < 0) {
+			ast_log(LOG_ERROR, "Not able to claim the USB device\n");
 			pthread_exit(NULL);
 		}
 	}
-	memset(buf,0,sizeof(buf));
+	memset(buf, 0, sizeof(buf));
 	buf[2] = o->hid_gpio_ctl;
 	buf[1] = 0;
-	hid_set_outputs(usb_handle,buf);
-	traceusb1(("hidthread: Starting normally!!\n"));
+	hid_set_outputs(usb_handle, buf);
+	traceusb1("hidthread: Starting normally!!\n");
 	lastrx = 0;
-	while(!o->stophid) {
+	while (!o->stophid) {
 		buf[o->hid_gpio_ctl_loc] = o->hid_gpio_ctl;
-		hid_get_inputs(usb_handle,buf);
+		hid_get_inputs(usb_handle, buf);
 		keyed = !(buf[o->hid_io_cor_loc] & o->hid_io_cor);
 		if (keyed != o->rxhidsq) {
-			if(o->debuglevel)
-				printf("chan_usbradio() hidthread: update rxhidsq = %d\n", keyed);
-			o->rxhidsq=keyed;		 
+			if (o->debuglevel)
+				ast_log(LOG_NOTICE, "chan_usbradio() hidthread: update rxhidsq = %d\n", keyed);
+			o->rxhidsq = keyed;		 
 		}
 
 		/* if change in tx stuff */
-		txtmp=0;
-		if(o->txkeyed || o->txchankey || o->txtestkey || o->pmrChan->txPttOut)
-			txtmp=1;
+		txtmp = 0;
+		if (o->txkeyed || o->txchankey || o->txtestkey || o->pmrChan->txPttOut)
+			txtmp = 1;
 		
 		if (o->lasttx != txtmp) {
 			o->lasttx = txtmp;
-			if(o->debuglevel)
-				printf("hidthread: tx set to %d\n", txtmp);
+			if (o->debuglevel)
+				ast_log(LOG_NOTICE, "hidthread: tx set to %d\n", txtmp);
 			buf[o->hid_gpio_loc] = 0;
-			if (txtmp) buf[o->hid_gpio_loc] = o->hid_io_ptt;
+			if (txtmp)
+				buf[o->hid_gpio_loc] = o->hid_io_ptt;
 			buf[o->hid_gpio_ctl_loc] = o->hid_gpio_ctl;
-			hid_set_outputs(usb_handle,buf);
+			hid_set_outputs(usb_handle, buf);
 		}
 
 		time(&o->lasthidtime);
 		usleep(50000);
 	}
 	buf[o->hid_gpio_loc] = 0;
-	if (o->invertptt) buf[o->hid_gpio_loc] = o->hid_io_ptt;
+	if (o->invertptt)
+		buf[o->hid_gpio_loc] = o->hid_io_ptt;
 	buf[o->hid_gpio_ctl_loc] = o->hid_gpio_ctl;
-	hid_set_outputs(usb_handle,buf);
+	hid_set_outputs(usb_handle, buf);
 	pthread_exit(0);
 }
 
@@ -873,8 +870,7 @@
 	}
 
 	if (o->total_blocks == 0) {
-		if (0)					/* debugging */
-			ast_log(LOG_WARNING, "fragtotal %d size %d avail %d\n", info.fragstotal, info.fragsize, info.fragments);
+		ast_debug(4, "fragtotal %d size %d avail %d\n", info.fragstotal, info.fragsize, info.fragments);
 		o->total_blocks = info.fragments;
 	}
 
@@ -937,9 +933,8 @@
 				l = FRAME_SIZE - ofs;
 			if (l > s->datalen - start)	/* don't overflow the source */
 				l = s->datalen - start;
-			bcopy(s->data + start, myframe + ofs, l * 2);
-			if (0)
-				ast_log(LOG_WARNING, "send_sound sound %d/%d of %d into %d\n", l_sampsent, l, s->samplen, ofs);
+			memcpy(myframe + ofs, s->data + start, l * 2);
+			ast_debug(4, "send_sound sound %d/%d of %d into %d\n", l_sampsent, l, s->samplen, ofs);
 			l_sampsent += l;
 		} else {				/* end of samples, maybe some silence */
 			static const short silence[FRAME_SIZE] = { 0, };
@@ -948,14 +943,14 @@
 			if (l > 0) {
 				if (l > FRAME_SIZE - ofs)
 					l = FRAME_SIZE - ofs;
-				bcopy(silence, myframe + ofs, l * 2);
+				memcpy(myframe + ofs, silence, l * 2);
 				l_sampsent += l;
 			} else {			/* silence is over, restart sound if loop */
 				if (s->repeat == 0) {	/* last block */
 					o->cursound = -1;
 					o->nosound = 0;	/* allow audio data */
 					if (ofs < FRAME_SIZE)	/* pad with silence */
-						bcopy(silence, myframe + ofs, (FRAME_SIZE - ofs) * 2);
+						memcpy(myframe + ofs, silence, (FRAME_SIZE - ofs) * 2);
 				}
 				l_sampsent = 0;
 			}
@@ -969,7 +964,7 @@
 static void *sound_thread(void *arg)
 {
 	char ign[4096];
-	struct chan_usbradio_pvt *o = (struct chan_usbradio_pvt *) arg;
+	struct chan_usbradio_pvt *o = arg;
 
 	/*
 	 * Just in case, kick the driver by trying to read from it.
@@ -987,9 +982,7 @@
 		if (o->cursound > -1 && o->sounddev < 0)
 			setformat(o, O_RDWR);	/* need the channel, try to reopen */
 		else if (o->cursound == -1 && o->owner == NULL)
-		{
 			setformat(o, O_CLOSE);	/* can close */
-		}
 		if (o->sounddev > -1) {
 			if (!o->owner) {	/* no one owns the audio, so we must drain it */
 				FD_SET(o->sounddev, &rfds);
@@ -1041,7 +1034,7 @@
 static int setformat(struct chan_usbradio_pvt *o, int mode)
 {
 	int fmt, desired, res, fd;
-	char device[100];
+	char device[20];
 
 	if (o->sounddev >= 0) {
 		ioctl(o->sounddev, SNDCTL_DSP_RESET, 0);
@@ -1054,9 +1047,9 @@
 	if (ast_tvdiff_ms(ast_tvnow(), o->lastopen) < 1000)
 		return -1;				/* don't open too often */
 	o->lastopen = ast_tvnow();
-	strcpy(device,"/dev/dsp");
+	strcpy(device, "/dev/dsp");
 	if (o->devicenum)
-		sprintf(device,"/dev/dsp%d",o->devicenum);
+		snprintf(device + strlen("/dev/dsp"), sizeof(device) - strlen("/dev/dsp"), "%d", o->devicenum);
 	fd = o->sounddev = open(device, mode | O_NONBLOCK);
 	if (fd < 0) {
 		ast_log(LOG_WARNING, "Unable to re-open DSP device %d: %s\n", o->devicenum, strerror(errno));
@@ -1212,7 +1205,7 @@
 		}
 	}
 	o->stophid = 1;
-	pthread_join(o->hidthread,NULL);
+	pthread_join(o->hidthread, NULL);
 	return 0;
 }
 
@@ -1223,7 +1216,7 @@
 	int src,datalen;
 	struct chan_usbradio_pvt *o = c->tech_pvt;
 
-	traceusb2(("usbradio_write() o->nosound= %i\n",o->nosound));	/*sph maw asdf */
+	traceusb2("usbradio_write() o->nosound=%d\n", o->nosound);	/*sph maw asdf */
 
 	/* Immediately return if no sound is enabled */
 	if (o->nosound)
@@ -1237,30 +1230,33 @@
 	 * Keep the residue stored for future use.
 	 */
 
-	if(o->txkeyed||o->txtestkey)o->pmrChan->txPttIn=1;
-	else o->pmrChan->txPttIn=0;
+	if (o->txkeyed || o->txtestkey)
+		o->pmrChan->txPttIn = 1;
+	else
+		o->pmrChan->txPttIn = 0;
 
 	#if DEBUG_CAPTURES == 1	/* to write input data to a file   datalen=320 */
 	if (ftxcapraw && o->b.txcapraw) {
 		i16 i, tbuff[f->datalen];
-		for(i=0;i<f->datalen;i+=2) {
-			tbuff[i]= ((i16*)(f->data))[i/2];
-			tbuff[i+1]= o->txkeyed*M_Q13;
-		}
-		fwrite(tbuff,2,f->datalen,ftxcapraw);
+		for (i = 0; i < f->datalen; i += 2) {
+			tbuff[i] = ((i16 *)(f->data))[i / 2];
+			tbuff[i + 1] = o->txkeyed * M_Q13;
+		}
+		fwrite(tbuff, 2, f->datalen, ftxcapraw);
 		/*fwrite(f->data,1,f->datalen,ftxcapraw); */
 	}
 	#endif
 
 	PmrTx(o->pmrChan,(i16*)f->data,(i16*)o->usbradio_write_buf_1);
 
-	#if 0	// to write 48KS/s stereo data to a file
+	#if 0	/* to write 48KS/s stereo data to a file */
 	if (!ftxoutraw) ftxoutraw = fopen(TX_CAP_OUT_FILE,"w");
 	if (ftxoutraw) fwrite(o->usbradio_write_buf_1,1,f->datalen * 2 * 6,ftxoutraw);
 	#endif
 
 	#if DEBUG_CAPTURES == 1
-    if (o->b.txcap2 && ftxcaptrace) fwrite((o->pmrChan->ptxDebug),1,FRAME_SIZE * 2 * 16,ftxcaptrace);
+    if (o->b.txcap2 && ftxcaptrace)
+		fwrite((o->pmrChan->ptxDebug), 1, FRAME_SIZE * 2 * 16, ftxcaptrace);
 	#endif
 
 	src = 0;					/* read position into f->data */
@@ -1288,35 +1284,31 @@
 {
 	int res;
 	struct chan_usbradio_pvt *o = c->tech_pvt;
-	struct ast_frame *f = &o->read_f,*f1;
+	struct ast_frame *f = &o->read_f, *f1;
 	struct ast_frame wf = { AST_FRAME_CONTROL };
 	time_t now;
 
-	traceusb2(("usbradio_read()\n"));	//sph maw asdf
-
-	if (o->lasthidtime)
-	{
+	traceusb2("usbradio_read()\n");	/* sph maw asdf */
+
+	if (o->lasthidtime) {
 		time(&now);
-		if ((now - o->lasthidtime) > 3)
-		{
-			ast_log(LOG_ERROR,"HID process has died or something!!\n");
+		if ((now - o->lasthidtime) > 3) {
+			ast_log(LOG_ERROR, "HID process has died or something!!\n");
 			return NULL;
 		}
 	}
-	if (o->lastrx && (!o->rxkeyed))
-	{
+	if (o->lastrx && (!o->rxkeyed)) {
 		o->lastrx = 0;
 		wf.subclass = AST_CONTROL_RADIO_UNKEY;
 		ast_queue_frame(o->owner, &wf);
-	} else if ((!o->lastrx) && (o->rxkeyed))
-	{
+	} else if ((!o->lastrx) && (o->rxkeyed)) {
 		o->lastrx = 1;
 		wf.subclass = AST_CONTROL_RADIO_KEY;
 		ast_queue_frame(o->owner, &wf);
 	}
 	/* XXX can be simplified returning &ast_null_frame */
 	/* prepare a NULL frame in case we don't have enough data to return */
-	bzero(f, sizeof(struct ast_frame));
+	memset(f, 0, sizeof(struct ast_frame));
 	f->frametype = AST_FRAME_NULL;
 	f->src = usbradio_tech.type;
 
@@ -1333,31 +1325,31 @@
 		return f;
 
 	#if DEBUG_CAPTURES == 1
-	if (o->b.rxcapraw && frxcapraw) fwrite((o->usbradio_read_buf + AST_FRIENDLY_OFFSET),1,FRAME_SIZE * 2 * 2 * 6,frxcapraw);
+	if (o->b.rxcapraw && frxcapraw)
+		fwrite((o->usbradio_read_buf + AST_FRIENDLY_OFFSET), 1, FRAME_SIZE * 2 * 2 * 6, frxcapraw);
 	#endif
 
 	#if 1
-	PmrRx(         o->pmrChan, 
+	PmrRx(         o->pmrChan,
 		   (i16 *)(o->usbradio_read_buf + AST_FRIENDLY_OFFSET),
 		   (i16 *)(o->usbradio_read_buf_8k + AST_FRIENDLY_OFFSET));
 
 	#else
 	static FILE *hInput;
-	i16 iBuff[FRAME_SIZE*2*6];
-
-	o->pmrChan->b.rxCapture=1;
-
-	if(!hInput)
-	{
-		hInput  = fopen("/usr/src/xpmr/testdata/rx_in.pcm","r");
-		if(!hInput)
-		{
-			printf(" Input Data File Not Found.\n");
+	i16 iBuff[FRAME_SIZE * 2 * 6];
+
+	o->pmrChan->b.rxCapture = 1;
+
+	if(!hInput) {
+		hInput = fopen("/usr/src/xpmr/testdata/rx_in.pcm", "r");
+		if(!hInput) {
+			ast_log(LOG_ERROR, " Input Data File Not Found.\n");
 			return 0;
 		}
 	}
 
-	if(0==fread((void *)iBuff,2,FRAME_SIZE*2*6,hInput))exit;
+	if (0 == fread((void *)iBuff, 2, FRAME_SIZE * 2 * 6, hInput))
+		exit;
 
 	PmrRx(         o->pmrChan, 
 		   (i16 *)iBuff,
@@ -1366,49 +1358,44 @@
 	#endif
 
 	#if 0
-	if (!frxoutraw) frxoutraw = fopen(RX_CAP_OUT_FILE,"w");
-    if (frxoutraw) fwrite((o->usbradio_read_buf_8k + AST_FRIENDLY_OFFSET),1,FRAME_SIZE * 2,frxoutraw);
+	if (!frxoutraw) frxoutraw = fopen(RX_CAP_OUT_FILE, "w");
+    if (frxoutraw) fwrite((o->usbradio_read_buf_8k + AST_FRIENDLY_OFFSET), 1, FRAME_SIZE * 2, frxoutraw);
 	#endif
 
 	#if DEBUG_CAPTURES == 1
-    if (frxcaptrace && o->b.rxcap2) fwrite((o->pmrChan->prxDebug),1,FRAME_SIZE * 2 * 16,frxcaptrace);
+    if (frxcaptrace && o->b.rxcap2) fwrite((o->pmrChan->prxDebug), 1, FRAME_SIZE * 2 * 16, frxcaptrace);
 	#endif
 
-	if(o->rxcdtype==CD_HID && (o->pmrChan->rxExtCarrierDetect!=o->rxhidsq))
-		o->pmrChan->rxExtCarrierDetect=o->rxhidsq;
-	if(o->rxcdtype==CD_HID_INVERT && (o->pmrChan->rxExtCarrierDetect==o->rxhidsq))
-		o->pmrChan->rxExtCarrierDetect=!o->rxhidsq;
+	if (o->rxcdtype == CD_HID && (o->pmrChan->rxExtCarrierDetect != o->rxhidsq))
+		o->pmrChan->rxExtCarrierDetect = o->rxhidsq;
+	if (o->rxcdtype == CD_HID_INVERT && (o->pmrChan->rxExtCarrierDetect == o->rxhidsq))
+		o->pmrChan->rxExtCarrierDetect = !o->rxhidsq;
 		
-	if( (o->rxcdtype==CD_HID && o->rxhidsq) ||
-		(o->rxcdtype==CD_HID_INVERT && !o->rxhidsq) ||
-		(o->rxcdtype==CD_XPMR_NOISE && o->pmrChan->rxCarrierDetect) ||
-		(o->rxcdtype==CD_XPMR_VOX && o->pmrChan->rxCarrierDetect)
-	  )
-	{
-		res=1;	
-	}
-	else res=0;
-
-	if(res!=o->rxcarrierdetect)
-	{
-		o->rxcarrierdetect=res;
-		if(o->debuglevel)printf("rxcarrierdetect = %i\n",res);
-	}
-
-	if(o->pmrChan->rxCtcss->decode!=o->rxctcssdecode)
-	{
-		if(o->debuglevel)printf("rxctcssdecode = %i\n",o->pmrChan->rxCtcss->decode);
-		o->rxctcssdecode=o->pmrChan->rxCtcss->decode;
-	}
-
-	if ( 	 
-	      (  o->rxctcssfreq &&  (o->rxctcssdecode == o->pmrChan->rxCtcssIndex)) || 
-	      ( !o->rxctcssfreq && 	o->rxcarrierdetect)
-	   ) 
-	{
+	if ( (o->rxcdtype == CD_HID && o->rxhidsq) ||
+		 (o->rxcdtype == CD_HID_INVERT && !o->rxhidsq) ||
+		 (o->rxcdtype == CD_XPMR_NOISE && o->pmrChan->rxCarrierDetect) ||
+		 (o->rxcdtype == CD_XPMR_VOX && o->pmrChan->rxCarrierDetect) )
+		res = 1;
+	else
+		res = 0;
+
+	if (res != o->rxcarrierdetect) {
+		o->rxcarrierdetect = res;
+		if (o->debuglevel)
+			ast_debug(4, "rxcarrierdetect = %d\n", res);
+	}
+
+	if (o->pmrChan->rxCtcss->decode != o->rxctcssdecode) {
+		if (o->debuglevel)
+			ast_debug(4, "rxctcssdecode = %d\n", o->pmrChan->rxCtcss->decode);
+		o->rxctcssdecode = o->pmrChan->rxCtcss->decode;
+	}
+
+	if ( (  o->rxctcssfreq && (o->rxctcssdecode == o->pmrChan->rxCtcssIndex)) || 
+		 ( !o->rxctcssfreq && o->rxcarrierdetect) ) 
 		o->rxkeyed = 1;
-	}
-	else o->rxkeyed = 0;
+	else
+		o->rxkeyed = 0;
 
 
 	o->readpos = AST_FRIENDLY_OFFSET;	/* reset read pointer for next frame */
@@ -1434,19 +1421,16 @@
 	}
 
 	f->offset = AST_FRIENDLY_OFFSET;
-	if (o->dsp)
-	  {
-	    f1 = ast_dsp_process(c,o->dsp,f);
-		if ((f1->frametype == AST_FRAME_DTMF_END) ||
-		(f1->frametype == AST_FRAME_DTMF_BEGIN))
-		{
-		if ((f1->subclass == 'm') || (f1->subclass == 'u'))
-		    f1->frametype = AST_FRAME_DTMF_BEGIN;
-		if (f1->frametype == AST_FRAME_DTMF_END)
-		    ast_log(LOG_NOTICE,"Got DTMF char %c\n",f1->subclass);
-		return(f1);
-		}
-	  }
+	if (o->dsp) {
+		f1 = ast_dsp_process(c, o->dsp, f);
+		if ((f1->frametype == AST_FRAME_DTMF_END) || (f1->frametype == AST_FRAME_DTMF_BEGIN)) {
+			if ((f1->subclass == 'm') || (f1->subclass == 'u'))
+			    f1->frametype = AST_FRAME_DTMF_BEGIN;
+			if (f1->frametype == AST_FRAME_DTMF_END)
+			    ast_log(LOG_NOTICE,"Got DTMF char %c\n",f1->subclass);
+			return f1;
+		}
+	}
 	return f;
 }
 
@@ -1519,10 +1503,10 @@
 static struct ast_channel *usbradio_new(struct chan_usbradio_pvt *o, char *ext, char *ctx, int state)
 {
 	struct ast_channel *c;
-	char device[100];
-
-	strcpy(device,"dsp");
-	if (o->devicenum) sprintf(device,"dsp%d",o->devicenum);
+	char device[15] = "dsp";
+
+	if (o->devicenum)
+		snprintf(device + 3, sizeof(device) - 3, "%d", o->devicenum);
 	c = ast_channel_alloc(1, state, o->cid_num, o->cid_name, "", ext, ctx, 0, "usbRadio/%s", device);
 	if (c == NULL)
 		return NULL;
@@ -1566,10 +1550,7 @@
 	struct ast_channel *c;
 	struct chan_usbradio_pvt *o = find_desc(data);
 
-	if (0)
-	{
-		ast_log(LOG_WARNING, "usbradio_request ty <%s> data 0x%p <%s>\n", type, data, (char *) data);
-	}
+	ast_debug(4, "usbradio_request ty <%s> data 0x%p <%s>\n", type, data, (char *) data);
 	if (o == NULL) {
 		ast_log(LOG_NOTICE, "Device %s not found\n", (char *) data);
 		/* XXX we could default to 'dsp' perhaps ? */
@@ -1676,177 +1657,172 @@
 	if ((a->argc < 2) || (a->argc > 4))
 		return CLI_SHOWUSAGE; 
 
-	if (a->argc == 2) /* just show stuff */
-	{
-		ast_cli(a->fd,"Output A is currently set to ");
-		if(o->txmixa==TX_OUT_COMPOSITE)ast_cli(a->fd,"composite.\n");
-		else if (o->txmixa==TX_OUT_VOICE)ast_cli(a->fd,"voice.\n");
-		else if (o->txmixa==TX_OUT_LSD)ast_cli(a->fd,"tone.\n");
-		else if (o->txmixa==TX_OUT_AUX)ast_cli(a->fd,"auxvoice.\n");
-		else ast_cli(a->fd,"off.\n");
-
-		ast_cli(a->fd,"Output B is currently set to ");
-		if(o->txmixb==TX_OUT_COMPOSITE)ast_cli(a->fd,"composite.\n");
-		else if (o->txmixb==TX_OUT_VOICE)ast_cli(a->fd,"voice.\n");
-		else if (o->txmixb==TX_OUT_LSD)ast_cli(a->fd,"tone.\n");
-		else if (o->txmixb==TX_OUT_AUX)ast_cli(a->fd,"auxvoice.\n");
-		else ast_cli(a->fd,"off.\n");
-
-		ast_cli(a->fd,"Tx Voice Level currently set to %d\n",o->txmixaset);
-		ast_cli(a->fd,"Tx Tone Level currently set to %d\n",o->txctcssadj);
-		ast_cli(a->fd,"Rx Squelch currently set to %d\n",o->rxsquelchadj);
+	if (a->argc == 2) { /* just show stuff */
+		ast_cli(a->fd, "Output A is currently set to %s.\n",
+			o->txmixa == TX_OUT_COMPOSITE ? "composite" :
+			o->txmixa == TX_OUT_VOICE ? "voice" :
+			o->txmixa == TX_OUT_LSD ? "tone" :
+			o->txmixa == TX_OUT_AUX ? "auxvoice" :
+			"off");
+
+		ast_cli(a->fd, "Output B is currently set to %s.\n",
+			o->txmixb == TX_OUT_COMPOSITE ? "composite" :
+			o->txmixb == TX_OUT_VOICE ? "voice" :
+			o->txmixb == TX_OUT_LSD ? "tone" :
+			o->txmixb == TX_OUT_AUX ? "auxvoice" :
+			"off");
+
+		ast_cli(a->fd, "Tx Voice Level currently set to %d\n", o->txmixaset);
+		ast_cli(a->fd, "Tx Tone Level currently set to %d\n", o->txctcssadj);
+		ast_cli(a->fd, "Rx Squelch currently set to %d\n", o->rxsquelchadj);
 		return CLI_SHOWUSAGE;
 	}
 
 	o = find_desc(usbradio_active);
 
-	if (!strcasecmp(a->argv[2],"rxnoise")) tune_rxinput(o);
-	else if (!strcasecmp(a->argv[2],"rxvoice")) tune_rxvoice(o);
-	else if (!strcasecmp(a->argv[2],"rxtone")) tune_rxctcss(o);
-	else if (!strcasecmp(a->argv[2],"rxsquelch"))
-	{
-		if (a->argc == 3)
-		{
-		    ast_cli(a->fd,"Current Signal Strength is %d\n",((32767-o->pmrChan->rxRssi)*1000/32767));
-		    ast_cli(a->fd,"Current Squelch setting is %d\n",o->rxsquelchadj);
-			//ast_cli(a->fd,"Current Raw RSSI        is %d\n",o->pmrChan->rxRssi);
-		    //ast_cli(a->fd,"Current (real) Squelch setting is %d\n",*(o->pmrChan->prxSquelchAdjust));
+	if (!strcasecmp(a->argv[2], "rxnoise"))
+		tune_rxinput(o);
+	else if (!strcasecmp(a->argv[2], "rxvoice"))
+		tune_rxvoice(o);
+	else if (!strcasecmp(a->argv[2], "rxtone"))
+		tune_rxctcss(o);
+	else if (!strcasecmp(a->argv[2], "rxsquelch")) {
+		if (a->argc == 3) {
+		    ast_cli(a->fd, "Current Signal Strength is %d\n", ((32767 - o->pmrChan->rxRssi) * 1000 / 32767));
+		    ast_cli(a->fd, "Current Squelch setting is %d\n", o->rxsquelchadj);
+#if 0
+			ast_cli(a->fd,"Current Raw RSSI        is %d\n",o->pmrChan->rxRssi);
+		    ast_cli(a->fd,"Current (real) Squelch setting is %d\n",*(o->pmrChan->prxSquelchAdjust));
+#endif
 		} else {
 			i = atoi(a->argv[3]);
-			if ((i < 0) || (i > 999)) return CLI_SHOWUSAGE;
-			ast_cli(a->fd,"Changed Squelch setting to %d\n",i);
+			if ((i < 0) || (i > 999))
+				return CLI_SHOWUSAGE;
+			ast_cli(a->fd, "Changed Squelch setting to %d\n", i);
 			o->rxsquelchadj = i;
-			*(o->pmrChan->prxSquelchAdjust)= ((999 - i) * 32767) / 1000;
-		}
-	}
-	else if (!strcasecmp(a->argv[2],"txvoice")) {
+			*(o->pmrChan->prxSquelchAdjust) = ((999 - i) * 32767) / 1000;
+		}
+	} else if (!strcasecmp(a->argv[2], "txvoice")) {
 		i = 0;
 
-		if( (o->txmixa!=TX_OUT_VOICE) && (o->txmixb!=TX_OUT_VOICE) &&
-			(o->txmixa!=TX_OUT_COMPOSITE) && (o->txmixb!=TX_OUT_COMPOSITE)
-		  )
-		{
-			ast_log(LOG_ERROR,"No txvoice output configured.\n");
-		}
-		else if (a->argc == 3)
-		{
-			if((o->txmixa==TX_OUT_VOICE)||(o->txmixa==TX_OUT_COMPOSITE))
-				ast_cli(a->fd,"Current txvoice setting on Channel A is %d\n",o->txmixaset);
+		if ((o->txmixa != TX_OUT_VOICE) && (o->txmixb != TX_OUT_VOICE) &&
+			(o->txmixa != TX_OUT_COMPOSITE) && (o->txmixb != TX_OUT_COMPOSITE)) {
+			ast_log(LOG_ERROR, "No txvoice output configured.\n");
+		} else if (a->argc == 3) {
+			if ((o->txmixa == TX_OUT_VOICE) || (o->txmixa == TX_OUT_COMPOSITE))
+				ast_cli(a->fd, "Current txvoice setting on Channel A is %d\n", o->txmixaset);
 			else
-				ast_cli(a->fd,"Current txvoice setting on Channel B is %d\n",o->txmixbset);
-		}
-		else
-		{
+				ast_cli(a->fd, "Current txvoice setting on Channel B is %d\n", o->txmixbset);
+		} else {
 			i = atoi(a->argv[3]);
-			if ((i < 0) || (i > 999)) return CLI_SHOWUSAGE;
-
-			if((o->txmixa==TX_OUT_VOICE)||(o->txmixa==TX_OUT_COMPOSITE))
-			{
-			 	o->txmixaset=i;
-				ast_cli(a->fd,"Changed txvoice setting on Channel A to %d\n",o->txmixaset);
-			}
-			else
-			{
-			 	o->txmixbset=i;   
-				ast_cli(a->fd,"Changed txvoice setting on Channel B to %d\n",o->txmixbset);
+			if ((i < 0) || (i > 999))
+				return CLI_SHOWUSAGE;
+
+			if ((o->txmixa == TX_OUT_VOICE) || (o->txmixa == TX_OUT_COMPOSITE)) {
+			 	o->txmixaset = i;
+				ast_cli(a->fd, "Changed txvoice setting on Channel A to %d\n", o->txmixaset);
+			} else {
+			 	o->txmixbset = i;   
+				ast_cli(a->fd, "Changed txvoice setting on Channel B to %d\n", o->txmixbset);
 			}
 			mixer_write(o);
 			mult_set(o);
-			ast_cli(a->fd,"Changed Tx Voice Output setting to %d\n",i);
+			ast_cli(a->fd, "Changed Tx Voice Output setting to %d\n", i);
 		}
 		tune_txoutput(o,i);
-	}
-	else if (!strcasecmp(a->argv[2],"auxvoice")) {
+	} else if (!strcasecmp(a->argv[2], "auxvoice")) {
 		i = 0;
-		if( (o->txmixa!=TX_OUT_AUX) && (o->txmixb!=TX_OUT_AUX))
-		{
-			ast_log(LOG_WARNING,"No auxvoice output configured.\n");
-		}
-		else if (a->argc == 3)
-		{
-			if(o->txmixa==TX_OUT_AUX)
-				ast_cli(a->fd,"Current auxvoice setting on Channel A is %d\n",o->txmixaset);
+		if ( (o->txmixa != TX_OUT_AUX) && (o->txmixb != TX_OUT_AUX))
+			ast_log(LOG_WARNING, "No auxvoice output configured.\n");
+		else if (a->argc == 3) {
+			if (o->txmixa == TX_OUT_AUX)
+				ast_cli(a->fd, "Current auxvoice setting on Channel A is %d\n", o->txmixaset);
 			else
-				ast_cli(a->fd,"Current auxvoice setting on Channel B is %d\n",o->txmixbset);
-		}
-		else
-		{
+				ast_cli(a->fd, "Current auxvoice setting on Channel B is %d\n", o->txmixbset);
+		} else {
 			i = atoi(a->argv[3]);
-			if ((i < 0) || (i > 999)) return CLI_SHOWUSAGE;
-			if(o->txmixa==TX_OUT_AUX)
-			{
-				o->txmixbset=i;
-				ast_cli(a->fd,"Changed auxvoice setting on Channel A to %d\n",o->txmixaset);
-			}
-			else
-			{
-				o->txmixbset=i;
-				ast_cli(a->fd,"Changed auxvoice setting on Channel B to %d\n",o->txmixbset);
+			if ((i < 0) || (i > 999))
+				return CLI_SHOWUSAGE;
+			if (o->txmixa == TX_OUT_AUX) {
+				o->txmixbset = i;
+				ast_cli(a->fd, "Changed auxvoice setting on Channel A to %d\n", o->txmixaset);
+			} else {
+				o->txmixbset = i;
+				ast_cli(a->fd, "Changed auxvoice setting on Channel B to %d\n", o->txmixbset);
 			}
 			mixer_write(o);
 			mult_set(o);
 		}
-		//tune_auxoutput(o,i);
-	}
-	else if (!strcasecmp(a->argv[2],"txtone"))
-	{
+		/* tune_auxoutput(o,i); */
+	} else if (!strcasecmp(a->argv[2], "txtone")) {
 		if (a->argc == 3)
-			ast_cli(a->fd,"Current Tx CTCSS modulation setting = %d\n",o->txctcssadj);
-		else
-		{
+			ast_cli(a->fd, "Current Tx CTCSS modulation setting = %d\n", o->txctcssadj);
+		else {
 			i = atoi(a->argv[3]);
-			if ((i < 0) || (i > 999)) return CLI_SHOWUSAGE;
+			if ((i < 0) || (i > 999))
+				return CLI_SHOWUSAGE;
 			o->txctcssadj = i;
 			set_txctcss_level(o);
-			ast_cli(a->fd,"Changed Tx CTCSS modulation setting to %i\n",i);
-		}
-		o->txtestkey=1;
+			ast_cli(a->fd, "Changed Tx CTCSS modulation setting to %i\n", i);
+		}
+		o->txtestkey = 1;
 		usleep(5000000);
-		o->txtestkey=0;
-	}
-	else if (!strcasecmp(a->argv[2],"dump")) pmrdump(o);
-	else if (!strcasecmp(a->argv[2],"nocap")) 
-	{
-		ast_cli(a->fd,"File capture (trace) was rx=%d tx=%d and now off.\n",o->b.rxcap2,o->b.txcap2);
-		ast_cli(a->fd,"File capture (raw)   was rx=%d tx=%d and now off.\n",o->b.rxcapraw,o->b.txcapraw);
-		o->b.rxcapraw=o->b.txcapraw=o->b.rxcap2=o->b.txcap2=o->pmrChan->b.rxCapture=o->pmrChan->b.txCapture=0;
-		if (frxcapraw) { fclose(frxcapraw); frxcapraw = NULL; }
-		if (frxcaptrace) { fclose(frxcaptrace); frxcaptrace = NULL; }
-		if (frxoutraw) { fclose(frxoutraw); frxoutraw = NULL; }
-		if (ftxcapraw) { fclose(ftxcapraw); ftxcapraw = NULL; }
-		if (ftxcaptrace) { fclose(ftxcaptrace); ftxcaptrace = NULL; }
-		if (ftxoutraw) { fclose(ftxoutraw); ftxoutraw = NULL; }
-	}
-	else if (!strcasecmp(a->argv[2],"rxtracecap")) 
-	{
-		if (!frxcaptrace) frxcaptrace= fopen(RX_CAP_TRACE_FILE,"w");
-		ast_cli(a->fd,"Trace rx on.\n");
-		o->b.rxcap2=o->pmrChan->b.rxCapture=1;
-	}
-	else if (!strcasecmp(a->argv[2],"txtracecap")) 
-	{
-		if (!ftxcaptrace) ftxcaptrace= fopen(TX_CAP_TRACE_FILE,"w");
-		ast_cli(a->fd,"Trace tx on.\n");
-		o->b.txcap2=o->pmrChan->b.txCapture=1;
-	}
-	else if (!strcasecmp(a->argv[2],"rxcap")) 
-	{
-		if (!frxcapraw) frxcapraw = fopen(RX_CAP_RAW_FILE,"w");
-		ast_cli(a->fd,"cap rx raw on.\n");
-		o->b.rxcapraw=1;
-	}
-	else if (!strcasecmp(a->argv[2],"txcap")) 
-	{
-		if (!ftxcapraw) ftxcapraw = fopen(TX_CAP_RAW_FILE,"w");
-		ast_cli(a->fd,"cap tx raw on.\n");
-		o->b.txcapraw=1;
-	}
-	else if (!strcasecmp(a->argv[2],"save"))
-	{
+		o->txtestkey = 0;
+	} else if (!strcasecmp(a->argv[2],"dump"))
+		pmrdump(o);
+	else if (!strcasecmp(a->argv[2],"nocap")) {
+		ast_cli(a->fd, "File capture (trace) was rx=%d tx=%d and now off.\n", o->b.rxcap2, o->b.txcap2);
+		ast_cli(a->fd, "File capture (raw)   was rx=%d tx=%d and now off.\n", o->b.rxcapraw, o->b.txcapraw);
+		o->b.rxcapraw = o->b.txcapraw = o->b.rxcap2 = o->b.txcap2 = o->pmrChan->b.rxCapture = o->pmrChan->b.txCapture = 0;
+		if (frxcapraw) {
+			fclose(frxcapraw);
+			frxcapraw = NULL;
+		}
+		if (frxcaptrace) {
+			fclose(frxcaptrace);
+			frxcaptrace = NULL;
+		}
+		if (frxoutraw) {
+			fclose(frxoutraw);
+			frxoutraw = NULL;
+		}
+		if (ftxcapraw) {
+			fclose(ftxcapraw);
+			ftxcapraw = NULL;
+		}
+		if (ftxcaptrace) {
+			fclose(ftxcaptrace);
+			ftxcaptrace = NULL;
+		}
+		if (ftxoutraw) {
+			fclose(ftxoutraw);
+			ftxoutraw = NULL;
+		}
+	} else if (!strcasecmp(a->argv[2], "rxtracecap")) {
+		if (!frxcaptrace)
+			frxcaptrace = fopen(RX_CAP_TRACE_FILE, "w");
+		ast_cli(a->fd, "Trace rx on.\n");
+		o->b.rxcap2 = o->pmrChan->b.rxCapture = 1;
+	} else if (!strcasecmp(a->argv[2], "txtracecap")) {
+		if (!ftxcaptrace)
+			ftxcaptrace = fopen(TX_CAP_TRACE_FILE, "w");
+		ast_cli(a->fd, "Trace tx on.\n");
+		o->b.txcap2 = o->pmrChan->b.txCapture = 1;

[... 1226 lines stripped ...]



More information about the asterisk-commits mailing list