From 491e6eacb7da903bc9f93de8260760a1907565ca Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sun, 26 Jan 2014 16:18:22 -0400 Subject: [PATCH] src/io/: add missing error strings prefixes --- src/io/sink_sndfile.c | 10 +++++----- src/io/source_avcodec.c | 24 ++++++++++++------------ src/io/source_sndfile.c | 18 +++++++++--------- tests/src/test-cvec.c | 3 ++- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/io/sink_sndfile.c b/src/io/sink_sndfile.c index 11143652..dace3151 100644 --- a/src/io/sink_sndfile.c +++ b/src/io/sink_sndfile.c @@ -49,7 +49,7 @@ aubio_sink_sndfile_t * new_aubio_sink_sndfile(char_t * path, uint_t samplerate) SF_INFO sfinfo; if (path == NULL) { - AUBIO_ERR("Aborted opening null path\n"); + AUBIO_ERR("sink_sndfile: Aborted opening null path\n"); 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 */ - 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; } @@ -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) { - 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; @@ -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) { - 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; @@ -120,7 +120,7 @@ uint_t aubio_sink_sndfile_close (aubio_sink_sndfile_t *s) { 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; diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c index 772691e1..60e6314b 100644 --- a/src/io/source_avcodec.c +++ b/src/io/source_avcodec.c @@ -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_ERR("Aborted opening null path\n"); + AUBIO_ERR("source_avcodec: Aborted opening null path\n"); 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) { - 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; } @@ -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)); - AUBIO_ERR("Failed opening %s (%s)\n", s->path, errorstr); + AUBIO_ERR("source_avcodec: Failed opening %s (%s)\n", s->path, errorstr); 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)); - 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; } @@ -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 { - 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) { - 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); @@ -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) { - 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)); - 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; } @@ -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) { - 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) { - 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 */ @@ -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)); - 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; diff --git a/src/io/source_sndfile.c b/src/io/source_sndfile.c index 9076b489..e34df952 100644 --- a/src/io/source_sndfile.c +++ b/src/io/source_sndfile.c @@ -66,15 +66,15 @@ aubio_source_sndfile_t * new_aubio_source_sndfile(char_t * path, uint_t samplera 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) { - 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) { - 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; } @@ -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 */ - 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; } @@ -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) { - 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; } @@ -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 ) { - 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; } - 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) { - 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 */ @@ -272,7 +272,7 @@ uint_t aubio_source_sndfile_close (aubio_source_sndfile_t *s) { 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; diff --git a/tests/src/test-cvec.c b/tests/src/test-cvec.c index 59272f06..75a19d7e 100644 --- a/tests/src/test-cvec.c +++ b/tests/src/test-cvec.c @@ -4,10 +4,11 @@ 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; + utils_init_random(); + while (rand_times -- ) { // fill with random phas and norm for ( i = 0; i < complex_vector->length; i++ ) { -- 2.11.0