From 12c144a77acc8a531e0d4449a6c6d0273f62adaf Mon Sep 17 00:00:00 2001 From: Stefan Jahn Date: Mon, 20 Feb 2023 22:37:24 +0100 Subject: [PATCH] Videodump reading now also works in Windows --- videodev-dumpfile.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/videodev-dumpfile.cc b/videodev-dumpfile.cc index 02b0e8c..2d33aff 100644 --- a/videodev-dumpfile.cc +++ b/videodev-dumpfile.cc @@ -121,7 +121,7 @@ int VideoDev_Dumpfile::Open() { } filesize = s.st_size; - if ((fd = open(fname.c_str(), O_RDONLY)) == -1) { + if ((fd = open(fname.c_str(), O_RDONLY | O_BINARY)) == -1) { printf ("%s:%d could not open file '%s' error:%s\n", __FILE__, __LINE__, fname.c_str(), strerror(errno)); return VDEV_STATUS_ERROR; } @@ -267,9 +267,8 @@ int VideoDev_Dumpfile::ReadFrame() { // // read frame if (read (fd, inbuf, 4*2) != 4*2) { - printf ("%s:%d could not read frame header\n", __FILE__, __LINE__); + printf ("%s:%d could not read frame header: %s\n", __FILE__, __LINE__, strerror(errno)); Close(); - } filepos += (4*2); inframe_size = ntohl(inbuf[0]); @@ -291,10 +290,9 @@ int VideoDev_Dumpfile::ReadFrame() { printf ("%s:%d cloud not allocate enought memory\n", __FILE__, __LINE__); return VDEV_CBSTATUS_ERROR; } - if (read (fd, inframe, inframe_size) != inframe_size) { - printf ("%s:%d could not read frame\n", __FILE__, __LINE__); - Close(); + printf ("%s:%d could not read frame: %s\n", __FILE__, __LINE__, strerror(errno)); + Close(); } filepos += inframe_size;