#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#include <math.h>
#include <asterisk/pbx.h>
#include <asterisk/frame.h>
#include <asterisk/sched.h>
#include <asterisk/options.h>
#include <asterisk/channel.h>
#include <asterisk/channel_pvt.h>
#include <asterisk/logger.h>
#include <asterisk/file.h>
#include <asterisk/translate.h>
#include <asterisk/manager.h>
#include <asterisk/chanvars.h>
#include <asterisk/linkedlists.h>
#include <asterisk/indications.h>
#include <asterisk/lock.h>
#include <asterisk/utils.h>
Go to the source code of this file.
Defines | |
#define | MAX_AUTOMONS 256 |
Functions | |
AST_MUTEX_DEFINE_STATIC (autolock) | |
int | ast_autoservice_start (struct ast_channel *chan) |
int | ast_autoservice_stop (struct ast_channel *chan) |
|
Definition at line 38 of file autoservice.c. |
|
Automatically service a channel for us... Definition at line 88 of file autoservice.c. References ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_pthread_create(), AST_PTHREADT_NULL, asent::chan, free, LOG_WARNING, malloc, and asent::next. Referenced by ast_dtmf_stream(), ast_get_enum(), ast_get_srv(), and ast_get_txt(). 00089 { 00090 int res = -1; 00091 struct asent *as; 00092 int needstart; 00093 ast_mutex_lock(&autolock); 00094 needstart = (asthread == AST_PTHREADT_NULL) ? 1 : 0 /* aslist ? 0 : 1 */; 00095 as = aslist; 00096 while(as) { 00097 if (as->chan == chan) 00098 break; 00099 as = as->next; 00100 } 00101 if (!as) { 00102 as = malloc(sizeof(struct asent)); 00103 if (as) { 00104 memset(as, 0, sizeof(struct asent)); 00105 as->chan = chan; 00106 as->next = aslist; 00107 aslist = as; 00108 res = 0; 00109 if (needstart) { 00110 if (ast_pthread_create(&asthread, NULL, autoservice_run, NULL)) { 00111 ast_log(LOG_WARNING, "Unable to create autoservice thread :(\n"); 00112 free(aslist); 00113 aslist = NULL; 00114 res = -1; 00115 } else 00116 pthread_kill(asthread, SIGURG); 00117 } 00118 } 00119 } 00120 ast_mutex_unlock(&autolock); 00121 return res; 00122 }
|
|
Stop servicing a channel for us... Returns -1 on error or if channel has been hungup Definition at line 124 of file autoservice.c. References ast_mutex_lock, ast_mutex_unlock, AST_PTHREADT_NULL, asent::chan, free, and asent::next. Referenced by ast_dtmf_stream(), ast_get_enum(), ast_get_srv(), and ast_get_txt(). 00125 { 00126 int res = -1; 00127 struct asent *as, *prev; 00128 ast_mutex_lock(&autolock); 00129 as = aslist; 00130 prev = NULL; 00131 while(as) { 00132 if (as->chan == chan) 00133 break; 00134 prev = as; 00135 as = as->next; 00136 } 00137 if (as) { 00138 if (prev) 00139 prev->next = as->next; 00140 else 00141 aslist = as->next; 00142 free(as); 00143 if (!chan->_softhangup) 00144 res = 0; 00145 } 00146 if (asthread != AST_PTHREADT_NULL) 00147 pthread_kill(asthread, SIGURG); 00148 ast_mutex_unlock(&autolock); 00149 /* Wait for it to un-block */ 00150 while(chan->blocking) 00151 usleep(1000); 00152 return res; 00153 }
|
|
|