ref: 0ff4434fc7261f0000ca516beb68c3fabc68e49f
parent: 79b54ea4ea3a2d413a10447a937ef3a6337dfb71
author: Paul Brossier <piem@piem.org>
date: Thu Sep 4 15:41:07 EDT 2014
src/io/source_wavread.c: improve seek errors processing
--- a/src/io/source_wavread.c
+++ b/src/io/source_wavread.c
@@ -355,10 +355,19 @@
}
uint_t aubio_source_wavread_seek (aubio_source_wavread_t * s, uint_t pos) {
- uint_t ret = fseek(s->fid, s->seek_start + pos * s->blockalign, SEEK_SET);
+ uint_t ret = 0;
+ if ((sint_t)pos < 0) {
+ return AUBIO_FAIL;
+ }
+ ret = fseek(s->fid, s->seek_start + pos * s->blockalign, SEEK_SET);
+ if (ret != 0) {
+ AUBIO_ERR("source_wavread: could not seek %s at %d (%s)\n", s->path, pos, strerror(errno));
+ return AUBIO_FAIL;
+ }
+ // reset some values
s->eof = 0;
s->read_index = 0;
- return ret;
+ return AUBIO_OK;
}
uint_t aubio_source_wavread_close (aubio_source_wavread_t * s) {