[svn-commits] branch jcollie/bug6082 r35576 - in /team/jcollie/bug6082: ./ channels/ includ...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Thu Jun 22 13:26:57 MST 2006


Author: jcollie
Date: Thu Jun 22 15:26:56 2006
New Revision: 35576

URL: http://svn.digium.com/view/asterisk?rev=35576&view=rev
Log:
Merged revisions 35533,35553-35555 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r35533 | russell | 2006-06-22 11:26:09 -0500 (Thu, 22 Jun 2006) | 2 lines

actually allow all of the sub directories to be built when running "make", oops

........
r35553 | russell | 2006-06-22 12:05:17 -0500 (Thu, 22 Jun 2006) | 14 lines

- dynamically allocate the ast_jb structure that is on the channel structure
  so that channels not using a jitterbuffer don't waste as much memory
- ensure that the channel drivers that use jitterbuffers can handle a failure
  from configuring a jitterbuffer on a new channel because of a memory
  allocation error
- On passing through these channel drivers, configure the jitterbuffer before
  starting the PBX thread instead of afterwards. If the pbx fails to start for
  whatever reason, this would have caused a crash.
- Also on passing, move the increase of the usecount to after all of the
  possible failure conditions in the function
- fix a place where ast_update_use_count() was not called
- ensure that the owner channel pointer of the channel pvt strcutures is set to
  NULL in failure conditions

........
r35554 | russell | 2006-06-22 12:10:16 -0500 (Thu, 22 Jun 2006) | 7 lines

- move the increase of the use count to be after the possible failures
- if the pbx fails to start, set the owner channel of the pvt strucutre
  to be NULL
- return immediately if the pbx fails to start so the loop to set all of
  the variables from the "setvar" options aren't set as a bunch of global
  variables instead

........
r35555 | russell | 2006-06-22 12:49:28 -0500 (Thu, 22 Jun 2006) | 2 lines

don't blow up if a jitterbuffer is not in use

........

Modified:
    team/jcollie/bug6082/   (props changed)
    team/jcollie/bug6082/Makefile
    team/jcollie/bug6082/abstract_jb.c
    team/jcollie/bug6082/channel.c
    team/jcollie/bug6082/channels/chan_alsa.c
    team/jcollie/bug6082/channels/chan_h323.c
    team/jcollie/bug6082/channels/chan_iax2.c
    team/jcollie/bug6082/channels/chan_jingle.c
    team/jcollie/bug6082/channels/chan_mgcp.c
    team/jcollie/bug6082/channels/chan_oss.c
    team/jcollie/bug6082/channels/chan_sip.c
    team/jcollie/bug6082/channels/chan_skinny.c
    team/jcollie/bug6082/channels/chan_zap.c
    team/jcollie/bug6082/include/asterisk/abstract_jb.h
    team/jcollie/bug6082/include/asterisk/channel.h

Propchange: team/jcollie/bug6082/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Jun 22 15:26:56 2006
@@ -1,1 +1,1 @@
-/trunk:1-35531
+/trunk:1-35575

Modified: team/jcollie/bug6082/Makefile
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug6082/Makefile?rev=35576&r1=35575&r2=35576&view=diff
==============================================================================
--- team/jcollie/bug6082/Makefile (original)
+++ team/jcollie/bug6082/Makefile Thu Jun 22 15:26:56 2006
@@ -883,4 +883,4 @@
 	@echo "Generating list of available modules ..."
 	@build_tools/prep_moduledeps > $@
 
-.PHONY: sounds clean clean-depend dist-clean all _all depend cleantest uninstall _uninstall uninstall-all dont-optimize valgrind $(SUBDIRS_INSTALL) $(SUBDIRS_CLEAN) $(SUBDIRS_CLEAN_DEPEND) $(SUBDIRS_DEPEND) $(SUBDIRS_UNINSTALL) sounds
+.PHONY: sounds clean clean-depend dist-clean all _all depend cleantest uninstall _uninstall uninstall-all dont-optimize valgrind $(SUBDIRS_INSTALL) $(SUBDIRS_CLEAN) $(SUBDIRS_CLEAN_DEPEND) $(SUBDIRS_DEPEND) $(SUBDIRS_UNINSTALL) $(SUBDIRS)

