ref: f33ab63b2c27ccdc8c9ec14c468f173c512a6707
parent: 0ff4434fc7261f0000ca516beb68c3fabc68e49f
author: Paul Brossier <piem@piem.org>
date: Thu Sep 4 15:41:59 EDT 2014
src/io/source_sndfile.c: improve seek errors and strings
--- a/src/io/source_sndfile.c
+++ b/src/io/source_sndfile.c
@@ -199,7 +199,7 @@
smpl_t **ptr_data;
#ifdef HAVE_SAMPLERATE
if (s->ratio != 1) {
- AUBIO_ERR("source_sndfile: no multi channel resampling yet");
+ AUBIO_ERR("source_sndfile: no multi channel resampling yet\n");
return;
//ptr_data = s->input_data->data;
} else
@@ -264,7 +264,17 @@
uint_t aubio_source_sndfile_seek (aubio_source_sndfile_t * s, uint_t pos) {
uint_t resampled_pos = (uint_t)ROUND(pos / s->ratio);
- return sf_seek (s->handle, resampled_pos, SEEK_SET);
+ sf_count_t sf_ret = sf_seek (s->handle, resampled_pos, SEEK_SET);
+ if (sf_ret == -1) {
+ AUBIO_ERR("source_sndfile: Failed seeking %s at %d: %s\n", s->path, pos, sf_strerror (NULL));
+ return AUBIO_FAIL;
+ }
+ if (sf_ret != resampled_pos) {
+ AUBIO_ERR("source_sndfile: Tried seeking %s at %d, but got %lld: %s\n",
+ s->path, resampled_pos, sf_ret, sf_strerror (NULL));
+ return AUBIO_FAIL;
+ }
+ return AUBIO_OK;
}
uint_t aubio_source_sndfile_close (aubio_source_sndfile_t *s) {
@@ -272,7 +282,7 @@
return AUBIO_FAIL;
}
if(sf_close(s->handle)) {
- AUBIO_ERR("source_sndfile: Error closing file %s: %s", s->path, sf_strerror (NULL));
+ AUBIO_ERR("source_sndfile: Error closing file %s: %s\n", s->path, sf_strerror (NULL));
return AUBIO_FAIL;
}
return AUBIO_OK;