static struct ast_channel_tech lcr_tech;
+void lock_debug(char *text)
+{
+ printf("%s", text); fflush(stdout);
+}
+
/*
* logging
*/
char ast_text[128] = "NULL";
va_list args;
+ lock_debug("L");
ast_mutex_lock(&log_lock);
va_start(args,fmt);
ast_log(type, file, line, function, "[call=%s ast=%s] %s", call_text, ast_text, buffer);
ast_mutex_unlock(&log_lock);
+ lock_debug("l");
}
/*
if (param->setup.callerinfo.name[0])
ast->cid.cid_name = strdup(param->setup.callerinfo.name);
if (param->setup.redirinfo.id[0])
- ast->cid.cid_name = strdup(numberrize_callerinfo(param->setup.callerinfo.id, param->setup.callerinfo.ntype, options.national, options.international));
+ ast->cid.cid_rdnis = strdup(numberrize_callerinfo(param->setup.redirinfo.id, param->setup.redirinfo.ntype, options.national, options.international));
switch (param->setup.callerinfo.present) {
case INFO_PRESENT_ALLOWED:
ast->cid.cid_pres = AST_PRES_ALLOWED;
p = call->queue_string;
ast = call->ast;
if (*p && ast) {
+ lock_debug("A1");
ast_channel_lock(ast);
while(*p) {
switch (*p) {
}
call->queue_string[0] = '\0';
ast_channel_unlock(ast);
+ lock_debug("a1");
}
call = call->next;
}
void lock_chan(void)
{
+ lock_debug("C");
ast_mutex_lock(&chan_lock);
}
void unlock_chan(void)
{
ast_mutex_unlock(&chan_lock);
+ lock_debug("c");
}
/* chan_lcr thread */
/* open socket the first time */
handle_retry(NULL, NULL, 0);
+ lock_debug("A2");
ast_mutex_lock(&chan_lock);
while(!quit) {
CERROR(NULL, NULL, "Thread exit.\n");
ast_mutex_unlock(&chan_lock);
+ lock_debug("a2");
return NULL;
}
struct ast_channel *ast;
struct chan_call *call;
+ lock_debug("A3");
ast_mutex_lock(&chan_lock);
CDEBUG(NULL, NULL, "Received request from Asterisk. (data=%s)\n", (char *)data);
if (lcr_sock < 0) {
CERROR(NULL, NULL, "Rejecting call from Asterisk, because LCR not running.\n");
ast_mutex_unlock(&chan_lock);
+ lock_debug("a3");
return NULL;
}
if (!call) {
/* failed to create instance */
ast_mutex_unlock(&chan_lock);
+ lock_debug("a3");
return NULL;
}
free_call(call);
/* failed to create instance */
ast_mutex_unlock(&chan_lock);
+ lock_debug("a3");
return NULL;
}
ast->tech = &lcr_tech;
apply_opt(call, (char *)opt);
ast_mutex_unlock(&chan_lock);
+ lock_debug("a3");
return ast;
}
union parameter newparam;
struct chan_call *call;
+ lock_debug("A4");
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
if (!call) {
CERROR(NULL, ast, "Received call from Asterisk, but call instance does not exist.\n");
ast_mutex_unlock(&chan_lock);
+ lock_debug("a4");
return -1;
}
sizeof(call->cid_rdnis)-1);
ast_mutex_unlock(&chan_lock);
+ lock_debug("a4");
return 0;
}
if (digit > 126 || digit < 32)
return 0;
+ lock_debug("A5");
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
if (!call) {
CERROR(NULL, ast, "Received digit from Asterisk, but no call instance exists.\n");
ast_mutex_unlock(&chan_lock);
+ lock_debug("a5");
return -1;
}
}
ast_mutex_unlock(&chan_lock);
+ lock_debug("a5");
#ifdef LCR_FOR_ASTERISK
return 0;
struct chan_call *call;
#endif
+ lock_debug("A6");
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
"Received digit from Asterisk, "
"but no call instance exists.\n");
ast_mutex_unlock(&chan_lock);
+ lock_debug("a6");
return -1;
}
}
ast_mutex_unlock(&chan_lock);
+ lock_debug("a6");
if (inband_dtmf) {
CDEBUG(call, ast, "-> sending '%c' inband.\n", digit);
union parameter newparam;
struct chan_call *call;
+ lock_debug("A7");
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
if (!call) {
CERROR(NULL, ast, "Received answer from Asterisk, but no call instance exists.\n");
ast_mutex_unlock(&chan_lock);
+ lock_debug("a7");
return -1;
}
// send_message(MESSAGE_ENABLEKEYPAD, call->ref, &newparam);
ast_mutex_unlock(&chan_lock);
+ lock_debug("a7");
return 0;
}
struct chan_call *call;
pthread_t tid = pthread_self();
- if (!pthread_equal(tid, chan_tid))
+ if (!pthread_equal(tid, chan_tid)) {
+ lock_debug("H");
ast_mutex_lock(&chan_lock);
+ }
call = ast->tech_pvt;
if (!call) {
CERROR(NULL, ast, "Received hangup from Asterisk, but no call instance exists.\n");
- if (!pthread_equal(tid, chan_tid))
+ if (!pthread_equal(tid, chan_tid)) {
ast_mutex_unlock(&chan_lock);
+ lock_debug("h");
+ }
return -1;
}
send_release_and_import(call, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL);
/* remove call */
free_call(call);
- if (!pthread_equal(tid, chan_tid))
+ if (!pthread_equal(tid, chan_tid)) {
ast_mutex_unlock(&chan_lock);
+ lock_debug("h");
+ }
return 0;
} else {
/* ref is not set, due to prepare setup or release */
call->ast = NULL;
}
}
- if (!pthread_equal(tid, chan_tid))
+ if (!pthread_equal(tid, chan_tid)) {
ast_mutex_unlock(&chan_lock);
+ lock_debug("h");
+ }
return 0;
}
if (!(f->subclass & ast->nativeformats))
CDEBUG(NULL, ast, "Unexpected format.\n");
+ lock_debug("A8");
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
if (!call) {
ast_mutex_unlock(&chan_lock);
+ lock_debug("a8");
return -1;
}
if (call->bchannel && f->samples)
bchannel_transmit(call->bchannel, *((unsigned char **)&(f->data)), f->samples);
ast_mutex_unlock(&chan_lock);
+ lock_debug("a8");
return 0;
}
struct chan_call *call;
int len;
+ lock_debug("A9");
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
if (!call) {
ast_mutex_unlock(&chan_lock);
+ lock_debug("a9");
return NULL;
}
if (call->pipe[0] > -1) {
}
if (len < 0 && errno == EAGAIN) {
ast_mutex_unlock(&chan_lock);
+ lock_debug("a9");
#ifdef LCR_FOR_ASTERISK
return &ast_null_frame;
call->pipe[0] = -1;
global_change = 1;
ast_mutex_unlock(&chan_lock);
+ lock_debug("a9");
return NULL;
} else if (call->rebuffer && call->framepos < 160) {
/* Not a complete frame, so we send a null-frame */
ast_mutex_unlock(&chan_lock);
+ lock_debug("a9");
return &ast_null_frame;
}
}
call->read_fr.delivery = ast_tv(0,0);
*((unsigned char **)&(call->read_fr.data)) = call->read_buff;
ast_mutex_unlock(&chan_lock);
+ lock_debug("a9");
return &call->read_fr;
}
union parameter newparam;
int res = 0;
struct chan_call *call;
+ const struct tone_zone_sound *ts = NULL;
+ lock_debug("A0");
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
if (!call) {
CERROR(NULL, ast, "Received indicate from Asterisk, but no call instance exists.\n");
ast_mutex_unlock(&chan_lock);
+ lock_debug("a0");
return -1;
}
send_message(MESSAGE_DISCONNECT, call->ref, &newparam);
/* change state */
call->state = CHAN_LCR_STATE_OUT_DISCONNECT;
+ } else {
+ CDEBUG(call, ast, "Using Asterisk 'busy' indication\n");
+ ts = ast_get_indication_tone(ast->zone, "busy");
}
break;
case AST_CONTROL_CONGESTION:
send_message(MESSAGE_DISCONNECT, call->ref, &newparam);
/* change state */
call->state = CHAN_LCR_STATE_OUT_DISCONNECT;
+ } else {
+ CDEBUG(call, ast, "Using Asterisk 'congestion' indication\n");
+ ts = ast_get_indication_tone(ast->zone, "congestion");
}
break;
case AST_CONTROL_PROCEEDING:
send_message(MESSAGE_ALERTING, call->ref, &newparam);
/* change state */
call->state = CHAN_LCR_STATE_IN_ALERTING;
+ } else {
+ CDEBUG(call, ast, "Using Asterisk 'ring' indication\n");
+ ts = ast_get_indication_tone(ast->zone, "ring");
}
break;
case AST_CONTROL_PROGRESS:
break;
case -1:
CDEBUG(call, ast, "Received indicate -1.\n");
+ ast_playtones_stop(ast);
res = -1;
break;
break;
}
+ if (ts && ts->data[0]) {
+ ast_playtones_start(ast, 0, ts->data, 1);
+ }
+
/* return */
ast_mutex_unlock(&chan_lock);
+ lock_debug("a0");
return res;
}
return -1;
}
+ lock_debug("Af");
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
if (!call) {
CERROR(NULL, ast, "Received fixup from Asterisk, but no call instance exists.\n");
ast_mutex_unlock(&chan_lock);
+ lock_debug("af");
return -1;
}
CDEBUG(call, ast, "Received fixup from Asterisk.\n");
call->ast = ast;
ast_mutex_unlock(&chan_lock);
+ lock_debug("af");
return 0;
}
struct chan_call *call;
union parameter newparam;
+ lock_debug("At");
ast_mutex_lock(&chan_lock);
call = ast->tech_pvt;
if (!call) {
CERROR(NULL, ast, "Received send_text from Asterisk, but no call instance exists.\n");
ast_mutex_unlock(&chan_lock);
+ lock_debug("at");
return -1;
}
memset(&newparam, 0, sizeof(union parameter));
strncpy(newparam.notifyinfo.display, text, sizeof(newparam.notifyinfo.display)-1);
send_message(MESSAGE_NOTIFY, call->ref, &newparam);
- ast_mutex_lock(&chan_lock);
+ ast_mutex_unlock(&chan_lock);
+ lock_debug("at");
return 0;
}
carr[1] = ast2;
/* join via dsp (if the channels are currently open) */
+ lock_debug("Ab");
ast_mutex_lock(&chan_lock);
call1 = ast1->tech_pvt;
call2 = ast2->tech_pvt;
if (!call1 || !call2) {
CDEBUG(NULL, NULL, "Bridge, but we don't have two call instances, exitting.\n");
ast_mutex_unlock(&chan_lock);
+ lock_debug("ab");
return AST_BRIDGE_COMPLETE;
}
}
ast_mutex_unlock(&chan_lock);
+ lock_debug("ab");
while(1) {
to = -1;
CDEBUG(NULL, NULL, "Releasing bridge.\n");
/* split channels */
+ lock_debug("Ab");
ast_mutex_lock(&chan_lock);
call1 = ast1->tech_pvt;
call2 = ast2->tech_pvt;
call2->bridge_call = NULL;
ast_mutex_unlock(&chan_lock);
+ lock_debug("ab");
return AST_BRIDGE_COMPLETE;
}
static struct ast_channel_tech lcr_tech = {
{
struct chan_call *call;
+ lock_debug("Ae");
ast_mutex_lock(&chan_lock);
#ifdef LCR_FOR_ASTERISK
CERROR(NULL, ast, "lcr_config app not called by chan_lcr channel.\n");
ast_mutex_unlock(&chan_lock);
+ lock_debug("ae");
return 0;
}
hae
{
int res;
+ lock_debug("U");
ast_mutex_lock(&usecnt_lock);
res = usecnt;
ast_mutex_unlock(&usecnt_lock);
+ lock_debug("u");
return res;
}
#endif