[sink_wavwrite] check fseek and fwrite return values
[aubio.git] / src / io / sink.c
index e86d085..f8ac5fd 100644 (file)
@@ -97,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;
 }
 
@@ -132,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;
 }