Modified: team/jcollie/bug6082/abstract_jb.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug6082/abstract_jb.c?rev=35576&r1=35575&r2=35576&view=diff
==============================================================================
--- team/jcollie/bug6082/abstract_jb.c (original)
+++ team/jcollie/bug6082/abstract_jb.c Thu Jun 22 15:26:56 2006
@@ -176,7 +176,7 @@
 
 static void jb_choose_impl(struct ast_channel *chan)
 {
-	struct ast_jb *jb = &chan->jb;
+	struct ast_jb *jb = chan->jb;
 	struct ast_jb_conf *jbconf = &jb->conf;
 	struct ast_jb_impl *test_impl;
 	int i, avail_impl_count = sizeof(avail_impl) / sizeof(avail_impl[0]);
@@ -197,8 +197,8 @@
 
 int ast_jb_do_usecheck(struct ast_channel *c0, struct ast_channel *c1)
 {
-	struct ast_jb *jb0 = &c0->jb;
-	struct ast_jb *jb1 = &c1->jb;
+	struct ast_jb *jb0 = c0->jb;
+	struct ast_jb *jb1 = c1->jb;
 	struct ast_jb_conf *conf0 = &jb0->conf;
 	struct ast_jb_conf *conf1 = &jb1->conf;
 	int c0_wants_jitter = c0->tech->properties & AST_CHAN_TP_WANTSJITTER;
@@ -258,8 +258,8 @@
 
 int ast_jb_get_when_to_wakeup(struct ast_channel *c0, struct ast_channel *c1, int time_left)
 {
-	struct ast_jb *jb0 = &c0->jb;
-	struct ast_jb *jb1 = &c1->jb;
+	struct ast_jb *jb0 = c0->jb;
+	struct ast_jb *jb1 = c1->jb;
 	int c0_use_jb = ast_test_flag(jb0, JB_USE);
 	int c0_jb_is_created = ast_test_flag(jb0, JB_CREATED);
 	int c1_use_jb = ast_test_flag(jb1, JB_USE);
@@ -298,7 +298,7 @@
 
 int ast_jb_put(struct ast_channel *chan, struct ast_frame *f)
 {
-	struct ast_jb *jb = &chan->jb;
+	struct ast_jb *jb = chan->jb;
 	struct ast_jb_impl *jbimpl = jb->impl;
 	void *jbobj = jb->jbobj;
 	struct ast_frame *frr;
@@ -366,8 +366,8 @@
 
 void ast_jb_get_and_deliver(struct ast_channel *c0, struct ast_channel *c1)
 {
-	struct ast_jb *jb0 = &c0->jb;
-	struct ast_jb *jb1 = &c1->jb;
+	struct ast_jb *jb0 = c0->jb;
+	struct ast_jb *jb1 = c1->jb;
 	int c0_use_jb = ast_test_flag(jb0, JB_USE);
 	int c0_jb_is_created = ast_test_flag(jb0, JB_CREATED);
 	int c1_use_jb = ast_test_flag(jb1, JB_USE);
@@ -383,7 +383,7 @@
 
 static void jb_get_and_deliver(struct ast_channel *chan)
 {
-	struct ast_jb *jb = &chan->jb;
+	struct ast_jb *jb = chan->jb;
 	struct ast_jb_impl *jbimpl = jb->impl;
 	void *jbobj = jb->jbobj;
 	struct ast_frame *f, finterp;
@@ -447,7 +447,7 @@
 
 static int create_jb(struct ast_channel *chan, struct ast_frame *frr)
 {
-	struct ast_jb *jb = &chan->jb;
+	struct ast_jb *jb = chan->jb;
 	struct ast_jb_conf *jbconf = &jb->conf;
 	struct ast_jb_impl *jbimpl = jb->impl;
 	void *jbobj;
@@ -527,7 +527,7 @@
 
 void ast_jb_destroy(struct ast_channel *chan)
 {
-	struct ast_jb *jb = &chan->jb;
+	struct ast_jb *jb = chan->jb;
 	struct ast_jb_impl *jbimpl = jb->impl;
 	void *jbobj = jb->jbobj;
 	struct ast_frame *f;
@@ -551,6 +551,8 @@
 		if (option_verbose > 2)
 			ast_verbose(VERBOSE_PREFIX_3 "%s jitterbuffer destroyed on channel %s\n", jbimpl->name, chan->name);
 	}
+
+	free(jb);
 }
 
 
@@ -601,15 +603,25 @@
 }
 
 
-void ast_jb_configure(struct ast_channel *chan, const struct ast_jb_conf *conf)
-{
-	memcpy(&chan->jb.conf, conf, sizeof(*conf));
-}
-
-
-void ast_jb_get_config(const struct ast_channel *chan, struct ast_jb_conf *conf)
-{
-	memcpy(conf, &chan->jb.conf, sizeof(*conf));
+int ast_jb_configure(struct ast_channel *chan, const struct ast_jb_conf *conf)
+{
+	if (!(chan->jb = ast_calloc(1, sizeof(*chan->jb))))
+		return -1;
+
+	memcpy(&chan->jb->conf, conf, sizeof(*conf));
+
+	return 0;
+}
+
+
+int ast_jb_get_config(const struct ast_channel *chan, struct ast_jb_conf *conf)
+{
+	if (!chan->jb)
+		return -1;
+
+	memcpy(conf, &chan->jb->conf, sizeof(*conf));
+
+	return 0;
 }
 
 

Modified: team/jcollie/bug6082/channel.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug6082/channel.c?rev=35576&r1=35575&r2=35576&view=diff
==============================================================================
--- team/jcollie/bug6082/channel.c (original)
+++ team/jcollie/bug6082/channel.c Thu Jun 22 15:26:56 2006
@@ -1015,7 +1015,8 @@
 		ast_var_delete(vardata);
 
 	/* Destroy the jitterbuffer */
-	ast_jb_destroy(chan);
+	if (chan->jb)
+		ast_jb_destroy(chan);
 
 	ast_string_field_free_all(chan);
 	free(chan);

Modified: team/jcollie/bug6082/channels/chan_alsa.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug6082/channels/chan_alsa.c?rev=35576&r1=35575&r2=35576&view=diff
==============================================================================
--- team/jcollie/bug6082/channels/chan_alsa.c (original)
+++ team/jcollie/bug6082/channels/chan_alsa.c Thu Jun 22 15:26:56 2006
@@ -812,19 +812,23 @@
 			ast_string_field_set(tmp, language, language);
 		p->owner = tmp;
 		ast_setstate(tmp, state);
+		if (ast_jb_configure(tmp, &global_jbconf)) {
+			ast_hangup(tmp);
+			p->owner = NULL;
+			return NULL;
+		}
+		if (state != AST_STATE_DOWN) {
+			if (ast_pbx_start(tmp)) {
+				ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
+				ast_hangup(tmp);
+				p->owner = NULL;
+				return NULL;
+			}
+		}
 		ast_mutex_lock(&usecnt_lock);
 		usecnt++;
 		ast_mutex_unlock(&usecnt_lock);
 		ast_update_use_count();
-		if (state != AST_STATE_DOWN) {
-			if (ast_pbx_start(tmp)) {
-				ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
-				ast_hangup(tmp);
-				tmp = NULL;
-			}
-		}
-		if (tmp)
-			ast_jb_configure(tmp, &global_jbconf);
 	}
 	return tmp;
 }

Modified: team/jcollie/bug6082/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug6082/channels/chan_h323.c?rev=35576&r1=35575&r2=35576&view=diff
==============================================================================
--- team/jcollie/bug6082/channels/chan_h323.c (original)
+++ team/jcollie/bug6082/channels/chan_h323.c Thu Jun 22 15:26:56 2006
@@ -746,9 +746,6 @@
 	/* Don't hold a oh323_pvt lock while we allocate a chanel */
 	ast_mutex_unlock(&pvt->lock);
 	ch = ast_channel_alloc(1);
-	/* Update usage counter */
-	ast_atomic_fetchadd_int(&__mod_desc->usecnt, +1);
-	ast_update_use_count();
 	ast_mutex_lock(&pvt->lock);
 	if (ch) {
 		ch->tech = &oh323_tech;
@@ -803,17 +800,25 @@
 			ch->cid.cid_dnid = strdup(pvt->exten);
 		}
 		ast_setstate(ch, state);
+		/* Configure the new channel jb */
+		if (pvt->rtp) {
+			if (ast_jb_configure(ch, &global_jbconf)) {
+				ast_hangup(ch);
+				pvt->owner = NULL;
+				return NULL;
+			}
+		}
 		if (state != AST_STATE_DOWN) {
 			if (ast_pbx_start(ch)) {
 				ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ch->name);
 				ast_hangup(ch);
-				ch = NULL;
-			}
-		}
-
-		/* Configure the new channel jb */
-		if (ch && pvt && pvt->rtp)
-			ast_jb_configure(ch, &global_jbconf);
+				pvt->owner = NULL;
+				return NULL;
+			}
+		}
+		/* Update usage counter */
+		ast_atomic_fetchadd_int(&__mod_desc->usecnt, +1);
+		ast_update_use_count();
 	} else  {
 		ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
 	}

