From 5561ba19aa8ebb0be8a74f291ebaf0805f8cbf29 Mon Sep 17 00:00:00 2001 From: Jeff Peeler Date: Thu, 10 Sep 2009 20:18:30 +0000 Subject: [PATCH] Stop caller id transmission when offhook event detected. This fixes the problem that would occur if an analog phone was picked up while the caller id was being sent. The caller id before sent the whole spill even after pickup and is now corrected. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@217744 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_dahdi.c | 13 +++++++++++++ channels/sig_analog.c | 12 ++++++++++++ channels/sig_analog.h | 1 + 3 files changed, 26 insertions(+) diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index f5217ea533..b78c6aa72e 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -2104,6 +2104,15 @@ static int my_check_confirmanswer(void *pvt) return 0; } +static void my_cancel_cidspill(void *pvt) +{ + struct dahdi_pvt *p = pvt; + if (p->cidspill) { + ast_free(p->cidspill); + p->cidspill = NULL; + } +} + static void my_increase_ss_count(void) { ast_mutex_lock(&ss_thread_lock); @@ -2435,6 +2444,8 @@ static int my_is_off_hook(void *pvt) int res; struct dahdi_params par; + memset(&par, 0, sizeof(par)); + if (p->subs[SUB_REAL].dfd > -1) res = ioctl(p->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &par); else { @@ -2833,6 +2844,7 @@ static struct analog_callback dahdi_analog_callbacks = .check_waitingfordt = my_check_waitingfordt, .set_confirmanswer = my_set_confirmanswer, .check_confirmanswer = my_check_confirmanswer, + .cancel_cidspill = my_cancel_cidspill, }; static struct dahdi_pvt *round_robin[32]; @@ -4359,6 +4371,7 @@ static int send_callerid(struct dahdi_pvt *p) } while (p->cidpos < p->cidlen) { res = write(p->subs[SUB_REAL].dfd, p->cidspill + p->cidpos, p->cidlen - p->cidpos); + ast_debug(4, "writing callerid at pos %d of %d, res = %d\n", p->cidpos, p->cidlen, res); if (res < 0) { if (errno == EAGAIN) return 0; diff --git a/channels/sig_analog.c b/channels/sig_analog.c index 398b5f1709..e822fc3396 100644 --- a/channels/sig_analog.c +++ b/channels/sig_analog.c @@ -771,6 +771,15 @@ static int analog_check_confirmanswer(struct analog_pvt *p) return 0; } +static void analog_cancel_cidspill(struct analog_pvt *p) +{ + if (!p->calls->cancel_cidspill) { + return; + } + + p->calls->cancel_cidspill(p->chan_pvt); +} + static int analog_set_linear_mode(struct analog_pvt *p, int index, int linear_mode) { if (p->calls->set_linear_mode) { @@ -2541,6 +2550,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_ /* Make sure it stops ringing */ analog_off_hook(p); ast_debug(1, "channel %d answered\n", p->channel); + analog_cancel_cidspill(p); analog_set_dialing(p, 0); p->callwaitcas = 0; if (analog_check_confirmanswer(p)) { @@ -2662,6 +2672,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_ } if (ast->rings > p->cidrings) { + analog_cancel_cidspill(p); p->callwaitcas = 0; } p->subs[index].f.frametype = AST_FRAME_CONTROL; @@ -3187,6 +3198,7 @@ int analog_handle_init_event(struct analog_pvt *i, int event) if (res && (errno == EBUSY)) { break; } + analog_cancel_cidspill(i); if (i->immediate) { analog_set_echocanceller(i, 1); /* The channel is immediately up. Start right away */ diff --git a/channels/sig_analog.h b/channels/sig_analog.h index ce41ccc70d..1b9a14de13 100644 --- a/channels/sig_analog.h +++ b/channels/sig_analog.h @@ -201,6 +201,7 @@ struct analog_callback { int (* const check_waitingfordt)(void *pvt); void (* const set_confirmanswer)(void *pvt, int flag); int (* const check_confirmanswer)(void *pvt); + void (* const cancel_cidspill)(void *pvt); };