From 18e11ba9a8ccc8526fe051c3c3b57453455c1b39 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Wed, 13 Jan 2010 20:01:28 +0100 Subject: fixed sndfile seeking --- plugins/sndfile/sndfile.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'plugins/sndfile') diff --git a/plugins/sndfile/sndfile.c b/plugins/sndfile/sndfile.c index 99f717cc..e6dfb7ce 100644 --- a/plugins/sndfile/sndfile.c +++ b/plugins/sndfile/sndfile.c @@ -62,7 +62,11 @@ sf_vfs_write (const void *ptr, sf_count_t count, void *user_data) { static sf_count_t sf_vfs_seek (sf_count_t offset, int whence, void *user_data) { sndfilectx_t *ctx = user_data; - return deadbeef->fseek (ctx->file, offset, whence); + int ret = deadbeef->fseek (ctx->file, offset, whence); + if (!ret) { + return offset; + } + return -1; } static sf_count_t @@ -174,7 +178,11 @@ sndfile_read_float32 (char *bytes, int size) { static int sndfile_seek_sample (int sample) { - sfctx.currentsample = sf_seek (sfctx.ctx, sample + sfctx.startsample, SEEK_SET); + int ret = sf_seek (sfctx.ctx, sample + sfctx.startsample, SEEK_SET); + if (ret < 0) { + return -1; + } + sfctx.currentsample = ret; plugin.info.readpos = (float)(sfctx.currentsample - sfctx.startsample) / plugin.info.samplerate; return 0; } -- cgit v1.2.3