From a0976a0f3e1a4738ec7444562b6bcf4ffd55c4d1 Mon Sep 17 00:00:00 2001 From: MelwareDE Date: Tue, 6 Jan 2009 13:40:49 +0000 Subject: [PATCH] - adapt to new Asterisk 1.6.1 changes. --- CHANGES | 1 + chan_capi.c | 7 ++++--- chan_capi.h | 6 ++++++ chan_capi_utils.c | 16 ++++++++-------- create_config.sh | 7 +++++++ 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/CHANGES b/CHANGES index dc52d23..171ac9e 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,7 @@ HEAD Dial() option 'G' is used to activate this feature. - fixed big-endian issue for DATA_B3 messages in internal libcapi code. - fixed NULL-pointer when no digits are signaled in DID mode. +- adapt to new Asterisk 1.6.1 changes. chan_capi-1.1.1 diff --git a/chan_capi.c b/chan_capi.c index 0ca5b38..7ad9c03 100644 --- a/chan_capi.c +++ b/chan_capi.c @@ -668,8 +668,9 @@ static int local_queue_frame(struct capi_pvt *i, struct ast_frame *f) wbuflen = sizeof(struct ast_frame) + f->datalen; wbuf = alloca(wbuflen); memcpy(wbuf, f, sizeof(struct ast_frame)); - if (f->datalen) - memcpy(wbuf + sizeof(struct ast_frame), f->data, f->datalen); + if (f->datalen) { + memcpy(wbuf + sizeof(struct ast_frame), f->FRAME_DATA_PTR, f->datalen); + } if (write(i->writerfd, wbuf, wbuflen) != wbuflen) { cc_log(LOG_ERROR, "Could not write to pipe for %s\n", @@ -3277,7 +3278,7 @@ static void capidev_handle_data_b3_indication(_cmsg *CMSG, unsigned int PLCI, un fr.frametype = AST_FRAME_VOICE; fr.subclass = capi_capability; - fr.data = b3buf; + fr.FRAME_DATA_PTR = b3buf; fr.datalen = b3len; fr.samples = b3len; fr.offset = AST_FRIENDLY_OFFSET; diff --git a/chan_capi.h b/chan_capi.h index a5e4352..00112bd 100644 --- a/chan_capi.h +++ b/chan_capi.h @@ -119,6 +119,12 @@ static inline unsigned int read_capi_dword(void *m) #define CC_CHANNEL_PVT(c) (c)->tech_pvt #define CC_BRIDGE_RETURN enum ast_bridge_result +#ifdef CC_AST_HAS_UNION_DATA_IN_FRAME +#define FRAME_DATA_PTR data.ptr +#else +#define FRAME_DATA_PTR data +#endif + /* */ #define return_on_no_interface(x) \ if (!i) { \ diff --git a/chan_capi_utils.c b/chan_capi_utils.c index 8a1eed1..17ffb51 100644 --- a/chan_capi_utils.c +++ b/chan_capi_utils.c @@ -1113,7 +1113,7 @@ struct ast_frame *capi_read_pipeframe(struct capi_pvt *i) } f->mallocd = 0; - f->data = NULL; + f->FRAME_DATA_PTR = NULL; if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP)) { return NULL; @@ -1129,7 +1129,7 @@ struct ast_frame *capi_read_pipeframe(struct capi_pvt *i) if (readsize != f->datalen) { cc_log(LOG_ERROR, "did not read whole frame data\n"); } - f->data = i->frame_data + AST_FRIENDLY_OFFSET; + f->FRAME_DATA_PTR = i->frame_data + AST_FRIENDLY_OFFSET; } return f; } @@ -1176,7 +1176,7 @@ int capi_write_frame(struct capi_pvt *i, struct ast_frame *f) i->vname); return 0; } - if ((!f->data) || (!f->datalen)) { + if ((!f->FRAME_DATA_PTR) || (!f->datalen)) { cc_log(LOG_DEBUG, "No data for FRAME_VOICE %s\n", i->vname); return 0; } @@ -1209,11 +1209,11 @@ int capi_write_frame(struct capi_pvt *i, struct ast_frame *f) if ((i->doES == 1) && (!capi_tcap_is_digital(i->transfercapability))) { for (j = 0; j < fsmooth->datalen; j++) { - buf[j] = capi_reversebits[ ((unsigned char *)fsmooth->data)[j] ]; + buf[j] = capi_reversebits[ ((unsigned char *)fsmooth->FRAME_DATA_PTR)[j] ]; if (capi_capability == AST_FORMAT_ULAW) { - txavg += abs( capiULAW2INT[capi_reversebits[ ((unsigned char*)fsmooth->data)[j]]] ); + txavg += abs( capiULAW2INT[capi_reversebits[ ((unsigned char*)fsmooth->FRAME_DATA_PTR)[j]]] ); } else { - txavg += abs( capiALAW2INT[capi_reversebits[ ((unsigned char*)fsmooth->data)[j]]] ); + txavg += abs( capiALAW2INT[capi_reversebits[ ((unsigned char*)fsmooth->FRAME_DATA_PTR)[j]]] ); } } txavg = txavg / j; @@ -1224,11 +1224,11 @@ int capi_write_frame(struct capi_pvt *i, struct ast_frame *f) } else { if ((i->txgain == 1.0) || (capi_tcap_is_digital(i->transfercapability))) { for (j = 0; j < fsmooth->datalen; j++) { - buf[j] = capi_reversebits[((unsigned char *)fsmooth->data)[j]]; + buf[j] = capi_reversebits[((unsigned char *)fsmooth->FRAME_DATA_PTR)[j]]; } } else { for (j = 0; j < fsmooth->datalen; j++) { - buf[j] = i->g.txgains[capi_reversebits[((unsigned char *)fsmooth->data)[j]]]; + buf[j] = i->g.txgains[capi_reversebits[((unsigned char *)fsmooth->FRAME_DATA_PTR)[j]]]; } } } diff --git a/create_config.sh b/create_config.sh index fabafc8..82cdda6 100755 --- a/create_config.sh +++ b/create_config.sh @@ -151,6 +151,13 @@ check_version_onesix() echo "#undef CC_AST_HAS_DSP_SET_DIGITMODE" >>$CONFIGFILE echo " * no new 'ast_dsp_set_digitmode' function" fi + if grep -q "union .* data" $INCLUDEDIR/frame.h; then + echo "#define CC_AST_HAS_UNION_DATA_IN_FRAME" >>$CONFIGFILE + echo " * found new union data in ast_frame structure" + else + echo "#undef CC_AST_HAS_UNION_DATA_IN_FRAME" >>$CONFIGFILE + echo " * no new union data in ast_frame structure" + fi } case $VER in