[asterisk-commits] jpeeler: branch jpeeler/chan_dahdi14 r120062 - in /team/jpeeler/chan_dahdi14:...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jun 3 13:23:41 CDT 2008
Author: jpeeler
Date: Tue Jun 3 13:23:40 2008
New Revision: 120062
URL: http://svn.digium.com/view/asterisk?view=rev&rev=120062
Log:
access proper device nodes depending on which driver is detected
Modified:
team/jpeeler/chan_dahdi14/channels/chan_iax2.c
team/jpeeler/chan_dahdi14/include/asterisk/dahdi_compat.h
team/jpeeler/chan_dahdi14/main/asterisk.c
team/jpeeler/chan_dahdi14/main/channel.c
team/jpeeler/chan_dahdi14/main/file.c
team/jpeeler/chan_dahdi14/res/res_musiconhold.c
Modified: team/jpeeler/chan_dahdi14/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/chan_dahdi14/channels/chan_iax2.c?view=diff&rev=120062&r1=120061&r2=120062
==============================================================================
--- team/jpeeler/chan_dahdi14/channels/chan_iax2.c (original)
+++ team/jpeeler/chan_dahdi14/channels/chan_iax2.c Tue Jun 3 13:23:40 2008
@@ -59,7 +59,7 @@
#include <sys/stat.h>
#include <regex.h>
-#ifdef HAVE_ZAPTEL
+#if defined(HAVE_ZAPTEL) || defined (HAVE_DAHDI)
#include <sys/ioctl.h>
#include "asterisk/dahdi_compat.h"
#endif
@@ -9790,7 +9790,7 @@
static void set_timing(void)
{
-#ifdef HAVE_ZAPTEL
+#ifdef HAVE_DAHDI
int bs = trunkfreq * 8;
if (timingfd > -1) {
if (
@@ -11073,14 +11073,22 @@
jb_setoutput(jb_error_output, jb_warning_output, NULL);
#ifdef HAVE_ZAPTEL
-#ifdef DAHDI_TIMERACK
+#ifdef ZAPTEL_TIMERACK
timingfd = open("/dev/zap/timer", O_RDWR);
if (timingfd < 0)
#endif
timingfd = open("/dev/zap/pseudo", O_RDWR);
if (timingfd < 0)
ast_log(LOG_WARNING, "Unable to open IAX timing interface: %s\n", strerror(errno));
-#endif
+#elif defined(HAVE_DAHDI)
+#ifdef DAHDI_TIMERACK
+ timingfd = open("/dev/dahdi/timer", O_RDWR);
+ if (timingfd < 0)
+#endif
+ timingfd = open("/dev/dahdi/pseudo", O_RDWR);
+ if (timingfd < 0)
+ ast_log(LOG_WARNING, "Unable to open IAX timing interface: %s\n", strerror(errno));
+#endif
memset(iaxs, 0, sizeof(iaxs));
Modified: team/jpeeler/chan_dahdi14/include/asterisk/dahdi_compat.h
URL: http://svn.digium.com/view/asterisk/team/jpeeler/chan_dahdi14/include/asterisk/dahdi_compat.h?view=diff&rev=120062&r1=120061&r2=120062
==============================================================================
--- team/jpeeler/chan_dahdi14/include/asterisk/dahdi_compat.h (original)
+++ team/jpeeler/chan_dahdi14/include/asterisk/dahdi_compat.h Tue Jun 3 13:23:40 2008
@@ -180,6 +180,7 @@
#define DAHDI_TRANSCODE_OP ZT_TRANSCODE_OP
#define DAHDI_vldtmf ZT_vldtmf
#define DAHDI_WINK ZT_WINK
+#define HAVE_DAHDI HAVE_ZAPTEL
#define dahdi_ring_cadence zt_ring_cadence
Modified: team/jpeeler/chan_dahdi14/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/chan_dahdi14/main/asterisk.c?view=diff&rev=120062&r1=120061&r2=120062
==============================================================================
--- team/jpeeler/chan_dahdi14/main/asterisk.c (original)
+++ team/jpeeler/chan_dahdi14/main/asterisk.c Tue Jun 3 13:23:40 2008
@@ -81,9 +81,9 @@
#include <pwd.h>
#include <sys/stat.h>
-#ifdef HAVE_ZAPTEL
+#if defined(HAVE_ZAPTEL) || defined (HAVE_DAHDI)
#include <sys/ioctl.h>
-#include <zaptel/zaptel.h>
+#include "asterisk/dahdi_compat.h"
#endif
#ifdef linux
@@ -2969,7 +2969,7 @@
int x = 160;
fd = open("/dev/zap/timer", O_RDWR);
if (fd >= 0) {
- if (ioctl(fd, ZT_TIMERCONFIG, &x)) {
+ if (ioctl(fd, DAHDI_TIMERCONFIG, &x)) {
ast_log(LOG_ERROR, "You have Zaptel built and drivers loaded, but the Zaptel timer test failed to set ZT_TIMERCONFIG to %d.\n", x);
exit(1);
}
@@ -2990,6 +2990,34 @@
close(fd);
}
}
+#elif defined(HAVE_DAHDI)
+{
+ int fd;
+ int x = 160;
+ fd = open("/dev/dahdi/timer", O_RDWR);
+ if (fd >= 0) {
+ if (ioctl(fd, DAHDI_TIMERCONFIG, &x)) {
+ ast_log(LOG_ERROR, "You have DAHDI built and drivers loaded, but the DAHDI timer test failed to set DAHDI_TIMERCONFIG to %d.\n", x);
+ exit(1);
+ }
+ if ((x = ast_wait_for_input(fd, 300)) < 0) {
+ ast_log(LOG_ERROR, "You have DAHDI built and drivers loaded, but the DAHDI timer could not be polled during the DAHDI timer test.\n");
+ exit(1);
+ }
+ if (!x) {
+ const char dahdi_timer_error[] = {
+ "Asterisk has detected a problem with your DAHDI configuration and will shutdown for your protection. You have options:"
+ "\n\t1. You only have to compile DAHDI support into Asterisk if you need it. One option is to recompile without DAHDI support."
+ "\n\t2. You only have to load DAHDI drivers if you want to take advantage of DAHDI services. One option is to unload DAHDI modules if you don't need them."
+ "\n\t3. If you need DAHDI services, you must correctly configure DAHDI."
+ };
+ ast_log(LOG_ERROR, "%s\n", dahdi_timer_error);
+ exit(1);
+ }
+ close(fd);
+ }
+ }
+
#endif
threadstorage_init();
Modified: team/jpeeler/chan_dahdi14/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/chan_dahdi14/main/channel.c?view=diff&rev=120062&r1=120061&r2=120062
==============================================================================
--- team/jpeeler/chan_dahdi14/main/channel.c (original)
+++ team/jpeeler/chan_dahdi14/main/channel.c Tue Jun 3 13:23:40 2008
@@ -37,7 +37,7 @@
#include <unistd.h>
#include <math.h>
-#ifdef HAVE_ZAPTEL
+#if defined(HAVE_ZAPTEL) || defined (HAVE_DAHDI)
#include <sys/ioctl.h>
#include "asterisk/dahdi_compat.h"
#endif
@@ -742,8 +742,14 @@
for (x = 0; x < AST_MAX_FDS - 2; x++)
tmp->fds[x] = -1;
+#ifdef HAVE_DAHDI
+
#ifdef HAVE_ZAPTEL
tmp->timingfd = open("/dev/zap/timer", O_RDWR);
+#else
+ tmp->timingfd = open("/dev/dahdi/timer", O_RDWR);
+#endif
+
if (tmp->timingfd > -1) {
/* Check if timing interface supports new
ping/pong scheme */
@@ -758,7 +764,7 @@
if (needqueue) {
if (pipe(tmp->alertpipe)) {
ast_log(LOG_WARNING, "Channel allocation failed: Can't create alert pipe!\n");
-#ifdef HAVE_ZAPTEL
+#ifdef HAVE_DAHDI
if (tmp->timingfd > -1)
close(tmp->timingfd);
#endif
@@ -926,7 +932,7 @@
if (write(chan->alertpipe[1], &blah, sizeof(blah)) != sizeof(blah))
ast_log(LOG_WARNING, "Unable to write to alert pipe on %s, frametype/subclass %d/%d (qlen = %d): %s!\n",
chan->name, f->frametype, f->subclass, qlen, strerror(errno));
-#ifdef HAVE_ZAPTEL
+#ifdef HAVE_DAHDI
} else if (chan->timingfd > -1) {
ioctl(chan->timingfd, DAHDI_TIMERPING, &blah);
#endif
@@ -1794,7 +1800,7 @@
int ast_settimeout(struct ast_channel *c, int samples, int (*func)(const void *data), void *data)
{
int res = -1;
-#ifdef HAVE_ZAPTEL
+#ifdef HAVE_DAHDI
if (c->timingfd > -1) {
if (!func) {
samples = 0;
@@ -1997,7 +2003,7 @@
if (chan->alertpipe[0] > -1)
read(chan->alertpipe[0], &blah, sizeof(blah));
-#ifdef HAVE_ZAPTEL
+#ifdef HAVE_DAHDI
if (chan->timingfd > -1 && chan->fdno == AST_TIMING_FD && ast_test_flag(chan, AST_FLAG_EXCEPTION)) {
int res;
Modified: team/jpeeler/chan_dahdi14/main/file.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/chan_dahdi14/main/file.c?view=diff&rev=120062&r1=120061&r2=120062
==============================================================================
--- team/jpeeler/chan_dahdi14/main/file.c (original)
+++ team/jpeeler/chan_dahdi14/main/file.c Tue Jun 3 13:23:40 2008
@@ -679,7 +679,7 @@
}
}
if (whennext != s->lasttimeout) {
-#ifdef HAVE_ZAPTEL
+#ifdef HAVE_DAHDI
if (s->owner->timingfd > -1) {
int zap_timer_samples = whennext;
int rate;
@@ -702,7 +702,7 @@
return_failure:
s->owner->streamid = -1;
-#ifdef HAVE_ZAPTEL
+#ifdef HAVE_DAHDI
ast_settimeout(s->owner, 0, NULL, NULL);
#endif
return FSREAD_FAILURE;
@@ -813,7 +813,7 @@
if (f->fmt->format < AST_FORMAT_MAX_AUDIO) {
f->owner->stream = NULL;
AST_SCHED_DEL(f->owner->sched, f->owner->streamid);
-#ifdef HAVE_ZAPTEL
+#ifdef HAVE_DAHDI
ast_settimeout(f->owner, 0, NULL, NULL);
#endif
} else {
Modified: team/jpeeler/chan_dahdi14/res/res_musiconhold.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/chan_dahdi14/res/res_musiconhold.c?view=diff&rev=120062&r1=120061&r2=120062
==============================================================================
--- team/jpeeler/chan_dahdi14/res/res_musiconhold.c (original)
+++ team/jpeeler/chan_dahdi14/res/res_musiconhold.c Tue Jun 3 13:23:40 2008
@@ -863,7 +863,7 @@
static int moh_register(struct mohclass *moh, int reload)
{
-#ifdef HAVE_ZAPTEL
+#ifdef HAVE_DAHDI
int x;
#endif
struct mohclass *mohclass = NULL;
@@ -907,10 +907,14 @@
ast_set_flag(moh, MOH_QUIET);
moh->srcfd = -1;
-#ifdef HAVE_ZAPTEL
+#ifdef HAVE_DAHDI
/* Open /dev/zap/pseudo for timing... Is
there a better, yet reliable way to do this? */
+#ifdef HAVE_ZAPTEL
moh->pseudofd = open("/dev/zap/pseudo", O_RDONLY);
+#else
+ moh->pseudofd = open("/dev/dahdi/pseudo", O_RDONLY);
+#endif
if (moh->pseudofd < 0) {
ast_log(LOG_WARNING, "Unable to open pseudo channel for timing... Sound may be choppy.\n");
} else {
More information about the asterisk-commits
mailing list