<!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][14331] </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=14331">14331</a></dd>
<dt>Author</dt> <dd>anthm</dd>
<dt>Date</dt> <dd>2009-07-23 10:55:13 -0500 (Thu, 23 Jul 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre><a href="http://jira.freeswitch.org/browse/FSCORE-403">FSCORE-403</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcincludeswitch_resampleh">freeswitch/trunk/src/include/switch_resample.h</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_conferencemod_conferencec">freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_filec">freeswitch/trunk/src/switch_core_file.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_ioc">freeswitch/trunk/src/switch_core_io.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_speechc">freeswitch/trunk/src/switch_core_speech.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_resamplec">freeswitch/trunk/src/switch_resample.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcincludeswitch_resampleh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_resample.h (14330 => 14331)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_resample.h        2009-07-23 15:49:00 UTC (rev 14330)
+++ freeswitch/trunk/src/include/switch_resample.h        2009-07-23 15:55:13 UTC (rev 14331)
</span><span class="lines">@@ -80,10 +80,11 @@
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_resample_perform_create(switch_audio_resampler_t **new_resampler,
</span><span class="cx">                                                                                                                          uint32_t from_rate, uint32_t to_rate, uint32_t to_size,
</span><span class="cx">                                                                                                                          int quality,
</span><ins>+                                                                                                                         uint32_t channels,
</ins><span class="cx">                                                                                                                          const char *file, const char *func, int line);
</span><span class="cx">
</span><span class="cx">
</span><del>-#define switch_resample_create(_n, _fr, _tr, _ts, _q) switch_resample_perform_create(_n, _fr, _tr, _ts, _q, __FILE__, __SWITCH_FUNC__, __LINE__)
</del><ins>+#define switch_resample_create(_n, _fr, _tr, _ts, _q, _c) switch_resample_perform_create(_n, _fr, _tr, _ts, _q, _c, __FILE__, __SWITCH_FUNC__, __LINE__)
</ins><span class="cx">
</span><span class="cx"> /*!
</span><span class="cx"> \brief Destroy an existing resampler handle
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_conferencemod_conferencec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (14330 => 14331)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c        2009-07-23 15:49:00 UTC (rev 14330)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c        2009-07-23 15:55:13 UTC (rev 14331)
</span><span class="lines">@@ -4795,7 +4795,7 @@
</span><span class="cx">         if (read_impl.actual_samples_per_second != conference->rate) {
</span><span class="cx">                 if (switch_resample_create(&member->read_resampler,
</span><span class="cx">                                                                  read_impl.actual_samples_per_second,
</span><del>-                                                                 conference->rate, member->frame_size, SWITCH_RESAMPLE_QUALITY) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                 conference->rate, member->frame_size, SWITCH_RESAMPLE_QUALITY, 1) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to create resampler!\n");
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_filec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_file.c (14330 => 14331)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_file.c        2009-07-23 15:49:00 UTC (rev 14330)
+++ freeswitch/trunk/src/switch_core_file.c        2009-07-23 15:55:13 UTC (rev 14331)
</span><span class="lines">@@ -123,6 +123,12 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        if (fh->pre_buffer_datalen) {
+                //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Prebuffering %d bytes\n", (int)fh->pre_buffer_datalen);
+                switch_buffer_create_dynamic(&fh->pre_buffer, fh->pre_buffer_datalen * fh->channels, fh->pre_buffer_datalen * fh->channels / 2, 0);
+                fh->pre_buffer_data = switch_core_alloc(fh->memory_pool, fh->pre_buffer_datalen * fh->channels);
+        }
+
</ins><span class="cx">         if (fh->channels > 1 && (flags & SWITCH_FILE_FLAG_READ)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "File has %d channels, muxing to mono will occur.\n", fh->channels);
</span><span class="cx">         }
</span><span class="lines">@@ -212,7 +218,7 @@
</span><span class="cx">         if (!switch_test_flag(fh, SWITCH_FILE_NATIVE) && fh->native_rate != fh->samplerate) {
</span><span class="cx">                 if (!fh->resampler) {
</span><span class="cx">                         if (switch_resample_create(&fh->resampler,
</span><del>-                                                                         fh->native_rate, fh->samplerate, (uint32_t) orig_len, SWITCH_RESAMPLE_QUALITY) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                         fh->native_rate, fh->samplerate, (uint32_t) orig_len, SWITCH_RESAMPLE_QUALITY, 1) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to create resampler!\n");
</span><span class="cx">                                 return SWITCH_STATUS_GENERR;
</span><span class="cx">                         }
</span><span class="lines">@@ -273,31 +279,31 @@
</span><span class="cx">                         if (switch_resample_create(&fh->resampler,
</span><span class="cx">                                                                          fh->native_rate,
</span><span class="cx">                                                                          fh->samplerate,
</span><del>-                                                                         (uint32_t) orig_len *fh->channels,
-                                                                         SWITCH_RESAMPLE_QUALITY) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                         (uint32_t) orig_len * 2 * fh->channels,
+                                                                         SWITCH_RESAMPLE_QUALITY, fh->channels) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to create resampler!\n");
</span><span class="cx">                                 return SWITCH_STATUS_GENERR;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                switch_resample_process(fh->resampler, data, (uint32_t)(*len * fh->channels));
</del><span class="cx">
</span><del>-                if (fh->resampler->to_len > orig_len * fh->channels) {
</del><ins>+                switch_resample_process(fh->resampler, data, (uint32_t)*len);
+                
+                if (fh->resampler->to_len > orig_len) {
</ins><span class="cx">                         if (!fh->dbuf) {
</span><span class="cx">                                 void *mem;
</span><del>-                                fh->dbuflen = fh->resampler->to_len * 2;
</del><ins>+                                fh->dbuflen = fh->resampler->to_len * 2 * fh->channels;
</ins><span class="cx">                                 mem = realloc(fh->dbuf, fh->dbuflen);
</span><span class="cx">                                 switch_assert(mem);
</span><span class="cx">                                 fh->dbuf = mem;
</span><span class="cx">                         }
</span><span class="cx">                         switch_assert(fh->resampler->to_len * 2 <= fh->dbuflen);
</span><del>-                        memcpy(fh->dbuf, fh->resampler->to, fh->resampler->to_len * 2);
</del><ins>+                        memcpy(fh->dbuf, fh->resampler->to, fh->resampler->to_len * 2 * fh->channels);
</ins><span class="cx">                         data = fh->dbuf;
</span><span class="cx">                 } else {
</span><del>-                        memcpy(data, fh->resampler->to, fh->resampler->to_len * 2);
</del><ins>+                        memcpy(data, fh->resampler->to, fh->resampler->to_len * 2 * fh->channels);
</ins><span class="cx">                 }
</span><span class="cx">
</span><del>-                *len = fh->resampler->to_len / fh->channels;
-
</del><ins>+                *len = fh->resampler->to_len;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!*len) {
</span><span class="lines">@@ -316,7 +322,7 @@
</span><span class="cx">                 if (rlen >= fh->pre_buffer_datalen) {
</span><span class="cx">                         if ((blen = switch_buffer_read(fh->pre_buffer, fh->pre_buffer_data, fh->pre_buffer_datalen))) {
</span><span class="cx">                                 if (!asis) blen /= 2;
</span><del>-                                if (fh->channels) blen /= fh->channels;
</del><ins>+                                if (fh->channels > 1) blen /= fh->channels;
</ins><span class="cx">                                 if ((status = fh->file_interface->file_write(fh, fh->pre_buffer_data, &blen)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         *len = 0;
</span><span class="cx">                                 }
</span><span class="lines">@@ -427,7 +433,7 @@
</span><span class="cx">                         while((rlen = switch_buffer_inuse(fh->pre_buffer))) {
</span><span class="cx">                                 if ((blen = switch_buffer_read(fh->pre_buffer, fh->pre_buffer_data, fh->pre_buffer_datalen))) {
</span><span class="cx">                                         if (!asis) blen /= 2;
</span><del>-                                        if (fh->channels) blen /= fh->channels;
</del><ins>+                                        if (fh->channels > 1) blen /= fh->channels;
</ins><span class="cx">                                         if (fh->file_interface->file_write(fh, fh->pre_buffer_data, &blen) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                 break;
</span><span class="cx">                                         }
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_ioc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_io.c (14330 => 14331)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_io.c        2009-07-23 15:49:00 UTC (rev 14330)
+++ freeswitch/trunk/src/switch_core_io.c        2009-07-23 15:55:13 UTC (rev 14331)
</span><span class="lines">@@ -271,7 +271,7 @@
</span><span class="cx">                                                                                                         read_frame->codec->implementation->actual_samples_per_second,
</span><span class="cx">                                                                                                         session->read_impl.actual_samples_per_second,
</span><span class="cx">                                                                                                         session->read_impl.decoded_bytes_per_packet,
</span><del>-                                                                                                        SWITCH_RESAMPLE_QUALITY);
</del><ins>+                                                                                                        SWITCH_RESAMPLE_QUALITY, 1);
</ins><span class="cx">                                         
</span><span class="cx">                                         switch_mutex_unlock(session->resample_mutex);
</span><span class="cx">
</span><span class="lines">@@ -677,7 +677,7 @@
</span><span class="cx">                                                                                                 frame->codec->implementation->actual_samples_per_second,
</span><span class="cx">                                                                                                 session->write_impl.actual_samples_per_second,
</span><span class="cx">                                                                                                 session->write_impl.decoded_bytes_per_packet,
</span><del>-                                                                                                SWITCH_RESAMPLE_QUALITY);
</del><ins>+                                                                                                SWITCH_RESAMPLE_QUALITY, 1);
</ins><span class="cx">                                                                                                 
</span><span class="cx">                                 
</span><span class="cx">                                 switch_mutex_unlock(session->resample_mutex);
</span><span class="lines">@@ -961,7 +961,7 @@
</span><span class="cx">                                                                                                                                         frame->codec->implementation->actual_samples_per_second,
</span><span class="cx">                                                                                                                                         session->write_impl.actual_samples_per_second,
</span><span class="cx">                                                                                                                                         session->write_impl.decoded_bytes_per_packet,
</span><del>-                                                                                                                                        SWITCH_RESAMPLE_QUALITY);
</del><ins>+                                                                                                                                        SWITCH_RESAMPLE_QUALITY, 1);
</ins><span class="cx">                                                                 }
</span><span class="cx">                                                                 switch_mutex_unlock(session->resample_mutex);
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_speechc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_speech.c (14330 => 14331)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_speech.c        2009-07-23 15:49:00 UTC (rev 14330)
+++ freeswitch/trunk/src/switch_core_speech.c        2009-07-23 15:55:13 UTC (rev 14331)
</span><span class="lines">@@ -227,7 +227,7 @@
</span><span class="cx">         if (sh->native_rate && sh->samplerate && sh->native_rate != sh->samplerate) {
</span><span class="cx">                 if (!sh->resampler) {
</span><span class="cx">                         if (switch_resample_create(&sh->resampler,
</span><del>-                                                                         sh->native_rate, sh->samplerate, (uint32_t) orig_len, SWITCH_RESAMPLE_QUALITY) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                         sh->native_rate, sh->samplerate, (uint32_t) orig_len, SWITCH_RESAMPLE_QUALITY, 1) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to create resampler!\n");
</span><span class="cx">                                 return SWITCH_STATUS_GENERR;
</span><span class="cx">                         }
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_resamplec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_resample.c (14330 => 14331)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_resample.c        2009-07-23 15:49:00 UTC (rev 14330)
+++ freeswitch/trunk/src/switch_resample.c        2009-07-23 15:55:13 UTC (rev 14331)
</span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx">                                                                                                                          uint32_t from_rate, uint32_t to_rate,
</span><span class="cx">                                                                                                                          uint32_t to_size,
</span><span class="cx">                                                                                                                          int quality,
</span><ins>+                                                                                                                         uint32_t channels,
</ins><span class="cx">                                                                                                                          const char *file, const char *func, int line)
</span><span class="cx"> {
</span><span class="cx">         int err = 0;
</span><span class="lines">@@ -64,7 +65,7 @@
</span><span class="cx">
</span><span class="cx">         switch_zmalloc(resampler, sizeof(*resampler));
</span><span class="cx">         
</span><del>-        resampler->resampler = speex_resampler_init(1, from_rate, to_rate, quality, &err);
</del><ins>+        resampler->resampler = speex_resampler_init(channels ? channels : 1, from_rate, to_rate, quality, &err);
</ins><span class="cx">
</span><span class="cx">         if (!resampler->resampler) {
</span><span class="cx">                 free(resampler);
</span><span class="lines">@@ -88,7 +89,7 @@
</span><span class="cx"> SWITCH_DECLARE(uint32_t) switch_resample_process(switch_audio_resampler_t *resampler, int16_t *src, uint32_t srclen)
</span><span class="cx"> {
</span><span class="cx">         resampler->to_len = resampler->to_size;
</span><del>-        speex_resampler_process_int(resampler->resampler, 0, src, &srclen, resampler->to, &resampler->to_len);
</del><ins>+        speex_resampler_process_interleaved_int(resampler->resampler, src, &srclen, resampler->to, &resampler->to_len);
</ins><span class="cx">         return resampler->to_len;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>