src/io/sink_{sndfile,wavwrite}.c: use AUBIO_MAX_CHANNELS, fix error message
authorPaul Brossier <piem@piem.org>
Wed, 30 Nov 2016 18:10:10 +0000 (19:10 +0100)
committerPaul Brossier <piem@piem.org>
Wed, 30 Nov 2016 18:10:10 +0000 (19:10 +0100)
src/io/sink_sndfile.c
src/io/sink_wavwrite.c

index 4256a49..562b327 100644 (file)
@@ -31,7 +31,6 @@
 #include "io/sink_sndfile.h"
 #include "io/ioutils.h"
 
 #include "io/sink_sndfile.h"
 #include "io/ioutils.h"
 
-#define MAX_CHANNELS 6
 #define MAX_SIZE 4096
 
 #if !HAVE_AUBIO_DOUBLE
 #define MAX_SIZE 4096
 
 #if !HAVE_AUBIO_DOUBLE
@@ -148,9 +147,10 @@ uint_t aubio_sink_sndfile_open(aubio_sink_sndfile_t *s) {
 
   s->scratch_size = s->max_size*s->channels;
   /* allocate data for de/interleaving reallocated when needed. */
 
   s->scratch_size = s->max_size*s->channels;
   /* allocate data for de/interleaving reallocated when needed. */
-  if (s->scratch_size >= MAX_SIZE * MAX_CHANNELS) {
+  if (s->scratch_size >= MAX_SIZE * AUBIO_MAX_CHANNELS) {
+    abort();
     AUBIO_ERR("sink_sndfile: %d x %d exceeds maximum aubio_sink_sndfile buffer size %d\n",
     AUBIO_ERR("sink_sndfile: %d x %d exceeds maximum aubio_sink_sndfile buffer size %d\n",
-        s->max_size, s->channels, MAX_CHANNELS * MAX_CHANNELS);
+        s->max_size, s->channels, MAX_SIZE * AUBIO_MAX_CHANNELS);
     return AUBIO_FAIL;
   }
   s->scratch_data = AUBIO_ARRAY(smpl_t,s->scratch_size);
     return AUBIO_FAIL;
   }
   s->scratch_data = AUBIO_ARRAY(smpl_t,s->scratch_size);
index 79ae402..a108a2f 100644 (file)
@@ -31,7 +31,6 @@
 
 #include <errno.h>
 
 
 #include <errno.h>
 
-#define MAX_CHANNELS 6
 #define MAX_SIZE 4096
 
 #define FLOAT_TO_SHORT(x) (short)(x * 32768)
 #define MAX_SIZE 4096
 
 #define FLOAT_TO_SHORT(x) (short)(x * 32768)
@@ -220,9 +219,9 @@ uint_t aubio_sink_wavwrite_open(aubio_sink_wavwrite_t *s) {
 
   s->scratch_size = s->max_size * s->channels;
   /* allocate data for de/interleaving reallocated when needed. */
 
   s->scratch_size = s->max_size * s->channels;
   /* allocate data for de/interleaving reallocated when needed. */
-  if (s->scratch_size >= MAX_SIZE * MAX_CHANNELS) {
+  if (s->scratch_size >= MAX_SIZE * AUBIO_MAX_CHANNELS) {
     AUBIO_ERR("sink_wavwrite: %d x %d exceeds SIZE maximum buffer size %d\n",
     AUBIO_ERR("sink_wavwrite: %d x %d exceeds SIZE maximum buffer size %d\n",
-        s->max_size, s->channels, MAX_SIZE * MAX_CHANNELS);
+        s->max_size, s->channels, MAX_SIZE * AUBIO_MAX_CHANNELS);
     goto beach;
   }
   s->scratch_data = AUBIO_ARRAY(unsigned short,s->scratch_size);
     goto beach;
   }
   s->scratch_data = AUBIO_ARRAY(unsigned short,s->scratch_size);