<p>Andre Barbosa has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15987">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_stasis_playback<br><br>When we try to play a list of sound files in the same Play command, we get only one PlaybackFinish event, after all sounds are played.<br><br>But in the case where the Play fails (because channel is destroyed for example), Asterisk will send one PlaybackFinish event for each sound file still to be played. If the list is big, Asterisk is sending lot of events.<br><br>This patch adds STASIS_PLAYBACK_STATE_ERROR state so we can understand that the play failed. On that case we don't send the event, if we still have a list of sounds to be played.<br><br>When we reach the last sound, we fired the PlaybackFinish with the error state.<br><br>ASTERISK-29464 #close<br><br>Change-Id: I4c2e5921cc597702513af0d7c6c2c982e1798322<br>---<br>M include/asterisk/stasis_app_playback.h<br>M res/res_stasis_playback.c<br>2 files changed, 13 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/87/15987/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/asterisk/stasis_app_playback.h b/include/asterisk/stasis_app_playback.h</span><br><span>index 0038fd6..110a516 100644</span><br><span>--- a/include/asterisk/stasis_app_playback.h</span><br><span>+++ b/include/asterisk/stasis_app_playback.h</span><br><span>@@ -45,6 +45,8 @@</span><br><span>         STASIS_PLAYBACK_STATE_CONTINUING,</span><br><span>    /*! The media has stopped playing */</span><br><span>         STASIS_PLAYBACK_STATE_COMPLETE,</span><br><span style="color: hsl(120, 100%, 40%);">+       /*! The media has stopped because of an error playing the file */</span><br><span style="color: hsl(120, 100%, 40%);">+     STASIS_PLAYBACK_STATE_ERROR,</span><br><span>         /*! The playback was canceled. */</span><br><span>    STASIS_PLAYBACK_STATE_CANCELED,</span><br><span>      /*! The playback was stopped. */</span><br><span>diff --git a/res/res_stasis_playback.c b/res/res_stasis_playback.c</span><br><span>index d60a49a..f479a38 100644</span><br><span>--- a/res/res_stasis_playback.c</span><br><span>+++ b/res/res_stasis_playback.c</span><br><span>@@ -107,6 +107,8 @@</span><br><span>              type = "PlaybackContinuing";</span><br><span>       } else if (!strcmp(state, "done")) {</span><br><span>               type = "PlaybackFinished";</span><br><span style="color: hsl(120, 100%, 40%);">+  } else if (!strcmp(state, "error")) {</span><br><span style="color: hsl(120, 100%, 40%);">+               type = "PlaybackFinished";            </span><br><span>     } else {</span><br><span>             return NULL;</span><br><span>         }</span><br><span>@@ -202,6 +204,8 @@</span><br><span>              return "paused";</span><br><span>   case STASIS_PLAYBACK_STATE_CONTINUING:</span><br><span>               return "continuing";</span><br><span style="color: hsl(120, 100%, 40%);">+        case STASIS_PLAYBACK_STATE_ERROR:</span><br><span style="color: hsl(120, 100%, 40%);">+             return "error";               </span><br><span>     case STASIS_PLAYBACK_STATE_STOPPED:</span><br><span>  case STASIS_PLAYBACK_STATE_COMPLETE:</span><br><span>         case STASIS_PLAYBACK_STATE_CANCELED:</span><br><span>@@ -275,7 +279,12 @@</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%);">-                  playback->state = STASIS_PLAYBACK_STATE_STOPPED;</span><br><span style="color: hsl(120, 100%, 40%);">+                           </span><br><span style="color: hsl(120, 100%, 40%);">+                      if (playback->media_index == AST_VECTOR_SIZE(&playback->medias) - 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+                              playback->state = STASIS_PLAYBACK_STATE_ERROR;</span><br><span style="color: hsl(120, 100%, 40%);">+                     } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                              playback->state = STASIS_PLAYBACK_STATE_CONTINUING;</span><br><span style="color: hsl(120, 100%, 40%);">+                        }</span><br><span>            }</span><br><span>    }</span><br><span> </span><br><span>@@ -701,6 +710,7 @@</span><br><span>  [STASIS_PLAYBACK_STATE_PAUSED][STASIS_PLAYBACK_UNPAUSE] = playback_unpause,</span><br><span> </span><br><span>      [STASIS_PLAYBACK_STATE_COMPLETE][STASIS_PLAYBACK_STOP] = playback_noop,</span><br><span style="color: hsl(120, 100%, 40%);">+       [STASIS_PLAYBACK_STATE_ERROR][STASIS_PLAYBACK_STOP] = playback_noop,</span><br><span>         [STASIS_PLAYBACK_STATE_CANCELED][STASIS_PLAYBACK_STOP] = playback_noop,</span><br><span>      [STASIS_PLAYBACK_STATE_STOPPED][STASIS_PLAYBACK_STOP] = playback_noop,</span><br><span> };</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15987">change 15987</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/+/15987"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I4c2e5921cc597702513af0d7c6c2c982e1798322 </div>
<div style="display:none"> Gerrit-Change-Number: 15987 </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>