<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/10022">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Frederic LE FOLL: Looks good to me, but someone else must approve
Michael L. Young: Looks good to me, but someone else must approve
Matthew Fredrickson: Looks good to me, approved
Jenkins2: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_musiconhold.c: Restart MOH if previous hold just reached end-of-file<br><br>On MOH activation, moh_files_readframe() is called while the current<br>stream attached to the channel is NULL and it calls ast_moh_files_next()<br>immediately. However, it won't call ast_moh_files_next() again if sample<br>reading fails. The failure may occur because res_musiconhold retains the<br>last sample reading position in the channel data and MOH during the<br>previous hold/retrieve just reached EOF. Obviously, a bit of bad luck is<br>required here.<br><br>* Restructured moh_files_readframe() to try a second time to start MOH if<br>there was no stream setup and the saved position was at EOF. Also added<br>comments describing what is going on for each step.<br><br>ASTERISK-28029<br><br>Change-Id: I1508cf2c094f8feca22d6f76deaa9fdfa9944860<br>---<br>M res/res_musiconhold.c<br>1 file changed, 20 insertions(+), 3 deletions(-)<br><br></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..9bb9a8d 100644</span><br><span>--- a/res/res_musiconhold.c</span><br><span>+++ b/res/res_musiconhold.c</span><br><span>@@ -400,11 +400,28 @@</span><br><span> </span><br><span> static struct ast_frame *moh_files_readframe(struct ast_channel *chan)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- struct ast_frame *f = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_frame *f;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!(ast_channel_stream(chan) && (f = ast_readframe(ast_channel_stream(chan))))) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (!ast_moh_files_next(chan))</span><br><span style="color: hsl(120, 100%, 40%);">+ f = ast_readframe(ast_channel_stream(chan));</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!f) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Either there was no file stream setup or we reached EOF. */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_moh_files_next(chan)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /*</span><br><span style="color: hsl(120, 100%, 40%);">+ * Either we resetup the previously saved file stream position</span><br><span style="color: hsl(120, 100%, 40%);">+ * or we started a new file stream.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span> f = ast_readframe(ast_channel_stream(chan));</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!f) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /*</span><br><span style="color: hsl(120, 100%, 40%);">+ * We can get here if we were very unlucky because the</span><br><span style="color: hsl(120, 100%, 40%);">+ * resetup file stream was saved at EOF when MOH was</span><br><span style="color: hsl(120, 100%, 40%);">+ * previously stopped.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_moh_files_next(chan)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ f = ast_readframe(ast_channel_stream(chan));</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> </span><br><span> return f;</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: merged </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: 2 </div>
<div style="display:none"> Gerrit-Owner: Frederic LE FOLL <frederic.lefoll@c-s.fr> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Frederic LE FOLL <frederic.lefoll@c-s.fr> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Matthew Fredrickson <creslin@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Michael L. Young <elgueromexicano@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>