diff options
author | Tuomas Virtanen <katajakasa@gmail.com> | 2018-07-01 22:04:49 +0300 |
---|---|---|
committer | Tuomas Virtanen <katajakasa@gmail.com> | 2018-07-01 22:04:49 +0300 |
commit | 2ea872a24eda920974ea1c9b69542248620c306a (patch) | |
tree | c57e648d06003736aeffea810e1f6723b96d2726 /src | |
parent | 6d30b5ed4a555875f504d13ebb362205fbbf056f (diff) |
Handle AVSEEK_FORCE
Diffstat (limited to 'src')
-rw-r--r-- | src/kitsource.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/kitsource.c b/src/kitsource.c index fddb410..71a73b0 100644 --- a/src/kitsource.c +++ b/src/kitsource.c @@ -137,17 +137,14 @@ static int64_t _RWGetSize(SDL_RWops *rw_ops) { static int64_t _RWSeekCallback(void *userdata, int64_t offset, int whence) { int rw_whence = 0; - // Looking for file size. Will return size of -1 if not supported. - if(whence == AVSEEK_SIZE) { + if(whence & AVSEEK_SIZE) return _RWGetSize(userdata); - } - - // RW and normal seeks *should* be the same, but it's not guaranteed by docs. - switch(whence) { - case SEEK_CUR: rw_whence = RW_SEEK_CUR; break; - case SEEK_SET: rw_whence = RW_SEEK_SET; break; - case SEEK_END: rw_whence = RW_SEEK_END; break; - } + if((whence & ~AVSEEK_FORCE) == SEEK_CUR) + rw_whence = RW_SEEK_CUR; + if((whence & ~AVSEEK_FORCE) == SEEK_SET) + rw_whence = RW_SEEK_SET; + if((whence & ~AVSEEK_FORCE) == SEEK_END) + rw_whence = RW_SEEK_END; if(SDL_RWseek((SDL_RWops*)userdata, offset, rw_whence) < 0) { return -1; |