Remove some unnecessary calls to ast_bridged_channel() in chan_dahdi.c/sig_analog.c
authorRichard Mudgett <rmudgett@digium.com>
Wed, 1 May 2013 20:00:31 +0000 (20:00 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Wed, 1 May 2013 20:00:31 +0000 (20:00 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@387181 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_dahdi.c
channels/sig_analog.c

index 81bfb45..7a8847e 100644 (file)
@@ -6547,8 +6547,7 @@ static int dahdi_hangup(struct ast_channel *ast)
                                p->owner = p->subs[SUB_REAL].owner;
                                if (ast_channel_state(p->owner) != AST_STATE_UP)
                                        p->subs[SUB_REAL].needanswer = 1;
-                               if (ast_bridged_channel(p->subs[SUB_REAL].owner))
-                                       ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD);
+                               ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD);
                        } else if (p->subs[SUB_THREEWAY].dfd > -1) {
                                swap_subs(p, SUB_THREEWAY, SUB_REAL);
                                unalloc_sub(p, SUB_THREEWAY);
@@ -6569,7 +6568,7 @@ static int dahdi_hangup(struct ast_channel *ast)
                        if (p->subs[SUB_CALLWAIT].inthreeway) {
                                /* This is actually part of a three way, placed on hold.  Place the third part
                                   on music on hold now */
-                               if (p->subs[SUB_THREEWAY].owner && ast_bridged_channel(p->subs[SUB_THREEWAY].owner)) {
+                               if (p->subs[SUB_THREEWAY].owner) {
                                        ast_queue_control_data(p->subs[SUB_THREEWAY].owner, AST_CONTROL_HOLD,
                                                S_OR(p->mohsuggest, NULL),
                                                !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
@@ -6584,7 +6583,7 @@ static int dahdi_hangup(struct ast_channel *ast)
                        if (p->subs[SUB_CALLWAIT].inthreeway) {
                                /* The other party of the three way call is currently in a call-wait state.
                                   Start music on hold for them, and take the main guy out of the third call */
-                               if (p->subs[SUB_CALLWAIT].owner && ast_bridged_channel(p->subs[SUB_CALLWAIT].owner)) {
+                               if (p->subs[SUB_CALLWAIT].owner) {
                                        ast_queue_control_data(p->subs[SUB_CALLWAIT].owner, AST_CONTROL_HOLD,
                                                S_OR(p->mohsuggest, NULL),
                                                !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
@@ -7838,11 +7837,10 @@ static int attempt_transfer(struct dahdi_pvt *p)
           together (but then, why would we want to?) */
        if (ast_bridged_channel(p->subs[SUB_REAL].owner)) {
                /* The three-way person we're about to transfer to could still be in MOH, so
-                  stop if now if appropriate */
-               if (ast_bridged_channel(p->subs[SUB_THREEWAY].owner))
-                       ast_queue_control(p->subs[SUB_THREEWAY].owner, AST_CONTROL_UNHOLD);
+                  stop it now */
+               ast_queue_control(p->subs[SUB_THREEWAY].owner, AST_CONTROL_UNHOLD);
                if (ast_channel_state(p->subs[SUB_REAL].owner) == AST_STATE_RINGING) {
-                       ast_indicate(ast_bridged_channel(p->subs[SUB_REAL].owner), AST_CONTROL_RINGING);
+                       ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_RINGING);
                }
                if (ast_channel_state(p->subs[SUB_THREEWAY].owner) == AST_STATE_RING) {
                        tone_zone_play_tone(p->subs[SUB_THREEWAY].dfd, DAHDI_TONE_RINGTONE);
@@ -7858,7 +7856,7 @@ static int attempt_transfer(struct dahdi_pvt *p)
        } else if (ast_bridged_channel(p->subs[SUB_THREEWAY].owner)) {
                ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD);
                if (ast_channel_state(p->subs[SUB_THREEWAY].owner) == AST_STATE_RINGING) {
-                       ast_indicate(ast_bridged_channel(p->subs[SUB_THREEWAY].owner), AST_CONTROL_RINGING);
+                       ast_queue_control(p->subs[SUB_THREEWAY].owner, AST_CONTROL_RINGING);
                }
                if (ast_channel_state(p->subs[SUB_REAL].owner) == AST_STATE_RING) {
                        tone_zone_play_tone(p->subs[SUB_REAL].dfd, DAHDI_TONE_RINGTONE);
@@ -8524,8 +8522,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                /* Make sure it stops ringing */
                                dahdi_set_hook(p->subs[idx].dfd, DAHDI_OFFHOOK);
                                /* Okay -- probably call waiting*/
-                               if (ast_bridged_channel(p->owner))
-                                       ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
+                               ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
                                p->subs[idx].needunhold = 1;
                                break;
                        case AST_STATE_RESERVED:
@@ -8679,17 +8676,15 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                p->cidcwexpire = 0;
                                p->cid_suppress_expire = 0;
                                /* Start music on hold if appropriate */
-                               if (!p->subs[SUB_CALLWAIT].inthreeway && ast_bridged_channel(p->subs[SUB_CALLWAIT].owner)) {
+                               if (!p->subs[SUB_CALLWAIT].inthreeway) {
                                        ast_queue_control_data(p->subs[SUB_CALLWAIT].owner, AST_CONTROL_HOLD,
                                                S_OR(p->mohsuggest, NULL),
                                                !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
                                }
                                p->subs[SUB_CALLWAIT].needhold = 1;
-                               if (ast_bridged_channel(p->subs[SUB_REAL].owner)) {
-                                       ast_queue_control_data(p->subs[SUB_REAL].owner, AST_CONTROL_HOLD,
-                                               S_OR(p->mohsuggest, NULL),
-                                               !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
-                               }
+                               ast_queue_control_data(p->subs[SUB_REAL].owner, AST_CONTROL_HOLD,
+                                       S_OR(p->mohsuggest, NULL),
+                                       !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
                                p->subs[SUB_REAL].needunhold = 1;
                        } else if (!p->subs[SUB_THREEWAY].owner) {
                                if (!p->threewaycalling) {
@@ -8766,12 +8761,10 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                        } else {
                                                ast_verb(3, "Started three way call on channel %d\n", p->channel);
 
-                                               /* Start music on hold if appropriate */
-                                               if (ast_bridged_channel(p->subs[SUB_THREEWAY].owner)) {
-                                                       ast_queue_control_data(p->subs[SUB_THREEWAY].owner, AST_CONTROL_HOLD,
-                                                               S_OR(p->mohsuggest, NULL),
-                                                               !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
-                                               }
+                                               /* Start music on hold */
+                                               ast_queue_control_data(p->subs[SUB_THREEWAY].owner, AST_CONTROL_HOLD,
+                                                       S_OR(p->mohsuggest, NULL),
+                                                       !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
                                                p->subs[SUB_THREEWAY].needhold = 1;
                                        }
                                        ast_callid_threadstorage_auto_clean(callid, callid_created);
@@ -8808,7 +8801,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                                        swap_subs(p, SUB_THREEWAY, SUB_REAL);
                                                        otherindex = SUB_REAL;
                                                }
-                                               if (p->subs[otherindex].owner && ast_bridged_channel(p->subs[otherindex].owner))
+                                               if (p->subs[otherindex].owner)
                                                        ast_queue_control(p->subs[otherindex].owner, AST_CONTROL_UNHOLD);
                                                p->subs[otherindex].needunhold = 1;
                                                p->owner = p->subs[SUB_REAL].owner;
@@ -8817,7 +8810,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                                swap_subs(p, SUB_THREEWAY, SUB_REAL);
                                                ast_channel_softhangup_internal_flag_add(p->subs[SUB_THREEWAY].owner, AST_SOFTHANGUP_DEV);
                                                p->owner = p->subs[SUB_REAL].owner;
-                                               if (p->subs[SUB_REAL].owner && ast_bridged_channel(p->subs[SUB_REAL].owner))
+                                               if (p->subs[SUB_REAL].owner)
                                                        ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD);
                                                p->subs[SUB_REAL].needunhold = 1;
                                                dahdi_enable_ec(p);
@@ -9011,7 +9004,7 @@ static struct ast_frame *__dahdi_exception(struct ast_channel *ast)
                        (res != DAHDI_EVENT_HOOKCOMPLETE)) {
                        ast_debug(1, "Restoring owner of channel %d on event %d\n", p->channel, res);
                        p->owner = p->subs[SUB_REAL].owner;
-                       if (p->owner && ast_bridged_channel(p->owner))
+                       if (p->owner)
                                ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
                        p->subs[SUB_REAL].needunhold = 1;
                }
@@ -9056,8 +9049,7 @@ static struct ast_frame *__dahdi_exception(struct ast_channel *ast)
                                p->callwaitingrepeat = 0;
                                p->cidcwexpire = 0;
                                p->cid_suppress_expire = 0;
-                               if (ast_bridged_channel(p->owner))
-                                       ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
+                               ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
                                p->subs[SUB_REAL].needunhold = 1;
                        } else
                                ast_log(LOG_WARNING, "Absorbed on hook, but nobody is left!?!?\n");
@@ -10694,8 +10686,7 @@ static void *analog_ss_thread(void *data)
                                        swap_subs(p, SUB_REAL, SUB_THREEWAY);
                                        unalloc_sub(p, SUB_THREEWAY);
                                        p->owner = p->subs[SUB_REAL].owner;
-                                       if (ast_bridged_channel(p->subs[SUB_REAL].owner))
-                                               ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD);
+                                       ast_queue_control(p->subs[SUB_REAL].owner, AST_CONTROL_UNHOLD);
                                        ast_hangup(chan);
                                        goto quit;
                                } else {
index 593d033..7d34390 100644 (file)
@@ -1354,9 +1354,7 @@ int analog_hangup(struct analog_pvt *p, struct ast_channel *ast)
                                if (ast_channel_state(p->owner) != AST_STATE_UP) {
                                        ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_ANSWER);
                                }
-                               if (ast_bridged_channel(p->subs[ANALOG_SUB_REAL].owner)) {
-                                       ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_UNHOLD);
-                               }
+                               ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_UNHOLD);
                                /* Unlock the call-waiting call that we swapped to real-call. */
                                ast_channel_unlock(p->subs[ANALOG_SUB_REAL].owner);
                        } else if (p->subs[ANALOG_SUB_THREEWAY].allocd) {
@@ -1383,7 +1381,7 @@ int analog_hangup(struct analog_pvt *p, struct ast_channel *ast)
 
                                /* This is actually part of a three way, placed on hold.  Place the third part
                                   on music on hold now */
-                               if (p->subs[ANALOG_SUB_THREEWAY].owner && ast_bridged_channel(p->subs[ANALOG_SUB_THREEWAY].owner)) {
+                               if (p->subs[ANALOG_SUB_THREEWAY].owner) {
                                        ast_queue_control_data(p->subs[ANALOG_SUB_THREEWAY].owner, AST_CONTROL_HOLD,
                                                S_OR(p->mohsuggest, NULL),
                                                !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
@@ -1407,7 +1405,7 @@ int analog_hangup(struct analog_pvt *p, struct ast_channel *ast)
                                /* The other party of the three way call is currently in a call-wait state.
                                   Start music on hold for them, and take the main guy out of the third call */
                                analog_set_inthreeway(p, ANALOG_SUB_CALLWAIT, 0);
-                               if (p->subs[ANALOG_SUB_CALLWAIT].owner && ast_bridged_channel(p->subs[ANALOG_SUB_CALLWAIT].owner)) {
+                               if (p->subs[ANALOG_SUB_CALLWAIT].owner) {
                                        ast_queue_control_data(p->subs[ANALOG_SUB_CALLWAIT].owner, AST_CONTROL_HOLD,
                                                S_OR(p->mohsuggest, NULL),
                                                !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
@@ -2325,9 +2323,7 @@ static void *__analog_ss_thread(void *data)
                                        analog_swap_subs(p, ANALOG_SUB_REAL, ANALOG_SUB_THREEWAY);
                                        analog_unalloc_sub(p, ANALOG_SUB_THREEWAY);
                                        analog_set_new_owner(p, p->subs[ANALOG_SUB_REAL].owner);
-                                       if (ast_bridged_channel(p->subs[ANALOG_SUB_REAL].owner)) {
-                                               ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_UNHOLD);
-                                       }
+                                       ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_UNHOLD);
                                        ast_hangup(chan);
                                        goto quit;
                                } else {
@@ -3027,10 +3023,8 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                        case AST_STATE_UP:
                                /* Make sure it stops ringing */
                                analog_off_hook(p);
-                               /* Okay -- probably call waiting*/
-                               if (ast_bridged_channel(p->owner)) {
-                                       ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
-                               }
+                               /* Okay -- probably call waiting */
+                               ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
                                break;
                        case AST_STATE_RESERVED:
                                /* Start up dialtone */
@@ -3188,16 +3182,14 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                                analog_stop_callwait(p);
 
                                /* Start music on hold if appropriate */
-                               if (!p->subs[ANALOG_SUB_CALLWAIT].inthreeway && ast_bridged_channel(p->subs[ANALOG_SUB_CALLWAIT].owner)) {
+                               if (!p->subs[ANALOG_SUB_CALLWAIT].inthreeway) {
                                        ast_queue_control_data(p->subs[ANALOG_SUB_CALLWAIT].owner, AST_CONTROL_HOLD,
                                                S_OR(p->mohsuggest, NULL),
                                                !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
                                }
-                               if (ast_bridged_channel(p->subs[ANALOG_SUB_REAL].owner)) {
-                                       ast_queue_control_data(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_HOLD,
-                                               S_OR(p->mohsuggest, NULL),
-                                               !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
-                               }
+                               ast_queue_control_data(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_HOLD,
+                                       S_OR(p->mohsuggest, NULL),
+                                       !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
                                ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_UNHOLD);
 
                                /* Unlock the call-waiting call that we swapped to real-call. */
@@ -3289,12 +3281,10 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                                        } else {
                                                ast_verb(3, "Started three way call on channel %d\n", p->channel);
 
-                                               /* Start music on hold if appropriate */
-                                               if (ast_bridged_channel(p->subs[ANALOG_SUB_THREEWAY].owner)) {
-                                                       ast_queue_control_data(p->subs[ANALOG_SUB_THREEWAY].owner, AST_CONTROL_HOLD,
-                                                               S_OR(p->mohsuggest, NULL),
-                                                               !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
-                                               }
+                                               /* Start music on hold */
+                                               ast_queue_control_data(p->subs[ANALOG_SUB_THREEWAY].owner, AST_CONTROL_HOLD,
+                                                       S_OR(p->mohsuggest, NULL),
+                                                       !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
                                        }
                                        ast_callid_threadstorage_auto_clean(callid, callid_created);
                                }
@@ -3344,9 +3334,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                                                        analog_swap_subs(p, ANALOG_SUB_THREEWAY, ANALOG_SUB_REAL);
                                                        orig_3way_sub = ANALOG_SUB_REAL;
                                                }
-                                               if (ast_bridged_channel(p->subs[orig_3way_sub].owner)) {
-                                                       ast_queue_control(p->subs[orig_3way_sub].owner, AST_CONTROL_UNHOLD);
-                                               }
+                                               ast_queue_control(p->subs[orig_3way_sub].owner, AST_CONTROL_UNHOLD);
                                                analog_set_new_owner(p, p->subs[ANALOG_SUB_REAL].owner);
                                        } else {
                                                ast_verb(3, "Dumping incomplete call on %s\n", ast_channel_name(p->subs[ANALOG_SUB_THREEWAY].owner));
@@ -3354,9 +3342,7 @@ static struct ast_frame *__analog_handle_event(struct analog_pvt *p, struct ast_
                                                orig_3way_sub = ANALOG_SUB_REAL;
                                                ast_softhangup_nolock(p->subs[ANALOG_SUB_THREEWAY].owner, AST_SOFTHANGUP_DEV);
                                                analog_set_new_owner(p, p->subs[ANALOG_SUB_REAL].owner);
-                                               if (ast_bridged_channel(p->subs[ANALOG_SUB_REAL].owner)) {
-                                                       ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_UNHOLD);
-                                               }
+                                               ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_UNHOLD);
                                                analog_set_echocanceller(p, 1);
                                        }
                                }
@@ -3598,7 +3584,7 @@ struct ast_frame *analog_exception(struct analog_pvt *p, struct ast_channel *ast
                                ast_log(LOG_WARNING, "Event %s on %s is not restored owner %s\n",
                                        analog_event2str(res), ast_channel_name(ast), ast_channel_name(p->owner));
                        }
-                       if (p->owner && ast_bridged_channel(p->owner)) {
+                       if (p->owner) {
                                ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
                        }
                }
@@ -3638,9 +3624,7 @@ struct ast_frame *analog_exception(struct analog_pvt *p, struct ast_channel *ast
                                        ast_setstate(p->owner, AST_STATE_UP);
                                }
                                analog_stop_callwait(p);
-                               if (ast_bridged_channel(p->owner)) {
-                                       ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
-                               }
+                               ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
                        } else {
                                ast_log(LOG_WARNING, "Absorbed %s, but nobody is left!?!?\n",
                                        analog_event2str(res));