]> git.tuebingen.mpg.de Git - paraslash.git/commit
mp4: Provide whence parameter for the seek callback.
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 24 Aug 2021 18:47:03 +0000 (20:47 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 30 May 2022 19:37:36 +0000 (21:37 +0200)
commit3b7939a8c294dc3ee103d99e6ff00e2800cf39f3
tree977c77648f60415ec69e68b58bff912a66d26d6e
parentd440a71683940a58747de6dc32643db452d9cf54
mp4: Provide whence parameter for the seek callback.

This adds a parameter to make ->seek() work like the lseek(2) system
call. This is easy to implement in both the memory-mapped callback
case used to retrieve the file information and the metadata update
case where ->seek() is a trivial wrapper for lseek(2).

With the additional functionality in place we don't need to track
the file size and the current file offset any more in mp4.c as these
values can now be obtained by calling ->seek() with a zero offset and
whence set to SEEK_END and SEEK_CUR, respectively. This also makes
the code more robust against corrupt mp4 files because we no longer
rely on the values from the atom headers to compute the file size.

The way mp4.c calls ->seek() should never cause the underlying lseek(2)
system call to fail. Therefore it suffices to check the return value
only in the callback wrapper and abort on failure.
aac_afh.c
mp4.c
mp4.h