[asterisk-commits] irroot: branch irroot/distrotech-customers-10 r338893 - /team/irroot/distrote...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Oct 1 02:01:33 CDT 2011
Author: irroot
Date: Sat Oct 1 02:01:25 2011
New Revision: 338893
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=338893
Log:
Move chan_local fixup from local_write to local_indicate
Modified:
team/irroot/distrotech-customers-10/channels/chan_local.c
Modified: team/irroot/distrotech-customers-10/channels/chan_local.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-10/channels/chan_local.c?view=diff&rev=338893&r1=338892&r2=338893
==============================================================================
--- team/irroot/distrotech-customers-10/channels/chan_local.c (original)
+++ team/irroot/distrotech-customers-10/channels/chan_local.c Sat Oct 1 02:01:25 2011
@@ -587,10 +587,8 @@
static int local_write(struct ast_channel *ast, struct ast_frame *f)
{
struct local_pvt *p = ast->tech_pvt;
- struct ast_channel *bridge;
int res = -1;
int isoutbound;
- int lockcheck = 10;
if (!p) {
return -1;
@@ -603,28 +601,6 @@
if (isoutbound && f && (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO)) {
check_bridge(p);
- } else if (f && (f->frametype == AST_FRAME_VOICE)) {
- /* fixup audio formats nativeformat has changed we must adjust
- * ast is p->owner and is locked here*/
- ao2_unlock(p);
- bridge = ast_bridged_channel(ast);
- ao2_lock(p);
- if (p->chan && bridge && (bridge != p->chan) &&
- !ast_format_cap_identical(bridge->nativeformats, ast->nativeformats)) {
- while (lockcheck && ast_channel_trylock(p->chan)) {
- lockcheck--;
- usleep(1000);
- }
- if (lockcheck) {
- ast_format_cap_copy(ast->nativeformats, bridge->nativeformats);
- ast_set_read_format(ast, &ast->readformat);
- ast_set_write_format(ast, &ast->writeformat);
- ast_format_cap_copy(p->chan->nativeformats, bridge->nativeformats);
- ast_set_read_format(p->chan, &p->chan->readformat);
- ast_set_write_format(p->chan, &p->chan->writeformat);
- ast_channel_unlock(p->chan);
- }
- }
}
if (!ast_test_flag(p, LOCAL_ALREADY_MASQED)) {
@@ -673,9 +649,10 @@
static int local_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
{
struct local_pvt *p = ast->tech_pvt;
+ struct ast_channel *bridge;
int res = 0;
struct ast_frame f = { AST_FRAME_CONTROL, };
- int isoutbound;
+ int isoutbound = IS_OUTBOUND(ast, p);
if (!p)
return -1;
@@ -698,7 +675,6 @@
* happens to be in this control frame. The same applies for redirecting information, which
* is why it is handled here as well.*/
ao2_lock(p);
- isoutbound = IS_OUTBOUND(ast, p);
if (isoutbound) {
this_channel = p->chan;
the_other_channel = p->owner;
@@ -721,10 +697,33 @@
res = local_queue_frame(p, isoutbound, &f, ast, 1);
}
ao2_unlock(p);
+ } else if (!isoutbound && (condition == AST_CONTROL_SRCUPDATE)) {
+ bridge = ast_bridged_channel(ast);
+ ao2_lock(p);
+ /* fixup audio formats nativeformat might have changed we must adjust.
+ * ast is p->owner and is locked here*/
+ if (p->chan && bridge && (bridge != p->chan) &&
+ !ast_format_cap_identical(bridge->nativeformats, ast->nativeformats)) {
+ if (!ast_channel_trylock(p->chan)) {
+ ast_format_cap_copy(ast->nativeformats, bridge->nativeformats);
+ ast_set_read_format(ast, &ast->readformat);
+ ast_set_write_format(ast, &ast->writeformat);
+ ast_format_cap_copy(p->chan->nativeformats, bridge->nativeformats);
+ ast_set_read_format(p->chan, &p->chan->readformat);
+ ast_set_write_format(p->chan, &p->chan->writeformat);
+ ast_channel_unlock(p->chan);
+ } else {
+ ast_verb(3, "Tried to get lock on %s to set audio format but failed\n", p->chan->name);
+ }
+ }
+ f.subclass.integer = condition;
+ f.data.ptr = (void*)data;
+ f.datalen = datalen;
+ res = local_queue_frame(p, isoutbound, &f, ast, 1);
+ ao2_unlock(p);
} else {
/* Queue up a frame representing the indication as a control frame */
ao2_lock(p);
- isoutbound = IS_OUTBOUND(ast, p);
f.subclass.integer = condition;
f.data.ptr = (void*)data;
f.datalen = datalen;
More information about the asterisk-commits
mailing list