shithub: aubio

Download patch

ref: b03f1bf503d0efb09c34b0548d5de00782be0550
parent: 26bd5e0b04becfb8b7f62f0181898d3f6584701c
author: Paul Brossier <piem@piem.org>
date: Sat Dec 22 19:09:31 EST 2018

[sink_wavwrite] use STRERR macro

--- a/src/io/sink_wavwrite.c
+++ b/src/io/sink_wavwrite.c
@@ -28,8 +28,6 @@
 #include "io/sink_wavwrite.h"
 #include "io/ioutils.h"
 
-#include <errno.h>
-
 #define MAX_SIZE 4096
 
 #define FLOAT_TO_SHORT(x) (short)(x * 32768)
@@ -167,9 +165,7 @@
   /* open output file */
   s->fid = fopen((const char *)s->path, "wb");
   if (!s->fid) {
-    char errorstr[256];
-    AUBIO_STRERROR(errno, errorstr, sizeof(errorstr));
-    AUBIO_ERR("sink_wavwrite: could not open %s (%s)\n", s->path, errorstr);
+    AUBIO_STRERR("sink_wavwrite: could not open %s (%s)\n", s->path, errorstr);
     goto beach;
   }
 
@@ -216,9 +212,7 @@
 
   // fwrite(*, *, 1, s->fid) was called 13 times, check success
   if (written != 13) {
-    char errorstr[256];
-    AUBIO_STRERROR(errno, errorstr, sizeof(errorstr));
-    AUBIO_WRN("sink_wavwrite: writing header to %s failed, expected %d"
+    AUBIO_STRERR("sink_wavwrite: writing header to %s failed, expected %d"
         " write but got only %d (%s)\n", s->path, 13, written, errorstr);
     return AUBIO_FAIL;
   }
@@ -246,9 +240,7 @@
   written_frames = fwrite(s->scratch_data, 2 * s->channels, write, s->fid);
 
   if (written_frames != write) {
-    char errorstr[256];
-    AUBIO_STRERROR(errno, errorstr, sizeof(errorstr));
-    AUBIO_WRN("sink_wavwrite: trying to write %d frames to %s, but only %d"
+    AUBIO_STRERR("sink_wavwrite: trying to write %d frames to %s, but only %d"
         " could be written (%s)\n", write, s->path, written_frames, errorstr);
   }
   s->total_frames_written += written_frames;
@@ -297,16 +289,12 @@
   err += fseek(s->fid, 40, SEEK_SET);
   written += fwrite(write_little_endian(data_size, buf, 4), 4, 1, s->fid);
   if (written != 2 || err != 0) {
-    char errorstr[256];
-    AUBIO_STRERROR(errno, errorstr, sizeof(errorstr));
-    AUBIO_WRN("sink_wavwrite: updating header of %s failed, expected %d"
+    AUBIO_STRERR("sink_wavwrite: updating header of %s failed, expected %d"
         " write but got only %d (%s)\n", s->path, 2, written, errorstr);
   }
   // close file
   if (fclose(s->fid)) {
-    char errorstr[256];
-    AUBIO_STRERROR(errno, errorstr, sizeof(errorstr));
-    AUBIO_ERR("sink_wavwrite: Error closing file %s (%s)\n", s->path, errorstr);
+    AUBIO_STRERR("sink_wavwrite: Error closing file %s (%s)\n", s->path, errorstr);
   }
   s->fid = NULL;
   return AUBIO_OK;