<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13808">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_mixmonitor: Set MIXMONITOR_FILENAME to correct value when wav49 is used<br><br>When opening a file for writing, Asterisk silently converts filenames<br>ending with 'wav49' to 'WAV.' We aren't taking that in to account when<br>setting the MIXMONITOR_FILENAME variable in MixMonitor.<br><br>* If the user wants to write to a wav49 file, make sure that it is<br> reflected properly in MIXMONITOR_FILENAME.<br><br>* Add a note to the documentation describing this behavior.<br><br>ASTERISK-24695 #close<br>Reported by: xrobau<br><br>Change-Id: I384691ce624eb55c80a125b9ca206d2d691c574c<br>---<br>M apps/app_mixmonitor.c<br>1 file changed, 26 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/08/13808/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c</span><br><span>index ecb0830..ad3ac99 100644</span><br><span>--- a/apps/app_mixmonitor.c</span><br><span>+++ b/apps/app_mixmonitor.c</span><br><span>@@ -156,6 +156,11 @@</span><br><span> <para>This application does not automatically answer and should be preceeded by</span><br><span> an application such as Answer or Progress().</para></span><br><span> <note><para>MixMonitor runs as an audiohook.</para></note></span><br><span style="color: hsl(120, 100%, 40%);">+ <note><para>If a filename passed to MixMonitor ends with</span><br><span style="color: hsl(120, 100%, 40%);">+ <literal>.wav49</literal>, Asterisk will silently convert the extension to</span><br><span style="color: hsl(120, 100%, 40%);">+ <literal>.WAV</literal> for legacy reasons. <variable>MIXMONITOR_FILENAME</variable></span><br><span style="color: hsl(120, 100%, 40%);">+ will contain the actual filename that Asterisk is writing to, not necessarily the</span><br><span style="color: hsl(120, 100%, 40%);">+ value that was passed in.</para></note></span><br><span> <variablelist></span><br><span> <variable name="MIXMONITOR_FILENAME"></span><br><span> <para>Will contain the filename used to record.</para></span><br><span>@@ -1003,17 +1008,35 @@</span><br><span> static char *filename_parse(char *filename, char *buffer, size_t len)</span><br><span> {</span><br><span> char *slash;</span><br><span style="color: hsl(120, 100%, 40%);">+ char *ext;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_assert(len > 0);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (ast_strlen_zero(filename)) {</span><br><span> ast_log(LOG_WARNING, "No file name was provided for a file save option.\n");</span><br><span style="color: hsl(0, 100%, 40%);">- } else if (filename[0] != '/') {</span><br><span style="color: hsl(0, 100%, 40%);">- char *build;</span><br><span style="color: hsl(0, 100%, 40%);">- build = ast_alloca(strlen(ast_config_AST_MONITOR_DIR) + strlen(filename) + 3);</span><br><span style="color: hsl(120, 100%, 40%);">+ buffer[0] = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ return buffer;</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%);">+ /* If we don't have an absolute path, make one */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (*filename != '/') {</span><br><span style="color: hsl(120, 100%, 40%);">+ char *build = ast_alloca(strlen(ast_config_AST_MONITOR_DIR) + strlen(filename) + 3);</span><br><span> sprintf(build, "%s/%s", ast_config_AST_MONITOR_DIR, filename);</span><br><span> filename = build;</span><br><span> }</span><br><span> </span><br><span> ast_copy_string(buffer, filename, len);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* If the provided filename has a .wav49 extension, we need to convert it to .WAV to</span><br><span style="color: hsl(120, 100%, 40%);">+ match the behavior of build_filename in main/file.c. Otherwise MIXMONITOR_FILENAME</span><br><span style="color: hsl(120, 100%, 40%);">+ ends up referring to a file that does not/will not exist */</span><br><span style="color: hsl(120, 100%, 40%);">+ ext = strrchr(buffer, '.');</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ext && !strcmp(ext, ".wav49")) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Change to WAV - we know we have at least 6 writeable bytes where 'ext' points,</span><br><span style="color: hsl(120, 100%, 40%);">+ * so this is safe */</span><br><span style="color: hsl(120, 100%, 40%);">+ memcpy(ext, ".WAV", sizeof(".WAV"));</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if ((slash = strrchr(filename, '/'))) {</span><br><span> *slash = '\0';</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13808">change 13808</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/+/13808"/><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-Change-Id: I384691ce624eb55c80a125b9ca206d2d691c574c </div>
<div style="display:none"> Gerrit-Change-Number: 13808 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>