examples/: return 1 if object creation failed
authorPaul Brossier <piem@piem.org>
Mon, 3 Oct 2016 16:59:12 +0000 (18:59 +0200)
committerPaul Brossier <piem@piem.org>
Mon, 3 Oct 2016 16:59:12 +0000 (18:59 +0200)
examples/aubiomfcc.c
examples/aubionotes.c
examples/aubioonset.c
examples/aubiopitch.c
examples/aubiotrack.c

index d8bb910..0942ade 100644 (file)
@@ -48,6 +48,7 @@ void process_print (void)
 }
 
 int main(int argc, char **argv) {
+  int ret = 0;
   // change some default params
   buffer_size  = 512;
   hop_size = 256;
@@ -62,6 +63,10 @@ int main(int argc, char **argv) {
   fftgrain = new_cvec (buffer_size);
   mfcc = new_aubio_mfcc(buffer_size, n_filters, n_coefs, samplerate);
   mfcc_out = new_fvec(n_coefs);
+  if (pv == NULL || fftgrain == NULL || mfcc == NULL || mfcc_out == NULL) {
+    ret = 1;
+    goto beach;
+  }
 
   examples_common_process((aubio_process_func_t)process_block, process_print);
 
@@ -70,7 +75,7 @@ int main(int argc, char **argv) {
   del_aubio_mfcc(mfcc);
   del_fvec(mfcc_out);
 
+beach:
   examples_common_del();
-  return 0;
+  return ret;
 }
-
index 9e8149f..5b3c44e 100644 (file)
@@ -50,6 +50,8 @@ void process_print (void)
 }
 
 int main(int argc, char **argv) {
+  int ret = 0;
+
   examples_common_init(argc,argv);
 
   verbmsg ("using source: %s at %dHz\n", source_uri, samplerate);
@@ -65,6 +67,7 @@ int main(int argc, char **argv) {
   verbmsg ("tolerance: %f\n", pitch_tolerance);
 
   notes = new_aubio_notes ("default", buffer_size, hop_size, samplerate);
+  if (notes == NULL) { ret = 1; goto beach; }
 
   examples_common_process((aubio_process_func_t)process_block, process_print);
 
@@ -73,7 +76,7 @@ int main(int argc, char **argv) {
 
   del_aubio_notes (notes);
 
+beach:
   examples_common_del();
-  return 0;
+  return ret;
 }
-
index 3d00576..bf996a4 100644 (file)
@@ -58,6 +58,7 @@ void process_print (void)
 }
 
 int main(int argc, char **argv) {
+  int ret = 0;
   examples_common_init(argc,argv);
 
   verbmsg ("using source: %s at %dHz\n", source_uri, samplerate);
@@ -68,6 +69,7 @@ int main(int argc, char **argv) {
   verbmsg ("threshold: %f\n", onset_threshold);
 
   o = new_aubio_onset (onset_method, buffer_size, hop_size, samplerate);
+  if (o == NULL) { ret = 1; goto beach; }
   if (onset_threshold != 0.)
     aubio_onset_set_threshold (o, onset_threshold);
   if (silence_threshold != -90.)
@@ -88,6 +90,7 @@ int main(int argc, char **argv) {
   del_aubio_wavetable (wavetable);
   del_fvec (onset);
 
+beach:
   examples_common_del();
-  return 0;
+  return ret;
 }
index 73ed27c..2d7a012 100644 (file)
@@ -52,6 +52,7 @@ void process_print (void)
 }
 
 int main(int argc, char **argv) {
+  int ret = 0;
 
   buffer_size = 2048;
 
@@ -65,6 +66,7 @@ int main(int argc, char **argv) {
   verbmsg ("tolerance: %f\n", pitch_tolerance);
 
   o = new_aubio_pitch (pitch_method, buffer_size, hop_size, samplerate);
+  if (o == NULL) { ret = 1; goto beach; }
   if (pitch_tolerance != 0.)
     aubio_pitch_set_tolerance (o, pitch_tolerance);
   if (silence_threshold != -90.)
@@ -83,7 +85,7 @@ int main(int argc, char **argv) {
   del_aubio_wavetable (wavetable);
   del_fvec (pitch);
 
+beach:
   examples_common_del();
-  return 0;
+  return ret;
 }
-
index f6087b5..8667b01 100644 (file)
@@ -60,6 +60,7 @@ void process_print (void) {
 }
 
 int main(int argc, char **argv) {
+  int ret = 0;
   // override general settings from utils.c
   buffer_size = 1024;
   hop_size = 512;
@@ -75,6 +76,7 @@ int main(int argc, char **argv) {
 
   tempo_out = new_fvec(2);
   tempo = new_aubio_tempo(tempo_method, buffer_size, hop_size, samplerate);
+  if (tempo == NULL) { ret = 1; goto beach; }
   // set silence threshold very low to output beats even during silence
   // aubio_tempo_set_silence(tempo, -1000.);
   if (onset_threshold != 0.) aubio_tempo_set_threshold (tempo, onset_threshold);
@@ -92,7 +94,7 @@ int main(int argc, char **argv) {
   del_aubio_wavetable (wavetable);
   del_fvec(tempo_out);
 
+beach:
   examples_common_del();
-  return 0;
+  return ret;
 }
-