Index: channels/chan_vpb.cc
===================================================================
--- channels/chan_vpb.cc (revision 61682)
+++ channels/chan_vpb.cc (working copy)
@@ -33,6 +33,8 @@
vpbapi
***/
+#include
+
extern "C" {
#include "asterisk.h"
@@ -66,7 +68,6 @@
#include
#include
-#include
#include
#ifdef pthread_create
@@ -179,7 +180,7 @@
static int break_for_dtmf=1;
/* Set EC suppression threshold */
-static int ec_supp_threshold=-1;
+static short ec_supp_threshold=-1;
/* Inter Digit Delay for collecting DTMF's */
static int dtmf_idd = 3000;
@@ -189,17 +190,17 @@
#define TIMER_PERIOD_RING 4000
static int timer_period_ring = TIMER_PERIOD_RING;
-#define VPB_EVENTS_ALL (VPB_MRING|VPB_MDIGIT|VPB_MDTMF|VPB_MTONEDETECT|VPB_MTIMEREXP|VPB_MPLAY_UNDERFLOW \
- |VPB_MRECORD_OVERFLOW|VPB_MSTATION_OFFHOOK|VPB_MSTATION_ONHOOK \
+#define VPB_EVENTS_ALL (VPB_MRING|VPB_MDIGIT|VPB_MDTMF|VPB_MTONEDETECT|VPB_MTIMEREXP \
+ |VPB_MSTATION_OFFHOOK|VPB_MSTATION_ONHOOK \
|VPB_MRING_OFF|VPB_MDROP|VPB_MSTATION_FLASH)
-#define VPB_EVENTS_NODROP (VPB_MRING|VPB_MDIGIT|VPB_MDTMF|VPB_MTONEDETECT|VPB_MTIMEREXP|VPB_MPLAY_UNDERFLOW \
- |VPB_MRECORD_OVERFLOW|VPB_MSTATION_OFFHOOK|VPB_MSTATION_ONHOOK \
+#define VPB_EVENTS_NODROP (VPB_MRING|VPB_MDIGIT|VPB_MDTMF|VPB_MTONEDETECT|VPB_MTIMEREXP \
+ |VPB_MSTATION_OFFHOOK|VPB_MSTATION_ONHOOK \
|VPB_MRING_OFF|VPB_MSTATION_FLASH)
-#define VPB_EVENTS_NODTMF (VPB_MRING|VPB_MDIGIT|VPB_MTONEDETECT|VPB_MTIMEREXP|VPB_MPLAY_UNDERFLOW \
- |VPB_MRECORD_OVERFLOW|VPB_MSTATION_OFFHOOK|VPB_MSTATION_ONHOOK \
+#define VPB_EVENTS_NODTMF (VPB_MRING|VPB_MDIGIT|VPB_MTONEDETECT|VPB_MTIMEREXP \
+ |VPB_MSTATION_OFFHOOK|VPB_MSTATION_ONHOOK \
|VPB_MRING_OFF|VPB_MDROP|VPB_MSTATION_FLASH)
-#define VPB_EVENTS_STAT (VPB_MRING|VPB_MDIGIT|VPB_MDTMF|VPB_MTONEDETECT|VPB_MTIMEREXP|VPB_MPLAY_UNDERFLOW \
- |VPB_MRECORD_OVERFLOW|VPB_MSTATION_OFFHOOK|VPB_MSTATION_ONHOOK \
+#define VPB_EVENTS_STAT (VPB_MRING|VPB_MDIGIT|VPB_MDTMF|VPB_MTONEDETECT|VPB_MTIMEREXP \
+ |VPB_MSTATION_OFFHOOK|VPB_MSTATION_ONHOOK \
|VPB_MRING_OFF|VPB_MSTATION_FLASH)
@@ -340,7 +341,7 @@
static void *do_chanreads(void *pvt);
static struct ast_channel *vpb_request(const char *type, int format, void *data, int *cause);
static int vpb_digit_begin(struct ast_channel *ast, char digit);
-static int vpb_digit_end(struct ast_channel *ast, char digit);
+static int vpb_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
static int vpb_call(struct ast_channel *ast, char *dest, int timeout);
static int vpb_hangup(struct ast_channel *ast);
static int vpb_answer(struct ast_channel *ast);
@@ -369,13 +370,17 @@
send_html: NULL,
exception: NULL,
bridge: ast_vpb_bridge,
+ early_bridge: NULL,
indicate: vpb_indicate,
fixup: vpb_fixup,
setoption: NULL,
queryoption: NULL,
transfer: NULL,
write_video: NULL,
- bridged_channel: NULL
+ write_text: NULL,
+ bridged_channel: NULL,
+ func_channel_read: NULL,
+ func_channel_write: NULL
};
static struct ast_channel_tech vpb_tech_indicate = {
@@ -397,13 +402,17 @@
send_html: NULL,
exception: NULL,
bridge: ast_vpb_bridge,
+ early_bridge: NULL,
fixup: vpb_fixup,
setoption: NULL,
queryoption: NULL,
transfer: NULL,
write_video: NULL,
- bridged_channel: NULL
+ write_text: NULL,
+ bridged_channel: NULL,
+ func_channel_read: NULL,
+ func_channel_write: NULL
};
/* Can't get ast_vpb_bridge() working on v4pci without either a horrible
@@ -1008,7 +1017,7 @@
}
break;
- case VPB_PLAY_UNDERFLOW:
+/* case VPB_PLAY_UNDERFLOW:
f.frametype = AST_FRAME_NULL;
vpb_reset_play_fifo_alarm(p->handle);
break;
@@ -1017,7 +1026,7 @@
f.frametype = AST_FRAME_NULL;
vpb_reset_record_fifo_alarm(p->handle);
break;
-
+*/
default:
f.frametype = AST_FRAME_NULL;
break;
@@ -1466,7 +1475,7 @@
/* Why do other drivers kill the thread? No need says I, simply awake thread with event. */
VPB_EVENT e;
e.handle = 0;
- e.type = VPB_NULL_EVENT;
+ e.type = VPB_EVT_NONE;
e.data = 0;
if (option_verbose > 3)
@@ -1523,11 +1532,7 @@
vpb_echo_canc_enable();
ast_log(LOG_NOTICE, "Voicetronix echo cancellation ON\n");
if (ec_supp_threshold > -1){
- #ifdef VPB_PRI
- vpb_echo_canc_set_sup_thresh(0,(short *)&ec_supp_threshold);
- #else
- vpb_echo_canc_set_sup_thresh((short *)&ec_supp_threshold);
- #endif
+ vpb_echo_canc_set_sup_thresh(0, &ec_supp_threshold);
ast_log(LOG_NOTICE, "Voicetronix EC Sup Thres set\n");
}
}
@@ -1643,7 +1648,7 @@
}
tmp->vpb_model = vpb_model_unknown;
- if( vpb_get_model(buf) == VPB_OK ) {
+ if( vpb_get_model(tmp->handle, buf) == VPB_OK ) {
if(strcmp(buf,"V12PCI")==0)
tmp->vpb_model = vpb_model_v12pci;
else if(strcmp(buf,"VPB4")==0)
@@ -1831,7 +1836,7 @@
/* XXX Modify this callback to let Asterisk control the length of DTMF */
return 0;
}
-static int vpb_digit_end(struct ast_channel *ast, char digit)
+static int vpb_digit_end(struct ast_channel *ast, char digit, unsigned int duration)
{
struct vpb_pvt *p = (struct vpb_pvt *)ast->tech_pvt;
char s[2];
@@ -1905,7 +1910,7 @@
return -1;
}
if (p->mode != MODE_FXO) /* Station port, ring it. */
- res = vpb_ring_station_async(p->handle, VPB_RING_STATION_ON,0);
+ res = vpb_ring_station_async(p->handle, 2);
else {
VPB_CALL call;
@@ -2046,7 +2051,7 @@
if (p->mode != MODE_FXO) {
/* station port. */
- vpb_ring_station_async(p->handle, VPB_RING_STATION_OFF,0);
+ vpb_ring_station_async(p->handle, 0);
if(p->state!=VPB_STATE_ONHOOK){
/* This is causing a "dial end" "play tone" loop
playtone(p->handle, &Busytone);
@@ -2193,7 +2198,7 @@
return &f;
}
-static inline int ast2vpbformat(int ast_format)
+static inline AudioCompress ast2vpbformat(int ast_format)
{
switch(ast_format) {
case AST_FORMAT_ALAW:
@@ -2205,7 +2210,7 @@
case AST_FORMAT_ADPCM:
return VPB_OKIADPCM;
default:
- return -1;
+ return VPB_RAW;
}
}
@@ -2259,7 +2264,8 @@
static int vpb_write(struct ast_channel *ast, struct ast_frame *frame)
{
struct vpb_pvt *p = (struct vpb_pvt *)ast->tech_pvt;
- int res = 0, fmt = 0;
+ int res = 0;
+ AudioCompress fmt = VPB_RAW;
struct timeval play_buf_time_start;
int tdiff;
@@ -2363,7 +2369,8 @@
struct ast_frame *fr = &p->fr;
char *readbuf = ((char *)p->buf) + AST_FRIENDLY_OFFSET;
int bridgerec = 0;
- int afmt, readlen, res, fmt, trycnt=0;
+ int afmt, readlen, res,trycnt=0;
+ AudioCompress fmt;
int ignore_dtmf;
const char * getdtmf_var = NULL;
@@ -2489,7 +2496,7 @@
if (p->lastinput == -1) {
vpb_record_buf_start(p->handle, fmt);
- vpb_reset_record_fifo_alarm(p->handle);
+/* vpb_reset_record_fifo_alarm(p->handle); */
p->lastinput = fmt;
if(option_verbose>1)
ast_verbose( VERBOSE_PREFIX_2 "%s: Starting record mode (codec=%d)[%s]\n",p->dev,fmt,ast2vpbformatname(afmt));
@@ -2626,7 +2633,7 @@
if (option_verbose > 3)
ast_verbose("%s: New call for context [%s]\n",me->dev,context);
- tmp = ast_channel_alloc(1, state, 0, 0, "", me->exten, me->context, 0, me->dev);
+ tmp = ast_channel_alloc(1, state, 0, 0, "", me->ext, me->context, 0, me->dev);
if (tmp) {
if (use_ast_ind == 1){
tmp->tech = &vpb_tech_indicate;
@@ -2655,11 +2662,11 @@
tmp->tech_pvt = me;
strncpy(tmp->context, context, sizeof(tmp->context)-1);
- if (strlen(me->ext))
- strncpy(tmp->exten, me->ext, sizeof(tmp->exten)-1);
+ if (!ast_strlen_zero(me->ext))
+ ast_copy_string(tmp->exten, me->ext, sizeof(tmp->exten));
else
- strncpy(tmp->exten, "s", sizeof(tmp->exten) - 1);
- if (strlen(me->language))
+ strcpy(tmp->exten, "s");
+ if (!ast_strlen_zero(me->language))
ast_string_field_set(tmp, language, me->language);
me->owner = tmp;
@@ -2767,7 +2774,7 @@
}
-int unload_module()
+static int unload_module(void)
{
struct vpb_pvt *p;
/* First, take us out of the channel loop */
@@ -2819,20 +2826,22 @@
iflist = NULL;
} ast_mutex_unlock(&iflock);
- ast_mutex_lock(&bridge_lock); {
- memset(bridges, 0, sizeof bridges);
- } ast_mutex_unlock(&bridge_lock);
- ast_mutex_destroy(&bridge_lock);
- for(int i = 0; i < max_bridges; i++ ) {
- ast_mutex_destroy(&bridges[i].lock);
- ast_cond_destroy(&bridges[i].cond);
+ if (bridges) {
+ ast_mutex_lock(&bridge_lock); {
+ memset(bridges, 0, sizeof bridges);
+ } ast_mutex_unlock(&bridge_lock);
+ ast_mutex_destroy(&bridge_lock);
+ for(int i = 0; i < max_bridges; i++ ) {
+ ast_mutex_destroy(&bridges[i].lock);
+ ast_cond_destroy(&bridges[i].cond);
+ }
+ free(bridges);
}
- free(bridges);
return 0;
}
-int load_module()
+static enum ast_module_load_result load_module(void)
{
struct ast_config *cfg;
struct ast_variable *v;
@@ -2846,7 +2855,7 @@
int got_gain=0;
int first_channel = 1;
int echo_cancel = DEFAULT_ECHO_CANCEL;
- int error = 0; /* Error flag */
+ enum ast_module_load_result error = AST_MODULE_LOAD_SUCCESS; /* Error flag */
int bal1 = -1; /* Special value - means do not set */
int bal2 = -1;
int bal3 = -1;
@@ -2897,7 +2906,7 @@
timer_period_ring = atoi(v->value);
}
else if (strcasecmp(v->name, "ecsuppthres") ==0) {
- ec_supp_threshold = atoi(v->value);
+ ec_supp_threshold = (short)atoi(v->value);
}
else if (strcasecmp(v->name, "dtmfidd") ==0) {
dtmf_idd = atoi(v->value);
@@ -2935,7 +2944,7 @@
iflist = tmp;
} else {
ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
- error = -1;
+ error = AST_MODULE_LOAD_FAILURE;
goto done;
}
} else if (strcasecmp(v->name, "language") == 0) {
@@ -3001,18 +3010,18 @@
ast_config_destroy(cfg);
if (use_ast_ind == 1){
- if (!error && ast_channel_register(&vpb_tech_indicate) != 0) {
+ if (error == AST_MODULE_LOAD_SUCCESS && ast_channel_register(&vpb_tech_indicate) != 0) {
ast_log(LOG_ERROR, "Unable to register channel class 'vpb'\n");
- error = -1;
+ error = AST_MODULE_LOAD_FAILURE;
}
else {
ast_log(LOG_NOTICE,"VPB driver Registered (w/AstIndication)\n");
}
}
else {
- if (!error && ast_channel_register(&vpb_tech) != 0) {
+ if (error == AST_MODULE_LOAD_SUCCESS && ast_channel_register(&vpb_tech) != 0) {
ast_log(LOG_ERROR, "Unable to register channel class 'vpb'\n");
- error = -1;
+ error = AST_MODULE_LOAD_FAILURE;
}
else {
ast_log(LOG_NOTICE,"VPB driver Registered )\n");
@@ -3020,7 +3029,7 @@
}
- if (error)
+ if (error != AST_MODULE_LOAD_SUCCESS)
unload_module();
else
restart_monitor(); /* And start the monitor for the first time */
@@ -3028,10 +3037,12 @@
return error;
}
+/*
int usecount()
{
return usecnt;
}
+*/
const char *description()
{
@@ -3043,10 +3054,21 @@
return ASTERISK_GPL_KEY;
}
+static int reload_module(void)
+{
+
+ return 0;
+
+}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Voicetronix VPB Card Driver",
+ load_module,
+ unload_module,
+ reload_module
+);
+
/**/
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
/**/
-
-
Index: include/asterisk/module.h
===================================================================
--- include/asterisk/module.h (revision 61682)
+++ include/asterisk/module.h (working copy)
@@ -226,8 +226,10 @@
static struct ast_module_info __mod_info = { \
NULL, \
load_func, \
+ reload_func, \
unload_func, \
- reload_func, \
+ NULL, \
+ NULL, \
AST_MODULE, \
desc, \
keystr, \
Index: include/asterisk/stringfields.h
===================================================================
--- include/asterisk/stringfields.h (revision 61682)
+++ include/asterisk/stringfields.h (working copy)
@@ -235,7 +235,7 @@
*/
#define ast_string_field_index_set(x, index, data) do { \
char *__zz__ = (char*)(x)->__begin_field[index]; \
- int __dlen__ = strlen(data); \
+ unsigned int __dlen__ = strlen(data); \
if( __dlen__ == 0 ) { (x)->__begin_field[index] = __ast_string_field_empty; \
} else { \
if( __zz__[0] != 0 && __dlen__ <= strlen(__zz__) ) { \