src/io/: add missing error strings prefixes
authorPaul Brossier <piem@piem.org>
Sun, 26 Jan 2014 20:18:22 +0000 (16:18 -0400)
committerPaul Brossier <piem@piem.org>
Sun, 26 Jan 2014 20:18:22 +0000 (16:18 -0400)
src/io/sink_sndfile.c
src/io/source_avcodec.c
src/io/source_sndfile.c
tests/src/test-cvec.c

index 1114365..dace315 100644 (file)
@@ -49,7 +49,7 @@ aubio_sink_sndfile_t * new_aubio_sink_sndfile(char_t * path, uint_t samplerate)
   SF_INFO sfinfo;
 
   if (path == NULL) {
   SF_INFO sfinfo;
 
   if (path == NULL) {
-    AUBIO_ERR("Aborted opening null path\n");
+    AUBIO_ERR("sink_sndfile: Aborted opening null path\n");
     return NULL;
   }
 
     return NULL;
   }
 
@@ -69,7 +69,7 @@ aubio_sink_sndfile_t * new_aubio_sink_sndfile(char_t * path, uint_t samplerate)
 
   if (s->handle == NULL) {
     /* show libsndfile err msg */
 
   if (s->handle == NULL) {
     /* show libsndfile err msg */
-    AUBIO_ERR("Failed opening %s. %s\n", s->path, sf_strerror (NULL));
+    AUBIO_ERR("sink_sndfile: Failed opening %s. %s\n", s->path, sf_strerror (NULL));
     AUBIO_FREE(s);
     return NULL;
   }    
     AUBIO_FREE(s);
     return NULL;
   }    
