[asterisk-commits] bridge softmix.c: Fix crash if could not allocate the dsp. (asterisk[master])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Apr 14 10:02:19 CDT 2016
Anonymous Coward #1000019 has submitted this change and it was merged.
Change subject: bridge_softmix.c: Fix crash if could not allocate the dsp.
......................................................................
bridge_softmix.c: Fix crash if could not allocate the dsp.
Fix off nominal crash where we could not setup the channel to process
frames for the softmix bridge technology because of allocation failure.
Change-Id: Ic307a8386e46bf551e48fcd1eb97276714d56372
---
M bridges/bridge_softmix.c
1 file changed, 15 insertions(+), 4 deletions(-)
Approvals:
Anonymous Coward #1000019: Verified
Joshua Colp: Looks good to me, approved
George Joseph: Looks good to me, but someone else must approve
diff --git a/bridges/bridge_softmix.c b/bridges/bridge_softmix.c
index 850e398..bad3e43 100644
--- a/bridges/bridge_softmix.c
+++ b/bridges/bridge_softmix.c
@@ -357,6 +357,7 @@
{
struct softmix_channel *sc = bridge_channel->tech_pvt;
struct ast_format *slin_format;
+ int setup_fail;
slin_format = ast_format_cache_get_slin_by_rate(rate);
@@ -386,17 +387,24 @@
sc->read_slin_format = slin_format;
/* Setup smoother */
- ast_slinfactory_init_with_format(&sc->factory, slin_format);
+ setup_fail = ast_slinfactory_init_with_format(&sc->factory, slin_format);
/* set new read and write formats on channel. */
ast_channel_lock(bridge_channel->chan);
- ast_set_read_format_path(bridge_channel->chan,
+ setup_fail |= ast_set_read_format_path(bridge_channel->chan,
ast_channel_rawreadformat(bridge_channel->chan), slin_format);
ast_channel_unlock(bridge_channel->chan);
- ast_set_write_format(bridge_channel->chan, slin_format);
+ setup_fail |= ast_set_write_format(bridge_channel->chan, slin_format);
/* set up new DSP. This is on the read side only right before the read frame enters the smoother. */
sc->dsp = ast_dsp_new_with_rate(rate);
+ if (setup_fail || !sc->dsp) {
+ /* Bad news. Could not setup the channel for softmix. */
+ ast_mutex_unlock(&sc->lock);
+ ast_bridge_channel_leave_bridge(bridge_channel, BRIDGE_CHANNEL_STATE_END, 0);
+ return;
+ }
+
/* we want to aggressively detect silence to avoid feedback */
if (bridge_channel->tech_args.talking_threshold) {
ast_dsp_set_threshold(sc->dsp, bridge_channel->tech_args.talking_threshold);
@@ -616,7 +624,10 @@
ast_channel_unlock(bridge_channel->chan);
}
- ast_dsp_silence_with_energy(sc->dsp, frame, &totalsilence, &cur_energy);
+ /* The channel will be leaving soon if there is no dsp. */
+ if (sc->dsp) {
+ ast_dsp_silence_with_energy(sc->dsp, frame, &totalsilence, &cur_energy);
+ }
if (bridge->softmix.video_mode.mode == AST_BRIDGE_VIDEO_MODE_TALKER_SRC) {
int cur_slot = sc->video_talker.energy_history_cur_slot;
--
To view, visit https://gerrit.asterisk.org/2588
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic307a8386e46bf551e48fcd1eb97276714d56372
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
More information about the asterisk-commits
mailing list