]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - aac_afh.c
mp4: Provide whence parameter for the seek callback.
[paraslash.git] / aac_afh.c
index 0a80bfcf3a44205ea7d42f9ac260c03f910ba199..b6c90d59009a3315f9249e5e3b200429132d6296 100644 (file)
--- a/aac_afh.c
+++ b/aac_afh.c
@@ -41,11 +41,19 @@ static ssize_t aac_afh_read_cb(void *user_data, void *dest, size_t want)
        return rv;
 }
 
-static uint32_t aac_afh_seek_cb(void *user_data, uint64_t pos)
+static off_t aac_afh_seek_cb(void *user_data, off_t offset, int whence)
 {
        struct aac_afh_context *c = user_data;
-       c->fpos = pos;
-       return 0;
+
+       if (whence == SEEK_SET)
+               c->fpos = offset;
+       else if (whence == SEEK_CUR)
+               c->fpos += offset;
+       else if (whence == SEEK_END)
+               c->fpos = c->mapsize + offset;
+       else
+               assert(false);
+       return c->fpos;
 }
 
 static int aac_afh_open(const void *map, size_t mapsize, void **afh_context)
@@ -167,10 +175,13 @@ static ssize_t aac_afh_meta_read_cb(void *user_data, void *dest, size_t want)
        return read(fd, dest, want);
 }
 
-static uint32_t aac_afh_meta_seek_cb(void *user_data, uint64_t pos)
+static off_t aac_afh_meta_seek_cb(void *user_data, off_t offset, int whence)
 {
        int fd = *(int *)user_data;
-       return lseek(fd, pos, SEEK_SET);
+       off_t ret = lseek(fd, offset, whence);
+
+       assert(ret != (off_t)-1);
+       return ret;
 }
 
 static ssize_t aac_afh_meta_write_cb(void *user_data, void *dest, size_t count)