Modified: team/jcollie/bug6082/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug6082/channels/chan_iax2.c?rev=35576&r1=35575&r2=35576&view=diff
==============================================================================
--- team/jcollie/bug6082/channels/chan_iax2.c (original)
+++ team/jcollie/bug6082/channels/chan_iax2.c Thu Jun 22 15:26:56 2006
@@ -3307,20 +3307,20 @@
 		i->owner = tmp;
 		i->capability = capability;
 		ast_setstate(tmp, state);
+		if (state != AST_STATE_DOWN) {
+			if (ast_pbx_start(tmp)) {
+				ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
+				ast_hangup(tmp);
+				i->owner = NULL;
+				return NULL;
+			}
+		}
+		for (v = i->vars ; v ; v = v->next)
+			pbx_builtin_setvar_helper(tmp,v->name,v->value);
 		ast_mutex_lock(&usecnt_lock);
 		usecnt++;
 		ast_mutex_unlock(&usecnt_lock);
 		ast_update_use_count();
-		if (state != AST_STATE_DOWN) {
-			if (ast_pbx_start(tmp)) {
-				ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
-				ast_hangup(tmp);
-				tmp = NULL;
-			}
-		}
-		for (v = i->vars ; v ; v = v->next)
-			pbx_builtin_setvar_helper(tmp,v->name,v->value);
-		
 	}
 	return tmp;
 }

