<p>Torrey Searle has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/6013">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res/res_stasis_snoop: generate silence when audiohook returns null<br><br>Currently when rtp is paused, no packets are written to the<br>recorded audio file, causing the silence to be skipped and recording<br>not properly time aligned.  The read handler as been adapted to<br>return a silence frame of the correct size.<br><br>ASTERISK-27128 #close<br><br>Change-Id: I2d7f60650457860b9c70907b14426756b058a844<br>---<br>M res/res_stasis_snoop.c<br>1 file changed, 21 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/13/6013/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_stasis_snoop.c b/res/res_stasis_snoop.c<br>index cd51638..f797a9b 100644<br>--- a/res/res_stasis_snoop.c<br>+++ b/res/res_stasis_snoop.c<br>@@ -72,6 +72,8 @@<br>   unsigned int whisper_active:1;<br>        /*! \brief Uniqueid of the channel this snoop is snooping on */<br>       char uniqueid[AST_MAX_UNIQUEID];<br>+     /*! \brief A frame of silence to use when the audiohook returns null */<br>+      struct ast_frame silence;<br> };<br> <br> /*! \brief Destructor for snoop structure */<br>@@ -89,6 +91,11 @@<br> <br>       if (snoop->whisper_active) {<br>               ast_audiohook_destroy(&snoop->whisper);<br>+       }<br>+<br>+ if (snoop->silence.data.ptr) {<br>+            ast_free(snoop->silence.data.ptr);<br>+                snoop->silence.data.ptr = NULL;<br>    }<br> <br>  ast_free(snoop->app);<br>@@ -197,7 +204,7 @@<br>         frame = ast_audiohook_read_frame(&snoop->spy, snoop->spy_samples, snoop->spy_direction, snoop->spy_format);<br>   ast_audiohook_unlock(&snoop->spy);<br> <br>- return frame ? frame : &ast_null_frame;<br>+  return frame ? frame : &snoop->silence;<br> }<br> <br> /*! \brief Callback function for hanging up a Snoop channel */<br>@@ -383,6 +390,19 @@<br> <br>               snoop->spy_samples = ast_format_get_sample_rate(snoop->spy_format) / (1000 / SNOOP_INTERVAL);<br>           snoop->spy_active = 1;<br>+<br>+         snoop->silence.frametype = AST_FRAME_VOICE,<br>+               snoop->silence.datalen = snoop->spy_samples * sizeof(uint16_t),<br>+                snoop->silence.samples = snoop->spy_samples,<br>+           snoop->silence.mallocd = 0,<br>+               snoop->silence.offset = 0,<br>+                snoop->silence.src = __PRETTY_FUNCTION__,<br>+         snoop->silence.subclass.format = snoop->spy_format,<br>+            snoop->silence.data.ptr = ast_calloc(snoop->spy_samples, sizeof(uint16_t));<br>+            if (!snoop->silence.data.ptr) {<br>+                   ast_hangup(snoop->chan);<br>+                  return NULL;<br>+         }<br>     }<br> <br>  /* If whispering is enabled set up the audiohook */<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6013">change 6013</a>. To unsubscribe, 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/6013"/><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-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I2d7f60650457860b9c70907b14426756b058a844 </div>
<div style="display:none"> Gerrit-Change-Number: 6013 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Torrey Searle <tsearle@gmail.com> </div>