i&#39;d like to know if there&#39;s a much cleaner way to know if a specific chan is on hold.<br>The goal behind is simpler: make a new CLI command to list all the channels that are currently on hold.<br><br>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) ?
<br>Something like:<br>if ( chan-&gt;music_state) {<br>&nbsp;&nbsp; //the call is onhold<br>}<br><br>if yes, I&#39;ve noticed the chan-&gt;music_state stays there, even after the chan has been taken back from hold.<br>Why the chan-&gt;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?
<br><br>before posting my patch for this new cli command, i&#39;d like some feedback.<br><br>Here&#39;s the patch to clean the chan-&gt;music_state. is that viable?<br>Index: res/res_musiconhold.c<br>===================================================================
<br>--- res/res_musiconhold.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (revision 80239)<br>+++ res/res_musiconhold.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (working copy)<br>@@ -214,6 +214,7 @@<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ast_log(LOG_WARNING, &quot;Unable to restore channel &#39;%s&#39; to format &#39;%d&#39;\n&quot;, chan-&gt;name, state-&gt;origwfmt);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state-&gt;save_pos = state-&gt;pos;<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chan-&gt;music_state = NULL;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (state-&gt;class-&gt;delete &amp;&amp; ast_atomic_dec_and_test(&amp;state-&gt;class-&gt;inuse))
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ast_moh_destroy_one(state-&gt;class);<br>@@ -700,6 +701,7 @@<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ast_log(LOG_WARNING, &quot;Unable to restore channel &#39;%s&#39; to format %s\n&quot;, chan-&gt;name, ast_getformatname(oldwfmt));
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (option_verbose &gt; 2)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ast_verbose(VERBOSE_PREFIX_3 &quot;Stopped music on hold on %s\n&quot;, chan-&gt;name);<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chan-&gt;music_state = NULL;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br>&nbsp;}<br><br clear="all"><br>-- <br>Clod Patry