shithub: aubio

Download patch

ref: 3e1c4829e339e6cb24c8f862e8f5a3f715bd4d85
parent: e406835d9afa329ea1cd40e837f3e7d45c79b9a1
author: Paul Brossier <piem@piem.org>
date: Sun Dec 16 14:17:26 EST 2018

[io] clean up sink_wavwrite

--- a/src/io/sink_wavwrite.c
+++ b/src/io/sink_wavwrite.c
@@ -87,12 +87,7 @@
     AUBIO_ERR("sink_wavwrite: Aborted opening null path\n");
     goto beach;
   }
-  if ((sint_t)samplerate < 0) {
-    AUBIO_ERR("sink_wavwrite: Can not create %s with samplerate %d\n", path, samplerate);
-    goto beach;
-  }
 
-  if (s->path) AUBIO_FREE(s->path);
   s->path = AUBIO_ARRAY(char_t, strnlen(path, PATH_MAX) + 1);
   strncpy(s->path, path, strnlen(path, PATH_MAX) + 1);
 
@@ -135,7 +130,7 @@
   }
   s->samplerate = samplerate;
   // automatically open when both samplerate and channels have been set
-  if (s->samplerate != 0 && s->channels != 0) {
+  if (/* s->samplerate != 0 && */ s->channels != 0) {
     return aubio_sink_wavwrite_open(s);
   }
   return AUBIO_OK;
@@ -148,7 +143,7 @@
   }
   s->channels = channels;
   // automatically open when both samplerate and channels have been set
-  if (s->samplerate != 0 && s->channels != 0) {
+  if (s->samplerate != 0 /* && s->channels != 0 */) {
     return aubio_sink_wavwrite_open(s);
   }
   return AUBIO_OK;
@@ -294,10 +289,13 @@
 }
 
 void del_aubio_sink_wavwrite(aubio_sink_wavwrite_t * s){
-  if (!s) return;
-  aubio_sink_wavwrite_close(s);
-  if (s->path) AUBIO_FREE(s->path);
-  AUBIO_FREE(s->scratch_data);
+  AUBIO_ASSERT(s);
+  if (s->fid)
+    aubio_sink_wavwrite_close(s);
+  if (s->path)
+    AUBIO_FREE(s->path);
+  if (s->scratch_data)
+    AUBIO_FREE(s->scratch_data);
   AUBIO_FREE(s);
 }