Modified: team/jcollie/bug6082/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug6082/channels/chan_jingle.c?rev=35576&r1=35575&r2=35576&view=diff
==============================================================================
--- team/jcollie/bug6082/channels/chan_jingle.c (original)
+++ team/jcollie/bug6082/channels/chan_jingle.c Thu Jun 22 15:26:56 2006
@@ -756,9 +756,6 @@
 	if (!ast_strlen_zero(client->musicclass))
 		ast_string_field_set(tmp, musicclass, client->musicclass);
 	i->owner = tmp;
-	ast_mutex_lock(&usecnt_lock);
-	usecnt++;
-	ast_mutex_unlock(&usecnt_lock);
 	ast_copy_string(tmp->context, client->context, sizeof(tmp->context));
 	ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
 	if (!ast_strlen_zero(i->cid_num))
@@ -769,16 +766,26 @@
 		tmp->cid.cid_dnid = ast_strdup(i->exten);
 	tmp->priority = 1;
 	ast_setstate(tmp, state);
+	/* Configure the new channel jb */
+	if (i->rtp) {
+		if (ast_jb_configure(tmp, &global_jbconf)) {
+			ast_hangup(tmp);
+			i->owner = NULL;
+			return NULL;
+		}
+	}
 	if (state != AST_STATE_DOWN && ast_pbx_start(tmp)) {
 		ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
 		tmp->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
 		ast_hangup(tmp);
-		tmp = NULL;
-	}
-
-	/* Configure the new channel jb */
-	if (tmp && i && i->rtp)
-		ast_jb_configure(tmp, &global_jbconf);
+		i->owner = NULL;
+		return NULL;
+	}
+
+	ast_mutex_lock(&usecnt_lock);
+	usecnt++;
+	ast_mutex_unlock(&usecnt_lock);
+	ast_update_use_count();
 
 	return tmp;
 }

