libudfread | branch: master | Petri Hintukainen <[email protected]> | Thu May 11 15:16:39 2017 +0300| [d29a734a8189aa2b7e7944ac51ed8567933a6ba2] | committer: Petri Hintukainen
Add pread() replacement > http://git.videolan.org/gitweb.cgi/libudfread.git/?a=commit;h=d29a734a8189aa2b7e7944ac51ed8567933a6ba2 --- src/default_blockinput.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/default_blockinput.c b/src/default_blockinput.c index ac4d671..4daa6a3 100644 --- a/src/default_blockinput.c +++ b/src/default_blockinput.c @@ -1,6 +1,6 @@ /* * This file is part of libudfread - * Copyright (C) 2014-2015 VLC authors and VideoLAN + * Copyright (C) 2014-2017 VLC authors and VideoLAN * * Authors: Petri Hintukainen <[email protected]> * @@ -70,7 +70,30 @@ static ssize_t pread(int fd, void *buf, size_t count, off_t offset) } return got; } -#endif + +#elif defined (NEED_PREAD_IMPL) + +#include <pthread.h> +static ssize_t pread_impl(int fd, void *buf, size_t count, off_t offset) +{ + static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; + ssize_t result; + + pthread_mutex_lock(&lock); + + if (lseek(fd, offset, SEEK_SET) != offset) { + result = -1; + } else { + result = read(fd, buf, count); + } + + pthread_mutex_unlock(&lock); + return result; +} + +#define pread(a,b,c,d) pread_impl(a,b,c,d) + +#endif /* _WIN32 || NEED_PREAD_IMPL */ typedef struct default_block_input { _______________________________________________ libbluray-devel mailing list [email protected] https://mailman.videolan.org/listinfo/libbluray-devel
