From 798b257bdfb795a096dccd06851791d19c4cb731 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sat, 19 Jan 2008 21:25:18 +0000 Subject: [PATCH] fix FSCORE-90 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7300 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/formats/mod_shout/mod_shout.c | 28 +++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/mod/formats/mod_shout/mod_shout.c b/src/mod/formats/mod_shout/mod_shout.c index 9d82a68ae2..fa37cb6c44 100644 --- a/src/mod/formats/mod_shout/mod_shout.c +++ b/src/mod/formats/mod_shout/mod_shout.c @@ -837,10 +837,30 @@ static switch_status_t shout_file_write(switch_file_handle_t *handle, void *data 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;