[io] always call del_aubio_sink
[aubio.git] / src / io / sink.c
index a13316a..f8ac5fd 100644 (file)
@@ -18,7 +18,6 @@
 
 */
 
-#include "config.h"
 #include "aubio_priv.h"
 #include "fvec.h"
 #include "fmat.h"
@@ -98,9 +97,12 @@ aubio_sink_t * new_aubio_sink(const char_t * uri, uint_t samplerate) {
     return s;
   }
 #endif /* HAVE_WAVWRITE */
-  AUBIO_ERROR("sink: failed creating %s with samplerate %dHz\n",
-      uri, samplerate);
-  AUBIO_FREE(s);
+#if !defined(HAVE_WAVWRITE) && \
+  !defined(HAVE_SNDFILE) && \
+  !defined(HAVE_SINK_APPLE_AUDIO)
+  AUBIO_ERROR("sink: failed creating '%s' at %dHz (no sink built-in)\n", uri, samplerate);
+#endif
+  del_aubio_sink(s);
   return NULL;
 }
 
@@ -133,8 +135,8 @@ uint_t aubio_sink_close(aubio_sink_t *s) {
 }
 
 void del_aubio_sink(aubio_sink_t * s) {
-  if (!s) return;
-  s->s_del((void *)s->sink);
+  AUBIO_ASSERT(s);
+  if (s->s_del && s->sink)
+    s->s_del((void *)s->sink);
   AUBIO_FREE(s);
-  return;
 }