[asterisk-dev] channel on hold

Clod Patry cpatry at gmail.com
Wed Aug 22 08:11:54 CDT 2007


i'd like to know if there's a much cleaner way to know if a specific chan is
on hold.
The goal behind is simpler: make a new CLI command to list all the channels
that are currently on hold.

Based on that, i could use the ast_channel struct with music_state, since
all on hold starts it, right (if res_musiconhold.so is loaded) ?
Something like:
if ( chan->music_state) {
   //the call is onhold
}

if yes, I've noticed the chan->music_state stays there, even after the chan
has been taken back from hold.
Why the chan->music_state still allocated after the channel has been taken
back from hold? To resume the MOH where it has been left the previous time?

before posting my patch for this new cli command, i'd like some feedback.

Here's the patch to clean the chan->music_state. is that viable?
Index: res/res_musiconhold.c
===================================================================
--- res/res_musiconhold.c       (revision 80239)
+++ res/res_musiconhold.c       (working copy)
@@ -214,6 +214,7 @@
                        ast_log(LOG_WARNING, "Unable to restore channel '%s'
to format '%d'\n", chan->name, state->origwfmt);
                }
                state->save_pos = state->pos;
+               chan->music_state = NULL;
        }
        if (state->class->delete &&
ast_atomic_dec_and_test(&state->class->inuse))
                ast_moh_destroy_one(state->class);
@@ -700,6 +701,7 @@
                        ast_log(LOG_WARNING, "Unable to restore channel '%s'
to format %s\n", chan->name, ast_getformatname(oldwfmt));
                if (option_verbose > 2)
                        ast_verbose(VERBOSE_PREFIX_3 "Stopped music on hold
on %s\n", chan->name);
+               chan->music_state = NULL;
        }
 }


-- 
Clod Patry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20070822/ef49547a/attachment-0001.htm 


More information about the asterisk-dev mailing list