Modified: team/jcollie/bug6082/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug6082/channels/chan_mgcp.c?rev=35576&r1=35575&r2=35576&view=diff
==============================================================================
--- team/jcollie/bug6082/channels/chan_mgcp.c (original)
+++ team/jcollie/bug6082/channels/chan_mgcp.c Thu Jun 22 15:26:56 2006
@@ -1478,8 +1478,6 @@
 		if (i->amaflags)
 			tmp->amaflags = i->amaflags;
 		sub->owner = tmp;
-		ast_atomic_fetchadd_int(&__mod_desc->usecnt, +1);
-		ast_update_use_count();
 		tmp->callgroup = i->callgroup;
 		tmp->pickupgroup = i->pickupgroup;
 		ast_string_field_set(tmp, call_forward, i->call_forward);
@@ -1490,22 +1488,28 @@
 		if (!i->adsi)
 			tmp->adsicpe = AST_ADSI_UNAVAILABLE;
 		tmp->priority = 1;
+		/* Configure the new channel jb */
+		if (sub->rtp) {
+			if (ast_jb_configure(tmp, &global_jbconf)) {
+				ast_hangup(tmp);
+				sub->owner = NULL;
+				return NULL;
+			}
+		}
 		if (state != AST_STATE_DOWN) {
 			if (ast_pbx_start(tmp)) {
 				ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
 				ast_hangup(tmp);
-				tmp = NULL;
-			}
-		}
-		/* SC: verbose level check */
+				sub->owner = NULL;
+				return NULL;
+			}
+		}
 		if (option_verbose > 2) {
 			ast_verbose(VERBOSE_PREFIX_3 "MGCP mgcp_new(%s) created in state: %s\n",
 				tmp->name, ast_state2str(state));
 		}
-
-		/* Configure the new channel jb */
-		if (tmp && sub && sub->rtp)
-			ast_jb_configure(tmp, &global_jbconf);
+		ast_atomic_fetchadd_int(&__mod_desc->usecnt, +1);
+		ast_update_use_count();
 	} else {
 		ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
 	}

Modified: team/jcollie/bug6082/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug6082/channels/chan_oss.c?rev=35576&r1=35575&r2=35576&view=diff
==============================================================================
--- team/jcollie/bug6082/channels/chan_oss.c (original)
+++ team/jcollie/bug6082/channels/chan_oss.c Thu Jun 22 15:26:56 2006
@@ -1000,21 +1000,24 @@
 
 	o->owner = c;
 	ast_setstate(c, state);
+	if (ast_jb_configure(c, &global_jbconf)) {
+		ast_hangup(c);
+		o->owner = NULL;
+		return NULL;
+	}
+	if (state != AST_STATE_DOWN) {
+		if (ast_pbx_start(c)) {
+			ast_log(LOG_WARNING, "Unable to start PBX on %s\n", c->name);
+			ast_hangup(c);
+			o->owner = NULL;
+			return NULL;
+		}
+	}
+
 	ast_mutex_lock(&usecnt_lock);
 	usecnt++;
 	ast_mutex_unlock(&usecnt_lock);
 	ast_update_use_count();
