shithub: aubio

Download patch

ref: 26a6af7d29e6ec29f66e076b3a26157c2415c8d2
parent: b643a33823c19608bcf924edf18ba048dd3198a4
author: Paul Brossier <piem@piem.org>
date: Thu Apr 21 15:02:41 EDT 2016

src/io/source_{avcodec,sndfile}.c: avoid modifying input param

--- a/src/io/source_avcodec.c
+++ b/src/io/source_avcodec.c
@@ -166,10 +166,10 @@
   //AUBIO_DBG("input_channels: %d\n", s->input_channels);
 
   if (samplerate == 0) {
-    samplerate = s->input_samplerate;
-    //AUBIO_DBG("sampling rate set to 0, automagically adjusting to %d\n", samplerate);
+    s->samplerate = s->input_samplerate;
+  } else {
+    s->samplerate = samplerate;
   }
-  s->samplerate = samplerate;
 
   if (s->samplerate >  s->input_samplerate) {
     AUBIO_WRN("source_avcodec: upsampling %s from %d to %d\n", s->path,
--- a/src/io/source_sndfile.c
+++ b/src/io/source_sndfile.c
@@ -107,10 +107,11 @@
   s->input_format     = sfinfo.format;
 
   if (samplerate == 0) {
-    samplerate = s->input_samplerate;
+    s->samplerate = s->input_samplerate;
     //AUBIO_DBG("sampling rate set to 0, automagically adjusting to %d\n", samplerate);
+  } else {
+    s->samplerate = samplerate;
   }
-  s->samplerate = samplerate;
   /* compute input block size required before resampling */
   s->ratio = s->samplerate/(smpl_t)s->input_samplerate;
   s->input_hop_size = (uint_t)FLOOR(s->hop_size / s->ratio + .5);