<p>Andre Barbosa has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/16180">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_stasis_playback: Check for chan hangup on play_on_channels<br><br>Verify `ast_check_hangup` before looping to the next sound file.<br>If the call is already hangup we just break the cycle.<br>It also ensures that the PlaybackFinished event is sent if the call was hangup.<br><br>This is also use-full when we are playing a big list of file for a channel that is hangup.<br>Before this patch Asterisk will give a warning for every sound not played and fire a PlaybackStart for every sound file on the list tried to be played.<br><br>With the patch we just break the playback cycle when the chan is hangup.<br><br>ASTERISK-29501 #close<br><br>Change-Id: Ic4e1c01b974c9a1f2d9678c9d6b380bcfc69feb8<br>---<br>M res/res_stasis_playback.c<br>1 file changed, 13 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/80/16180/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_stasis_playback.c b/res/res_stasis_playback.c</span><br><span>index 2013bb7..d558e18 100644</span><br><span>--- a/res/res_stasis_playback.c</span><br><span>+++ b/res/res_stasis_playback.c</span><br><span>@@ -261,13 +261,13 @@</span><br><span> }</span><br><span> </span><br><span> static void playback_final_update(struct stasis_app_playback *playback,</span><br><span style="color: hsl(0, 100%, 40%);">- long playedms, int res, const char *uniqueid)</span><br><span style="color: hsl(120, 100%, 40%);">+ long playedms, int res, int hangup, const char *uniqueid)</span><br><span> {</span><br><span> SCOPED_AO2LOCK(lock, playback);</span><br><span> </span><br><span> playback->playedms = playedms;</span><br><span> if (res == 0) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (playback->media_index == AST_VECTOR_SIZE(&playback->medias) - 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (playback->media_index == AST_VECTOR_SIZE(&playback->medias) - 1 || hangup ) {</span><br><span> playback->state = STASIS_PLAYBACK_STATE_COMPLETE;</span><br><span> } else {</span><br><span> playback->state = STASIS_PLAYBACK_STATE_CONTINUING;</span><br><span>@@ -279,7 +279,7 @@</span><br><span> } else {</span><br><span> ast_log(LOG_WARNING, "%s: Playback failed for %s\n",</span><br><span> uniqueid, playback->media);</span><br><span style="color: hsl(0, 100%, 40%);">- if (playback->media_index == AST_VECTOR_SIZE(&playback->medias) - 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (playback->media_index == AST_VECTOR_SIZE(&playback->medias) - 1 || hangup ) {</span><br><span> playback->state = STASIS_PLAYBACK_STATE_FAILED;</span><br><span> } else {</span><br><span> playback->state = STASIS_PLAYBACK_STATE_CONTINUING;</span><br><span>@@ -294,6 +294,7 @@</span><br><span> struct ast_channel *chan)</span><br><span> {</span><br><span> int res;</span><br><span style="color: hsl(120, 100%, 40%);">+ int hangup;</span><br><span> long offsetms;</span><br><span> size_t index;</span><br><span> </span><br><span>@@ -377,8 +378,16 @@</span><br><span> continue;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- playback_final_update(playback, offsetms, res,</span><br><span style="color: hsl(120, 100%, 40%);">+ hangup = ast_check_hangup(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ playback_final_update(playback, offsetms, res, hangup,</span><br><span> ast_channel_uniqueid(chan));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (hangup) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_DEBUG, "Channel: %s already hangup, stop playback\n", ast_channel_name(chan));</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (res == AST_CONTROL_STREAM_STOP) {</span><br><span> break;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/16180">change 16180</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/c/asterisk/+/16180"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Ic4e1c01b974c9a1f2d9678c9d6b380bcfc69feb8 </div>
<div style="display:none"> Gerrit-Change-Number: 16180 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Andre Barbosa <andre.emanuel.barbosa@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>