src/io/source_wavread.c: avoid calling fclose twice, print an error if fclose fails
authorPaul Brossier <piem@piem.org>
Mon, 3 Feb 2014 19:21:11 +0000 (16:21 -0300)
committerPaul Brossier <piem@piem.org>
Mon, 3 Feb 2014 19:21:11 +0000 (16:21 -0300)
src/io/source_wavread.c

index d587868..2058b44 100644 (file)
@@ -347,9 +347,14 @@ uint_t aubio_source_wavread_seek (aubio_source_wavread_t * s, uint_t pos) {
 }
 
 uint_t aubio_source_wavread_close (aubio_source_wavread_t * s) {
-  if (!s->fid || fclose(s->fid)) {
+  if (!s->fid) {
+    return AUBIO_FAIL;
+  }
+  if (fclose(s->fid)) {
+    AUBIO_ERR("source_wavread: could not close %s (%s)\n", s->path, strerror(errno));
     return AUBIO_FAIL;
   }
+  s->fid = NULL;
   return AUBIO_OK;
 }