-	if (state != AST_STATE_DOWN) {
-		if (ast_pbx_start(c)) {
-			ast_log(LOG_WARNING, "Unable to start PBX on %s\n", c->name);
-			ast_hangup(c);
-			o->owner = c = NULL;
-			/* XXX what about the channel itself ? */
-			/* XXX what about usecnt ? */
-		}
-	}
-	if (c)
-		ast_jb_configure(c, &global_jbconf);
 
 	return c;
 }

Modified: team/jcollie/bug6082/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug6082/channels/chan_sip.c?rev=35576&r1=35575&r2=35576&view=diff
==============================================================================
--- team/jcollie/bug6082/channels/chan_sip.c (original)
+++ team/jcollie/bug6082/channels/chan_sip.c Thu Jun 22 15:26:56 2006
@@ -3648,9 +3648,6 @@
 	if (!ast_strlen_zero(i->musicclass))
 		ast_string_field_set(tmp, musicclass, i->musicclass);
 	i->owner = tmp;
-	ast_mutex_lock(&usecnt_lock);
-	usecnt++;
-	ast_mutex_unlock(&usecnt_lock);
 	ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
 	ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
 	if (!ast_strlen_zero(i->cid_num)) 
@@ -3671,11 +3668,20 @@
 	if (!ast_strlen_zero(i->callid))
 		pbx_builtin_setvar_helper(tmp, "SIPCALLID", i->callid);
 	ast_setstate(tmp, state);
+	/* Configure the new channel jb */
+	if (i->rtp) {
+		if (ast_jb_configure(tmp, &global_jbconf)) {
+			ast_hangup(tmp);
+			i->owner = NULL;
+			return NULL;
+		}
+	}
 	if (state != AST_STATE_DOWN && ast_pbx_start(tmp)) {
 		ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
 		tmp->hangupcause = AST_CAUSE_SWITCH_CONGESTION;
 		ast_hangup(tmp);
-		tmp = NULL;
+		i->owner = NULL;
+		return NULL;
 	}
 	/* Set channel variables for this call from configuration */
 	for (v = i->chanvars ; v ; v = v->next)
@@ -3684,9 +3690,9 @@
 	if (recordhistory)
 		append_history(i, "NewChan", "Channel %s - from %s", tmp->name, i->callid);
 
-	/* Configure the new channel jb */
-	if (tmp && i && i->rtp)
-		ast_jb_configure(tmp, &global_jbconf);
+	ast_mutex_lock(&usecnt_lock);
+	usecnt++;
+	ast_mutex_unlock(&usecnt_lock);
 
 	return tmp;
 }

Modified: team/jcollie/bug6082/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug6082/channels/chan_skinny.c?rev=35576&r1=35575&r2=35576&view=diff
==============================================================================
--- team/jcollie/bug6082/channels/chan_skinny.c (original)
+++ team/jcollie/bug6082/channels/chan_skinny.c Thu Jun 22 15:26:56 2006
@@ -2516,10 +2516,6 @@
 		if (l->amaflags)
 			tmp->amaflags = l->amaflags;
 
-		ast_mutex_lock(&usecnt_lock);
-		usecnt++;
-		ast_mutex_unlock(&usecnt_lock);
-		ast_update_use_count();
 		tmp->callgroup = l->callgroup;
 		tmp->pickupgroup = l->pickupgroup;
 		ast_string_field_set(tmp, call_forward, l->call_forward);
@@ -2530,18 +2526,29 @@
 		tmp->priority = 1;
 		tmp->adsicpe = AST_ADSI_UNAVAILABLE;
 
+		/* Configure the new channel jb */
+		if (sub->rtp) {
+			if (ast_jb_configure(tmp, &global_jbconf)) {
+				ast_hangup(tmp);
+				sub->owner = NULL;
+				return NULL;
+			}
+		}
 		if (state != AST_STATE_DOWN) {
 			if (ast_pbx_start(tmp)) {
 				ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
 				ast_hangup(tmp);
-				tmp = NULL;
+				sub->owner = NULL;
+				return NULL;
 			}
 		}
