[libdvdnav-devel] Fix partial read handling in file_read()
Evgeny Grin
git at videolan.org
Wed Dec 3 16:40:05 CET 2014
libdvdread | branch: master | Evgeny Grin <karlson2k at kodi.tv> | Tue Nov 25 18:12:45 2014 +0300| [72f87861057b9f3fcf929e9ba31312f72d9ab081] | committer: Jean-Baptiste Kempf
Fix partial read handling in file_read()
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/libdvdread.git/?a=commit;h=72f87861057b9f3fcf929e9ba31312f72d9ab081
---
src/dvd_input.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/dvd_input.c b/src/dvd_input.c
index da4803e..2d6a8af 100644
--- a/src/dvd_input.c
+++ b/src/dvd_input.c
@@ -218,12 +218,13 @@ static int file_title(dvd_input_t dev UNUSED, int block UNUSED)
static int file_read(dvd_input_t dev, void *buffer, int blocks,
int flags UNUSED)
{
- size_t len;
+ size_t len, bytes;
len = (size_t)blocks * DVD_VIDEO_LB_LEN;
+ bytes = 0;
while(len > 0) {
- ssize_t ret = read(dev->fd, buffer, len);
+ ssize_t ret = read(dev->fd, ((char*)buffer) + bytes, len);
if(ret < 0) {
/* One of the reads failed, too bad. We won't even bother
@@ -235,7 +236,6 @@ static int file_read(dvd_input_t dev, void *buffer, int blocks,
if(ret == 0) {
/* Nothing more to read. Return all of the whole blocks, if any.
* Adjust the file position back to the previous block boundary. */
- size_t bytes = (size_t)blocks * DVD_VIDEO_LB_LEN - len;
off_t over_read = -(bytes % DVD_VIDEO_LB_LEN);
off_t pos = lseek(dev->fd, over_read, SEEK_CUR);
if(pos % 2048 != 0)
@@ -244,6 +244,7 @@ static int file_read(dvd_input_t dev, void *buffer, int blocks,
}
len -= ret;
+ bytes += ret;
}
return blocks;
More information about the libdvdnav-devel
mailing list