From e2318bdba91efdd5c8c2cb21d91307997b0345bf Mon Sep 17 00:00:00 2001 From: Mark Spencer <markster@digium.com> Date: Thu, 30 Sep 2004 15:26:04 +0000 Subject: [PATCH] Merge ring pulse stuff (Bug #2016) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3856 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_zap.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/channels/chan_zap.c b/channels/chan_zap.c index b4149cfc90..5997ac209d 100755 --- a/channels/chan_zap.c +++ b/channels/chan_zap.c @@ -9480,6 +9480,7 @@ static int setup_zap(void) int i; struct zt_ring_cadence new_cadence; int cid_location = -1; + int firstcadencepos = 0; char original_args[80]; int cadence_is_ok = 1; @@ -9495,23 +9496,30 @@ static int setup_zap(void) /* Ring cadences cannot be negative */ for (i=0;i<element_count;i++) { - if (c[i] < 1) { - if ((i % 2 == 1) && (cid_location == -1)) { - /* Silence duration, negative possibly okay */ - if (c[i] == 0) { - ast_log(LOG_ERROR, "Silence duration cannot be zero: %s\n", original_args); - cadence_is_ok = 0; - } else { - cid_location = i; + if (c[i] == 0) { + ast_log(LOG_ERROR, "Ring or silence duration cannot be zero: %s\n", original_args); + cadence_is_ok = 0; + break; + } else if (c[i] < 0) { + if (i % 2 == 1) { + /* Silence duration, negative possibly okay */ + if (cid_location == -1) { + cid_location = i; c[i] *= -1; + } else { + ast_log(LOG_ERROR, "CID location specified twice: %s\n",original_args); + cadence_is_ok = 0; + break; } - } else if (cid_location) { - ast_log(LOG_ERROR, "CID location specified twice: %s\n",original_args); - cadence_is_ok = 0; } else { - ast_log(LOG_ERROR, "Negative or zero ring duration: %s\n",original_args); - cadence_is_ok = 0; - break; + if (firstcadencepos == 0) { + firstcadencepos = i; /* only recorded to avoid duplicate specification */ + /* duration will be passed negative to the zaptel driver */ + } else { + ast_log(LOG_ERROR, "First cadence position specified twice: %s\n",original_args); + cadence_is_ok = 0; + break; + } } } } -- GitLab