[libbdplus-devel] [Git][videolan/libbdplus][master] 4 commits: Fix error message
Petri Hintukainen (@hpi)
gitlab at videolan.org
Mon Oct 11 10:49:20 UTC 2021
Petri Hintukainen pushed to branch master at VideoLAN / libbdplus
Commits:
4ec3ac18 by anonymous at 2021-10-11T13:42:18+03:00
Fix error message
- - - - -
5da78118 by anonymous at 2021-10-11T13:42:45+03:00
Silence warning
- - - - -
4d1e6a4c by anonymous at 2021-10-11T13:47:17+03:00
Merge _file_write() from libbluray
- - - - -
f4b8e043 by anonymous at 2021-10-11T13:47:17+03:00
Add comment
- - - - -
6 changed files:
- src/examples/bdplus_test.c
- src/examples/convtab_dump.c
- src/file/file_posix.c
- src/file/file_win32.c
- src/file/filesystem.h
- src/libbdplus/bdplus_data.h
Changes:
=====================================
src/examples/bdplus_test.c
=====================================
@@ -98,7 +98,11 @@ int main(int argc, char **argv)
unsigned ii;
if (argc < 2) {
+#ifndef HAVE_LIBAACS
+ fprintf(stderr, "%s /path/tobluray <VID>\r\n", argv[0]);
+#else
fprintf(stderr, "%s /path/tobluray [VID]\r\n", argv[0]);
+#endif
fprintf(stderr, "Where we expect to find /path/tobluray/BDSVM/\r\n");
exit(1);
}
=====================================
src/examples/convtab_dump.c
=====================================
@@ -68,7 +68,7 @@ int main(int argc, char **argv)
}
if (_read_tab(argv[1]) < 1) {
- fprintf(stderr, "Error reading %s\n", argv[0]);
+ fprintf(stderr, "Error reading %s\n", argv[1]);
exit(1);
}
=====================================
src/file/file_posix.c
=====================================
@@ -78,7 +78,7 @@ static int64_t _file_read(BD_FILE_H *file, uint8_t *buf, int64_t size)
ssize_t got, result;
if (size <= 0 || size >= BD_MAX_SSIZE) {
- BD_DEBUG(DBG_FILE | DBG_CRIT, "Ignoring invalid read of size %"PRId64" (%p)\n", size, (void*)file);
+ BD_DEBUG(DBG_FILE | DBG_CRIT, "Ignoring invalid read of size %" PRId64 " (%p)\n", size, (void*)file);
return 0;
}
@@ -98,6 +98,35 @@ static int64_t _file_read(BD_FILE_H *file, uint8_t *buf, int64_t size)
return (int64_t)got;
}
+static int64_t _file_write(BD_FILE_H *file, const uint8_t *buf, int64_t size)
+{
+ ssize_t written, result;
+
+ if (size <= 0 || size >= BD_MAX_SSIZE) {
+ if (size == 0) {
+ if (fsync((int)(intptr_t)file->internal)) {
+ BD_DEBUG(DBG_FILE, "fsync() failed (%p)\n", (void*)file);
+ return -1;
+ }
+ return 0;
+ }
+ BD_DEBUG(DBG_FILE | DBG_CRIT, "Ignoring invalid write of size %" PRId64 " (%p)\n", size, (void*)file);
+ return 0;
+ }
+
+ for (written = 0; written < (ssize_t)size; written += result) {
+ result = write((int)(intptr_t)file->internal, buf + written, size - written);
+ if (result < 0) {
+ if (errno != EINTR) {
+ BD_DEBUG(DBG_FILE, "write() failed (%p)\n", (void*)file);
+ break;
+ }
+ result = 0;
+ }
+ }
+ return (int64_t)written;
+}
+
static BD_FILE_H *_file_open(void *handle, const char* filename)
{
BD_FILE_H *file;
@@ -131,6 +160,7 @@ static BD_FILE_H *_file_open(void *handle, const char* filename)
file->close = _file_close;
file->seek = _file_seek;
file->read = _file_read;
+ file->write = _file_write;
file->tell = _file_tell;
file->internal = (void*)(intptr_t)fd;
=====================================
src/file/file_win32.c
=====================================
@@ -74,7 +74,25 @@ static int64_t _file_read(BD_FILE_H *file, uint8_t *buf, int64_t size)
return (int64_t)fread(buf, 1, (size_t)size, (FILE *)file->internal);
}
- BD_DEBUG(DBG_FILE | DBG_CRIT, "Ignoring invalid read of size %"PRId64" (%p)\n", size, (void*)file);
+ BD_DEBUG(DBG_FILE | DBG_CRIT, "Ignoring invalid read of size %" PRId64 " (%p)\n", size, (void*)file);
+ return 0;
+}
+
+static int64_t _file_write(BD_FILE_H *file, const uint8_t *buf, int64_t size)
+{
+ if (size > 0 && size < BD_MAX_SSIZE) {
+ return (int64_t)fwrite(buf, 1, (size_t)size, (FILE *)file->internal);
+ }
+
+ if (size == 0) {
+ if (fflush((FILE *)file->internal)) {
+ BD_DEBUG(DBG_FILE, "fflush() failed (%p)\n", (void*)file);
+ return -1;
+ }
+ return 0;
+ }
+
+ BD_DEBUG(DBG_FILE | DBG_CRIT, "Ignoring invalid write of size %" PRId64 " (%p)\n", size, (void*)file);
return 0;
}
@@ -110,6 +128,7 @@ static BD_FILE_H *_file_open(void *handle, const char* filename)
file->close = _file_close;
file->seek = _file_seek;
file->read = _file_read;
+ file->write = _file_write;
file->tell = _file_tell;
BD_DEBUG(DBG_FILE, "Opened WIN32 file %s (%p)\n", filename, (void*)file);
=====================================
src/file/filesystem.h
=====================================
@@ -20,6 +20,10 @@
#ifndef BDPLUS_FILESYSTEM_H_
#define BDPLUS_FILESYSTEM_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <stdint.h>
#ifndef BD_PUBLIC
@@ -65,5 +69,8 @@ struct bdplus_s;
BD_PUBLIC
void bdplus_set_fopen(struct bdplus_s *bdplus, void *handle, BDPLUS_FILE_OPEN p);
+#ifdef __cplusplus
+}
+#endif
#endif /* BDPLUS_FILESYSTEM_H_ */
=====================================
src/libbdplus/bdplus_data.h
=====================================
@@ -51,7 +51,7 @@ struct bdplus_s {
uint8_t volumeID[BLURAY_VOLUMEID_LEN]; // This should probably be moved out,API?
uint8_t mediaKey[BLURAY_VOLUMEID_LEN]; // This should probably be moved out,API?
- struct conv_table_s *conv_tab;
+ struct conv_table_s *conv_tab; /* conversion table from VM */
struct conv_table_s *cache_tab;
struct bdplus_config_s *config;
View it on GitLab: https://code.videolan.org/videolan/libbdplus/-/compare/e851459c26c7f7fb476c14c1bee6c563a2c6f8d0...f4b8e043fa45021ec6e503574f658705a33e9337
--
View it on GitLab: https://code.videolan.org/videolan/libbdplus/-/compare/e851459c26c7f7fb476c14c1bee6c563a2c6f8d0...f4b8e043fa45021ec6e503574f658705a33e9337
You're receiving this email because of your account on code.videolan.org.
More information about the libbdplus-devel
mailing list