<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][15503] </title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=15503">15503</a></dd>
<dt>Author</dt> <dd>anthm</dd>
<dt>Date</dt> <dd>2009-11-17 15:40:09 -0600 (Tue, 17 Nov 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>add append and truncate to audio file api</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcincludeswitch_aprh">freeswitch/trunk/src/include/switch_apr.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_coreh">freeswitch/trunk/src/include/switch_core.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_module_interfacesh">freeswitch/trunk/src/include/switch_module_interfaces.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_typesh">freeswitch/trunk/src/include/switch_types.h</a></li>
<li><a href="#freeswitchtrunksrcmodformatsmod_native_filemod_native_filec">freeswitch/trunk/src/mod/formats/mod_native_file/mod_native_file.c</a></li>
<li><a href="#freeswitchtrunksrcmodformatsmod_shoutmod_shoutc">freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c</a></li>
<li><a href="#freeswitchtrunksrcmodformatsmod_sndfilemod_sndfilec">freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_spidermonkeymod_spidermonkeyc">freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_aprc">freeswitch/trunk/src/switch_apr.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_filec">freeswitch/trunk/src/switch_core_file.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_cppcpp">freeswitch/trunk/src/switch_cpp.cpp</a></li>
<li><a href="#freeswitchtrunksrcswitch_ivr_asyncc">freeswitch/trunk/src/switch_ivr_async.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_ivr_play_sayc">freeswitch/trunk/src/switch_ivr_play_say.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcincludeswitch_aprh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_apr.h (15502 => 15503)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_apr.h        2009-11-17 21:29:33 UTC (rev 15502)
+++ freeswitch/trunk/src/include/switch_apr.h        2009-11-17 21:40:09 UTC (rev 15503)
</span><span class="lines">@@ -786,6 +786,8 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_file_close(switch_file_t *thefile);
</span><span class="cx">
</span><ins>+SWITCH_DECLARE(switch_status_t) switch_file_trunc(switch_file_t *thefile, int64_t offset);
+
</ins><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_file_lock(switch_file_t *thefile, int type);
</span><span class="cx">
</span><span class="cx"> /**
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_coreh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_core.h (15502 => 15503)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_core.h        2009-11-17 21:29:33 UTC (rev 15502)
+++ freeswitch/trunk/src/include/switch_core.h        2009-11-17 21:40:09 UTC (rev 15503)
</span><span class="lines">@@ -1505,6 +1505,10 @@
</span><span class="cx"> \return SWITCH_STATUS_SUCCESS if the file handle was closed
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_core_file_close(_In_ switch_file_handle_t *fh);
</span><ins>+
+SWITCH_DECLARE(switch_status_t) switch_core_file_truncate(switch_file_handle_t *fh, int64_t offset);
+
+
</ins><span class="cx"> ///\}
</span><span class="cx">
</span><span class="cx"> ///\defgroup speech ASR/TTS Functions
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_module_interfacesh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_module_interfaces.h (15502 => 15503)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_module_interfaces.h        2009-11-17 21:29:33 UTC (rev 15502)
+++ freeswitch/trunk/src/include/switch_module_interfaces.h        2009-11-17 21:40:09 UTC (rev 15503)
</span><span class="lines">@@ -262,6 +262,8 @@
</span><span class="cx">         switch_status_t (*file_open) (switch_file_handle_t *, const char *file_path);
</span><span class="cx">         /*! function to close the file */
</span><span class="cx">         switch_status_t (*file_close) (switch_file_handle_t *);
</span><ins>+        /*! function to close the file */
+        switch_status_t (*file_truncate) (switch_file_handle_t *, int64_t offset);
</ins><span class="cx">         /*! function to read from the file */
</span><span class="cx">         switch_status_t (*file_read) (switch_file_handle_t *, void *data, switch_size_t *len);
</span><span class="cx">         /*! function to write from the file */
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_typesh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_types.h (15502 => 15503)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_types.h        2009-11-17 21:29:33 UTC (rev 15502)
+++ freeswitch/trunk/src/include/switch_types.h        2009-11-17 21:40:09 UTC (rev 15503)
</span><span class="lines">@@ -1166,7 +1166,8 @@
</span><span class="cx">         SWITCH_FILE_OPEN = (1 << 11),
</span><span class="cx">         SWITCH_FILE_CALLBACK = (1 << 12),
</span><span class="cx">         SWITCH_FILE_DONE = (1 << 13),
</span><del>-        SWITCH_FILE_BUFFER_DONE = (1 << 14)
</del><ins>+        SWITCH_FILE_BUFFER_DONE = (1 << 14),
+        SWITCH_FILE_WRITE_APPEND = (1 << 15)
</ins><span class="cx"> } switch_file_flag_enum_t;
</span><span class="cx"> typedef uint32_t switch_file_flag_t;
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodformatsmod_native_filemod_native_filec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/formats/mod_native_file/mod_native_file.c (15502 => 15503)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/formats/mod_native_file/mod_native_file.c        2009-11-17 21:29:33 UTC (rev 15502)
+++ freeswitch/trunk/src/mod/formats/mod_native_file/mod_native_file.c        2009-11-17 21:40:09 UTC (rev 15503)
</span><span class="lines">@@ -57,7 +57,13 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) {
</span><del>-                flags |= SWITCH_FOPEN_WRITE | SWITCH_FOPEN_CREATE | SWITCH_FOPEN_TRUNCATE;
</del><ins>+                flags |= SWITCH_FOPEN_WRITE | SWITCH_FOPEN_CREATE;
+                if (switch_test_flag(handle, SWITCH_FILE_WRITE_APPEND)) {
+                        flags |= SWITCH_FOPEN_READ;
+                } else {
+                        flags |= SWITCH_FOPEN_TRUNCATE;
+                }
+
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (switch_test_flag(handle, SWITCH_FILE_FLAG_READ)) {
</span><span class="lines">@@ -69,6 +75,12 @@
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        if (switch_test_flag(handle, SWITCH_FILE_WRITE_APPEND)) {
+                int64_t samples = 0;
+                switch_file_seek(context->fd, SEEK_END, &samples);
+                handle->pos = samples;
+        }
+
</ins><span class="cx">         handle->samples = 0;
</span><span class="cx">         handle->samplerate = 8000;
</span><span class="cx">         handle->channels = 1;
</span><span class="lines">@@ -84,6 +96,19 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static switch_status_t native_file_file_truncate(switch_file_handle_t *handle, int64_t offset)
+{
+        native_file_context *context = handle->private_info;
+        switch_status_t status;
+
+        if ((status = switch_file_trunc(context->fd, offset)) == SWITCH_STATUS_SUCCESS) {
+                handle->pos = 0;
+        }
+        
+        return status;
+
+}
+
</ins><span class="cx"> static switch_status_t native_file_file_close(switch_file_handle_t *handle)
</span><span class="cx"> {
</span><span class="cx">         native_file_context *context = handle->private_info;
</span><span class="lines">@@ -161,6 +186,7 @@
</span><span class="cx">         file_interface->extens = supported_formats;
</span><span class="cx">         file_interface->file_open = native_file_file_open;
</span><span class="cx">         file_interface->file_close = native_file_file_close;
</span><ins>+        file_interface->file_truncate = native_file_file_truncate;
</ins><span class="cx">         file_interface->file_read = native_file_file_read;
</span><span class="cx">         file_interface->file_write = native_file_file_write;
</span><span class="cx">         file_interface->file_seek = native_file_file_seek;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodformatsmod_shoutmod_shoutc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c (15502 => 15503)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c        2009-11-17 21:29:33 UTC (rev 15502)
+++ freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c        2009-11-17 21:40:09 UTC (rev 15503)
</span><span class="lines">@@ -626,6 +626,9 @@
</span><span class="cx">
</span><span class="cx">                 }
</span><span class="cx">         } else if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) {
</span><ins>+                if (switch_test_flag(handle, SWITCH_FILE_WRITE_APPEND)) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Appending to MP3 not supported.\n");
+                }
</ins><span class="cx">                 if (!(context->gfp = lame_init())) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not allocate lame\n");
</span><span class="cx">                         goto error;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodformatsmod_sndfilemod_sndfilec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c (15502 => 15503)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c        2009-11-17 21:29:33 UTC (rev 15502)
+++ freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c        2009-11-17 21:40:09 UTC (rev 15503)
</span><span class="lines">@@ -83,7 +83,11 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) {
</span><del>-                mode += SFM_WRITE;
</del><ins>+                if (switch_test_flag(handle, SWITCH_FILE_WRITE_APPEND)) {
+                        mode += SFM_RDWR;
+                } else {
+                        mode += SFM_WRITE;
+                }
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!mode) {
</span><span class="lines">@@ -98,8 +102,6 @@
</span><span class="cx">         map = switch_core_hash_find(globals.format_hash, ext);
</span><span class="cx">
</span><span class="cx">         if (mode & SFM_WRITE) {
</span><del>-                sf_count_t frames = 0;
-
</del><span class="cx">                 context->sfinfo.channels = handle->channels;
</span><span class="cx">                 context->sfinfo.samplerate = handle->samplerate;
</span><span class="cx">                 if (handle->samplerate == 8000 || handle->samplerate == 16000 ||
</span><span class="lines">@@ -107,8 +109,6 @@
</span><span class="cx">                         handle->samplerate == 11025 || handle->samplerate == 22050 || handle->samplerate == 44100) {
</span><span class="cx">                         context->sfinfo.format |= SF_FORMAT_PCM_16;
</span><span class="cx">                 }
</span><del>-
-                sf_command(context->handle, SFC_FILE_TRUNCATE, &frames, sizeof(frames));
</del><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (map) {
</span><span class="lines">@@ -206,6 +206,14 @@
</span><span class="cx">         handle->speed = 0;
</span><span class="cx">         handle->private_info = context;
</span><span class="cx">
</span><ins>+        if (switch_test_flag(handle, SWITCH_FILE_WRITE_APPEND)) {
+                handle->pos = sf_seek(context->handle, 0, SEEK_END);
+        } else {
+                sf_count_t frames = 0;
+                sf_command(context->handle, SFC_FILE_TRUNCATE, &frames, sizeof(frames));
+        }
+
+
</ins><span class="cx"> end:
</span><span class="cx">
</span><span class="cx">         switch_safe_free(alt_path);
</span><span class="lines">@@ -214,6 +222,14 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static switch_status_t sndfile_file_truncate(switch_file_handle_t *handle, int64_t offset)
+{
+        sndfile_context *context = handle->private_info;
+        sf_command(context->handle, SFC_FILE_TRUNCATE, &offset, sizeof(offset));
+        handle->pos = 0;
+        return SWITCH_STATUS_SUCCESS;
+}
+
</ins><span class="cx"> static switch_status_t sndfile_file_close(switch_file_handle_t *handle)
</span><span class="cx"> {
</span><span class="cx">         sndfile_context *context = handle->private_info;
</span><span class="lines">@@ -416,6 +432,7 @@
</span><span class="cx">         file_interface->extens = supported_formats;
</span><span class="cx">         file_interface->file_open = sndfile_file_open;
</span><span class="cx">         file_interface->file_close = sndfile_file_close;
</span><ins>+        file_interface->file_truncate = sndfile_file_truncate;
</ins><span class="cx">         file_interface->file_read = sndfile_file_read;
</span><span class="cx">         file_interface->file_write = sndfile_file_write;
</span><span class="cx">         file_interface->file_seek = sndfile_file_seek;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_spidermonkeymod_spidermonkeyc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (15502 => 15503)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c        2009-11-17 21:29:33 UTC (rev 15502)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c        2009-11-17 21:40:09 UTC (rev 15503)
</span><span class="lines">@@ -1247,6 +1247,8 @@
</span><span class="cx">                                 switch_set_flag(fh, SWITCH_FILE_PAUSE);
</span><span class="cx">                         }
</span><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><ins>+                } else if (!strcasecmp(ret, "truncate")) {
+                        switch_core_file_truncate(fh, 0);
</ins><span class="cx">                 } else if (!strcasecmp(ret, "restart")) {
</span><span class="cx">                         uint32_t pos = 0;
</span><span class="cx">                         fh->speed = 0;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_aprc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_apr.c (15502 => 15503)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_apr.c        2009-11-17 21:29:33 UTC (rev 15502)
+++ freeswitch/trunk/src/switch_apr.c        2009-11-17 21:40:09 UTC (rev 15503)
</span><span class="lines">@@ -420,6 +420,11 @@
</span><span class="cx">         return apr_file_close(thefile);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+SWITCH_DECLARE(switch_status_t) switch_file_trunc(switch_file_t *thefile, int64_t offset)
+{
+        return apr_file_trunc(thefile, offset);
+}
+
</ins><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_file_lock(switch_file_t *thefile, int type)
</span><span class="cx"> {
</span><span class="cx">         return apr_file_lock(thefile, type);
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_filec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_file.c (15502 => 15503)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_file.c        2009-11-17 21:29:33 UTC (rev 15502)
+++ freeswitch/trunk/src/switch_core_file.c        2009-11-17 21:40:09 UTC (rev 15503)
</span><span class="lines">@@ -475,6 +475,36 @@
</span><span class="cx">         return fh->file_interface->file_get_string(fh, col, string);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+SWITCH_DECLARE(switch_status_t) switch_core_file_truncate(switch_file_handle_t *fh, int64_t offset)
+{
+        switch_status_t status;
+        
+        switch_assert(fh != NULL);
+        switch_assert(fh->file_interface != NULL);
+
+        if (!(switch_test_flag(fh, SWITCH_FILE_OPEN) && switch_test_flag(fh, SWITCH_FILE_FLAG_WRITE))) {
+                return SWITCH_STATUS_FALSE;
+        }
+
+        if (!fh->file_interface->file_truncate) {
+                return SWITCH_STATUS_FALSE;
+        }
+
+        if ((status=fh->file_interface->file_truncate(fh, offset)) == SWITCH_STATUS_SUCCESS) {
+                if (fh->buffer) {
+                        switch_buffer_zero(fh->buffer);
+                }
+                if (fh->pre_buffer) {
+                        switch_buffer_zero(fh->pre_buffer);
+                }
+                fh->samples_out = 0;
+                fh->pos = 0;
+        }
+
+        return status;
+
+}
+
</ins><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_core_file_close(switch_file_handle_t *fh)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_cppcpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_cpp.cpp (15502 => 15503)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_cpp.cpp        2009-11-17 21:29:33 UTC (rev 15502)
+++ freeswitch/trunk/src/switch_cpp.cpp        2009-11-17 21:40:09 UTC (rev 15503)
</span><span class="lines">@@ -1275,6 +1275,8 @@
</span><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 } else if (!strcasecmp(result, "stop")) {
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><ins>+                } else if (!strcasecmp(result, "truncate")) {
+                        switch_core_file_truncate(fhp, 0);
</ins><span class="cx">                 } else if (!strcasecmp(result, "restart")) {
</span><span class="cx">                         unsigned int pos = 0;
</span><span class="cx">                         fhp->speed = 0;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_ivr_asyncc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_ivr_async.c (15502 => 15503)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_ivr_async.c        2009-11-17 21:29:33 UTC (rev 15502)
+++ freeswitch/trunk/src/switch_ivr_async.c        2009-11-17 21:40:09 UTC (rev 15503)
</span><span class="lines">@@ -879,7 +879,8 @@
</span><span class="cx">         uint8_t channels;
</span><span class="cx">         switch_codec_implementation_t read_impl = {0};
</span><span class="cx">         struct record_helper *rh = NULL;
</span><del>-
</del><ins>+        int file_flags = SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT;
+        
</ins><span class="cx"> switch_core_session_get_read_impl(session, &read_impl);
</span><span class="cx">
</span><span class="cx">         if ((status = switch_channel_pre_answer(channel)) != SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -922,7 +923,11 @@
</span><span class="cx">                 flags |= SMBF_ANSWER_REQ;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        if ((p = switch_channel_get_variable(channel, "RECORD_APPEND")) && switch_true(p)) {
+                file_flags |= SWITCH_FILE_WRITE_APPEND;
+        }
</ins><span class="cx">
</span><ins>+
</ins><span class="cx">         fh->samplerate = 0;
</span><span class="cx">         if ((vval = switch_channel_get_variable(channel, "record_sample_rate"))) {
</span><span class="cx">                 int tmp = 0;
</span><span class="lines">@@ -971,7 +976,7 @@
</span><span class="cx">                                                          file,
</span><span class="cx">                                                          channels,
</span><span class="cx">                                                          read_impl.actual_samples_per_second,
</span><del>-                                                         SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                         file_flags, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error opening %s\n", file);
</span><span class="cx">                 switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="cx">                 switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_ivr_play_sayc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_ivr_play_say.c (15502 => 15503)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_ivr_play_say.c        2009-11-17 21:29:33 UTC (rev 15502)
+++ freeswitch/trunk/src/switch_ivr_play_say.c        2009-11-17 21:40:09 UTC (rev 15503)
</span><span class="lines">@@ -398,6 +398,7 @@
</span><span class="cx">         unsigned char write_buf[SWITCH_RECOMMENDED_BUFFER_SIZE] = { 0 };
</span><span class="cx">         switch_event_t *event;
</span><span class="cx">         int divisor = 0;
</span><ins>+        int file_flags = SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT;
</ins><span class="cx">
</span><span class="cx"> switch_core_session_get_read_impl(session, &read_impl);
</span><span class="cx">
</span><span class="lines">@@ -505,11 +506,16 @@
</span><span class="cx">                 fh->pre_buffer_datalen = SWITCH_DEFAULT_FILE_BUFFER_LEN;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        if ((p = switch_channel_get_variable(channel, "RECORD_APPEND")) && switch_true(p)) {
+                file_flags |= SWITCH_FILE_WRITE_APPEND;
+        }
+
+
</ins><span class="cx">         if (switch_core_file_open(fh,
</span><span class="cx">                                                          file,
</span><span class="cx">                                                          fh->channels,
</span><span class="cx">                                                          read_impl.actual_samples_per_second,
</span><del>-                                                         SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                         file_flags, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="cx">                 switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>