[Freeswitch-svn] [commit] r7300 - freeswitch/trunk/src/mod/formats/mod_shout

Freeswitch SVN anthm at freeswitch.org
Sat Jan 19 16:25:18 EST 2008


Author: anthm
Date: Sat Jan 19 16:25:18 2008
New Revision: 7300

Modified:
   freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c

Log:
fix FSCORE-90

Modified: freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c
==============================================================================
--- freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c	(original)
+++ freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c	Sat Jan 19 16:25:18 2008
@@ -837,10 +837,30 @@
             context->lame_ready = 1;
         }
 
-		if ((rlen = lame_encode_buffer(context->gfp, audio, NULL, nsamples, mp3buf, sizeof(mp3buf))) < 0) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen);
-			return SWITCH_STATUS_FALSE;
-		}
+        if (handle->channels == 2) {
+            int16_t l[4096] = {0};
+            int16_t r[4096] = {0};
+            int i, j = 0;
+            
+            for(i = 0; i < nsamples; i++) {
+                l[i] = audio[j++];
+                r[i] = audio[j++];
+            }
+
+            if ((rlen = lame_encode_buffer(context->gfp, l, r, nsamples, mp3buf, sizeof(mp3buf))) < 0) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen);
+                return SWITCH_STATUS_FALSE;
+            }
+
+        } else if (handle->channels == 1) {
+            if ((rlen = lame_encode_buffer(context->gfp, audio, NULL, nsamples, mp3buf, sizeof(mp3buf))) < 0) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen);
+                return SWITCH_STATUS_FALSE;
+            }
+        } else {
+            rlen = 0;
+        }
+
 		if (rlen) {
 			if (fwrite(mp3buf, 1, rlen, context->fp) < 0) {
 				return SWITCH_STATUS_FALSE;



More information about the Freeswitch-svn mailing list