@@ -77,7 +77,7 @@ aubio_sink_sndfile_t * new_aubio_sink_sndfile(char_t * path, uint_t samplerate)
   s->scratch_size = s->max_size*s->channels;
   /* allocate data for de/interleaving reallocated when needed. */
   if (s->scratch_size >= MAX_SIZE * MAX_CHANNELS) {
   s->scratch_size = s->max_size*s->channels;
   /* allocate data for de/interleaving reallocated when needed. */
   if (s->scratch_size >= MAX_SIZE * MAX_CHANNELS) {
-    AUBIO_ERR("%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);
     AUBIO_FREE(s);
     return NULL;
         s->max_size, s->channels, MAX_CHANNELS * MAX_CHANNELS);
     AUBIO_FREE(s);
     return NULL;
@@ -109,7 +109,7 @@ void aubio_sink_sndfile_do(aubio_sink_sndfile_t *s, fvec_t * write_data, uint_t
 
   written_frames = sf_write_float (s->handle, s->scratch_data, nsamples);
   if (written_frames/channels != write) {
 
   written_frames = sf_write_float (s->handle, s->scratch_data, nsamples);
   if (written_frames/channels != write) {
-    AUBIO_WRN("trying to write %d frames to %s, but only %d could be written",
+    AUBIO_WRN("sink_sndfile: trying to write %d frames to %s, but only %d could be written",
       write, s->path, (uint_t)written_frames);
   }
   return;
       write, s->path, (uint_t)written_frames);
   }
   return;
@@ -120,7 +120,7 @@ uint_t aubio_sink_sndfile_close (aubio_sink_sndfile_t *s) {
     return AUBIO_FAIL;
   }
   if (sf_close(s->handle)) {
     return AUBIO_FAIL;
   }
   if (sf_close(s->handle)) {
-    AUBIO_ERR("Error closing file %s: %s", s->path, sf_strerror (NULL));
+    AUBIO_ERR("sink_sndfile: Error closing file %s: %s", s->path, sf_strerror (NULL));
     return AUBIO_FAIL;
   }
   s->handle = NULL;
     return AUBIO_FAIL;
   }
   s->handle = NULL;
index 772691e..60e6314 100644 (file)
@@ -67,15 +67,15 @@ aubio_source_avcodec_t * new_aubio_source_avcodec(char_t * path, uint_t samplera
   aubio_source_avcodec_t * s = AUBIO_NEW(aubio_source_avcodec_t);
   int err;
   if (path == NULL) {
   aubio_source_avcodec_t * s = AUBIO_NEW(aubio_source_avcodec_t);
   int err;
   if (path == NULL) {
-    AUBIO_ERR("Aborted opening null path\n");
+    AUBIO_ERR("source_avcodec: Aborted opening null path\n");
     goto beach;
   }
   if ((sint_t)samplerate < 0) {
     goto beach;
   }
   if ((sint_t)samplerate < 0) {
-    AUBIO_ERR("Can not open %s with samplerate %d\n", path, samplerate);
+    AUBIO_ERR("source_avcodec: Can not open %s with samplerate %d\n", path, samplerate);
     goto beach;
   }
   if ((sint_t)hop_size <= 0) {
     goto beach;
   }
   if ((sint_t)hop_size <= 0) {
-    AUBIO_ERR("Can not open %s with hop_size %d\n", path, hop_size);
+    AUBIO_ERR("source_avcodec: Can not open %s with hop_size %d\n", path, hop_size);
     goto beach;
   }
 
     goto beach;
   }
 
@@ -95,7 +95,7 @@ aubio_source_avcodec_t * new_aubio_source_avcodec(char_t * path, uint_t samplera
   if ( (err = avformat_open_input(&avFormatCtx, s->path, NULL, NULL) ) < 0 ) {
     char errorstr[256];
     av_strerror (err, errorstr, sizeof(errorstr));
   if ( (err = avformat_open_input(&avFormatCtx, s->path, NULL, NULL) ) < 0 ) {
     char errorstr[256];
     av_strerror (err, errorstr, sizeof(errorstr));
-    AUBIO_ERR("Failed opening %s (%s)\n", s->path, errorstr);
+    AUBIO_ERR("source_avcodec: Failed opening %s (%s)\n", s->path, errorstr);
     goto beach;
   }
 
     goto beach;
   }
 
@@ -106,7 +106,7 @@ aubio_source_avcodec_t * new_aubio_source_avcodec(char_t * path, uint_t samplera
   if ( (err = avformat_find_stream_info(avFormatCtx, NULL)) < 0 ) {
     char errorstr[256];
     av_strerror (err, errorstr, sizeof(errorstr));
   if ( (err = avformat_find_stream_info(avFormatCtx, NULL)) < 0 ) {
     char errorstr[256];
     av_strerror (err, errorstr, sizeof(errorstr));
-    AUBIO_ERR("Could not find stream information " "for %s (%s)\n", s->path,
+    AUBIO_ERR("source_avcodec: Could not find stream information " "for %s (%s)\n", s->path,
         errorstr);
     goto beach;
   }
         errorstr);
     goto beach;
   }
@@ -122,13 +122,13 @@ aubio_source_avcodec_t * new_aubio_source_avcodec(char_t * path, uint_t samplera
       if (selected_stream == -1) {
         selected_stream = i;
       } else {
       if (selected_stream == -1) {
         selected_stream = i;
       } else {
-        AUBIO_WRN("More than one audio stream in %s, "
+        AUBIO_WRN("source_avcodec: More than one audio stream in %s, "
             "taking the first one\n", s->path);
       }
     }
   }
   if (selected_stream == -1) {
             "taking the first one\n", s->path);
       }
     }
   }
   if (selected_stream == -1) {
-    AUBIO_ERR("No audio stream in %s\n", s->path);
+    AUBIO_ERR("source_avcodec: No audio stream in %s\n", s->path);
     goto beach;
   }
   //AUBIO_DBG("Taking stream %d in file %s\n", selected_stream, s->path);
     goto beach;
   }
   //AUBIO_DBG("Taking stream %d in file %s\n", selected_stream, s->path);
@@ -138,14 +138,14 @@ aubio_source_avcodec_t * new_aubio_source_avcodec(char_t * path, uint_t samplera
   avCodecCtx = avFormatCtx->streams[selected_stream]->codec;
   AVCodec *codec = avcodec_find_decoder(avCodecCtx->codec_id);
   if (codec == NULL) {
   avCodecCtx = avFormatCtx->streams[selected_stream]->codec;
   AVCodec *codec = avcodec_find_decoder(avCodecCtx->codec_id);
   if (codec == NULL) {
-    AUBIO_ERR("Could not find decoder for %s", s->path);
+    AUBIO_ERR("source_avcodec: Could not find decoder for %s", s->path);
     goto beach;
   }
 
   if ( ( err = avcodec_open2(avCodecCtx, codec, NULL) ) < 0) {
     char errorstr[256];
     av_strerror (err, errorstr, sizeof(errorstr));
     goto beach;
   }
 
   if ( ( err = avcodec_open2(avCodecCtx, codec, NULL) ) < 0) {
     char errorstr[256];
     av_strerror (err, errorstr, sizeof(errorstr));
-    AUBIO_ERR("Could not load codec for %s (%s)\n", s->path, errorstr);
+    AUBIO_ERR("source_avcodec: Could not load codec for %s (%s)\n", s->path, errorstr);
     goto beach;
   }
 
     goto beach;
   }
 
@@ -162,14 +162,14 @@ aubio_source_avcodec_t * new_aubio_source_avcodec(char_t * path, uint_t samplera
   s->samplerate = samplerate;
 
   if (s->samplerate >  s->input_samplerate) {
   s->samplerate = samplerate;
 
   if (s->samplerate >  s->input_samplerate) {
-    AUBIO_WRN("upsampling %s from %d to %d\n", s->path,
+    AUBIO_WRN("source_avcodec: upsampling %s from %d to %d\n", s->path,
         s->input_samplerate, s->samplerate);
   }
 
   AVFrame *avFrame = s->avFrame;
   avFrame = avcodec_alloc_frame();
   if (!avFrame) {
         s->input_samplerate, s->samplerate);
   }
 
   AVFrame *avFrame = s->avFrame;
   avFrame = avcodec_alloc_frame();
   if (!avFrame) {
-    AUBIO_ERR("Could not allocate frame for (%s)\n", s->path);
+    AUBIO_ERR("source_avcodec: Could not allocate frame for (%s)\n", s->path);
   }
 
   /* allocate output for avr */
   }
 
   /* allocate output for avr */
@@ -222,7 +222,7 @@ void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s, uint_t mul
     if ( ( err = avresample_open(avr) ) < 0) {
       char errorstr[256];
       av_strerror (err, errorstr, sizeof(errorstr));
     if ( ( err = avresample_open(avr) ) < 0) {
       char errorstr[256];
       av_strerror (err, errorstr, sizeof(errorstr));
-      AUBIO_ERR("Could not open AVAudioResampleContext for %s (%s)\n",
+      AUBIO_ERR("source_avcodec: Could not open AVAudioResampleContext for %s (%s)\n",
           s->path, errorstr);
       //goto beach;
       return;
           s->path, errorstr);
       //goto beach;
       return;
index 9076b48..e34df95 100644 (file)
@@ -66,15 +66,15 @@ aubio_source_sndfile_t * new_aubio_source_sndfile(char_t * path, uint_t samplera
   SF_INFO sfinfo;
 
   if (path == NULL) {
   SF_INFO sfinfo;
 
   if (path == NULL) {
-    AUBIO_ERR("Aborted opening null path\n");
+    AUBIO_ERR("source_sndfile: Aborted opening null path\n");
     goto beach;
   }
   if ((sint_t)samplerate < 0) {
     goto beach;
   }
   if ((sint_t)samplerate < 0) {
-    AUBIO_ERR("Can not open %s with samplerate %d\n", path, samplerate);
+    AUBIO_ERR("source_sndfile: Can not open %s with samplerate %d\n", path, samplerate);
     goto beach;
   }
   if ((sint_t)hop_size <= 0) {
     goto beach;
   }
   if ((sint_t)hop_size <= 0) {
-    AUBIO_ERR("Can not open %s with hop_size %d\n", path, hop_size);
+    AUBIO_ERR("source_sndfile: Can not open %s with hop_size %d\n", path, hop_size);
     goto beach;
   }
 
     goto beach;
   }
 
@@ -88,7 +88,7 @@ aubio_source_sndfile_t * new_aubio_source_sndfile(char_t * path, uint_t samplera
 
   if (s->handle == NULL) {
     /* show libsndfile err msg */
 
   if (s->handle == NULL) {
     /* show libsndfile err msg */
-    AUBIO_ERR("Failed opening %s: %s\n", s->path, sf_strerror (NULL));
+    AUBIO_ERR("source_sndfile: Failed opening %s: %s\n", s->path, sf_strerror (NULL));
     goto beach;
   }    
 
     goto beach;
   }    
 
@@ -107,7 +107,7 @@ aubio_source_sndfile_t * new_aubio_source_sndfile(char_t * path, uint_t samplera
   s->input_hop_size = (uint_t)FLOOR(s->hop_size / s->ratio + .5);
 
   if (s->input_hop_size * s->input_channels > MAX_SAMPLES) {
   s->input_hop_size = (uint_t)FLOOR(s->hop_size / s->ratio + .5);
 
   if (s->input_hop_size * s->input_channels > MAX_SAMPLES) {
-    AUBIO_ERR("Not able to process more than %d frames of %d channels\n",
+    AUBIO_ERR("source_sndfile: Not able to process more than %d frames of %d channels\n",
         MAX_SAMPLES / s->input_channels, s->input_channels);
     goto beach;
   }
         MAX_SAMPLES / s->input_channels, s->input_channels);
     goto beach;
   }
@@ -121,17 +121,17 @@ aubio_source_sndfile_t * new_aubio_source_sndfile(char_t * path, uint_t samplera
     if (s->ratio > 1) {
       // we would need to add a ring buffer for these
       if ( (uint_t)(s->input_hop_size * s->ratio + .5)  != s->hop_size ) {
     if (s->ratio > 1) {
       // we would need to add a ring buffer for these
       if ( (uint_t)(s->input_hop_size * s->ratio + .5)  != s->hop_size ) {
-        AUBIO_ERR("can not upsample %s from %d to %d\n", s->path,
+        AUBIO_ERR("source_sndfile: can not upsample %s from %d to %d\n", s->path,
             s->input_samplerate, s->samplerate);
         goto beach;
       }
             s->input_samplerate, s->samplerate);
         goto beach;
       }
-      AUBIO_WRN("upsampling %s from %d to %d\n", s->path,
+      AUBIO_WRN("source_sndfile: upsampling %s from %d to %d\n", s->path,
           s->input_samplerate, s->samplerate);
     }
   }
 #else
   if (s->ratio != 1) {
           s->input_samplerate, s->samplerate);
     }
   }
 #else
   if (s->ratio != 1) {
-    AUBIO_ERR("aubio was compiled without aubio_resampler\n");
+    AUBIO_ERR("source_sndfile: aubio was compiled without aubio_resampler\n");
     goto beach;
   }
 #endif /* HAVE_SAMPLERATE */
     goto beach;
   }
 #endif /* HAVE_SAMPLERATE */
@@ -272,7 +272,7 @@ uint_t aubio_source_sndfile_close (aubio_source_sndfile_t *s) {
     return AUBIO_FAIL;
   }
   if(sf_close(s->handle)) {
     return AUBIO_FAIL;
   }
   if(sf_close(s->handle)) {
-    AUBIO_ERR("Error closing file %s: %s", s->path, sf_strerror (NULL));
+    AUBIO_ERR("source_sndfile: Error closing file %s: %s", s->path, sf_strerror (NULL));
     return AUBIO_FAIL;
   }
   return AUBIO_OK;
     return AUBIO_FAIL;
   }
   return AUBIO_OK;
index 59272f0..75a19d7 100644 (file)
@@ -4,10 +4,11 @@
 int main (void)
 {
   uint_t i, window_size = 16; // window size
 int main (void)
 {
   uint_t i, window_size = 16; // window size
-  utils_init_random();
   cvec_t * complex_vector = new_cvec (window_size); // input buffer
   uint_t rand_times = 4;
 
   cvec_t * complex_vector = new_cvec (window_size); // input buffer
   uint_t rand_times = 4;
 
+  utils_init_random();
+
   while (rand_times -- ) {
     // fill with random phas and norm
     for ( i = 0; i < complex_vector->length; i++ ) {
   while (rand_times -- ) {
     // fill with random phas and norm
     for ( i = 0; i < complex_vector->length; i++ ) {