[Asterisk-cvs] asterisk/channels chan_vpb.c,1.34,1.35
bkramer at lists.digium.com
bkramer at lists.digium.com
Wed Aug 18 20:12:01 CDT 2004
Update of /usr/cvsroot/asterisk/channels
In directory localhost.localdomain:/tmp/cvs-serv20432
Modified Files:
chan_vpb.c
Log Message:
/ bit of a clean up and change of pthread_create to ast_pthread_create
Index: chan_vpb.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_vpb.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- chan_vpb.c 18 Aug 2004 05:06:26 -0000 1.34
+++ chan_vpb.c 18 Aug 2004 23:58:07 -0000 1.35
@@ -15,7 +15,8 @@
#include <stdio.h>
#include <string.h>
-#include <asterisk/lock.h>
+//#include <asterisk/lock.h>
+#include <asterisk/utils.h>
#include <asterisk/channel.h>
#include <asterisk/channel_pvt.h>
#include <asterisk/config.h>
@@ -52,9 +53,11 @@
#define MAX_VPB_GAIN 12.0
+/*
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
+*/
static char *desc = "VoiceTronix V6PCI/V12PCI/V4PCI API Support";
static char *type = "vpb";
@@ -634,9 +637,11 @@
ast_verbose(VERBOSE_PREFIX_4 "%s: handle_owned: putting frame type[%d]subclass[%d], bridge=%p\n",
p->dev, f.frametype, f.subclass, (void *)p->bridge);
+/*
if (option_verbose > 3) ast_verbose("%s: LOCKING in handle_owned [%d]\n", p->dev,res);
res = ast_mutex_lock(&p->lock);
if (option_verbose > 3) ast_verbose("%s: LOCKING count[%d] owner[%d] \n", p->dev, p->lock.__m_count,p->lock.__m_owner);
+*/
{
if (p->bridge) { /* Check what happened, see if we need to report it. */
switch (f.frametype) {
@@ -679,7 +684,9 @@
if (endbridge){
res = ast_mutex_unlock(&p->lock);
+/*
if (option_verbose > 3) ast_verbose("%s: unLOCKING in handle_owned [%d]\n", p->dev,res);
+*/
return 0;
}
@@ -696,7 +703,9 @@
}
}
res = ast_mutex_unlock(&p->lock);
+/*
if (option_verbose > 3) ast_verbose("%s: unLOCKING in handle_owned [%d]\n", p->dev,res);
+*/
return 0;
}
@@ -963,7 +972,7 @@
vpb_put_event(&e);
} else {
/* Start a new monitor */
- int pid = pthread_create(&monitor_thread, NULL, do_monitor, NULL);
+ int pid = ast_pthread_create(&monitor_thread, NULL, do_monitor, NULL);
if (option_verbose > 3)
ast_verbose(VERBOSE_PREFIX_4 "Created new monitor thread %d\n",pid);
if (pid < 0) {
@@ -1138,8 +1147,10 @@
}
*/
+/*
if (option_verbose > 3) ast_verbose("%s: LOCKING in indicate \n", p->dev);
if (option_verbose > 3) ast_verbose("%s: LOCKING count[%d] owner[%d] \n", p->dev, p->lock.__m_count,p->lock.__m_owner);
+*/
ast_mutex_lock(&p->lock);
switch(condition) {
case AST_CONTROL_BUSY:
@@ -1182,7 +1193,9 @@
break;
}
tmp = ast_mutex_unlock(&p->lock);
+/*
if (option_verbose > 3) ast_verbose("%s: unLOCKING in indicate [%d]\n", p->dev,tmp);
+*/
return res;
}
@@ -1191,8 +1204,10 @@
struct vpb_pvt *p = (struct vpb_pvt *)newchan->pvt->pvt;
int res = 0;
+/*
if (option_verbose > 3) ast_verbose("%s: LOCKING in fixup \n", p->dev);
if (option_verbose > 3) ast_verbose("%s: LOCKING count[%d] owner[%d] \n", p->dev, p->lock.__m_count,p->lock.__m_owner);
+*/
ast_mutex_lock(&p->lock);
ast_log(LOG_DEBUG, "New owner for channel %s is %s\n", p->dev, newchan->name);
@@ -1204,7 +1219,9 @@
vpb_indicate(newchan, AST_CONTROL_RINGING);
res= ast_mutex_unlock(&p->lock);
+/*
if (option_verbose > 3) ast_verbose("%s: unLOCKING in fixup [%d]\n", p->dev,res);
+*/
return 0;
}
@@ -1214,8 +1231,10 @@
char s[2];
int res = 0;
+/*
if (option_verbose > 3) ast_verbose("%s: LOCKING in digit \n", p->dev);
if (option_verbose > 3) ast_verbose("%s: LOCKING count[%d] owner[%d] \n", p->dev, p->lock.__m_count,p->lock.__m_owner);
+*/
ast_mutex_lock(&p->lock);
@@ -1230,7 +1249,9 @@
ast_mutex_unlock(&p->play_dtmf_lock);
res = ast_mutex_unlock(&p->lock);
+/*
if (option_verbose > 3) ast_verbose("%s: unLOCKING in digit [%d]\n", p->dev,res);
+*/
return 0;
}
@@ -1243,8 +1264,10 @@
char dialstring[254] = "";
int tmp = 0;
+/*
if (option_verbose > 3) ast_verbose("%s: LOCKING in call \n", p->dev);
if (option_verbose > 3) ast_verbose("%s: LOCKING count[%d] owner[%d] \n", p->dev, p->lock.__m_count,p->lock.__m_owner);
+*/
ast_mutex_lock(&p->lock);
if (s)
@@ -1264,7 +1287,9 @@
if (ast->_state != AST_STATE_DOWN && ast->_state != AST_STATE_RESERVED) {
ast_log(LOG_WARNING, "vpb_call on %s neither down nor reserved!\n", ast->name);
tmp = ast_mutex_unlock(&p->lock);
+/*
if (option_verbose > 3) ast_verbose("%s: unLOCKING in call [%d]\n", p->dev,tmp);
+*/
return -1;
}
if (p->mode != MODE_FXO) /* Station port, ring it. */
@@ -1335,11 +1360,13 @@
}
if (!p->readthread){
- pthread_create(&p->readthread, NULL, do_chanreads, (void *)p);
+ ast_pthread_create(&p->readthread, NULL, do_chanreads, (void *)p);
}
tmp = ast_mutex_unlock(&p->lock);
+/*
if (option_verbose > 3) ast_verbose("%s: unLOCKING in call [%d]\n", p->dev,tmp);
+*/
return res;
}
@@ -1362,7 +1389,9 @@
if (!ast->pvt || !ast->pvt->pvt) {
ast_log(LOG_WARNING, "%s: channel not connected?\n", ast->name);
res = ast_mutex_unlock(&p->lock);
+/*
if (option_verbose > 3) ast_verbose("%s: unLOCKING in hangup [%d]\n", p->dev,res);
+*/
return 0;
}
@@ -1391,9 +1420,11 @@
ast_setstate(ast,AST_STATE_DOWN);
+/*
if (option_verbose > 3) ast_verbose("%s: LOCKING in hangup \n", p->dev);
if (option_verbose > 3) ast_verbose("%s: LOCKING in hangup count[%d] owner[%d] \n", p->dev, p->lock.__m_count,p->lock.__m_owner);
if (option_verbose > 3) ast_verbose("%s: LOCKING pthread_self(%d)\n", p->dev,pthread_self());
+*/
ast_mutex_lock(&p->lock);
if (p->mode != MODE_FXO) {
@@ -1442,10 +1473,14 @@
ast_verbose(VERBOSE_PREFIX_2 "%s: Hangup complete\n", ast->name);
restart_monitor();
+/*
if (option_verbose > 3) ast_verbose("%s: LOCKING in hangup count[%d] owner[%d] \n", p->dev, p->lock.__m_count,p->lock.__m_owner);
+*/
res = ast_mutex_unlock(&p->lock);
+/*
if (option_verbose > 3) ast_verbose("%s: unLOCKING in hangup [%d]\n", p->dev,res);
if (option_verbose > 3) ast_verbose("%s: LOCKING in hangup count[%d] owner[%d] \n", p->dev, p->lock.__m_count,p->lock.__m_owner);
+*/
return 0;
}
@@ -1455,8 +1490,10 @@
VPB_EVENT je;
int ret;
int res = 0;
+/*
if (option_verbose > 3) ast_verbose("%s: LOCKING in answer \n", p->dev);
if (option_verbose > 3) ast_verbose("%s: LOCKING count[%d] owner[%d] \n", p->dev, p->lock.__m_count,p->lock.__m_owner);
+*/
ast_mutex_lock(&p->lock);
if (option_verbose > 3)
@@ -1490,7 +1527,7 @@
if( !p->readthread ){
// res = ast_mutex_unlock(&p->lock);
// ast_verbose("%s: unLOCKING in answer [%d]\n", p->dev,res);
- pthread_create(&p->readthread, NULL, do_chanreads, (void *)p);
+ ast_pthread_create(&p->readthread, NULL, do_chanreads, (void *)p);
} else {
if(option_verbose>3)
ast_verbose(VERBOSE_PREFIX_4 "%s: Record thread already running!!\n",p->dev);
@@ -1507,7 +1544,9 @@
ast_verbose("%s: Re-enabling Loop Drop detection\n",p->dev);
vpb_enable_event(p->handle,VPB_MDROP);
res = ast_mutex_unlock(&p->lock);
+/*
if(option_verbose>3) ast_verbose("%s: unLOCKING in answer [%d]\n", p->dev,res);
+*/
return 0;
}
@@ -1570,7 +1609,7 @@
}
}
-int gain_vector(float g, short *v, int n)
+int a_gain_vector(float g, short *v, int n)
{
int i;
float tmp;
@@ -1638,7 +1677,7 @@
// Apply extra gain !
if( p->txswgain > MAX_VPB_GAIN )
- gain_vector(p->txswgain - MAX_VPB_GAIN , (short*)frame->data, frame->datalen/sizeof(short));
+ a_gain_vector(p->txswgain - MAX_VPB_GAIN , (short*)frame->data, frame->datalen/sizeof(short));
ast_log(LOG_DEBUG, "%s: vpb_write: Applied gain..\n", p->dev);
@@ -1655,12 +1694,12 @@
gettimeofday(&play_buf_time_finish,NULL);
if (play_buf_time_finish.tv_sec == play_buf_time_start.tv_sec){
p->play_buf_time=(int)((play_buf_time_finish.tv_usec-play_buf_time_start.tv_usec)/1000);
- ast_log(LOG_DEBUG, "%s: vpb_write: Timing start(%d) finish(%d)\n", p->dev,play_buf_time_start.tv_usec,play_buf_time_finish.tv_usec);
+// ast_log(LOG_DEBUG, "%s: vpb_write: Timing start(%d) finish(%d)\n", p->dev,play_buf_time_start.tv_usec,play_buf_time_finish.tv_usec);
}
else {
p->play_buf_time=(int)((play_buf_time_finish.tv_sec - play_buf_time_start.tv_sec)*100)+(int)((play_buf_time_finish.tv_usec-play_buf_time_start.tv_usec)/1000);
}
- ast_log(LOG_DEBUG, "%s: vpb_write: Wrote data [%d](%d=>%s) to play_buf in [%d]ms..\n", p->dev,frame->datalen,fmt,ast2vpbformatname(frame->subclass),p->play_buf_time);
+// ast_log(LOG_DEBUG, "%s: vpb_write: Wrote data [%d](%d=>%s) to play_buf in [%d]ms..\n", p->dev,frame->datalen,fmt,ast2vpbformatname(frame->subclass),p->play_buf_time);
}
else {
p->chuck_count++;
@@ -1819,7 +1858,7 @@
}
// Apply extra gain !
if( p->rxswgain > MAX_VPB_GAIN )
- gain_vector(p->rxswgain - MAX_VPB_GAIN , (short*)readbuf, readlen/sizeof(short));
+ a_gain_vector(p->rxswgain - MAX_VPB_GAIN , (short*)readbuf, readlen/sizeof(short));
if (option_verbose > 5) {
ast_verbose("%s: chanreads: applied gain\n", p->dev);
}
@@ -2262,6 +2301,8 @@
return ASTERISK_GPL_KEY;
}
+/*
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
+*/
More information about the svn-commits
mailing list