-
-		/* Configure the new channel jb */
-		if (tmp && sub->rtp)
-			ast_jb_configure(tmp, &global_jbconf);
-	}
+	}
+
+	ast_mutex_lock(&usecnt_lock);
+	usecnt++;
+	ast_mutex_unlock(&usecnt_lock);
+	ast_update_use_count();
+
 	return tmp;
 }
 

Modified: team/jcollie/bug6082/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug6082/channels/chan_zap.c?rev=35576&r1=35575&r2=35576&view=diff
==============================================================================
--- team/jcollie/bug6082/channels/chan_zap.c (original)
+++ team/jcollie/bug6082/channels/chan_zap.c Thu Jun 22 15:26:56 2006
@@ -5190,22 +5190,28 @@
 		/* Assure there is no confmute on this channel */
 		zt_confmute(i, 0);
 		ast_setstate(tmp, state);
-		ast_mutex_lock(&usecnt_lock);
-		usecnt++;
-		ast_mutex_unlock(&usecnt_lock);
-		ast_update_use_count();
+		/* Configure the new channel jb */
+		if (ast_jb_configure(tmp, &global_jbconf)) {
+			ast_hangup(tmp);
+			i->owner = NULL;
+			return NULL;
+		}
 		if (startpbx) {
 			if (ast_pbx_start(tmp)) {
 				ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
 				ast_hangup(tmp);
-				tmp = NULL;
+				i->owner = NULL;
+				return NULL;
 			}
 		}
 	} else
 		ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
-	/* Configure the new channel jb */
-	if (tmp && i)
-		ast_jb_configure(tmp, &global_jbconf);
+
+	ast_mutex_lock(&usecnt_lock);
+	usecnt++;
+	ast_mutex_unlock(&usecnt_lock);
+	ast_update_use_count();
+	
 	return tmp;
 }
 

Modified: team/jcollie/bug6082/include/asterisk/abstract_jb.h
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug6082/include/asterisk/abstract_jb.h?rev=35576&r1=35575&r2=35576&view=diff
==============================================================================
--- team/jcollie/bug6082/include/asterisk/abstract_jb.h (original)
+++ team/jcollie/bug6082/include/asterisk/abstract_jb.h Thu Jun 22 15:26:56 2006
@@ -202,16 +202,22 @@
  *
  * Called from a channel driver when a channel is created and its jitterbuffer needs
  * to be configured.
- */
-void ast_jb_configure(struct ast_channel *chan, const struct ast_jb_conf *conf);
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int ast_jb_configure(struct ast_channel *chan, const struct ast_jb_conf *conf);
 
 
 /*!
  * \brief Copies a channel's jitterbuffer configuration.
  * \param chan channel.
  * \param conf destination.
- */
-void ast_jb_get_config(const struct ast_channel *chan, struct ast_jb_conf *conf);
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int ast_jb_get_config(const struct ast_channel *chan, struct ast_jb_conf *conf);
 
 
 #if defined(__cplusplus) || defined(c_plusplus)

Modified: team/jcollie/bug6082/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/jcollie/bug6082/include/asterisk/channel.h?rev=35576&r1=35575&r2=35576&view=diff
==============================================================================
--- team/jcollie/bug6082/include/asterisk/channel.h (original)
+++ team/jcollie/bug6082/include/asterisk/channel.h Thu Jun 22 15:26:56 2006
@@ -383,7 +383,7 @@
 
 	struct ast_channel_spy_list *spies;		/*!< Chan Spy stuff */
 	AST_LIST_ENTRY(ast_channel) chan_list;		/*!< For easy linking */
-	struct ast_jb jb;				/*!< The jitterbuffer state  */
+	struct ast_jb *jb;				/*!< The jitterbuffer state  */
 
 	/*! \brief Data stores on the channel */
 	AST_LIST_HEAD_NOLOCK(datastores, ast_datastore) datastores;



More information about the svn-commits mailing list