From: Paul Brossier Date: Fri, 5 Sep 2014 00:41:07 +0000 (-0500) Subject: src/io/source_wavread.c: improve seek errors processing X-Git-Tag: 0.4.2~63 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=0ff4434fc7261f0000ca516beb68c3fabc68e49f;p=aubio.git src/io/source_wavread.c: improve seek errors processing --- diff --git a/src/io/source_wavread.c b/src/io/source_wavread.c index bd3556c9..e01847f8 100644 --- a/src/io/source_wavread.c +++ b/src/io/source_wavread.c @@ -355,10 +355,19 @@ uint_t aubio_source_wavread_get_channels(aubio_source_wavread_t * s) { } 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) {