[xiph-commits] r7369 - icecast/trunk/ices0/src

brendan at dactyl.lonelymoon.com brendan
Tue Jul 27 11:20:09 PDT 2004


Author: brendan
Date: Tue Jul 27 11:20:09 2004
New Revision: 7369

Modified:
icecast/trunk/ices0/src/crossfade.c
icecast/trunk/ices0/src/plugin.h
icecast/trunk/ices0/src/stream.c
Log:
Crossfader is now working correctly. There's still a little glitch when the
encoder is reset. I don't know if there's a fix for that other than not
resetting the encoder.


Modified: icecast/trunk/ices0/src/crossfade.c
===================================================================
--- icecast/trunk/ices0/src/crossfade.c	2004-07-27 08:44:43 UTC (rev 7368)
+++ icecast/trunk/ices0/src/crossfade.c	2004-07-27 18:20:08 UTC (rev 7369)
@@ -16,13 +16,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*
+ * $Id$
*/

#include "definitions.h"
#include "plugin.h"

static void cf_new_track(void);
-static int cf_process(int ilen, int16_t* il, int16_t* ir, int16_t* ol, int16_t* or);
+static int cf_process(int ilen, int16_t* il, int16_t* ir);

static ices_plugin_t Crossfader = {
"crossfade",
@@ -31,7 +32,7 @@
};

static int NewTrack = 0;
-static int FadeSecs = 4;
+static int FadeSecs = 3;
static int FadeSamples;
static int16_t* FL;
static int16_t* FR;
@@ -51,10 +52,11 @@
NewTrack = FadeSamples;
}

-static int cf_process(int ilen, int16_t* il, int16_t* ir, int16_t* ol, int16_t* or)
+static int cf_process(int ilen, int16_t* il, int16_t* ir)
{
int i, j;
float weight;
+  int16_t swap;

i = 0;
/* if the buffer is not full, don't attempt to crossfade, just fill it */
@@ -63,12 +65,10 @@

while (ilen && NewTrack > 0) {
weight = (float)NewTrack / FadeSamples;
-
-    ol[i] = FL[fpos] * weight + il[i] * (1 - weight);
-    or[i] = FR[fpos] * weight + ir[i] * (1 - weight);
+    il[i] = FL[fpos] * weight + il[i] * (1 - weight);
+    ir[i] = FR[fpos] * weight + ir[i] * (1 - weight);
i++;
-    fpos++;
-    fpos = fpos % FadeSamples;
+    fpos = (fpos + 1) % FadeSamples;
ilen--;
NewTrack--;
if (!NewTrack)
@@ -80,21 +80,21 @@
FL[fpos] = il[j];
FR[fpos] = ir[j];
j++;
-    fpos++;
-    fpos = fpos % FadeSamples;
+    fpos = (fpos + 1) % FadeSamples;
flen++;
ilen--;
}

while (ilen) {
-    ol[i] = FL[fpos];
-    or[i] = FR[fpos];
-    FL[fpos] = il[j];
-    FR[fpos] = ir[j];
+    swap = il[j];
+    il[i] = FL[fpos];
+    FL[fpos] = swap;
+    swap = ir[j];
+    ir[i] = FR[fpos];
+    FR[fpos] = swap;
i++;
j++;
-    fpos++;
-    fpos = fpos % FadeSamples;
+    fpos = (fpos + 1) % FadeSamples;
ilen--;
}


Modified: icecast/trunk/ices0/src/plugin.h
===================================================================
--- icecast/trunk/ices0/src/plugin.h	2004-07-27 08:44:43 UTC (rev 7368)
+++ icecast/trunk/ices0/src/plugin.h	2004-07-27 18:20:08 UTC (rev 7369)
@@ -24,7 +24,7 @@
typedef struct {
const char *name;
void (*new_track)(void);
-  int (*process)(int ilen, int16_t *il, int16_t *ir, int16_t *ol, int16_t *or);
+  int (*process)(int ilen, int16_t *il, int16_t *ir);
} ices_plugin_t;

ices_plugin_t *crossfade_plugin(void);


Property changes on: icecast/trunk/ices0/src/plugin.h
___________________________________________________________________
Name: svn:keywords
+ Id

Modified: icecast/trunk/ices0/src/stream.c
===================================================================
--- icecast/trunk/ices0/src/stream.c	2004-07-27 08:44:43 UTC (rev 7368)
+++ icecast/trunk/ices0/src/stream.c	2004-07-27 18:20:08 UTC (rev 7369)
@@ -153,9 +153,6 @@
/* worst case decode: 22050 Hz at 8kbs = 44.1 samples/byte */
static int16_t left[INPUT_BUFSIZ * 45];
static int16_t right[INPUT_BUFSIZ * 45];
-  static int16_t ol[INPUT_BUFSIZ * 45];
-  static int16_t or[INPUT_BUFSIZ * 45];
-  int i;
static int16_t* rightp;
#endif

@@ -209,11 +206,7 @@
#ifdef HAVE_LIBLAME
/* run output through plugin */
if (samples && config->plugin) {
-      samples = config->plugin->process(samples, left, right, ol, or);
-      for (i = 0; i < samples; i++) {
-	left[i] = ol[i];
-	right[i] = or[i];
-      }
+      samples = config->plugin->process(samples, left, right);
}
#endif

@@ -225,7 +218,7 @@
ices_log_error ("Read error: %s", ices_util_strerror (errno, namespace, 1024));
goto err;
}
-
+
do_sleep = 1;
while (do_sleep) {
rc = olen = 0;
@@ -265,9 +258,9 @@
ices_log_debug ("Grew output buffer to %d bytes", obuf.len);
} else
ices_log_debug ("%d byte output buffer is too small", obuf.len);
-            } else if (olen > 0) {
-              rc = stream_send_data (stream, obuf.data, olen);
-            }
+		} else if (olen > 0) {
+		  rc = stream_send_data (stream, obuf.data, olen);
+		}
}
} else
#endif
@@ -301,7 +294,7 @@
if (stream->reencode && stream_needs_reencoding (source, stream)) {
len = ices_reencode_flush (stream, obuf.data, obuf.len);
if (len > 0)
-        rc = shout_send (stream->conn, obuf.data, len);
+        rc = stream_send_data (stream, obuf.data, len);
}

if (obuf.data)


Property changes on: icecast/trunk/ices0/src/stream.c
___________________________________________________________________
Name: svn:keywords
+ Id



More information about the commits mailing list