Skip to content

Commit

Permalink
mxfreader: Don't immediately log essence read errors
Browse files Browse the repository at this point in the history
Set the the MXF reader's mReadErrorMessage when less essence data is
read from a file than was requested, but don't log the error.
This avoids it being logged when reading a growing file where a later
attempt succeeds.

Note that this doesn't prevent non-essence read errors, e.g other KLVs.
  • Loading branch information
philipnbbc committed Sep 9, 2024
1 parent 8dd6bb1 commit 7f27a4e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions include/bmx/BMXException.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@
BMX_EXCEPTION(("'%s' check failed", #cond)); \
} while (0)

#define BMX_CHECK_NOLOG(cond) \
do { \
if (!(cond)) { \
throw BMXException( \
"'%s' check failed near %s:%d", #cond, __FILENAME__, __LINE__); \
} \
} while (0)

#define BMX_CHECK_M(cond, err) \
do { \
if (!(cond)) \
Expand Down
4 changes: 2 additions & 2 deletions src/mxf_reader/EssenceReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ uint32_t EssenceReader::ReadClipWrappedSamples(uint32_t num_samples)
frame->Grow((uint32_t)size);
uint32_t num_read = mFile->read(frame->GetBytesAvailable(), (uint32_t)size);
current_file_position += num_read;
BMX_CHECK(num_read == size);
BMX_CHECK_NOLOG(num_read == size);

size -= mImageEndOffset;
if (mImageStartOffset > 0) {
Expand Down Expand Up @@ -638,7 +638,7 @@ uint32_t EssenceReader::ReadFrameWrappedSamples(uint32_t num_samples)
if (!mParseOnly)
{
uint32_t num_read = mFile->read(frame->GetBytesAvailable(), (uint32_t)len);
BMX_CHECK(num_read == len);
BMX_CHECK_NOLOG(num_read == len);
} else {
mFile->skip(len);
}
Expand Down
2 changes: 1 addition & 1 deletion test/growing_file/growing_file.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2c0703daa26c571738c6f313cfd2b054
aa99fd8e8e058b07af7db303dc58653c

0 comments on commit 7f27a4e

Please sign in to comment.