<p>Frederic LE FOLL has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/10022">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_musiconhold : MOH will not start if previous hold just reached end of file<br><br>On MOH activation, moh_files_readframe() is called while current stream<br>attached to channel is NULL and it calls ast_moh_files_next() immediatly,<br>but it won't call ast_moh_files_next() again if sample reading fails.<br>This may occur - because res_musiconhold retains last sample reading position in<br>the channel data - if MOH during previous hold/retrieve just reached end of file<br>(obviously, a bit of bad luck is required here).<br><br>This patch adds a preliminary control of ast_channel_state(chan), with a call to<br>ast_moh_files_next() if NULL. This leaves a chance for switching to next file<br>with the existing ast_moh_files_next() below, if sample reading fails.<br><br>ASTERISK-28029<br><br>Change-Id: I1508cf2c094f8feca22d6f76deaa9fdfa9944860<br>---<br>M res/res_musiconhold.c<br>1 file changed, 7 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/22/10022/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c</span><br><span>index 4d98f60..e255564 100644</span><br><span>--- a/res/res_musiconhold.c</span><br><span>+++ b/res/res_musiconhold.c</span><br><span>@@ -402,6 +402,13 @@</span><br><span> {</span><br><span>      struct ast_frame *f = NULL;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+       /* When activating MOH (i.e. current ast_channel_stream(chan) is NULL),</span><br><span style="color: hsl(120, 100%, 40%);">+        * call ast_moh_files_next() first. This will keep a chance for another</span><br><span style="color: hsl(120, 100%, 40%);">+        * file search if read fails (e.g. if current file just reached EOF</span><br><span style="color: hsl(120, 100%, 40%);">+    * due to previous reading). */</span><br><span style="color: hsl(120, 100%, 40%);">+       if (ast_channel_stream(chan) == NULL)</span><br><span style="color: hsl(120, 100%, 40%);">+         ast_moh_files_next(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  if (!(ast_channel_stream(chan) && (f = ast_readframe(ast_channel_stream(chan))))) {</span><br><span>          if (!ast_moh_files_next(chan))</span><br><span>                       f = ast_readframe(ast_channel_stream(chan));</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10022">change 10022</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/10022"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I1508cf2c094f8feca22d6f76deaa9fdfa9944860 </div>
<div style="display:none"> Gerrit-Change-Number: 10022 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Frederic LE FOLL <frederic.lefoll@c-s.fr> </div>