* Asterisk -- A telephony toolkit for Linux.
*
* Radio Repeater / Remote Base program
- * version 0.15 8/21/04
+ * version 0.16 8/21/04
*
* See http://www.zapatatelephony.org/app_rpt.html
*
#include <tonezone.h>
#include <linux/zaptel.h>
-static char *tdesc = "Radio Repeater / Remote Base version 0.15 08/21/2004";
+static char *tdesc = "Radio Repeater / Remote Base version 0.16 08/21/2004";
static char *app = "Rpt";
static char *synopsis = "Radio Repeater/Remote Base Control System";
{
fprintf(stderr,"rpt:Dial number (%s) must be in format tech/number\n",myrpt->rxchanname);
ast_mutex_unlock(&myrpt->lock);
+ myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
*tele++ = 0;
fprintf(stderr,"rpt:Sorry unable to obtain Rx channel\n");
ast_mutex_unlock(&myrpt->lock);
ast_hangup(myrpt->rxchannel);
+ myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
ast_set_read_format(myrpt->rxchannel,AST_FORMAT_SLINEAR);
{
ast_mutex_unlock(&myrpt->lock);
ast_hangup(myrpt->rxchannel);
+ myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
}
{
fprintf(stderr,"rpt:Sorry unable to obtain Rx channel\n");
ast_mutex_unlock(&myrpt->lock);
+ myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
if (myrpt->txchanname)
{
fprintf(stderr,"rpt:Dial number (%s) must be in format tech/number\n",myrpt->txchanname);
ast_mutex_unlock(&myrpt->lock);
+ myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
*tele++ = 0;
ast_mutex_unlock(&myrpt->lock);
ast_hangup(myrpt->txchannel);
ast_hangup(myrpt->rxchannel);
+ myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
ast_set_read_format(myrpt->txchannel,AST_FORMAT_SLINEAR);
ast_mutex_unlock(&myrpt->lock);
ast_hangup(myrpt->rxchannel);
ast_hangup(myrpt->txchannel);
+ myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
}
fprintf(stderr,"rpt:Sorry unable to obtain Tx channel\n");
ast_mutex_unlock(&myrpt->lock);
ast_hangup(myrpt->rxchannel);
+ myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
}
if (myrpt->txchannel != myrpt->rxchannel)
ast_hangup(myrpt->txchannel);
ast_hangup(myrpt->rxchannel);
+ myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
/* make a conference for the tx */
if (myrpt->txchannel != myrpt->rxchannel)
ast_hangup(myrpt->txchannel);
ast_hangup(myrpt->rxchannel);
+ myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
/* save tx conference number */
if (myrpt->txchannel != myrpt->rxchannel)
ast_hangup(myrpt->txchannel);
ast_hangup(myrpt->rxchannel);
+ myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
/* save pseudo channel conference number */
if (myrpt->txchannel != myrpt->rxchannel)
ast_hangup(myrpt->txchannel);
ast_hangup(myrpt->rxchannel);
+ myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
/* make a conference for the tx */
if (myrpt->txchannel != myrpt->rxchannel)
ast_hangup(myrpt->txchannel);
ast_hangup(myrpt->rxchannel);
+ myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
}
/* Now, the idea here is to copy from the physical rx channel buffer
}
ast_mutex_unlock(&myrpt->lock);
if (debug) printf("@@@@ rpt:Hung up channel\n");
+ myrpt->rpt_thread = AST_PTHREADT_STOP;
pthread_exit(NULL);
return NULL;
}
ast_log(LOG_WARNING,"Did not specify ident for node %s\n",rpt_vars[i].name);
pthread_exit(NULL);
}
- ast_pthread_create(&rpt_vars[i].rpt_thread,NULL,rpt,(void *) &rpt_vars[i]);
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ ast_pthread_create(&rpt_vars[i].rpt_thread,&attr,rpt,(void *) &rpt_vars[i]);
}
usleep(500000);
for(;;)
/* Now monitor each thread, and restart it if necessary */
for(i = 0; i < n; i++)
{
+ int rv;
if (rpt_vars[i].remote) continue;
- if (pthread_kill(rpt_vars[i].rpt_thread,0))
+ if (rpt_vars[i].rpt_thread == AST_PTHREADT_STOP)
+ rv = -1;
+ else
+ rv = pthread_kill(rpt_vars[i].rpt_thread,0);
+ if (rv)
{
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);