changeset 4290:5b277773870e

don't change src settings in play time
author Eugene Zagidullin <e.asphyx@gmail.com>
date Mon, 18 Feb 2008 23:20:12 +0300
parents af88976df6a8
children ca077e01ed3a a16edefb8836
files src/audacious/output.c src/audacious/src_flow.c
diffstat 2 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/output.c	Mon Feb 18 22:51:06 2008 +0300
+++ b/src/audacious/output.c	Mon Feb 18 23:20:12 2008 +0300
@@ -336,7 +336,7 @@
         return TRUE;
     } else {
 #ifdef USE_SRC
-        if(cfg.enable_src) rate = cfg.src_rate;
+        rate = src_flow_init(rate, nch); /* returns sample rate unchanged if resampling switched off */
 #endif
     
         bit_depth = cfg.output_bit_depth;
@@ -429,6 +429,9 @@
     replay_gain_info.album_gain = 0.0;
     replay_gain_info.album_peak = 0.0;
 
+#ifdef USE_SRC
+    src_flow_free();
+#endif
     /* Do not close if there are still songs to play and the user has 
      * not requested a stop.  --nenolod
      */
@@ -446,9 +449,6 @@
     plugin_set_current((Plugin *)op);
     op->close_audio();
     AUDDBG("done\n");
-#ifdef USE_SRC
-    src_flow_free();
-#endif
 
     /* Reset the op_state. */
     op_state.fmt = op_state.rate = op_state.nch = 0;
--- a/src/audacious/src_flow.c	Mon Feb 18 22:51:06 2008 +0300
+++ b/src/audacious/src_flow.c	Mon Feb 18 23:20:12 2008 +0300
@@ -57,9 +57,9 @@
     AUDDBG("\n");
     if(src_state != NULL) src_state = src_delete(src_state);
     src_state = NULL;
-    if(srcOut != NULL) free(srcOut);
+    /*if(srcOut != NULL) free(srcOut);
     srcOut = NULL;
-    lengthOfSrcOut = 0;
+    lengthOfSrcOut = 0;*/
     inputFs = 0;
     overSamplingFs = 0;
     input_nch = 0;
@@ -68,11 +68,11 @@
 gint
 src_flow_init(gint infreq, gint nch)
 {
-    AUDDBG("input_rate=%d, nch=%d\n", infreq, nch);
     src_flow_free();
 
     /* don't resample if sampling rates are the same --nenolod */
     if (infreq == cfg.src_rate || !cfg.enable_src) return infreq;
+    AUDDBG("input_rate=%d, output_rate=%d, nch=%d\n", infreq, cfg.src_rate, nch);
     
     overSamplingFs = cfg.src_rate;
     inputFs = infreq;
@@ -92,14 +92,14 @@
 void
 src_flow(FlowContext *context) {
    
-    if(!cfg.enable_src) return;
+    if(src_state == NULL) return;
     
     if(context->fmt != FMT_FLOAT) {
         context->error = TRUE;
         return;
     }
 
-    if(src_state == NULL || context->srate != inputFs || context->channels != input_nch) {
+    if(context->srate != inputFs || context->channels != input_nch) {
         AUDDBG("reinitializing src\n");
         src_flow_init(context->srate, context->channels);
     }
@@ -108,7 +108,7 @@
     int overLrLength = (int)floor(lrLength * (src_data.src_ratio + 1));
     
     if(lengthOfSrcOut < overLrLength || srcOut == NULL) {
-        AUDDBG("reallocating srcOut\n");
+        AUDDBG("reallocating srcOut (%d bytes)\n", overLrLength);
         lengthOfSrcOut = overLrLength;
         srcOut = smart_realloc(srcOut, &lengthOfSrcOut);
     }