From f1e9371da8b502999b9aec1db7f68635395a7b6a Mon Sep 17 00:00:00 2001 From: Michiel van Baak <michiel@vanbaak.info> Date: Thu, 22 May 2008 16:29:54 +0000 Subject: [PATCH] - revert change to ast_queue_hangup and create ast_queue_hangup_with_cause - make data member of the ast_frame struct a named union instead of a void Recently the ast_queue_hangup function got a new parameter, the hangupcause Feedback came in that this is no good and that instead a new function should be created. This I did. The hangupcause was stored in the seqno member of the ast_frame struct. This is not very elegant, and since there's already a data member that one should be used. Problem is, this member was a void *. Now it's a named union so it can hold a pointer, an uint32 and there's a padding in case someone wants to store another type in there in the future. This commit is so massive, because all ast_frame.data uses have to be altered to ast_frame.data.data Thanks russellb and kpfleming for the feedback. (closes issue #12674) Reported by: mvanbaak git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@117802 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_alarmreceiver.c | 6 +++--- apps/app_chanspy.c | 2 +- apps/app_dial.c | 11 +++++----- apps/app_disa.c | 4 ++-- apps/app_externalivr.c | 4 ++-- apps/app_festival.c | 2 +- apps/app_followme.c | 4 ++-- apps/app_ices.c | 2 +- apps/app_meetme.c | 4 ++-- apps/app_milliwatt.c | 2 +- apps/app_mp3.c | 2 +- apps/app_nbscat.c | 2 +- apps/app_queue.c | 5 +++-- apps/app_sms.c | 4 ++-- apps/app_speech_utils.c | 2 +- apps/app_test.c | 2 +- apps/app_zapbarge.c | 4 ++-- apps/app_zapscan.c | 4 ++-- channels/chan_alsa.c | 12 +++++------ channels/chan_console.c | 2 +- channels/chan_gtalk.c | 4 ++-- channels/chan_h323.c | 6 +++--- channels/chan_iax2.c | 38 +++++++++++++++++----------------- channels/chan_jingle.c | 2 +- channels/chan_local.c | 8 ++++---- channels/chan_mgcp.c | 2 +- channels/chan_misdn.c | 6 +++--- channels/chan_oss.c | 12 +++++------ channels/chan_phone.c | 10 ++++----- channels/chan_sip.c | 24 +++++++++++----------- channels/chan_skinny.c | 8 ++++---- channels/chan_unistim.c | 10 ++++----- channels/chan_zap.c | 24 +++++++++++----------- channels/iax2-parser.c | 6 +++--- codecs/codec_a_mu.c | 8 ++++---- codecs/codec_adpcm.c | 8 ++++---- codecs/codec_alaw.c | 8 ++++---- codecs/codec_g722.c | 12 +++++------ codecs/codec_g726.c | 14 ++++++------- codecs/codec_gsm.c | 10 ++++----- codecs/codec_lpc10.c | 8 ++++---- codecs/codec_resample.c | 6 +++--- codecs/codec_ulaw.c | 8 ++++---- codecs/codec_zap.c | 6 +++--- formats/format_g723.c | 4 ++-- formats/format_g726.c | 4 ++-- formats/format_g729.c | 4 ++-- formats/format_gsm.c | 6 +++--- formats/format_h263.c | 4 ++-- formats/format_h264.c | 4 ++-- formats/format_ilbc.c | 4 ++-- formats/format_jpeg.c | 4 ++-- formats/format_pcm.c | 4 ++-- formats/format_sln.c | 4 ++-- formats/format_sln16.c | 4 ++-- formats/format_vox.c | 4 ++-- formats/format_wav.c | 8 ++++---- formats/format_wav_gsm.c | 10 ++++----- include/asterisk/channel.h | 11 +++++++++- include/asterisk/frame.h | 8 ++++---- main/abstract_jb.c | 2 +- main/app.c | 2 +- main/audiohook.c | 8 ++++---- main/channel.c | 42 ++++++++++++++++++++++++-------------- main/dsp.c | 10 ++++----- main/features.c | 4 ++-- main/file.c | 2 +- main/frame.c | 40 ++++++++++++++++++------------------ main/indications.c | 2 +- main/rtp.c | 42 +++++++++++++++++++------------------- main/slinfactory.c | 2 +- main/translate.c | 2 +- main/udptl.c | 8 ++++---- res/res_adsi.c | 4 ++-- res/res_agi.c | 4 ++-- res/res_musiconhold.c | 2 +- 76 files changed, 307 insertions(+), 284 deletions(-) diff --git a/apps/app_alarmreceiver.c b/apps/app_alarmreceiver.c index 5230681f21..37d8177429 100644 --- a/apps/app_alarmreceiver.c +++ b/apps/app_alarmreceiver.c @@ -185,7 +185,7 @@ static int send_tone_burst(struct ast_channel *chan, float freq, int duration, i wf.subclass = AST_FORMAT_ULAW; wf.offset = AST_FRIENDLY_OFFSET; wf.mallocd = 0; - wf.data = tone_block.buf; + wf.data.ptr = tone_block.buf; wf.datalen = f->datalen; wf.samples = wf.datalen; @@ -252,8 +252,8 @@ static int receive_dtmf_digits(struct ast_channel *chan, char *digit_string, int /* If they hung up, leave */ if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP)) { - if (f->seqno) { - chan->hangupcause = f->seqno; + if (f->data.uint32) { + chan->hangupcause = f->data.uint32; } ast_frfree(f); res = -1; diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c index 75d4851234..f6886347d1 100644 --- a/apps/app_chanspy.c +++ b/apps/app_chanspy.c @@ -263,7 +263,7 @@ static int spy_generate(struct ast_channel *chan, void *data, int len, int sampl } if (csth->fd) - write(csth->fd, f->data, f->datalen); + write(csth->fd, f->data.ptr, f->datalen); ast_frfree(f); diff --git a/apps/app_dial.c b/apps/app_dial.c index d72a85411c..105bce60d7 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -765,7 +765,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, } break; case AST_FRAME_HTML: - if (!ast_test_flag64(outgoing, DIAL_NOFORWARDHTML) && ast_channel_sendhtml(in, f->subclass, f->data, f->datalen) == -1) { + if (!ast_test_flag64(outgoing, DIAL_NOFORWARDHTML) && ast_channel_sendhtml(in, f->subclass, f->data.ptr, f->datalen) == -1) { ast_log(LOG_WARNING, "Unable to send URL\n"); } break; @@ -789,8 +789,9 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, strcpy(pa->status, "CANCEL"); ast_cdr_noanswer(in->cdr); if (f) { - if (f->seqno) - in->hangupcause = f->seqno; + if (f->data.uint32) { + in->hangupcause = f->data.uint32; + } ast_frfree(f); } return NULL; @@ -824,7 +825,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, /* Forward HTML stuff */ if (single && (f->frametype == AST_FRAME_HTML) && !ast_test_flag64(outgoing, DIAL_NOFORWARDHTML)) - if (ast_channel_sendhtml(outgoing->chan, f->subclass, f->data, f->datalen) == -1) + if (ast_channel_sendhtml(outgoing->chan, f->subclass, f->data.ptr, f->datalen) == -1) ast_log(LOG_WARNING, "Unable to send URL\n"); if (single && ((f->frametype == AST_FRAME_VOICE) || (f->frametype == AST_FRAME_DTMF_BEGIN) || (f->frametype == AST_FRAME_DTMF_END))) { @@ -837,7 +838,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, (f->subclass == AST_CONTROL_VIDUPDATE) || (f->subclass == AST_CONTROL_SRCUPDATE))) { ast_verb(3, "%s requested special control %d, passing it to %s\n", in->name, f->subclass, outgoing->chan->name); - ast_indicate_data(outgoing->chan, f->subclass, f->data, f->datalen); + ast_indicate_data(outgoing->chan, f->subclass, f->data.ptr, f->datalen); } ast_frfree(f); } diff --git a/apps/app_disa.c b/apps/app_disa.c index 53bcc2c990..b624a426a7 100644 --- a/apps/app_disa.c +++ b/apps/app_disa.c @@ -195,8 +195,8 @@ static int disa_exec(struct ast_channel *chan, void *data) } if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP)) { - if (f->seqno) - chan->hangupcause = f->seqno; + if (f->data.uint32) + chan->hangupcause = f->data.uint32; ast_frfree(f); ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY); return -1; diff --git a/apps/app_externalivr.c b/apps/app_externalivr.c index a7369602af..7d802579a5 100644 --- a/apps/app_externalivr.c +++ b/apps/app_externalivr.c @@ -630,8 +630,8 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u, } else if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP)) { ast_chan_log(LOG_NOTICE, chan, "Got AST_CONTROL_HANGUP\n"); send_eivr_event(eivr_events, 'H', NULL, chan); - if (f->seqno) { - chan->hangupcause = f->seqno; + if (f->data.uint32) { + chan->hangupcause = f->data.uint32; } ast_frfree(f); res = -1; diff --git a/apps/app_festival.c b/apps/app_festival.c index 096b34c257..42b71fb764 100644 --- a/apps/app_festival.c +++ b/apps/app_festival.c @@ -218,7 +218,7 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in myf.f.samples = res / 2; myf.f.offset = AST_FRIENDLY_OFFSET; myf.f.src = __PRETTY_FUNCTION__; - myf.f.data = myf.frdata; + myf.f.data.ptr = myf.frdata; if (ast_write(chan, &myf.f) < 0) { res = -1; ast_frfree(f); diff --git a/apps/app_followme.c b/apps/app_followme.c index 35ce6f7497..e582cc5df3 100644 --- a/apps/app_followme.c +++ b/apps/app_followme.c @@ -607,8 +607,8 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us switch(f->subclass) { case AST_CONTROL_HANGUP: ast_verb(3, "%s received a hangup frame.\n", winner->name); - if (f->seqno) { - winner->hangupcause = f->seqno; + if (f->data.uint32) { + winner->hangupcause = f->data.uint32; } if (dg == 0) { ast_verb(3, "The calling channel hungup. Need to drop everyone else.\n"); diff --git a/apps/app_ices.c b/apps/app_ices.c index 0a011b3b33..7a4c9f18fc 100644 --- a/apps/app_ices.c +++ b/apps/app_ices.c @@ -157,7 +157,7 @@ static int ices_exec(struct ast_channel *chan, void *data) break; } if (f->frametype == AST_FRAME_VOICE) { - res = write(fds[1], f->data, f->datalen); + res = write(fds[1], f->data.ptr, f->datalen); if (res < 0) { if (errno != EAGAIN) { ast_log(LOG_WARNING, "Write failed to pipe: %s\n", strerror(errno)); diff --git a/apps/app_meetme.c b/apps/app_meetme.c index ff52323aae..08e2fb56e2 100644 --- a/apps/app_meetme.c +++ b/apps/app_meetme.c @@ -2342,7 +2342,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c to write out all the samples. */ if (user->talking) - careful_write(fd, f->data, f->datalen, 0); + careful_write(fd, f->data.ptr, f->datalen, 0); } } else if ((f->frametype == AST_FRAME_DTMF) && (confflags & CONFFLAG_EXIT_CONTEXT)) { char tmp[2]; @@ -2566,7 +2566,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c fr.subclass = AST_FORMAT_SLINEAR; fr.datalen = res; fr.samples = res / 2; - fr.data = buf; + fr.data.ptr = buf; fr.offset = AST_FRIENDLY_OFFSET; if (!user->listen.actual && ((confflags & CONFFLAG_MONITOR) || diff --git a/apps/app_milliwatt.c b/apps/app_milliwatt.c index 754faa555a..cf6b1f5ee5 100644 --- a/apps/app_milliwatt.c +++ b/apps/app_milliwatt.c @@ -61,9 +61,9 @@ static int milliwatt_generate(struct ast_channel *chan, void *data, int len, int .frametype = AST_FRAME_VOICE, .subclass = AST_FORMAT_ULAW, .offset = AST_FRIENDLY_OFFSET, - .data = buf + AST_FRIENDLY_OFFSET, .src = __FUNCTION__, }; + wf.data.ptr = buf + AST_FRIENDLY_OFFSET; /* Instead of len, use samples, because channel.c generator_force * generate(chan, tmp, 0, 160) ignores len. In any case, len is diff --git a/apps/app_mp3.c b/apps/app_mp3.c index 33bee620a6..23db94fbc5 100644 --- a/apps/app_mp3.c +++ b/apps/app_mp3.c @@ -167,7 +167,7 @@ static int mp3_exec(struct ast_channel *chan, void *data) myf.f.src = __PRETTY_FUNCTION__; myf.f.delivery.tv_sec = 0; myf.f.delivery.tv_usec = 0; - myf.f.data = myf.frdata; + myf.f.data.ptr = myf.frdata; if (ast_write(chan, &myf.f) < 0) { res = -1; break; diff --git a/apps/app_nbscat.c b/apps/app_nbscat.c index f471296745..5bc920f50f 100644 --- a/apps/app_nbscat.c +++ b/apps/app_nbscat.c @@ -150,7 +150,7 @@ static int NBScat_exec(struct ast_channel *chan, void *data) myf.f.src = __PRETTY_FUNCTION__; myf.f.delivery.tv_sec = 0; myf.f.delivery.tv_usec = 0; - myf.f.data = myf.frdata; + myf.f.data.ptr = myf.frdata; if (ast_write(chan, &myf.f) < 0) { res = -1; break; diff --git a/apps/app_queue.c b/apps/app_queue.c index 904aebd6d2..8bbf733dd1 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -2669,8 +2669,9 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte /* Got hung up */ *to = -1; if (f) { - if (f->seqno) - in->hangupcause = f->seqno; + if (f->data.uint32) { + in->hangupcause = f->data.uint32; + } ast_frfree(f); } return NULL; diff --git a/apps/app_sms.c b/apps/app_sms.c index 0272468d60..e09bf59429 100644 --- a/apps/app_sms.c +++ b/apps/app_sms.c @@ -1501,7 +1501,7 @@ static int sms_generate(struct ast_channel *chan, void *data, int len, int sampl f.datalen = samples * sizeof(*buf); f.offset = AST_FRIENDLY_OFFSET; f.mallocd = 0; - f.data = buf; + f.data.ptr = buf; f.samples = samples; f.src = "app_sms"; /* create a buffer containing the digital sms pattern */ @@ -1905,7 +1905,7 @@ static int sms_exec(struct ast_channel *chan, void *data) break; } if (f->frametype == AST_FRAME_VOICE) { - sms_process(&h, f->samples, f->data); + sms_process(&h, f->samples, f->data.ptr); } ast_frfree(f); diff --git a/apps/app_speech_utils.c b/apps/app_speech_utils.c index 5082478afe..568c01bc38 100644 --- a/apps/app_speech_utils.c +++ b/apps/app_speech_utils.c @@ -647,7 +647,7 @@ static int speech_background(struct ast_channel *chan, void *data) } /* Write audio frame out to speech engine if no DTMF has been received */ if (!strlen(dtmf) && f != NULL && f->frametype == AST_FRAME_VOICE) { - ast_speech_write(speech, f->data, f->datalen); + ast_speech_write(speech, f->data.ptr, f->datalen); } break; case AST_SPEECH_STATE_WAIT: diff --git a/apps/app_test.c b/apps/app_test.c index e13dc865fd..e873777e41 100644 --- a/apps/app_test.c +++ b/apps/app_test.c @@ -84,7 +84,7 @@ static int measurenoise(struct ast_channel *chan, int ms, char *who) break; } if ((f->frametype == AST_FRAME_VOICE) && (f->subclass == AST_FORMAT_SLINEAR)) { - foo = (short *)f->data; + foo = (short *)f->data.ptr; for (x=0;x<f->samples;x++) { noise += abs(foo[x]); samples++; diff --git a/apps/app_zapbarge.c b/apps/app_zapbarge.c index bb8c4cbb3c..892dd1ec0a 100644 --- a/apps/app_zapbarge.c +++ b/apps/app_zapbarge.c @@ -207,7 +207,7 @@ zapretry: if (f->frametype == AST_FRAME_VOICE) { if (f->subclass == AST_FORMAT_ULAW) { /* Carefully write */ - careful_write(fd, f->data, f->datalen); + careful_write(fd, f->data.ptr, f->datalen); } else ast_log(LOG_WARNING, "Huh? Got a non-ulaw (%d) frame in the conference\n", f->subclass); } @@ -221,7 +221,7 @@ zapretry: fr.subclass = AST_FORMAT_ULAW; fr.datalen = res; fr.samples = res; - fr.data = buf; + fr.data.ptr = buf; fr.offset = AST_FRIENDLY_OFFSET; if (ast_write(chan, &fr) < 0) { ast_log(LOG_WARNING, "Unable to write frame to channel: %s\n", strerror(errno)); diff --git a/apps/app_zapscan.c b/apps/app_zapscan.c index 2f46f52dda..372467572d 100644 --- a/apps/app_zapscan.c +++ b/apps/app_zapscan.c @@ -231,7 +231,7 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags) if (f->frametype == AST_FRAME_VOICE) { if (f->subclass == AST_FORMAT_ULAW) { /* Carefully write */ - careful_write(fd, f->data, f->datalen); + careful_write(fd, f->data.ptr, f->datalen); } else { ast_log(LOG_WARNING, "Huh? Got a non-ulaw (%d) frame in the conference\n", f->subclass); } @@ -246,7 +246,7 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags) fr.subclass = AST_FORMAT_ULAW; fr.datalen = res; fr.samples = res; - fr.data = buf; + fr.data.ptr = buf; fr.offset = AST_FRIENDLY_OFFSET; if (ast_write(chan, &fr) < 0) { ast_log(LOG_WARNING, "Unable to write frame to channel: %s\n", strerror(errno)); diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c index 391c96d161..b4e194b134 100644 --- a/channels/chan_alsa.c +++ b/channels/chan_alsa.c @@ -377,7 +377,7 @@ static int alsa_write(struct ast_channel *chan, struct ast_frame *f) ast_log(LOG_WARNING, "Frame too large\n"); res = -1; } else { - memcpy(sizbuf + sizpos, f->data, f->datalen); + memcpy(sizbuf + sizpos, f->data.ptr, f->datalen); len += f->datalen; pos = 0; state = snd_pcm_state(alsa.ocard); @@ -426,7 +426,7 @@ static struct ast_frame *alsa_read(struct ast_channel *chan) f.subclass = 0; f.samples = 0; f.datalen = 0; - f.data = NULL; + f.data.ptr = NULL; f.offset = 0; f.src = "Console"; f.mallocd = 0; @@ -471,7 +471,7 @@ static struct ast_frame *alsa_read(struct ast_channel *chan) f.subclass = AST_FORMAT_SLINEAR; f.samples = FRAME_SIZE; f.datalen = FRAME_SIZE * 2; - f.data = buf; + f.data.ptr = buf; f.offset = AST_FRIENDLY_OFFSET; f.src = "Console"; f.mallocd = 0; @@ -718,14 +718,14 @@ static char *console_sendtext(struct ast_cli_entry *e, int cmd, struct ast_cli_a } text2send[strlen(text2send) - 1] = '\n'; - f.data = text2send; + f.data.ptr = text2send; f.datalen = strlen(text2send) + 1; grab_owner(); if (alsa.owner) { ast_queue_frame(alsa.owner, &f); f.frametype = AST_FRAME_CONTROL; f.subclass = AST_CONTROL_ANSWER; - f.data = NULL; + f.data.ptr = NULL; f.datalen = 0; ast_queue_frame(alsa.owner, &f); ast_channel_unlock(alsa.owner); @@ -765,7 +765,7 @@ static char *console_hangup(struct ast_cli_entry *e, int cmd, struct ast_cli_arg hookstate = 0; grab_owner(); if (alsa.owner) { - ast_queue_hangup(alsa.owner, AST_CAUSE_NORMAL_CLEARING); + ast_queue_hangup_with_cause(alsa.owner, AST_CAUSE_NORMAL_CLEARING); ast_channel_unlock(alsa.owner); } } diff --git a/channels/chan_console.c b/channels/chan_console.c index 4c8576db5e..0fe3cbef4f 100644 --- a/channels/chan_console.c +++ b/channels/chan_console.c @@ -874,7 +874,7 @@ static char *cli_console_hangup(struct ast_cli_entry *e, int cmd, struct ast_cli pvt->hookstate = 0; if (pvt->owner) - ast_queue_hangup(pvt->owner, -1); + ast_queue_hangup(pvt->owner); unref_pvt(pvt); diff --git a/channels/chan_gtalk.c b/channels/chan_gtalk.c index c633fbb7ef..4e5e5a36fb 100644 --- a/channels/chan_gtalk.c +++ b/channels/chan_gtalk.c @@ -620,7 +620,7 @@ static int gtalk_is_answered(struct gtalk *client, ikspak *pak) ast_getformatname_multiple(s2, BUFSIZ, tmp->peercapability), ast_getformatname_multiple(s3, BUFSIZ, tmp->jointcapability)); /* close session if capabilities don't match */ - ast_queue_hangup(tmp->owner, -1); + ast_queue_hangup(tmp->owner); return -1; @@ -749,7 +749,7 @@ static int gtalk_hangup_farend(struct gtalk *client, ikspak *pak) if (tmp) { tmp->alreadygone = 1; if (tmp->owner) - ast_queue_hangup(tmp->owner, -1); + ast_queue_hangup(tmp->owner); } else ast_log(LOG_NOTICE, "Whoa, didn't find call!\n"); gtalk_response(client, from, pak, NULL, NULL); diff --git a/channels/chan_h323.c b/channels/chan_h323.c index 2583b2d3e2..bbe0551189 100644 --- a/channels/chan_h323.c +++ b/channels/chan_h323.c @@ -342,7 +342,7 @@ static void __oh323_update_info(struct ast_channel *c, struct oh323_pvt *pvt) ast_debug(1, "Process pending hangup for %s\n", c->name); c->_softhangup |= AST_SOFTHANGUP_DEV; c->hangupcause = pvt->hangupcause; - ast_queue_hangup(c, pvt->hangupcause); + ast_queue_hangup_with_cause(c, pvt->hangupcause); pvt->needhangup = 0; pvt->newstate = pvt->newcontrol = pvt->newdigit = pvt->DTMFsched = -1; } @@ -2379,7 +2379,7 @@ static void cleanup_connection(unsigned call_reference, const char *call_token) /* Send hangup */ if (pvt->owner) { pvt->owner->_softhangup |= AST_SOFTHANGUP_DEV; - ast_queue_hangup(pvt->owner, -1); + ast_queue_hangup(pvt->owner); ast_channel_unlock(pvt->owner); } ast_mutex_unlock(&pvt->lock); @@ -2404,7 +2404,7 @@ static void hangup_connection(unsigned int call_reference, const char *token, in if (pvt->owner && !ast_channel_trylock(pvt->owner)) { pvt->owner->_softhangup |= AST_SOFTHANGUP_DEV; pvt->owner->hangupcause = pvt->hangupcause = cause; - ast_queue_hangup(pvt->owner, cause); + ast_queue_hangup_with_cause(pvt->owner, cause); ast_channel_unlock(pvt->owner); } else { diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 24cab65ba7..5d4a4e0846 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -1783,7 +1783,7 @@ static int iax2_queue_hangup(int callno) usleep(1); ast_mutex_lock(&iaxsl[callno]); } else { - ast_queue_hangup(iaxs[callno]->owner, -1); + ast_queue_hangup(iaxs[callno]->owner); ast_channel_unlock(iaxs[callno]->owner); break; } @@ -2244,7 +2244,7 @@ retry: /* If there's an owner, prod it to give up */ /* It is ok to use ast_queue_hangup() here instead of iax2_queue_hangup() * because we already hold the owner channel lock. */ - ast_queue_hangup(owner, -1); + ast_queue_hangup(owner); } if (pvt->peercallno) { @@ -2312,7 +2312,7 @@ static void __attempt_transmit(const void *data) ast_log(LOG_WARNING, "Max retries exceeded to host %s on %s (type = %d, subclass = %d, ts=%d, seqno=%d)\n", ast_inet_ntoa(iaxs[f->callno]->addr.sin_addr),iaxs[f->callno]->owner->name , f->af.frametype, f->af.subclass, f->ts, f->oseqno); iaxs[callno]->error = ETIMEDOUT; if (iaxs[callno]->owner) { - struct ast_frame fr = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP, .seqno = AST_CAUSE_DESTINATION_OUT_OF_ORDER }; + struct ast_frame fr = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP, .data.uint32 = AST_CAUSE_DESTINATION_OUT_OF_ORDER }; /* Hangup the fd */ iax2_queue_frame(callno, &fr); /* XXX */ /* Remember, owner could disappear */ @@ -3030,7 +3030,7 @@ static int iax2_sendtext(struct ast_channel *c, const char *text) static int iax2_sendimage(struct ast_channel *c, struct ast_frame *img) { - return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_IMAGE, img->subclass, 0, img->data, img->datalen, -1); + return send_command_locked(PTR_TO_CALLNO(c->tech_pvt), AST_FRAME_IMAGE, img->subclass, 0, img->data.ptr, img->datalen, -1); } static int iax2_sendhtml(struct ast_channel *c, int subclass, const char *data, int datalen) @@ -4418,7 +4418,7 @@ static int iax2_trunk_queue(struct chan_iax2_pvt *pvt, struct iax_frame *fr) tpeer->trunkdatalen += sizeof(struct ast_iax2_meta_trunk_entry); } /* Copy actual trunk data */ - memcpy(ptr, f->data, f->datalen); + memcpy(ptr, f->data.ptr, f->datalen); tpeer->trunkdatalen += f->datalen; tpeer->calls++; @@ -4698,7 +4698,7 @@ static int iax2_send(struct chan_iax2_pvt *pvt, struct ast_frame *f, unsigned in else fr->oseqno = pvt->oseqno++; fr->iseqno = pvt->iseqno; - fh = (struct ast_iax2_full_hdr *)(fr->af.data - sizeof(struct ast_iax2_full_hdr)); + fh = (struct ast_iax2_full_hdr *)(fr->af.data.ptr - sizeof(struct ast_iax2_full_hdr)); fh->scallno = htons(fr->callno | IAX_FLAG_FULL); fh->ts = htonl(fr->ts); fh->oseqno = fr->oseqno; @@ -4763,7 +4763,7 @@ static int iax2_send(struct chan_iax2_pvt *pvt, struct ast_frame *f, unsigned in /* Video frame have no sequence number */ fr->oseqno = -1; fr->iseqno = -1; - vh = (struct ast_iax2_video_hdr *)(fr->af.data - sizeof(struct ast_iax2_video_hdr)); + vh = (struct ast_iax2_video_hdr *)(fr->af.data.ptr - sizeof(struct ast_iax2_video_hdr)); vh->zeros = 0; vh->callno = htons(0x8000 | fr->callno); vh->ts = htons((fr->ts & 0x7FFF) | (fr->af.subclass & 0x1 ? 0x8000 : 0)); @@ -4779,7 +4779,7 @@ static int iax2_send(struct chan_iax2_pvt *pvt, struct ast_frame *f, unsigned in fr->oseqno = -1; fr->iseqno = -1; /* Mini frame will do */ - mh = (struct ast_iax2_mini_hdr *)(fr->af.data - sizeof(struct ast_iax2_mini_hdr)); + mh = (struct ast_iax2_mini_hdr *)(fr->af.data.ptr - sizeof(struct ast_iax2_mini_hdr)); mh->callno = htons(fr->callno); mh->ts = htons(fr->ts & 0xFFFF); fr->datalen = fr->af.datalen + sizeof(struct ast_iax2_mini_hdr); @@ -5666,7 +5666,7 @@ static int __send_command(struct chan_iax2_pvt *i, char type, int command, unsig f.subclass = command; f.datalen = datalen; f.src = __FUNCTION__; - f.data = (void *) data; + f.data.ptr = (void *) data; return iax2_send(i, &f, ts, seqno, now, transfer, final, media); } @@ -7810,9 +7810,9 @@ static int socket_process_meta(int packet_len, struct ast_iax2_meta_hdr *meta, s f.datalen = len; if (f.datalen >= 0) { if (f.datalen) - f.data = ptr; + f.data.ptr = ptr; else - f.data = NULL; + f.data.ptr = NULL; if (trunked_ts) fr->ts = (iaxs[fr->callno]->last & 0xFFFF0000L) | (trunked_ts & 0xffff); else @@ -8217,15 +8217,15 @@ static int socket_process(struct iax2_thread *thread) ast_mutex_unlock(&iaxsl[fr->callno]); return 1; } - f.data = NULL; + f.data.ptr = NULL; f.datalen = 0; } else - f.data = thread->buf + sizeof(*fh); + f.data.ptr = thread->buf + sizeof(*fh); } else { if (f.frametype == AST_FRAME_IAX) - f.data = NULL; + f.data.ptr = NULL; else - f.data = empty; + f.data.ptr = empty; memset(&ies, 0, sizeof(ies)); } @@ -9421,9 +9421,9 @@ retryowner2: } f.datalen = res - sizeof(*vh); if (f.datalen) - f.data = thread->buf + sizeof(*vh); + f.data.ptr = thread->buf + sizeof(*vh); else - f.data = NULL; + f.data.ptr = NULL; #ifdef IAXTESTS if (test_resync) { fr->ts = (iaxs[fr->callno]->last & 0xFFFF8000L) | ((ntohs(vh->ts) + test_resync) & 0x7fff); @@ -9448,9 +9448,9 @@ retryowner2: return 1; } if (f.datalen) - f.data = thread->buf + sizeof(*mh); + f.data.ptr = thread->buf + sizeof(*mh); else - f.data = NULL; + f.data.ptr = NULL; #ifdef IAXTESTS if (test_resync) { fr->ts = (iaxs[fr->callno]->last & 0xFFFF0000L) | ((ntohs(mh->ts) + test_resync) & 0xffff); diff --git a/channels/chan_jingle.c b/channels/chan_jingle.c index 290352cecb..dea5d502a5 100644 --- a/channels/chan_jingle.c +++ b/channels/chan_jingle.c @@ -573,7 +573,7 @@ static int jingle_hangup_farend(struct jingle *client, ikspak *pak) if (tmp) { tmp->alreadygone = 1; if (tmp->owner) - ast_queue_hangup(tmp->owner, -1); + ast_queue_hangup(tmp->owner); } else ast_log(LOG_NOTICE, "Whoa, didn't find call!\n"); jingle_response(client, pak, NULL, NULL); diff --git a/channels/chan_local.c b/channels/chan_local.c index 5ab27041d7..5d89cac3b3 100644 --- a/channels/chan_local.c +++ b/channels/chan_local.c @@ -396,7 +396,7 @@ static int local_indicate(struct ast_channel *ast, int condition, const void *da ast_mutex_lock(&p->lock); isoutbound = IS_OUTBOUND(ast, p); f.subclass = condition; - f.data = (void*)data; + f.data.ptr = (void*)data; f.datalen = datalen; if (!(res = local_queue_frame(p, isoutbound, &f, ast, 1))) ast_mutex_unlock(&p->lock); @@ -456,7 +456,7 @@ static int local_sendtext(struct ast_channel *ast, const char *text) ast_mutex_lock(&p->lock); isoutbound = IS_OUTBOUND(ast, p); - f.data = (char *) text; + f.data.ptr = (char *) text; f.datalen = strlen(text) + 1; if (!(res = local_queue_frame(p, isoutbound, &f, ast, 0))) ast_mutex_unlock(&p->lock); @@ -476,7 +476,7 @@ static int local_sendhtml(struct ast_channel *ast, int subclass, const char *dat ast_mutex_lock(&p->lock); isoutbound = IS_OUTBOUND(ast, p); f.subclass = subclass; - f.data = (char *)data; + f.data.ptr = (char *)data; f.datalen = datalen; if (!(res = local_queue_frame(p, isoutbound, &f, ast, 0))) ast_mutex_unlock(&p->lock); @@ -537,7 +537,7 @@ static int local_hangup(struct ast_channel *ast) { struct local_pvt *p = ast->tech_pvt; int isoutbound; - struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP, .seqno = ast->hangupcause }; + struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP, .data.uint32 = ast->hangupcause }; struct ast_channel *ochan = NULL; int glaredetect = 0, res = 0; diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index 592301e8c7..021999abdf 100644 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -610,7 +610,7 @@ static void mgcp_queue_hangup(struct mgcp_subchannel *sub) for(;;) { if (sub->owner) { if (!ast_channel_trylock(sub->owner)) { - ast_queue_hangup(sub->owner, -1); + ast_queue_hangup(sub->owner); ast_channel_unlock(sub->owner); break; } else { diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c index cdbe3b49cb..fc36785a3c 100644 --- a/channels/chan_misdn.c +++ b/channels/chan_misdn.c @@ -2320,13 +2320,13 @@ static int misdn_answer(struct ast_channel *ast) if (!p) { ast_log(LOG_WARNING, " --> Channel not connected ??\n"); - ast_queue_hangup(ast, AST_CAUSE_NETWORK_OUT_OF_ORDER); + ast_queue_hangup_with_cause(ast, AST_CAUSE_NETWORK_OUT_OF_ORDER); } if (!p->bc) { chan_misdn_log(1, 0, " --> Got Answer, but theres no bc obj ??\n"); - ast_queue_hangup(ast, AST_CAUSE_PROTOCOL_ERROR); + ast_queue_hangup_with_cause(ast, AST_CAUSE_PROTOCOL_ERROR); } tmp = pbx_builtin_getvar_helper(p->ast, "CRYPT_KEY"); @@ -3665,7 +3665,7 @@ static void hangup_chan(struct chan_list *ch) send_cause2ast(ch->ast, ch->bc, ch); if (ch->ast) - ast_queue_hangup(ch->ast, ch->bc->cause); + ast_queue_hangup_with_cause(ch->ast, ch->bc->cause); cb_log(2, port, " --> queue_hangup\n"); } else { cb_log(1, port, "Cannot hangup chan, no ast\n"); diff --git a/channels/chan_oss.c b/channels/chan_oss.c index 6edbbb88ce..268ff782fe 100644 --- a/channels/chan_oss.c +++ b/channels/chan_oss.c @@ -679,13 +679,13 @@ static int oss_write(struct ast_channel *c, struct ast_frame *f) int l = sizeof(o->oss_write_buf) - o->oss_write_dst; if (f->datalen - src >= l) { /* enough to fill a frame */ - memcpy(o->oss_write_buf + o->oss_write_dst, f->data + src, l); + memcpy(o->oss_write_buf + o->oss_write_dst, f->data.ptr + src, l); soundcard_writeframe(o, (short *) o->oss_write_buf); src += l; o->oss_write_dst = 0; } else { /* copy residue */ l = f->datalen - src; - memcpy(o->oss_write_buf + o->oss_write_dst, f->data + src, l); + memcpy(o->oss_write_buf + o->oss_write_dst, f->data.ptr + src, l); src += l; /* but really, we are done */ o->oss_write_dst += l; } @@ -724,10 +724,10 @@ static struct ast_frame *oss_read(struct ast_channel *c) f->subclass = AST_FORMAT_SLINEAR; f->samples = FRAME_SIZE; f->datalen = FRAME_SIZE * 2; - f->data = o->oss_read_buf + AST_FRIENDLY_OFFSET; + f->data.ptr = o->oss_read_buf + AST_FRIENDLY_OFFSET; if (o->boost != BOOST_SCALE) { /* scale and clip values */ int i, x; - int16_t *p = (int16_t *) f->data; + int16_t *p = (int16_t *) f->data.ptr; for (i = 0; i < f->samples; i++) { x = (p[i] * o->boost) / BOOST_SCALE; if (x > 32767) @@ -1012,7 +1012,7 @@ static char *console_sendtext(struct ast_cli_entry *e, int cmd, struct ast_cli_a buf[i] = '\n'; f.frametype = AST_FRAME_TEXT; f.subclass = 0; - f.data = buf; + f.data.ptr = buf; f.datalen = i + 1; ast_queue_frame(o->owner, &f); } @@ -1040,7 +1040,7 @@ static char *console_hangup(struct ast_cli_entry *e, int cmd, struct ast_cli_arg } o->hookstate = 0; if (o->owner) - ast_queue_hangup(o->owner, AST_CAUSE_NORMAL_CLEARING); + ast_queue_hangup_with_cause(o->owner, AST_CAUSE_NORMAL_CLEARING); setformat(o, O_CLOSE); return CLI_SUCCESS; } diff --git a/channels/chan_phone.c b/channels/chan_phone.c index 48b26c160d..8ee2cac6a7 100644 --- a/channels/chan_phone.c +++ b/channels/chan_phone.c @@ -494,7 +494,7 @@ static struct ast_frame *phone_exception(struct ast_channel *ast) /* Some nice norms */ p->fr.datalen = 0; p->fr.samples = 0; - p->fr.data = NULL; + p->fr.data.ptr = NULL; p->fr.src = "Phone"; p->fr.offset = 0; p->fr.mallocd=0; @@ -553,7 +553,7 @@ static struct ast_frame *phone_read(struct ast_channel *ast) /* Some nice norms */ p->fr.datalen = 0; p->fr.samples = 0; - p->fr.data = NULL; + p->fr.data.ptr = NULL; p->fr.src = "Phone"; p->fr.offset = 0; p->fr.mallocd=0; @@ -575,7 +575,7 @@ static struct ast_frame *phone_read(struct ast_channel *ast) ast_log(LOG_WARNING, "Error reading: %s\n", strerror(errno)); return NULL; } - p->fr.data = p->buf; + p->fr.data.ptr = p->buf; if (p->mode != MODE_FXS) switch(p->buf[0] & 0x3) { case '0': @@ -797,7 +797,7 @@ static int phone_write(struct ast_channel *ast, struct ast_frame *frame) } /* If we get here, we have a frame of Appropriate data */ sofar = 0; - pos = frame->data; + pos = frame->data.ptr; while(sofar < frame->datalen) { /* Write in no more than maxfr sized frames */ expected = frame->datalen - sofar; @@ -808,7 +808,7 @@ static int phone_write(struct ast_channel *ast, struct ast_frame *frame) if (frame->datalen == 4) { if (p->silencesupression) { memset(tmpbuf + 4, 0, sizeof(tmpbuf) - 4); - memcpy(tmpbuf, frame->data, 4); + memcpy(tmpbuf, frame->data.ptr, 4); expected = 24; res = phone_write_buf(p, tmpbuf, expected, maxfr, 0); } diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 8001e25104..82b25c8ae8 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2979,7 +2979,7 @@ static int retrans_pkt(const void *data) if (pkt->owner->owner) { sip_alreadygone(pkt->owner); ast_log(LOG_WARNING, "Hanging up call %s - no reply to our critical packet.\n", pkt->owner->callid); - ast_queue_hangup(pkt->owner->owner, AST_CAUSE_PROTOCOL_ERROR); + ast_queue_hangup_with_cause(pkt->owner->owner, AST_CAUSE_PROTOCOL_ERROR); ast_channel_unlock(pkt->owner->owner); } else { /* If no channel owner, destroy now */ @@ -3121,7 +3121,7 @@ static int __sip_autodestruct(const void *data) if (p->owner) { ast_log(LOG_WARNING, "Autodestruct on dialog '%s' with owner in place (Method: %s)\n", p->callid, sip_methods[p->method].text); - ast_queue_hangup(p->owner, AST_CAUSE_PROTOCOL_ERROR); + ast_queue_hangup_with_cause(p->owner, AST_CAUSE_PROTOCOL_ERROR); } else if (p->refer) { ast_debug(3, "Finally hanging up channel after transfer: %s\n", p->callid); transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, 1); @@ -5832,7 +5832,7 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p f = ast_rtp_read(p->trtp); /* RTP Text */ if (sipdebug_text) { int i; - unsigned char* arr = f->data; + unsigned char* arr = f->data.ptr; for (i=0; i < f->datalen; i++) ast_verbose("%c", (arr[i] > ' ' && arr[i] < '}') ? arr[i] : '.'); ast_verbose(" -> "); @@ -12056,7 +12056,7 @@ static void receive_message(struct sip_pvt *p, struct sip_request *req) f.frametype = AST_FRAME_TEXT; f.subclass = 0; f.offset = 0; - f.data = buf; + f.data.ptr = buf; f.datalen = strlen(buf); ast_queue_frame(p->owner, &f); transmit_response(p, "202 Accepted", req); /* We respond 202 accepted, since we relay the message */ @@ -15829,7 +15829,7 @@ static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, stru */ xmitres = transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, FALSE); if (p->owner && !req->ignore) { - ast_queue_hangup(p->owner, AST_CAUSE_NORMAL_CLEARING); + ast_queue_hangup_with_cause(p->owner, AST_CAUSE_NORMAL_CLEARING); append_history(p, "Hangup", "Got 487 on CANCEL request from us. Queued AST hangup request"); } else if (!req->ignore) { update_call_counter(p, DEC_CALL_LIMIT); @@ -15910,7 +15910,7 @@ static void handle_response_notify(struct sip_pvt *p, int resp, char *rest, stru if (p->owner) { if (!p->refer) { ast_log(LOG_WARNING, "Notify answer on an owned channel? - %s\n", p->owner->name); - ast_queue_hangup(p->owner, AST_CAUSE_NORMAL_UNSPECIFIED); + ast_queue_hangup_with_cause(p->owner, AST_CAUSE_NORMAL_UNSPECIFIED); } else { ast_debug(4, "Got OK on REFER Notify message\n"); } @@ -16470,7 +16470,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_ default: /* Send hangup */ if (owner && sipmethod != SIP_MESSAGE && sipmethod != SIP_INFO && sipmethod != SIP_BYE) - ast_queue_hangup(p->owner, AST_CAUSE_PROTOCOL_ERROR); + ast_queue_hangup_with_cause(p->owner, AST_CAUSE_PROTOCOL_ERROR); break; } /* ACK on invite */ @@ -16524,7 +16524,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_ ast_debug(1, "Got 200 OK on NOTIFY for transfer\n"); } else ast_log(LOG_WARNING, "Notify answer on an owned channel?\n"); - /* ast_queue_hangup(p->owner, -1); Disabled */ + /* ast_queue_hangup(p->owner); Disabled */ } else { if (!p->subscribed && !p->refer) p->needdestroy = 1; @@ -18374,7 +18374,7 @@ static int handle_request_cancel(struct sip_pvt *p, struct sip_request *req) stop_media_flows(p); /* Immediately stop RTP, VRTP and UDPTL as applicable */ if (p->owner) - ast_queue_hangup(p->owner, -1); + ast_queue_hangup(p->owner); else sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT); if (p->initreq.len > 0) { @@ -18533,15 +18533,15 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req) ast_queue_control(c, AST_CONTROL_UNHOLD); ast_async_goto(bridged_to, p->context, p->refer->refer_to, 1); } else - ast_queue_hangup(p->owner, -1); + ast_queue_hangup(p->owner); } } else { ast_log(LOG_WARNING, "Invalid transfer information from '%s'\n", ast_inet_ntoa(p->recv.sin_addr)); if (p->owner) - ast_queue_hangup(p->owner, AST_CAUSE_PROTOCOL_ERROR); + ast_queue_hangup_with_cause(p->owner, AST_CAUSE_PROTOCOL_ERROR); } } else if (p->owner) { - ast_queue_hangup(p->owner, -1); + ast_queue_hangup(p->owner); ast_debug(3, "Received bye, issuing owner hangup\n"); } else { sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT); diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 691fae0e83..f9f02c696d 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -4554,7 +4554,7 @@ static int handle_onhook_message(struct skinny_req *req, struct skinnysession *s if ((res = attempt_transfer(p)) < 0) { if (sub->next && sub->next->owner) { sub->next->alreadygone = 1; - ast_queue_hangup(sub->next->owner, -1); + ast_queue_hangup(sub->next->owner); } } else if (res) { ast_log(LOG_WARNING, "Transfer attempt failed\n"); @@ -4566,7 +4566,7 @@ static int handle_onhook_message(struct skinny_req *req, struct skinnysession *s /* If there is another active call, skinny_hangup will ring the phone with the other call */ if (sub->owner) { sub->alreadygone = 1; - ast_queue_hangup(sub->owner, -1); + ast_queue_hangup(sub->owner); } else { ast_log(LOG_WARNING, "Skinny(%s@%s-%d) channel already destroyed\n", l->name, d->name, sub->callid); @@ -5263,7 +5263,7 @@ static int handle_soft_key_event_message(struct skinny_req *req, struct skinnyse if ((res = attempt_transfer(p)) < 0) { if (sub->next && sub->next->owner) { sub->next->alreadygone = 1; - ast_queue_hangup(sub->next->owner, -1); + ast_queue_hangup(sub->next->owner); } } else if (res) { ast_log(LOG_WARNING, "Transfer attempt failed\n"); @@ -5275,7 +5275,7 @@ static int handle_soft_key_event_message(struct skinny_req *req, struct skinnyse /* If there is another active call, skinny_hangup will ring the phone with the other call */ if (sub->owner) { sub->alreadygone = 1; - ast_queue_hangup(sub->owner, -1); + ast_queue_hangup(sub->owner); } else { ast_log(LOG_WARNING, "Skinny(%s@%s-%d) channel already destroyed\n", l->name, d->name, sub->callid); diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c index 3eda9334a6..f806c1077b 100644 --- a/channels/chan_unistim.c +++ b/channels/chan_unistim.c @@ -1125,7 +1125,7 @@ static void close_client(struct unistimsession *s) if (sub->owner) { /* Call in progress ? */ if (unistimdebug) ast_verb(0, "Aborting call\n"); - ast_queue_hangup(sub->owner, AST_CAUSE_NETWORK_OUT_OF_ORDER); + ast_queue_hangup_with_cause(sub->owner, AST_CAUSE_NETWORK_OUT_OF_ORDER); } } else ast_log(LOG_WARNING, "Freeing a client with no subchannel !\n"); @@ -1974,11 +1974,11 @@ static void close_call(struct unistimsession *pte) if (attempt_transfer(sub, l->subs[SUB_THREEWAY]) < 0) ast_verb(0, "attempt_transfer failed.\n"); } else - ast_queue_hangup(sub->owner, -1); + ast_queue_hangup(sub->owner); } else { if (l->subs[SUB_THREEWAY]) { if (l->subs[SUB_THREEWAY]->owner) - ast_queue_hangup(l->subs[SUB_THREEWAY]->owner, AST_CAUSE_NORMAL_CLEARING); + ast_queue_hangup_with_cause(l->subs[SUB_THREEWAY]->owner, AST_CAUSE_NORMAL_CLEARING); else ast_log(LOG_WARNING, "threeway sub without owner\n"); } else @@ -2312,7 +2312,7 @@ static void TransferCallStep1(struct unistimsession *pte) if (unistimdebug) ast_verb(0, "Transfer canceled, hangup our threeway channel\n"); if (p->subs[SUB_THREEWAY]->owner) - ast_queue_hangup(p->subs[SUB_THREEWAY]->owner, AST_CAUSE_NORMAL_CLEARING); + ast_queue_hangup_with_cause(p->subs[SUB_THREEWAY]->owner, AST_CAUSE_NORMAL_CLEARING); else ast_log(LOG_WARNING, "Canceling a threeway channel without owner\n"); return; @@ -2368,7 +2368,7 @@ static void HandleCallOutgoing(struct unistimsession *s) /* start switch */ if (ast_pthread_create(&t, NULL, unistim_ss, c)) { display_last_error("Unable to create switch thread"); - ast_queue_hangup(c, AST_CAUSE_SWITCH_CONGESTION); + ast_queue_hangup_with_cause(c, AST_CAUSE_SWITCH_CONGESTION); } } else ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", diff --git a/channels/chan_zap.c b/channels/chan_zap.c index a7c62f5ef4..a5ce2b32ad 100644 --- a/channels/chan_zap.c +++ b/channels/chan_zap.c @@ -4306,7 +4306,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast) p->subs[index].f.mallocd = 0; p->subs[index].f.offset = 0; p->subs[index].f.src = "zt_handle_event"; - p->subs[index].f.data = NULL; + p->subs[index].f.data.ptr = NULL; f = &p->subs[index].f; if (index < 0) @@ -4523,7 +4523,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast) /* It hasn't been long enough since the last flashook. This is probably a bounce on hanging up. Hangup both channels now */ if (p->subs[SUB_THREEWAY].owner) - ast_queue_hangup(p->subs[SUB_THREEWAY].owner, AST_CAUSE_NO_ANSWER); + ast_queue_hangup_with_cause(p->subs[SUB_THREEWAY].owner, AST_CAUSE_NO_ANSWER); p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV; ast_debug(1, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel); ast_channel_unlock(p->subs[SUB_THREEWAY].owner); @@ -5123,7 +5123,7 @@ static struct ast_frame *__zt_exception(struct ast_channel *ast) p->subs[index].f.subclass = 0; p->subs[index].f.delivery = ast_tv(0,0); p->subs[index].f.src = "zt_exception"; - p->subs[index].f.data = NULL; + p->subs[index].f.data.ptr = NULL; if ((!p->owner) && (!(p->radio || (p->oprmode < 0)))) { @@ -5250,7 +5250,7 @@ static struct ast_frame *zt_read(struct ast_channel *ast) p->subs[index].f.subclass = 0; p->subs[index].f.delivery = ast_tv(0,0); p->subs[index].f.src = "zt_read"; - p->subs[index].f.data = NULL; + p->subs[index].f.data.ptr = NULL; /* make sure it sends initial key state as first frame */ if ((p->radio || (p->oprmode < 0)) && (!p->firstradio)) @@ -5416,9 +5416,9 @@ static struct ast_frame *zt_read(struct ast_channel *ast) p->subs[index].f.frametype = AST_FRAME_TEXT; p->subs[index].f.mallocd = 0; p->subs[index].f.offset = AST_FRIENDLY_OFFSET; - p->subs[index].f.data = p->subs[index].buffer + AST_FRIENDLY_OFFSET; + p->subs[index].f.data.ptr = p->subs[index].buffer + AST_FRIENDLY_OFFSET; p->subs[index].f.datalen = 1; - *((char *) p->subs[index].f.data) = c; + *((char *) p->subs[index].f.data.ptr) = c; ast_mutex_unlock(&p->lock); return &p->subs[index].f; } @@ -5452,7 +5452,7 @@ static struct ast_frame *zt_read(struct ast_channel *ast) p->subs[index].f.samples = READ_SIZE; p->subs[index].f.mallocd = 0; p->subs[index].f.offset = AST_FRIENDLY_OFFSET; - p->subs[index].f.data = p->subs[index].buffer + AST_FRIENDLY_OFFSET / sizeof(p->subs[index].buffer[0]); + p->subs[index].f.data.ptr = p->subs[index].buffer + AST_FRIENDLY_OFFSET / sizeof(p->subs[index].buffer[0]); #if 0 ast_debug(1, "Read %d of voice on %s\n", p->subs[index].f.datalen, ast->name); #endif @@ -5467,7 +5467,7 @@ static struct ast_frame *zt_read(struct ast_channel *ast) p->subs[index].f.samples = 0; p->subs[index].f.mallocd = 0; p->subs[index].f.offset = 0; - p->subs[index].f.data = NULL; + p->subs[index].f.data.ptr = NULL; p->subs[index].f.datalen= 0; } if (p->dsp && (!p->ignoredtmf || p->callwaitcas || p->busydetect || p->callprogress) && !index) { @@ -5592,7 +5592,7 @@ static int zt_write(struct ast_channel *ast, struct ast_frame *frame) return 0; } /* Return if it's not valid data */ - if (!frame->data || !frame->datalen) + if (!frame->data.ptr || !frame->datalen) return 0; if (frame->subclass == AST_FORMAT_SLINEAR) { @@ -5602,7 +5602,7 @@ static int zt_write(struct ast_channel *ast, struct ast_frame *frame) if (res) ast_log(LOG_WARNING, "Unable to set linear mode on channel %d\n", p->channel); } - res = my_zt_write(p, (unsigned char *)frame->data, frame->datalen, index, 1); + res = my_zt_write(p, (unsigned char *)frame->data.ptr, frame->datalen, index, 1); } else { /* x-law already */ if (p->subs[index].linear) { @@ -5611,7 +5611,7 @@ static int zt_write(struct ast_channel *ast, struct ast_frame *frame) if (res) ast_log(LOG_WARNING, "Unable to set companded mode on channel %d\n", p->channel); } - res = my_zt_write(p, (unsigned char *)frame->data, frame->datalen, index, 0); + res = my_zt_write(p, (unsigned char *)frame->data.ptr, frame->datalen, index, 0); } if (res < 0) { ast_log(LOG_WARNING, "write failed: %s\n", strerror(errno)); @@ -10133,7 +10133,7 @@ static int pri_hangup_all(struct zt_pvt *p, struct zt_pri *pri) ast_mutex_lock(&p->lock); } if (p->subs[x].owner) { - ast_queue_hangup(p->subs[x].owner, AST_CAUSE_PRE_EMPTED); + ast_queue_hangup_with_cause(p->subs[x].owner, AST_CAUSE_PRE_EMPTED); ast_channel_unlock(p->subs[x].owner); } } diff --git a/channels/iax2-parser.c b/channels/iax2-parser.c index a86bf74284..bb6e3b2e14 100644 --- a/channels/iax2-parser.c +++ b/channels/iax2-parser.c @@ -966,7 +966,7 @@ void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f) fr->af.src = f->src; fr->af.delivery.tv_sec = 0; fr->af.delivery.tv_usec = 0; - fr->af.data = fr->afdata; + fr->af.data.ptr = fr->afdata; fr->af.len = f->len; if (fr->af.datalen) { size_t copy_len = fr->af.datalen; @@ -979,10 +979,10 @@ void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f) /* We need to byte-swap slinear samples from network byte order */ if ((fr->af.frametype == AST_FRAME_VOICE) && (fr->af.subclass == AST_FORMAT_SLINEAR)) { /* 2 bytes / sample for SLINEAR */ - ast_swapcopy_samples(fr->af.data, f->data, copy_len / 2); + ast_swapcopy_samples(fr->af.data.ptr, f->data.ptr, copy_len / 2); } else #endif - memcpy(fr->af.data, f->data, copy_len); + memcpy(fr->af.data.ptr, f->data.ptr, copy_len); } } diff --git a/codecs/codec_a_mu.c b/codecs/codec_a_mu.c index a478dc7af0..23f04f0550 100644 --- a/codecs/codec_a_mu.c +++ b/codecs/codec_a_mu.c @@ -46,7 +46,7 @@ static unsigned char a2mu[256]; static int alawtoulaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { int x = f->samples; - unsigned char *src = f->data; + unsigned char *src = f->data.ptr; unsigned char *dst = (unsigned char *)pvt->outbuf + pvt->samples; pvt->samples += x; @@ -62,7 +62,7 @@ static int alawtoulaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) static int ulawtoalaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { int x = f->samples; - unsigned char *src = f->data; + unsigned char *src = f->data.ptr; unsigned char *dst = (unsigned char *)pvt->outbuf + pvt->samples; pvt->samples += x; @@ -87,7 +87,7 @@ static struct ast_frame *alawtoulaw_sample(void) f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; - f.data = ulaw_slin_ex; /* XXX what ? */ + f.data.ptr = ulaw_slin_ex; /* XXX what ? */ return &f; } @@ -101,7 +101,7 @@ static struct ast_frame *ulawtoalaw_sample(void) f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; - f.data = ulaw_slin_ex; + f.data.ptr = ulaw_slin_ex; return &f; } diff --git a/codecs/codec_adpcm.c b/codecs/codec_adpcm.c index 63a1ab1bc5..cad4ded750 100644 --- a/codecs/codec_adpcm.c +++ b/codecs/codec_adpcm.c @@ -229,7 +229,7 @@ static int adpcmtolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct adpcm_decoder_pvt *tmp = pvt->pvt; int x = f->datalen; - unsigned char *src = f->data; + unsigned char *src = f->data.ptr; int16_t *dst = (int16_t *)pvt->outbuf + pvt->samples; while (x--) { @@ -246,7 +246,7 @@ static int lintoadpcm_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct adpcm_encoder_pvt *tmp = pvt->pvt; - memcpy(&tmp->inbuf[pvt->samples], f->data, f->datalen); + memcpy(&tmp->inbuf[pvt->samples], f->data.ptr, f->datalen); pvt->samples += f->samples; return 0; } @@ -296,7 +296,7 @@ static struct ast_frame *adpcmtolin_sample(void) f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; - f.data = adpcm_slin_ex; + f.data.ptr = adpcm_slin_ex; return &f; } @@ -312,7 +312,7 @@ static struct ast_frame *lintoadpcm_sample(void) f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; - f.data = slin_adpcm_ex; + f.data.ptr = slin_adpcm_ex; return &f; } diff --git a/codecs/codec_alaw.c b/codecs/codec_alaw.c index ba5808f78e..b2f4f94357 100644 --- a/codecs/codec_alaw.c +++ b/codecs/codec_alaw.c @@ -44,7 +44,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") static int alawtolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { int i = f->samples; - unsigned char *src = f->data; + unsigned char *src = f->data.ptr; int16_t *dst = (int16_t *)pvt->outbuf + pvt->samples; pvt->samples += i; @@ -61,7 +61,7 @@ static int lintoalaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { int i = f->samples; char *dst = pvt->outbuf + pvt->samples; - int16_t *src = f->data; + int16_t *src = f->data.ptr; pvt->samples += i; pvt->datalen += i; /* 1 byte/sample */ @@ -83,7 +83,7 @@ static struct ast_frame *alawtolin_sample(void) f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; - f.data = ulaw_slin_ex; + f.data.ptr = ulaw_slin_ex; return &f; } @@ -98,7 +98,7 @@ static struct ast_frame *lintoalaw_sample(void) f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; - f.data = slin_ulaw_ex; + f.data.ptr = slin_ulaw_ex; return &f; } diff --git a/codecs/codec_g722.c b/codecs/codec_g722.c index 02f4720cda..a574136e82 100644 --- a/codecs/codec_g722.c +++ b/codecs/codec_g722.c @@ -108,7 +108,7 @@ static int g722tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) in_samples = f->samples / 2; out_samples = g722_decode(&tmp->g722, (int16_t *) &pvt->outbuf[pvt->samples * sizeof(int16_t)], - (uint8_t *) f->data, in_samples); + (uint8_t *) f->data.ptr, in_samples); pvt->samples += out_samples; @@ -123,7 +123,7 @@ static int lintog722_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) int outlen; outlen = g722_encode(&tmp->g722, (uint8_t *) (&pvt->outbuf[pvt->datalen]), - (int16_t *) f->data, f->samples); + (int16_t *) f->data.ptr, f->samples); pvt->samples += outlen * 2; @@ -140,7 +140,7 @@ static struct ast_frame *g722tolin_sample(void) .datalen = sizeof(g722_slin_ex), .samples = sizeof(g722_slin_ex) * 2, .src = __PRETTY_FUNCTION__, - .data = g722_slin_ex, + .data.ptr = g722_slin_ex, }; return &f; @@ -154,7 +154,7 @@ static struct ast_frame *g722tolin16_sample(void) .datalen = sizeof(g722_slin_ex), .samples = sizeof(g722_slin_ex) * 2, .src = __PRETTY_FUNCTION__, - .data = g722_slin_ex, + .data.ptr = g722_slin_ex, }; return &f; @@ -168,7 +168,7 @@ static struct ast_frame *lintog722_sample (void) .datalen = sizeof(slin_g722_ex), .samples = sizeof(slin_g722_ex) / sizeof(slin_g722_ex[0]), .src = __PRETTY_FUNCTION__, - .data = slin_g722_ex, + .data.ptr = slin_g722_ex, }; return &f; @@ -182,7 +182,7 @@ static struct ast_frame *lin16tog722_sample (void) .datalen = sizeof(slin_g722_ex), .samples = sizeof(slin_g722_ex) / sizeof(slin_g722_ex[0]), .src = __PRETTY_FUNCTION__, - .data = slin_g722_ex, + .data.ptr = slin_g722_ex, }; return &f; diff --git a/codecs/codec_g726.c b/codecs/codec_g726.c index c8a671ee83..8d1346e669 100644 --- a/codecs/codec_g726.c +++ b/codecs/codec_g726.c @@ -692,7 +692,7 @@ static int lintog726_new(struct ast_trans_pvt *pvt) static int g726aal2tolin_framein (struct ast_trans_pvt *pvt, struct ast_frame *f) { struct g726_coder_pvt *tmp = pvt->pvt; - unsigned char *src = f->data; + unsigned char *src = f->data.ptr; int16_t *dst = (int16_t *) pvt->outbuf + pvt->samples; unsigned int i; @@ -711,7 +711,7 @@ static int g726aal2tolin_framein (struct ast_trans_pvt *pvt, struct ast_frame *f static int lintog726aal2_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct g726_coder_pvt *tmp = pvt->pvt; - int16_t *src = f->data; + int16_t *src = f->data.ptr; unsigned int i; for (i = 0; i < f->samples; i++) { @@ -733,7 +733,7 @@ static int lintog726aal2_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) static int g726tolin_framein (struct ast_trans_pvt *pvt, struct ast_frame *f) { struct g726_coder_pvt *tmp = pvt->pvt; - unsigned char *src = f->data; + unsigned char *src = f->data.ptr; int16_t *dst = (int16_t *) pvt->outbuf + pvt->samples; unsigned int i; @@ -752,7 +752,7 @@ static int g726tolin_framein (struct ast_trans_pvt *pvt, struct ast_frame *f) static int lintog726_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { struct g726_coder_pvt *tmp = pvt->pvt; - int16_t *src = f->data; + int16_t *src = f->data.ptr; unsigned int i; for (i = 0; i < f->samples; i++) { @@ -773,7 +773,7 @@ static int lintog726_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) /*! \brief convert G726-32 RFC3551 packed data into AAL2 packed data (or vice-versa) */ static int g726tog726aal2_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { - unsigned char *src = f->data; + unsigned char *src = f->data.ptr; unsigned char *dst = (unsigned char *) pvt->outbuf + pvt->samples; unsigned int i; @@ -794,7 +794,7 @@ static struct ast_frame *g726tolin_sample(void) .datalen = sizeof(g726_slin_ex), .samples = sizeof(g726_slin_ex) * 2, /* 2 samples per byte */ .src = __PRETTY_FUNCTION__, - .data = g726_slin_ex, + .data.ptr = g726_slin_ex, }; return &f; @@ -808,7 +808,7 @@ static struct ast_frame *lintog726_sample (void) .datalen = sizeof(slin_g726_ex), .samples = sizeof(slin_g726_ex) / 2, /* 1 sample per 2 bytes */ .src = __PRETTY_FUNCTION__, - .data = slin_g726_ex, + .data.ptr = slin_g726_ex, }; return &f; diff --git a/codecs/codec_gsm.c b/codecs/codec_gsm.c index bb4af8cfb1..805e79b66b 100644 --- a/codecs/codec_gsm.c +++ b/codecs/codec_gsm.c @@ -79,7 +79,7 @@ static struct ast_frame *lintogsm_sample(void) f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; - f.data = slin_gsm_ex; + f.data.ptr = slin_gsm_ex; return &f; } @@ -94,7 +94,7 @@ static struct ast_frame *gsmtolin_sample(void) f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; - f.data = gsm_slin_ex; + f.data.ptr = gsm_slin_ex; return &f; } @@ -119,10 +119,10 @@ static int gsmtolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) /* XXX what's the point here! we should just work * on the full format. */ - conv65(f->data + x, data); + conv65(f->data.ptr + x, data); } else { len = GSM_SAMPLES; - src = f->data + x; + src = f->data.ptr + x; } /* XXX maybe we don't need to check */ if (pvt->samples + len > BUFFER_SAMPLES) { @@ -159,7 +159,7 @@ static int lintogsm_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) ast_log(LOG_WARNING, "Out of buffer space\n"); return -1; } - memcpy(tmp->buf + pvt->samples, f->data, f->datalen); + memcpy(tmp->buf + pvt->samples, f->data.ptr, f->datalen); pvt->samples += f->samples; return 0; } diff --git a/codecs/codec_lpc10.c b/codecs/codec_lpc10.c index 1e4ec37f33..dfcdc79882 100644 --- a/codecs/codec_lpc10.c +++ b/codecs/codec_lpc10.c @@ -86,7 +86,7 @@ static struct ast_frame *lintolpc10_sample(void) f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; - f.data = slin_lpc10_ex; + f.data.ptr = slin_lpc10_ex; return &f; } @@ -102,7 +102,7 @@ static struct ast_frame *lpc10tolin_sample(void) f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; - f.data = lpc10_slin_ex; + f.data.ptr = lpc10_slin_ex; return &f; } @@ -151,7 +151,7 @@ static int lpc10tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) ast_log(LOG_WARNING, "Out of buffer space\n"); return -1; } - extract_bits(bits, f->data + len); + extract_bits(bits, f->data.ptr + len); if (lpc10_decode(bits, tmpbuf, tmp->lpc10.dec)) { ast_log(LOG_WARNING, "Invalid lpc10 data\n"); return -1; @@ -179,7 +179,7 @@ static int lintolpc10_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) ast_log(LOG_WARNING, "Out of buffer space\n"); return -1; } - memcpy(tmp->buf + pvt->samples, f->data, f->datalen); + memcpy(tmp->buf + pvt->samples, f->data.ptr, f->datalen); pvt->samples += f->samples; return 0; } diff --git a/codecs/codec_resample.c b/codecs/codec_resample.c index 251d99c232..bdf9d19f91 100644 --- a/codecs/codec_resample.c +++ b/codecs/codec_resample.c @@ -102,7 +102,7 @@ static int resample_frame(struct ast_trans_pvt *pvt, { int total_in_buf_used = 0; int total_out_buf_used = 0; - int16_t *in_buf = (int16_t *) f->data; + int16_t *in_buf = (int16_t *) f->data.ptr; int16_t *out_buf = (int16_t *) pvt->outbuf + pvt->samples; float in_buf_f[f->samples]; float out_buf_f[2048]; @@ -168,7 +168,7 @@ static struct ast_frame *slin16_to_slin8_sample(void) .datalen = sizeof(slin16_slin8_ex), .samples = sizeof(slin16_slin8_ex) / sizeof(slin16_slin8_ex[0]), .src = __PRETTY_FUNCTION__, - .data = slin16_slin8_ex, + .data.ptr = slin16_slin8_ex, }; return &f; @@ -182,7 +182,7 @@ static struct ast_frame *slin8_to_slin16_sample(void) .datalen = sizeof(slin8_slin16_ex), .samples = sizeof(slin8_slin16_ex) / sizeof(slin8_slin16_ex[0]), .src = __PRETTY_FUNCTION__, - .data = slin8_slin16_ex, + .data.ptr = slin8_slin16_ex, }; return &f; diff --git a/codecs/codec_ulaw.c b/codecs/codec_ulaw.c index ebd1928a2b..2e0a16467d 100644 --- a/codecs/codec_ulaw.c +++ b/codecs/codec_ulaw.c @@ -44,7 +44,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") static int ulawtolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { int i = f->samples; - unsigned char *src = f->data; + unsigned char *src = f->data.ptr; int16_t *dst = (int16_t *)pvt->outbuf + pvt->samples; pvt->samples += i; @@ -62,7 +62,7 @@ static int lintoulaw_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) { int i = f->samples; char *dst = pvt->outbuf + pvt->samples; - int16_t *src = f->data; + int16_t *src = f->data.ptr; pvt->samples += i; pvt->datalen += i; /* 1 byte/sample */ @@ -84,7 +84,7 @@ static struct ast_frame *ulawtolin_sample(void) f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; - f.data = ulaw_slin_ex; + f.data.ptr = ulaw_slin_ex; return &f; } @@ -103,7 +103,7 @@ static struct ast_frame *lintoulaw_sample(void) f.mallocd = 0; f.offset = 0; f.src = __PRETTY_FUNCTION__; - f.data = slin_ulaw_ex; + f.data.ptr = slin_ulaw_ex; return &f; } diff --git a/codecs/codec_zap.c b/codecs/codec_zap.c index 01d9a1ed1e..645b65a356 100644 --- a/codecs/codec_zap.c +++ b/codecs/codec_zap.c @@ -144,7 +144,7 @@ static int zap_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) hdr->srcoffset = 0; } - memcpy(hdr->srcdata + hdr->srcoffset + hdr->srclen, f->data, f->datalen); + memcpy(hdr->srcdata + hdr->srcoffset + hdr->srclen, f->data.ptr, f->datalen); hdr->srclen += f->datalen; pvt->samples += f->samples; @@ -162,7 +162,7 @@ static struct ast_frame *zap_frameout(struct ast_trans_pvt *pvt) pvt->f.frametype = AST_FRAME_VOICE; pvt->f.subclass = 0; pvt->f.samples = 160; - pvt->f.data = NULL; + pvt->f.data.ptr = NULL; pvt->f.offset = 0; pvt->f.datalen = 0; pvt->f.mallocd = 0; @@ -182,7 +182,7 @@ static struct ast_frame *zap_frameout(struct ast_trans_pvt *pvt) pvt->f.frametype = AST_FRAME_VOICE; pvt->f.subclass = hdr->dstfmt; pvt->f.samples = hdr->dstsamples; - pvt->f.data = hdr->dstdata + hdr->dstoffset; + pvt->f.data.ptr = hdr->dstdata + hdr->dstoffset; pvt->f.offset = hdr->dstoffset; pvt->f.datalen = hdr->dstlen; pvt->f.mallocd = 0; diff --git a/formats/format_g723.c b/formats/format_g723.c index 6e57b4fa85..7b527da8cc 100644 --- a/formats/format_g723.c +++ b/formats/format_g723.c @@ -64,7 +64,7 @@ static struct ast_frame *g723_read(struct ast_filestream *s, int *whennext) s->fr.subclass = AST_FORMAT_G723_1; s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, size); - if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != size) { + if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != size) { ast_log(LOG_WARNING, "Short read (%d of %d bytes) (%s)!\n", res, size, strerror(errno)); return NULL; } @@ -100,7 +100,7 @@ static int g723_write(struct ast_filestream *s, struct ast_frame *f) ast_log(LOG_WARNING, "Unable to write size: res=%d (%s)\n", res, strerror(errno)); return -1; } - if ((res = fwrite(f->data, 1, f->datalen, s->f)) != f->datalen) { + if ((res = fwrite(f->data.ptr, 1, f->datalen, s->f)) != f->datalen) { ast_log(LOG_WARNING, "Unable to write frame: res=%d (%s)\n", res, strerror(errno)); return -1; } diff --git a/formats/format_g726.c b/formats/format_g726.c index e27476fedd..d54b52d2c0 100644 --- a/formats/format_g726.c +++ b/formats/format_g726.c @@ -123,7 +123,7 @@ static struct ast_frame *g726_read(struct ast_filestream *s, int *whennext) s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, frame_size[fs->rate]); s->fr.samples = 8 * FRAME_TIME; - if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) { + if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; @@ -151,7 +151,7 @@ static int g726_write(struct ast_filestream *s, struct ast_frame *f) f->datalen, frame_size[fs->rate]); return -1; } - if ((res = fwrite(f->data, 1, f->datalen, s->f)) != f->datalen) { + if ((res = fwrite(f->data.ptr, 1, f->datalen, s->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, frame_size[fs->rate], strerror(errno)); return -1; diff --git a/formats/format_g729.c b/formats/format_g729.c index 8df463d81a..cf7e20be7a 100644 --- a/formats/format_g729.c +++ b/formats/format_g729.c @@ -50,7 +50,7 @@ static struct ast_frame *g729_read(struct ast_filestream *s, int *whennext) s->fr.mallocd = 0; s->fr.samples = G729A_SAMPLES; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE); - if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) { + if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) { if (res && (res != 10)) /* XXX what for ? */ ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; @@ -74,7 +74,7 @@ static int g729_write(struct ast_filestream *fs, struct ast_frame *f) ast_log(LOG_WARNING, "Invalid data length, %d, should be multiple of 10\n", f->datalen); return -1; } - if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen) { + if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/10): %s\n", res, strerror(errno)); return -1; } diff --git a/formats/format_gsm.c b/formats/format_gsm.c index d43844e646..3506f563e1 100644 --- a/formats/format_gsm.c +++ b/formats/format_gsm.c @@ -56,7 +56,7 @@ static struct ast_frame *gsm_read(struct ast_filestream *s, int *whennext) s->fr.subclass = AST_FORMAT_GSM; AST_FRAME_SET_BUFFER(&(s->fr), s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE) s->fr.mallocd = 0; - if ((res = fread(s->fr.data, 1, GSM_FRAME_SIZE, s->f)) != GSM_FRAME_SIZE) { + if ((res = fread(s->fr.data.ptr, 1, GSM_FRAME_SIZE, s->f)) != GSM_FRAME_SIZE) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; @@ -82,7 +82,7 @@ static int gsm_write(struct ast_filestream *fs, struct ast_frame *f) /* This is in MSGSM format, need to be converted */ int len=0; while(len < f->datalen) { - conv65(f->data + len, gsm); + conv65(f->data.ptr + len, gsm); if ((res = fwrite(gsm, 1, 2*GSM_FRAME_SIZE, fs->f)) != 2*GSM_FRAME_SIZE) { ast_log(LOG_WARNING, "Bad write (%d/66): %s\n", res, strerror(errno)); return -1; @@ -94,7 +94,7 @@ static int gsm_write(struct ast_filestream *fs, struct ast_frame *f) ast_log(LOG_WARNING, "Invalid data length, %d, should be multiple of 33\n", f->datalen); return -1; } - if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen) { + if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/33): %s\n", res, strerror(errno)); return -1; } diff --git a/formats/format_h263.c b/formats/format_h263.c index b0b5cb27db..9b6ac6764f 100644 --- a/formats/format_h263.c +++ b/formats/format_h263.c @@ -83,7 +83,7 @@ static struct ast_frame *h263_read(struct ast_filestream *s, int *whennext) s->fr.subclass = AST_FORMAT_H263; s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len); - if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) { + if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; @@ -130,7 +130,7 @@ static int h263_write(struct ast_filestream *fs, struct ast_frame *f) ast_log(LOG_WARNING, "Bad write (%d/2): %s\n", res, strerror(errno)); return -1; } - if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen) { + if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno)); return -1; } diff --git a/formats/format_h264.c b/formats/format_h264.c index 06def313cd..fa938a8c67 100644 --- a/formats/format_h264.c +++ b/formats/format_h264.c @@ -75,7 +75,7 @@ static struct ast_frame *h264_read(struct ast_filestream *s, int *whennext) s->fr.subclass = AST_FORMAT_H264; s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len); - if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) { + if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) { if (res) ast_log(LOG_WARNING, "Short read (%d of %d) (%s)!\n", res, len, strerror(errno)); return NULL; @@ -119,7 +119,7 @@ static int h264_write(struct ast_filestream *s, struct ast_frame *f) ast_log(LOG_WARNING, "Bad write (%d/2): %s\n", res, strerror(errno)); return -1; } - if ((res = fwrite(f->data, 1, f->datalen, s->f)) != f->datalen) { + if ((res = fwrite(f->data.ptr, 1, f->datalen, s->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno)); return -1; } diff --git a/formats/format_ilbc.c b/formats/format_ilbc.c index aaddc6c383..22ca2edd1e 100644 --- a/formats/format_ilbc.c +++ b/formats/format_ilbc.c @@ -48,7 +48,7 @@ static struct ast_frame *ilbc_read(struct ast_filestream *s, int *whennext) s->fr.subclass = AST_FORMAT_ILBC; s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, ILBC_BUF_SIZE); - if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) != s->fr.datalen) { + if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; @@ -72,7 +72,7 @@ static int ilbc_write(struct ast_filestream *fs, struct ast_frame *f) ast_log(LOG_WARNING, "Invalid data length, %d, should be multiple of 50\n", f->datalen); return -1; } - if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen) { + if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/50): %s\n", res, strerror(errno)); return -1; } diff --git a/formats/format_jpeg.c b/formats/format_jpeg.c index 4d8d7855d4..92117fce12 100644 --- a/formats/format_jpeg.c +++ b/formats/format_jpeg.c @@ -49,7 +49,7 @@ static struct ast_frame *jpeg_read_image(int fd, int len) memset(&fr, 0, sizeof(fr)); fr.frametype = AST_FRAME_IMAGE; fr.subclass = AST_FORMAT_JPEG; - fr.data = buf; + fr.data.ptr = buf; fr.src = "JPEG Read"; fr.datalen = len; return ast_frisolate(&fr); @@ -79,7 +79,7 @@ static int jpeg_write_image(int fd, struct ast_frame *fr) return -1; } if (fr->datalen) { - res = write(fd, fr->data, fr->datalen); + res = write(fd, fr->data.ptr, fr->datalen); if (res != fr->datalen) { ast_log(LOG_WARNING, "Only wrote %d of %d bytes: %s\n", res, fr->datalen, strerror(errno)); return -1; diff --git a/formats/format_pcm.c b/formats/format_pcm.c index 1183535522..3ecc1c16ef 100644 --- a/formats/format_pcm.c +++ b/formats/format_pcm.c @@ -83,7 +83,7 @@ static struct ast_frame *pcm_read(struct ast_filestream *s, int *whennext) s->fr.subclass = s->fmt->format; s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE); - if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) < 1) { + if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; @@ -209,7 +209,7 @@ static int pcm_write(struct ast_filestream *fs, struct ast_frame *f) } #endif /* REALTIME_WRITE */ - if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen) { + if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno)); return -1; } diff --git a/formats/format_sln.c b/formats/format_sln.c index 51f796271e..c78a4fdcba 100644 --- a/formats/format_sln.c +++ b/formats/format_sln.c @@ -42,7 +42,7 @@ static struct ast_frame *slinear_read(struct ast_filestream *s, int *whennext) s->fr.subclass = AST_FORMAT_SLINEAR; s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE); - if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) < 1) { + if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; @@ -63,7 +63,7 @@ static int slinear_write(struct ast_filestream *fs, struct ast_frame *f) ast_log(LOG_WARNING, "Asked to write non-slinear frame (%d)!\n", f->subclass); return -1; } - if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen) { + if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno)); return -1; } diff --git a/formats/format_sln16.c b/formats/format_sln16.c index 50349f2dd9..78260f3373 100644 --- a/formats/format_sln16.c +++ b/formats/format_sln16.c @@ -43,7 +43,7 @@ static struct ast_frame *slinear_read(struct ast_filestream *s, int *whennext) s->fr.subclass = AST_FORMAT_SLINEAR16; s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE); - if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) < 1) { + if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; @@ -65,7 +65,7 @@ static int slinear_write(struct ast_filestream *fs, struct ast_frame *f) ast_log(LOG_WARNING, "Asked to write non-slinear16 frame (%d)!\n", f->subclass); return -1; } - if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen) { + if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno)); return -1; } diff --git a/formats/format_vox.c b/formats/format_vox.c index f22b4881a8..a9aef6070a 100644 --- a/formats/format_vox.c +++ b/formats/format_vox.c @@ -44,7 +44,7 @@ static struct ast_frame *vox_read(struct ast_filestream *s, int *whennext) s->fr.subclass = AST_FORMAT_ADPCM; s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, BUF_SIZE); - if ((res = fread(s->fr.data, 1, s->fr.datalen, s->f)) < 1) { + if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) < 1) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; @@ -65,7 +65,7 @@ static int vox_write(struct ast_filestream *s, struct ast_frame *f) ast_log(LOG_WARNING, "Asked to write non-ADPCM frame (%d)!\n", f->subclass); return -1; } - if ((res = fwrite(f->data, 1, f->datalen, s->f)) != f->datalen) { + if ((res = fwrite(f->data.ptr, 1, f->datalen, s->f)) != f->datalen) { ast_log(LOG_WARNING, "Bad write (%d/%d): %s\n", res, f->datalen, strerror(errno)); return -1; } diff --git a/formats/format_wav.c b/formats/format_wav.c index bbeb20bafa..5cf39ce993 100644 --- a/formats/format_wav.c +++ b/formats/format_wav.c @@ -362,7 +362,7 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext) s->fr.mallocd = 0; AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, bytes); - if ( (res = fread(s->fr.data, 1, s->fr.datalen, s->f)) <= 0 ) { + if ( (res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) <= 0 ) { if (res) ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno)); return NULL; @@ -370,7 +370,7 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext) s->fr.datalen = res; s->fr.samples = samples = res / 2; - tmp = (short *)(s->fr.data); + tmp = (short *)(s->fr.data.ptr); #if __BYTE_ORDER == __BIG_ENDIAN /* file format is little endian so we need to swap */ for( x = 0; x < samples; x++) @@ -407,14 +407,14 @@ static int wav_write(struct ast_filestream *fs, struct ast_frame *f) ast_log(LOG_WARNING, "Data length is too long\n"); return -1; } - tmpi = f->data; + tmpi = f->data.ptr; for (x=0; x < f->datalen/2; x++) tmp[x] = (tmpi[x] << 8) | ((tmpi[x] & 0xff00) >> 8); if ((res = fwrite(tmp, 1, f->datalen, fs->f)) != f->datalen ) { #else /* just write */ - if ((res = fwrite(f->data, 1, f->datalen, fs->f)) != f->datalen ) { + if ((res = fwrite(f->data.ptr, 1, f->datalen, fs->f)) != f->datalen ) { #endif ast_log(LOG_WARNING, "Bad write (%d): %s\n", res, strerror(errno)); return -1; diff --git a/formats/format_wav_gsm.c b/formats/format_wav_gsm.c index aa576195cf..4c3694cda0 100644 --- a/formats/format_wav_gsm.c +++ b/formats/format_wav_gsm.c @@ -402,7 +402,7 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext) AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, GSM_FRAME_SIZE); if (fs->secondhalf) { /* Just return a frame based on the second GSM frame */ - s->fr.data = (char *)s->fr.data + GSM_FRAME_SIZE; + s->fr.data.ptr = (char *)s->fr.data.ptr + GSM_FRAME_SIZE; s->fr.offset += GSM_FRAME_SIZE; } else { /* read and convert */ @@ -415,7 +415,7 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext) return NULL; } /* Convert from MS format to two real GSM frames */ - conv65(msdata, s->fr.data); + conv65(msdata, s->fr.data.ptr); } fs->secondhalf = !fs->secondhalf; *whennext = GSM_SAMPLES; @@ -449,16 +449,16 @@ static int wav_write(struct ast_filestream *s, struct ast_frame *f) int res; unsigned char *src, msdata[MSGSM_FRAME_SIZE]; if (fs->secondhalf) { /* second half of raw gsm to be converted */ - memcpy(s->buf + GSM_FRAME_SIZE, f->data + len, GSM_FRAME_SIZE); + memcpy(s->buf + GSM_FRAME_SIZE, f->data.ptr + len, GSM_FRAME_SIZE); conv66((unsigned char *) s->buf, msdata); src = msdata; fs->secondhalf = 0; } else if (size == GSM_FRAME_SIZE) { /* first half of raw gsm */ - memcpy(s->buf, f->data + len, GSM_FRAME_SIZE); + memcpy(s->buf, f->data.ptr + len, GSM_FRAME_SIZE); src = NULL; /* nothing to write */ fs->secondhalf = 1; } else { /* raw msgsm data */ - src = f->data + len; + src = f->data.ptr + len; } if (src && (res = fwrite(src, 1, MSGSM_FRAME_SIZE, s->f)) != MSGSM_FRAME_SIZE) { ast_log(LOG_WARNING, "Bad write (%d/65): %s\n", res, strerror(errno)); diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index 5177734a49..96dc52c0f6 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -731,7 +731,16 @@ int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f); * * \note The channel does not need to be locked before calling this function. */ -int ast_queue_hangup(struct ast_channel *chan, int cause); +int ast_queue_hangup(struct ast_channel *chan); + +/*! + * \brief Queue a hangup frame with hangupcause set + * + * \note The channel does not need to be locked before calling this function. + * \param chan channel to queue frame onto + * \param cause the hangup cause + */ +int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause); /*! * \brief Queue a control frame with payload diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h index 0cd748c032..e638b7d8c8 100644 --- a/include/asterisk/frame.h +++ b/include/asterisk/frame.h @@ -156,7 +156,7 @@ struct ast_frame { /*! Optional source of frame for debugging */ const char *src; /*! Pointer to actual data */ - void *data; + union { void *ptr; uint32_t uint32; char pad[8]; } data; /*! Global delivery time */ struct timeval delivery; /*! For placing in a linked list */ @@ -181,7 +181,7 @@ struct ast_frame { */ #define AST_FRAME_SET_BUFFER(fr, _base, _ofs, _datalen) \ { \ - (fr)->data = (char *)_base + (_ofs); \ + (fr)->data.ptr = (char *)_base + (_ofs); \ (fr)->offset = (_ofs); \ (fr)->datalen = (_datalen); \ } @@ -446,9 +446,9 @@ void ast_swapcopy_samples(void *dst, const void *src, int samples); little-endian and big-endian. */ #if __BYTE_ORDER == __LITTLE_ENDIAN #define ast_frame_byteswap_le(fr) do { ; } while(0) -#define ast_frame_byteswap_be(fr) do { struct ast_frame *__f = (fr); ast_swapcopy_samples(__f->data, __f->data, __f->samples); } while(0) +#define ast_frame_byteswap_be(fr) do { struct ast_frame *__f = (fr); ast_swapcopy_samples(__f->data.ptr, __f->data.ptr, __f->samples); } while(0) #else -#define ast_frame_byteswap_le(fr) do { struct ast_frame *__f = (fr); ast_swapcopy_samples(__f->data, __f->data, __f->samples); } while(0) +#define ast_frame_byteswap_le(fr) do { struct ast_frame *__f = (fr); ast_swapcopy_samples(__f->data.ptr, __f->data.ptr, __f->samples); } while(0) #define ast_frame_byteswap_be(fr) do { ; } while(0) #endif diff --git a/main/abstract_jb.c b/main/abstract_jb.c index e51187d7b7..a4637c1b0c 100644 --- a/main/abstract_jb.c +++ b/main/abstract_jb.c @@ -415,7 +415,7 @@ static void jb_get_and_deliver(struct ast_channel *chan) f->samples = interpolation_len * 8; f->mallocd = 0; f->src = "JB interpolation"; - f->data = NULL; + f->data.ptr = NULL; f->delivery = ast_tvadd(jb->timebase, ast_samp2tv(jb->next, 1000)); f->offset = AST_FRIENDLY_OFFSET; /* deliver the interpolated frame */ diff --git a/main/app.c b/main/app.c index 0cd6ba844d..ebdd237b31 100644 --- a/main/app.c +++ b/main/app.c @@ -337,7 +337,7 @@ static int linear_generator(struct ast_channel *chan, void *data, int len, int s struct ast_frame f = { .frametype = AST_FRAME_VOICE, .subclass = AST_FORMAT_SLINEAR, - .data = buf + AST_FRIENDLY_OFFSET / 2, + .data.ptr = buf + AST_FRIENDLY_OFFSET / 2, .offset = AST_FRIENDLY_OFFSET, }; int res; diff --git a/main/audiohook.c b/main/audiohook.c index 37970174e4..0e75cc6cda 100644 --- a/main/audiohook.c +++ b/main/audiohook.c @@ -158,7 +158,7 @@ static struct ast_frame *audiohook_read_frame_single(struct ast_audiohook *audio struct ast_frame frame = { .frametype = AST_FRAME_VOICE, .subclass = AST_FORMAT_SLINEAR, - .data = buf, + .data.ptr = buf, .datalen = sizeof(buf), .samples = samples, }; @@ -185,7 +185,7 @@ static struct ast_frame *audiohook_read_frame_both(struct ast_audiohook *audioho struct ast_frame frame = { .frametype = AST_FRAME_VOICE, .subclass = AST_FORMAT_SLINEAR, - .data = NULL, + .data.ptr = NULL, .datalen = sizeof(buf1), .samples = samples, }; @@ -263,7 +263,7 @@ static struct ast_frame *audiohook_read_frame_both(struct ast_audiohook *audioho final_buf = buf2; /* Make the final buffer part of the frame, so it gets duplicated fine */ - frame.data = final_buf; + frame.data.ptr = final_buf; /* Yahoo, a combined copy of the audio! */ return ast_frdup(&frame); @@ -586,7 +586,7 @@ static struct ast_frame *audio_audiohook_write_list(struct ast_channel *chan, st } AST_LIST_TRAVERSE_SAFE_END /* We take all of the combined whisper sources and combine them into the audio being written out */ - for (i = 0, data1 = middle_frame->data, data2 = combine_buf; i < samples; i++, data1++, data2++) + for (i = 0, data1 = middle_frame->data.ptr, data2 = combine_buf; i < samples; i++, data1++, data2++) ast_slinear_saturated_add(data1, data2); end_frame = middle_frame; } diff --git a/main/channel.c b/main/channel.c index ae005cf9d1..6b100ff363 100644 --- a/main/channel.c +++ b/main/channel.c @@ -1008,18 +1008,30 @@ int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin) } /*! \brief Queue a hangup frame for channel */ -int ast_queue_hangup(struct ast_channel *chan, int cause) +int ast_queue_hangup(struct ast_channel *chan) +{ + struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP }; + /* Yeah, let's not change a lock-critical value without locking */ + if (!ast_channel_trylock(chan)) { + chan->_softhangup |= AST_SOFTHANGUP_DEV; + ast_channel_unlock(chan); + } + return ast_queue_frame(chan, &f); +} + +/*! \brief Queue a hangup frame for channel */ +int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause) { struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP }; if (cause >= 0) - f.seqno = cause; + f.data.uint32 = cause; /* Yeah, let's not change a lock-critical value without locking */ if (!ast_channel_trylock(chan)) { chan->_softhangup |= AST_SOFTHANGUP_DEV; if (cause < 0) - f.seqno = chan->hangupcause; + f.data.uint32 = chan->hangupcause; ast_channel_unlock(chan); } @@ -1043,7 +1055,7 @@ int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type struct ast_frame f = { AST_FRAME_CONTROL, }; f.subclass = control; - f.data = (void *) data; + f.data.ptr = (void *) data; f.datalen = datalen; return ast_queue_frame(chan, &f); @@ -2235,7 +2247,7 @@ int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd) case AST_FRAME_VOICE: /* Write audio if appropriate */ if (audiofd > -1) - write(audiofd, f->data, f->datalen); + write(audiofd, f->data.ptr, f->datalen); default: /* Ignore */ break; @@ -2429,7 +2441,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) /* Interpret hangup and return NULL */ /* XXX why not the same for frames from the channel ? */ if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP) { - cause = f->seqno; + cause = f->data.uint32; ast_frfree(f); f = NULL; } @@ -2835,7 +2847,7 @@ char *ast_recvtext(struct ast_channel *chan, int timeout) if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP) done = 1; /* force a break */ else if (f->frametype == AST_FRAME_TEXT) { /* what we want */ - buf = ast_strndup((char *) f->data, f->datalen); /* dup and break */ + buf = ast_strndup((char *) f->data.ptr, f->datalen); /* dup and break */ done = 1; } ast_frfree(f); @@ -2933,7 +2945,7 @@ int ast_prod(struct ast_channel *chan) if (chan->_state != AST_STATE_UP) { ast_debug(1, "Prodding channel '%s'\n", chan->name); a.subclass = chan->rawwriteformat; - a.data = nothing + AST_FRIENDLY_OFFSET; + a.data.ptr = nothing + AST_FRIENDLY_OFFSET; a.src = "ast_prod"; if (ast_write(chan, &a)) ast_log(LOG_WARNING, "Prodding channel '%s' failed\n", chan->name); @@ -2996,7 +3008,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr) } else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass == AST_CONTROL_UNHOLD) { /* This is a side case where Echo is basically being called and the person put themselves on hold and took themselves off hold */ res = (chan->tech->indicate == NULL) ? 0 : - chan->tech->indicate(chan, fr->subclass, fr->data, fr->datalen); + chan->tech->indicate(chan, fr->subclass, fr->data.ptr, fr->datalen); } res = 0; /* XXX explain, why 0 ? */ goto done; @@ -3009,7 +3021,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr) switch (fr->frametype) { case AST_FRAME_CONTROL: res = (chan->tech->indicate == NULL) ? 0 : - chan->tech->indicate(chan, fr->subclass, fr->data, fr->datalen); + chan->tech->indicate(chan, fr->subclass, fr->data.ptr, fr->datalen); break; case AST_FRAME_DTMF_BEGIN: if (chan->audiohooks) { @@ -3045,12 +3057,12 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr) chan->tech->write_text(chan, fr); } else { res = (chan->tech->send_text == NULL) ? 0 : - chan->tech->send_text(chan, (char *) fr->data); + chan->tech->send_text(chan, (char *) fr->data.ptr); } break; case AST_FRAME_HTML: res = (chan->tech->send_html == NULL) ? 0 : - chan->tech->send_html(chan, fr->subclass, (char *) fr->data, fr->datalen); + chan->tech->send_html(chan, fr->subclass, (char *) fr->data.ptr, fr->datalen); break; case AST_FRAME_VIDEO: /* XXX Handle translation of video codecs one day XXX */ @@ -4212,7 +4224,7 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct case AST_CONTROL_UNHOLD: case AST_CONTROL_VIDUPDATE: case AST_CONTROL_SRCUPDATE: - ast_indicate_data(other, f->subclass, f->data, f->datalen); + ast_indicate_data(other, f->subclass, f->data.ptr, f->datalen); break; default: *fo = f; @@ -4689,7 +4701,7 @@ static int tonepair_generator(struct ast_channel *chan, void *data, int len, int ts->f.datalen = len; ts->f.samples = samples; ts->f.offset = AST_FRIENDLY_OFFSET; - ts->f.data = ts->data; + ts->f.data.ptr = ts->data; ast_write(chan, &ts->f); ts->pos += x; if (ts->duration > 0) { @@ -4873,7 +4885,7 @@ static int silence_generator_generate(struct ast_channel *chan, void *data, int struct ast_frame frame = { .frametype = AST_FRAME_VOICE, .subclass = AST_FORMAT_SLINEAR, - .data = buf, + .data.ptr = buf, .samples = samples, .datalen = sizeof(buf), }; diff --git a/main/dsp.c b/main/dsp.c index 935bcb0bf7..c0f4746dff 100644 --- a/main/dsp.c +++ b/main/dsp.c @@ -1075,7 +1075,7 @@ int ast_dsp_call_progress(struct ast_dsp *dsp, struct ast_frame *inf) ast_log(LOG_WARNING, "Can only check call progress in signed-linear frames\n"); return 0; } - return __ast_dsp_call_progress(dsp, inf->data, inf->datalen / 2); + return __ast_dsp_call_progress(dsp, inf->data.ptr, inf->datalen / 2); } static int __ast_dsp_silence_noise(struct ast_dsp *dsp, short *s, int len, int *totalsilence, int *totalnoise) @@ -1236,7 +1236,7 @@ int ast_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence) ast_log(LOG_WARNING, "Can only calculate silence on signed-linear frames :(\n"); return 0; } - s = f->data; + s = f->data.ptr; len = f->datalen/2; return __ast_dsp_silence_noise(dsp, s, len, totalsilence, NULL); } @@ -1254,7 +1254,7 @@ int ast_dsp_noise(struct ast_dsp *dsp, struct ast_frame *f, int *totalnoise) ast_log(LOG_WARNING, "Can only calculate noise on signed-linear frames :(\n"); return 0; } - s = f->data; + s = f->data.ptr; len = f->datalen/2; return __ast_dsp_silence_noise(dsp, s, len, NULL, totalnoise); } @@ -1276,12 +1276,12 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, if (af->frametype != AST_FRAME_VOICE) return af; - odata = af->data; + odata = af->data.ptr; len = af->datalen; /* Make sure we have short data */ switch (af->subclass) { case AST_FORMAT_SLINEAR: - shortdata = af->data; + shortdata = af->data.ptr; len = af->datalen / 2; break; case AST_FORMAT_ULAW: diff --git a/main/features.c b/main/features.c index 333b5a0f21..7b2d547267 100644 --- a/main/features.c +++ b/main/features.c @@ -2202,10 +2202,10 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast break; case AST_CONTROL_HOLD: case AST_CONTROL_UNHOLD: - ast_indicate_data(other, f->subclass, f->data, f->datalen); + ast_indicate_data(other, f->subclass, f->data.ptr, f->datalen); break; case AST_CONTROL_OPTION: - aoh = f->data; + aoh = f->data.ptr; /* Forward option Requests */ if (aoh && aoh->flag == AST_OPTION_FLAG_REQUEST) { ast_channel_setoption(other, ntohs(aoh->option), aoh->data, diff --git a/main/file.c b/main/file.c index 81d51e9a25..86efb60003 100644 --- a/main/file.c +++ b/main/file.c @@ -1193,7 +1193,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon, case AST_FRAME_VOICE: /* Write audio if appropriate */ if (audiofd > -1) - write(audiofd, fr->data, fr->datalen); + write(audiofd, fr->data.ptr, fr->datalen); default: /* Ignore all others */ break; diff --git a/main/frame.c b/main/frame.c index 75c6f91ccf..f92628e28a 100644 --- a/main/frame.c +++ b/main/frame.c @@ -180,7 +180,7 @@ int __ast_smoother_feed(struct ast_smoother *s, struct ast_frame *f, int swap) on the next read, thus eliminating the douple copy */ if (swap) - ast_swapcopy_samples(f->data, f->data, f->samples); + ast_swapcopy_samples(f->data.ptr, f->data.ptr, f->samples); s->opt = f; return 0; } @@ -192,9 +192,9 @@ int __ast_smoother_feed(struct ast_smoother *s, struct ast_frame *f, int swap) } } if (swap) - ast_swapcopy_samples(s->data+s->len, f->data, f->samples); + ast_swapcopy_samples(s->data+s->len, f->data.ptr, f->samples); else - memcpy(s->data + s->len, f->data, f->datalen); + memcpy(s->data + s->len, f->data.ptr, f->datalen); /* If either side is empty, reset the delivery time */ if (!s->len || ast_tvzero(f->delivery) || ast_tvzero(s->delivery)) /* XXX really ? */ s->delivery = f->delivery; @@ -229,14 +229,14 @@ struct ast_frame *ast_smoother_read(struct ast_smoother *s) /* Make frame */ s->f.frametype = AST_FRAME_VOICE; s->f.subclass = s->format; - s->f.data = s->framedata + AST_FRIENDLY_OFFSET; + s->f.data.ptr = s->framedata + AST_FRIENDLY_OFFSET; s->f.offset = AST_FRIENDLY_OFFSET; s->f.datalen = len; /* Samples will be improper given VAD, but with VAD the concept really doesn't even exist */ s->f.samples = len * s->samplesperbyte; /* XXX rounding */ s->f.delivery = s->delivery; /* Fill Data */ - memcpy(s->f.data, s->data, len); + memcpy(s->f.data.ptr, s->data, len); s->len -= len; /* Move remaining data to the front if applicable */ if (s->len) { @@ -331,8 +331,8 @@ void ast_frame_free(struct ast_frame *fr, int cache) #endif if (fr->mallocd & AST_MALLOCD_DATA) { - if (fr->data) - ast_free(fr->data - fr->offset); + if (fr->data.ptr) + ast_free(fr->data.ptr - fr->offset); } if (fr->mallocd & AST_MALLOCD_SRC) { if (fr->src) @@ -404,8 +404,8 @@ struct ast_frame *ast_frisolate(struct ast_frame *fr) newdata += AST_FRIENDLY_OFFSET; out->offset = AST_FRIENDLY_OFFSET; out->datalen = fr->datalen; - memcpy(newdata, fr->data, fr->datalen); - out->data = newdata; + memcpy(newdata, fr->data.ptr, fr->datalen); + out->data.ptr = newdata; } out->mallocd = AST_MALLOCD_HDR | AST_MALLOCD_SRC | AST_MALLOCD_DATA; @@ -470,8 +470,8 @@ struct ast_frame *ast_frdup(const struct ast_frame *f) out->mallocd = AST_MALLOCD_HDR; out->offset = AST_FRIENDLY_OFFSET; if (out->datalen) { - out->data = buf + sizeof(*out) + AST_FRIENDLY_OFFSET; - memcpy(out->data, f->data, out->datalen); + out->data.ptr = buf + sizeof(*out) + AST_FRIENDLY_OFFSET; + memcpy(out->data.ptr, f->data.ptr, out->datalen); } if (srclen > 0) { out->src = buf + sizeof(*out) + AST_FRIENDLY_OFFSET + f->datalen; @@ -780,7 +780,7 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix) if (f->datalen != sizeof(enum ast_control_t38)) { message = "Invalid"; } else { - enum ast_control_t38 state = *((enum ast_control_t38 *) f->data); + enum ast_control_t38 state = *((enum ast_control_t38 *) f->data.ptr); if (state == AST_T38_REQUEST_NEGOTIATE) message = "Negotiation Requested"; else if (state == AST_T38_REQUEST_TERMINATE) @@ -813,7 +813,7 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix) case AST_FRAME_TEXT: strcpy(ftype, "Text"); strcpy(subclass, "N/A"); - ast_copy_string(moreinfo, f->data, sizeof(moreinfo)); + ast_copy_string(moreinfo, f->data.ptr, sizeof(moreinfo)); break; case AST_FRAME_IMAGE: strcpy(ftype, "Image"); @@ -824,7 +824,7 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix) switch(f->subclass) { case AST_HTML_URL: strcpy(subclass, "URL"); - ast_copy_string(moreinfo, f->data, sizeof(moreinfo)); + ast_copy_string(moreinfo, f->data.ptr, sizeof(moreinfo)); break; case AST_HTML_DATA: strcpy(subclass, "Data"); @@ -843,7 +843,7 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix) break; case AST_HTML_LINKURL: strcpy(subclass, "Link URL"); - ast_copy_string(moreinfo, f->data, sizeof(moreinfo)); + ast_copy_string(moreinfo, f->data.ptr, sizeof(moreinfo)); break; case AST_HTML_UNLINK: strcpy(subclass, "Unlink"); @@ -1403,10 +1403,10 @@ int ast_codec_get_samples(struct ast_frame *f) int samples=0; switch(f->subclass) { case AST_FORMAT_SPEEX: - samples = speex_samples(f->data, f->datalen); + samples = speex_samples(f->data.ptr, f->datalen); break; case AST_FORMAT_G723_1: - samples = g723_samples(f->data, f->datalen); + samples = g723_samples(f->data.ptr, f->datalen); break; case AST_FORMAT_ILBC: samples = 240 * (f->datalen / 50); @@ -1424,7 +1424,7 @@ int ast_codec_get_samples(struct ast_frame *f) case AST_FORMAT_LPC10: /* assumes that the RTP packet contains one LPC10 frame */ samples = 22 * 8; - samples += (((char *)(f->data))[7] & 0x1) * 8; + samples += (((char *)(f->data.ptr))[7] & 0x1) * 8; break; case AST_FORMAT_ULAW: case AST_FORMAT_ALAW: @@ -1484,7 +1484,7 @@ int ast_codec_get_len(int format, int samples) int ast_frame_adjust_volume(struct ast_frame *f, int adjustment) { int count; - short *fdata = f->data; + short *fdata = f->data.ptr; short adjust_value = abs(adjustment); if ((f->frametype != AST_FRAME_VOICE) || (f->subclass != AST_FORMAT_SLINEAR)) @@ -1518,7 +1518,7 @@ int ast_frame_slinear_sum(struct ast_frame *f1, struct ast_frame *f2) if (f1->samples != f2->samples) return -1; - for (count = 0, data1 = f1->data, data2 = f2->data; + for (count = 0, data1 = f1->data.ptr, data2 = f2->data.ptr; count < f1->samples; count++, data1++, data2++) ast_slinear_saturated_add(data1, data2); diff --git a/main/indications.c b/main/indications.c index 2bb3e440e3..f75f27bad9 100644 --- a/main/indications.c +++ b/main/indications.c @@ -188,7 +188,7 @@ static int playtones_generator(struct ast_channel *chan, void *data, int len, in ps->f.datalen = len; ps->f.samples = samples; ps->f.offset = AST_FRIENDLY_OFFSET; - ps->f.data = ps->data; + ps->f.data.ptr = ps->data; ps->f.delivery.tv_sec = 0; ps->f.delivery.tv_usec = 0; ast_write(chan, &ps->f); diff --git a/main/rtp.c b/main/rtp.c index 647ed808c9..e11243358a 100644 --- a/main/rtp.c +++ b/main/rtp.c @@ -1035,12 +1035,12 @@ static struct ast_frame *process_rfc3389(struct ast_rtp *rtp, unsigned char *dat if (!len) return NULL; if (len < 24) { - rtp->f.data = rtp->rawdata + AST_FRIENDLY_OFFSET; + rtp->f.data.ptr = rtp->rawdata + AST_FRIENDLY_OFFSET; rtp->f.datalen = len - 1; rtp->f.offset = AST_FRIENDLY_OFFSET; - memcpy(rtp->f.data, data + 1, len - 1); + memcpy(rtp->f.data.ptr, data + 1, len - 1); } else { - rtp->f.data = NULL; + rtp->f.data.ptr = NULL; rtp->f.offset = 0; rtp->f.datalen = 0; } @@ -1621,14 +1621,14 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp) rtp->f.mallocd = 0; rtp->f.datalen = res - hdrlen; - rtp->f.data = rtp->rawdata + hdrlen + AST_FRIENDLY_OFFSET; + rtp->f.data.ptr = rtp->rawdata + hdrlen + AST_FRIENDLY_OFFSET; rtp->f.offset = hdrlen + AST_FRIENDLY_OFFSET; rtp->f.seqno = seqno; if (rtp->f.subclass == AST_FORMAT_T140 && (int)seqno - (prev_seqno+1) > 0 && (int)seqno - (prev_seqno+1) < 10) { - unsigned char *data = rtp->f.data; + unsigned char *data = rtp->f.data.ptr; - memmove(rtp->f.data+3, rtp->f.data, rtp->f.datalen); + memmove(rtp->f.data.ptr+3, rtp->f.data.ptr, rtp->f.datalen); rtp->f.datalen +=3; *data++ = 0xEF; *data++ = 0xBF; @@ -1636,7 +1636,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp) } if (rtp->f.subclass == AST_FORMAT_T140RED) { - unsigned char *data = rtp->f.data; + unsigned char *data = rtp->f.data.ptr; unsigned char *header_end; int num_generations; int header_length; @@ -1659,14 +1659,14 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp) if (!(rtp->f.datalen - len)) return &ast_null_frame; - rtp->f.data += len; + rtp->f.data.ptr += len; rtp->f.datalen -= len; } else if (diff > num_generations && diff < 10) { len -= 3; - rtp->f.data += len; + rtp->f.data.ptr += len; rtp->f.datalen -= len; - data = rtp->f.data; + data = rtp->f.data.ptr; *data++ = 0xEF; *data++ = 0xBF; *data = 0xBD; @@ -1674,7 +1674,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp) for ( x = 0; x < num_generations - diff; x++) len += data[x * 4 + 3]; - rtp->f.data += len; + rtp->f.data.ptr += len; rtp->f.datalen -= len; } } @@ -3147,7 +3147,7 @@ static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec rtp->lastts = f->ts * 8; /* Get a pointer to the header */ - rtpheader = (unsigned char *)(f->data - hdrlen); + rtpheader = (unsigned char *)(f->data.ptr - hdrlen); put_unaligned_uint32(rtpheader, htonl((2 << 30) | (codec << 16) | (rtp->seqno) | (mark << 23))); put_unaligned_uint32(rtpheader + 4, htonl(rtp->lastts)); @@ -3278,7 +3278,7 @@ int ast_rtp_write(struct ast_rtp *rtp, struct ast_frame *_f) ast_smoother_feed(rtp->smoother, _f); } - while ((f = ast_smoother_read(rtp->smoother)) && (f->data)) { + while ((f = ast_smoother_read(rtp->smoother)) && (f->data.ptr)) { if (f->subclass == AST_FORMAT_G722) { /* G.722 is silllllllllllllly */ f->samples /= 2; @@ -3292,7 +3292,7 @@ int ast_rtp_write(struct ast_rtp *rtp, struct ast_frame *_f) f = ast_frdup(_f); /*! \bug XXX this might never be free'd. Why do we do this? */ else f = _f; - if (f->data) + if (f->data.ptr) ast_rtp_raw_write(rtp, f, codec); if (f != _f) ast_frfree(f); @@ -3499,7 +3499,7 @@ static enum ast_bridge_result bridge_native_loop(struct ast_channel *c0, struct oldcodec0 = codec0 = pr0->get_codec(c0); if (pr1->get_codec && c1->tech_pvt) oldcodec1 = codec1 = pr1->get_codec(c1); - ast_indicate_data(other, fr->subclass, fr->data, fr->datalen); + ast_indicate_data(other, fr->subclass, fr->data.ptr, fr->datalen); ast_frfree(fr); } else { *fo = fr; @@ -3733,7 +3733,7 @@ static enum ast_bridge_result bridge_p2p_loop(struct ast_channel *c0, struct ast p0_callback = p2p_callback_enable(c0, p0, &p0_iod[0]); p1_callback = p2p_callback_enable(c1, p1, &p1_iod[0]); } - ast_indicate_data(other, fr->subclass, fr->data, fr->datalen); + ast_indicate_data(other, fr->subclass, fr->data.ptr, fr->datalen); ast_frfree(fr); } else { *fo = fr; @@ -4372,7 +4372,7 @@ static int red_write(const void *data) * \param red redundant data structure */ static struct ast_frame *red_t140_to_red(struct rtp_red *red) { - unsigned char *data = red->t140red.data; + unsigned char *data = red->t140red.data.ptr; int len = 0; int i; @@ -4395,7 +4395,7 @@ static struct ast_frame *red_t140_to_red(struct rtp_red *red) { len += data[i*4+3] = red->len[i]; /* add primary data to buffer */ - memcpy(&data[len], red->t140.data, red->t140.datalen); + memcpy(&data[len], red->t140.data.ptr, red->t140.datalen); red->t140red.datalen = len + red->t140.datalen; /* no primary data and no generations to send */ @@ -4425,11 +4425,11 @@ int rtp_red_init(struct ast_rtp *rtp, int ti, int *red_data_pt, int num_gen) r->t140.frametype = AST_FRAME_TEXT; r->t140.subclass = AST_FORMAT_T140RED; - r->t140.data = &r->buf_data; + r->t140.data.ptr = &r->buf_data; r->t140.ts = 0; r->t140red = r->t140; - r->t140red.data = &r->t140red_data; + r->t140red.data.ptr = &r->t140red_data; r->t140red.datalen = 0; r->ti = ti; r->num_gen = num_gen; @@ -4458,7 +4458,7 @@ void red_buffer_t140(struct ast_rtp *rtp, struct ast_frame *f) { if( f->datalen > -1 ) { struct rtp_red *red = rtp->red; - memcpy(&red->buf_data[red->t140.datalen], f->data, f->datalen); + memcpy(&red->buf_data[red->t140.datalen], f->data.ptr, f->datalen); red->t140.datalen += f->datalen; red->t140.ts = f->ts; } diff --git a/main/slinfactory.c b/main/slinfactory.c index af70399e67..0e3a39b222 100644 --- a/main/slinfactory.c +++ b/main/slinfactory.c @@ -161,7 +161,7 @@ int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples) } if ((frame_ptr = AST_LIST_REMOVE_HEAD(&sf->queue, frame_list))) { - frame_data = frame_ptr->data; + frame_data = frame_ptr->data.ptr; if (frame_ptr->samples <= ineed) { memcpy(offset, frame_data, frame_ptr->samples * sizeof(*offset)); diff --git a/main/translate.c b/main/translate.c index 750b2f5b66..9326f4880c 100644 --- a/main/translate.c +++ b/main/translate.c @@ -235,7 +235,7 @@ struct ast_frame *ast_trans_frameout(struct ast_trans_pvt *pvt, f->mallocd = 0; f->offset = AST_FRIENDLY_OFFSET; f->src = pvt->t->name; - f->data = pvt->outbuf; + f->data.ptr = pvt->outbuf; ast_set_flag(f, AST_FRFLAG_FROM_TRANSLATOR); diff --git a/main/udptl.c b/main/udptl.c index ea78f094a8..8d6d62c1a5 100644 --- a/main/udptl.c +++ b/main/udptl.c @@ -357,7 +357,7 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, int len) s->f[ifp_no].mallocd = 0; s->f[ifp_no].seqno = seq_no - i; s->f[ifp_no].datalen = lengths[i - 1]; - s->f[ifp_no].data = (uint8_t *) bufs[i - 1]; + s->f[ifp_no].data.ptr = (uint8_t *) bufs[i - 1]; s->f[ifp_no].offset = 0; s->f[ifp_no].src = "UDPTL"; if (ifp_no > 0) @@ -459,7 +459,7 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, int len) s->f[ifp_no].mallocd = 0; s->f[ifp_no].seqno = j; s->f[ifp_no].datalen = s->rx[l].buf_len; - s->f[ifp_no].data = s->rx[l].buf; + s->f[ifp_no].data.ptr = s->rx[l].buf; s->f[ifp_no].offset = 0; s->f[ifp_no].src = "UDPTL"; if (ifp_no > 0) @@ -480,7 +480,7 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, int len) s->f[ifp_no].mallocd = 0; s->f[ifp_no].seqno = seq_no; s->f[ifp_no].datalen = ifp_len; - s->f[ifp_no].data = (uint8_t *) ifp; + s->f[ifp_no].data.ptr = (uint8_t *) ifp; s->f[ifp_no].offset = 0; s->f[ifp_no].src = "UDPTL"; if (ifp_no > 0) @@ -909,7 +909,7 @@ int ast_udptl_write(struct ast_udptl *s, struct ast_frame *f) seq = s->tx_seq_no & 0xFFFF; /* Cook up the UDPTL packet, with the relevant EC info. */ - len = udptl_build_packet(s, buf, f->data, f->datalen); + len = udptl_build_packet(s, buf, f->data.ptr, f->datalen); if (len > 0 && s->them.sin_port && s->them.sin_addr.s_addr) { if ((res = sendto(s->fd, buf, len, 0, (struct sockaddr *) &s->them, sizeof(s->them))) < 0) diff --git a/res/res_adsi.c b/res/res_adsi.c index 2df5324aad..39a6cec429 100644 --- a/res/res_adsi.c +++ b/res/res_adsi.c @@ -134,7 +134,7 @@ static int adsi_careful_send(struct ast_channel *chan, unsigned char *buf, int l *remainder = *remainder - amt; outf.frametype = AST_FRAME_VOICE; outf.subclass = AST_FORMAT_ULAW; - outf.data = buf; + outf.data.ptr = buf; outf.datalen = amt; outf.samples = amt; if (ast_write(chan, &outf)) { @@ -174,7 +174,7 @@ static int adsi_careful_send(struct ast_channel *chan, unsigned char *buf, int l *remainder = inf->datalen - amt; outf.frametype = AST_FRAME_VOICE; outf.subclass = AST_FORMAT_ULAW; - outf.data = buf; + outf.data.ptr = buf; outf.datalen = amt; outf.samples = amt; if (ast_write(chan, &outf)) { diff --git a/res/res_agi.c b/res/res_agi.c index ae87391365..57cf128da2 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -1910,7 +1910,7 @@ static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc, } /* Write audio frame data into speech engine if possible */ if (fr && fr->frametype == AST_FRAME_VOICE) - ast_speech_write(speech, fr->data, fr->datalen); + ast_speech_write(speech, fr->data.ptr, fr->datalen); break; case AST_SPEECH_STATE_WAIT: /* Cue waiting sound if not already playing */ @@ -2613,7 +2613,7 @@ static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi /* If it's voice, write it to the audio pipe */ if ((agi->audio > -1) && (f->frametype == AST_FRAME_VOICE)) { /* Write, ignoring errors */ - write(agi->audio, f->data, f->datalen); + write(agi->audio, f->data.ptr, f->datalen); } ast_frfree(f); } diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index d64e55cce7..dffe719866 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -847,7 +847,7 @@ static int moh_generate(struct ast_channel *chan, void *data, int len, int sampl return 0; moh->f.datalen = res; - moh->f.data = buf + AST_FRIENDLY_OFFSET / 2; + moh->f.data.ptr = buf + AST_FRIENDLY_OFFSET / 2; moh->f.samples = ast_codec_get_samples(&moh->f); if (ast_write(chan, &moh->f) < 0) { -- GitLab