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

brendan at dactyl.lonelymoon.com brendan
Tue Jul 27 14:44:09 PDT 2004


Author: brendan
Date: Tue Jul 27 14:44:09 2004
New Revision: 7379

Modified:
icecast/trunk/ices0/src/crossfade.c
Log:
Use memcpy during buffer fill instead of sample-at-a-time.
This should be done for the swap (next clause), but since process
works in place, I'd need a separate buffer. Bleh.


Modified: icecast/trunk/ices0/src/crossfade.c
===================================================================
--- icecast/trunk/ices0/src/crossfade.c	2004-07-27 21:24:55 UTC (rev 7378)
+++ icecast/trunk/ices0/src/crossfade.c	2004-07-27 21:44:07 UTC (rev 7379)
@@ -59,7 +59,7 @@

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

@@ -82,12 +82,16 @@

j = i;
while (ilen && flen < FadeSamples) {
-    FL[fpos] = il[j];
-    FR[fpos] = ir[j];
-    j++;
-    fpos = (fpos + 1) % FadeSamples;
-    flen++;
-    ilen--;
+    clen = ilen < (FadeSamples - flen) ? ilen : (FadeSamples - flen);
+    if (FadeSamples - fpos < clen)
+      clen = FadeSamples - fpos;
+    printf("Buffering %d samples (pos: %d)\n", clen, fpos);
+    memcpy(FL + fpos, il + j, clen * 2);
+    memcpy(FR + fpos, ir + j, clen * 2);
+    fpos = (fpos + clen) % FadeSamples;
+    j += clen;
+    flen += clen;
+    ilen -= clen;
}

while (ilen) {



More information about the commits mailing list