[asterisk-commits] wedhorn: branch wedhorn/skinny-subs r196113 - /team/wedhorn/skinny-subs/chann...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 21 17:38:49 CDT 2009


Author: wedhorn
Date: Thu May 21 17:38:45 2009
New Revision: 196113

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=196113
Log:
Some more hangup work.

Modified:
    team/wedhorn/skinny-subs/channels/chan_skinny.c

Modified: team/wedhorn/skinny-subs/channels/chan_skinny.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/wedhorn/skinny-subs/channels/chan_skinny.c?view=diff&rev=196113&r1=196112&r2=196113
==============================================================================
--- team/wedhorn/skinny-subs/channels/chan_skinny.c (original)
+++ team/wedhorn/skinny-subs/channels/chan_skinny.c Thu May 21 17:38:45 2009
@@ -1204,7 +1204,7 @@
 	int autohangup;
 	int dialing;
 	int hangingup;
-	int endcalltonetime;
+	//int endcalltonetime;
 	char label[42];
 	pthread_t dialingthread;
 	char exten[AST_MAX_EXTENSION];
@@ -4815,7 +4815,8 @@
 	sub->autoans = 0;
 	sub->autoans_time = 3000;
 	sub->autoans_tone = 1;
-	sub->endcalltonetime = 0;
+	sub->autohangup = l->device->autohangup;
+	//sub->endcalltonetime = 0;
 	sub->dialing = 0;
 	sub->hangingup = 0;
 	sub->locks = 0;
@@ -5406,6 +5407,7 @@
 static void *skinny_thread_endcall(void *data)
 {
 	struct skinny_subchannel *sub = data;
+	struct skinny_device *d = sub->parent->device;
 	char sublabel[42];
 	sub->thread = pthread_self();
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
@@ -5414,8 +5416,11 @@
 	pthread_cleanup_push(endcallThreadCleanupHandler, &sublabel);
 	
 	pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
-	usleep(sub->endcalltonetime * 1000);
+	usleep(sub->autohangup * 1000);
+	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
+	SIMPLE_LOCK_DEVICE;
 	set_sub_state(sub, SUBSTATE_ONHOOK);
+	SIMPLE_UNLOCK_DEVICE;
 	pthread_cleanup_pop(0);
 	return NULL;
 }
@@ -5569,20 +5574,19 @@
 		}
 		break;
 	case SUBSTATE_ENDCALL:
+		sub->substate = SUBSTATE_ENDCALL;
 		if (sub->owner) {
 			ast_queue_hangup(sub->owner);
 			detach_channel(sub);
 		}
-		if (sub != d->activesub || sub->substate == SUBSTATE_RINGIN || d->autohangup || sub->autohangup) {
-			sub->substate = SUBSTATE_ENDCALL;
+		if (sub != d->activesub || sub->substate == SUBSTATE_RINGIN || sub->autohangup == 0) {
 			sub = set_sub_state(sub, SUBSTATE_ONHOOK);
 		} else {
-			sub->substate = SUBSTATE_ENDCALL;
 			transmit_activatecallplane(d, l);
 			stop_rtp(sub);
 			set_sub_state(sub, SUBSTATE_REORDER);
 			skinny_end_thread(sub);
-			if (sub->endcalltonetime > 0) {
+			if (sub->autohangup > 0) {
 				if (ast_pthread_create(&sub->thread, NULL, skinny_thread_endcall, sub)) {
 					ast_log(LOG_WARNING, "Unable to create %s endcall thread: %s\n", sub->label, strerror(errno));
 					set_sub_state(sub, SUBSTATE_ONHOOK);
@@ -5632,7 +5636,7 @@
 			ast_log(LOG_WARNING, "Skinny SET_SUB_STATE Bug: Asked to indicate RINGOUT on %s but doesn't make sense\n", sub->label);
 		}
 		break;
-	case SUBSTATE_ONHOOK:			/* Destroy sub */
+	case SUBSTATE_ONHOOK:
 		if (sub == d->activesub) {
 			stop_rtp(sub);
 			transmit_ringer_mode(d, SKINNY_RING_OFF);
@@ -5653,14 +5657,10 @@
 		sub->alreadygone = 1;
 
 		sub->cxmode = SKINNY_CX_RECVONLY;
-		//if (l->startfortraverse == sub) {
-		//	l->startfortraverse = NULL;
-		//}
 
 		set_call_info(sub);
 		destroy_sub(sub);
 		sub = NULL;
-//		set_line_lamp(l);
 //		update_info = 0;
 		break;
 	case SUBSTATE_INBOUNDCALL:
@@ -6955,7 +6955,7 @@
 			} else if (!(strcasecmp(ast_var_name(current),"AUTO_ANS_TONE"))) {
 				sub->autoans_tone = ast_true(ast_var_value(current));
 			} else if (!(strcasecmp(ast_var_name(current),"AUTO_HANGUP"))) {
-				sub->autohangup = ast_true(ast_var_value(current));
+				sub->autohangup = atoi(ast_var_value(current));
 			}
 		}
 		set_sub_state(sub, SUBSTATE_INBOUNDCALL);
@@ -7405,7 +7405,7 @@
  			}
  		} else if (!strcasecmp(v->name, "autohangup")) {
  			if (type & (TYPE_DEF_DEVICE | TYPE_DEVICE)) {
- 				CDEV_OPTS->autohangup = ast_true(v->value);
+ 				CDEV_OPTS->autohangup = atoi(v->value);
  				continue;
  			}
  		} else if (!strcasecmp(v->name, "host")) {




More information about the asterisk-commits mailing list