changeset 2648:51495131e4ae trunk

[svn] - synchronize SRC conversion patch with upstream
author nenolod
date Thu, 05 Apr 2007 05:32:15 -0700
parents 2afc8e31a378
children 153dc928115a
files ChangeLog src/audacious/build_stamp.c src/audacious/output.c
diffstat 3 files changed, 37 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Apr 03 11:54:52 2007 -0700
+++ b/ChangeLog	Thu Apr 05 05:32:15 2007 -0700
@@ -1,3 +1,11 @@
+2007-04-03 18:54:52 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
+  revision [4316]
+  - this probably fixes bug #858
+  
+  trunk/src/audacious/vfs_buffered_file.c |    3 ++-
+  1 file changed, 2 insertions(+), 1 deletion(-)
+
+
 2007-04-01 02:33:04 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
   revision [4314]
   - fix doublesize motion events. patch by gagern, closes #856.
--- a/src/audacious/build_stamp.c	Tue Apr 03 11:54:52 2007 -0700
+++ b/src/audacious/build_stamp.c	Thu Apr 05 05:32:15 2007 -0700
@@ -1,2 +1,2 @@
 #include <glib.h>
-const gchar *svn_stamp = "20070401-4314";
+const gchar *svn_stamp = "20070403-4316";
--- a/src/audacious/output.c	Tue Apr 03 11:54:52 2007 -0700
+++ b/src/audacious/output.c	Thu Apr 05 05:32:15 2007 -0700
@@ -230,10 +230,24 @@
 static int overSamplingFs = 96000;
 static int converter_type = SRC_SINC_BEST_QUALITY;
 static int srcError = 0;
+
+static float *srcIn = NULL, *srcOut = NULL;
+static short int *wOut = NULL;
+static int lengthOfSrcIn = 0;
+static int lengthOfSrcOut = 0;
+
 static void freeSRC()
 {
   if(src_state != NULL)
     src_state = src_delete(src_state);
+  free(srcIn);
+  free(srcOut);
+  free(wOut);
+  srcIn = NULL;
+  srcOut = NULL;
+  wOut = NULL;
+  lengthOfSrcIn = 0;
+  lengthOfSrcOut = 0;
 }
 #endif
 
@@ -391,12 +405,6 @@
     return op->buffer_playing();
 }
 
-#ifdef USE_SRC
-static float *srcIn = NULL, *srcOut = NULL;
-static short int *wOut = NULL;
-static gboolean isSrcAlloc = FALSE;
-#endif
-
 /* called by input plugin when data is ready */
 void
 produce_audio(gint time,        /* position             */
@@ -415,23 +423,25 @@
     int writeoffs;
 
 #ifdef USE_SRC
-    if(isSrcAlloc == TRUE)
-      {
-        g_free(srcIn);
-        g_free(srcOut);
-        g_free(wOut);
-        isSrcAlloc = FALSE;
-      }
-    
     if(src_state != NULL&&length > 0)
       {
         int lrLength = length/2;
         int overLrLength = (int)floor(lrLength*(src_data.src_ratio+1));
-        srcIn = (float*) g_malloc(sizeof(float)*lrLength);
-        srcOut = (float*) g_malloc(sizeof(float)*overLrLength);
-        wOut = (short int*) g_malloc(sizeof(short int)*overLrLength);
+	if(lengthOfSrcIn < lrLength)
+	  {
+	    lengthOfSrcIn = lrLength;
+	    free(srcIn);
+	    srcIn = (float*)malloc(sizeof(float)*lrLength);
+	  }
+	if(lengthOfSrcOut < overLrLength)
+	  {
+	    lengthOfSrcOut = overLrLength;
+	    free(srcOut);
+	    free(wOut);
+	    srcOut = (float*)malloc(sizeof(float)*overLrLength);
+	    wOut = (short int*)malloc(sizeof(short int)*overLrLength);
+	  }
         src_short_to_float_array((short int*)ptr, srcIn, lrLength);
-        isSrcAlloc = TRUE;
         src_data.data_in = srcIn;
         src_data.data_out = srcOut;
         src_data.end_of_input = 0;