Skip to content

Commit 7516fcc

Browse files
authored
Merge pull request #294 from cchampet/dev_InputFile_throwExceptionIfErrorWhileReadingNextPacket
InputFile: throw a runtime_error if there is an error while reading the next packet
2 parents 9e48d80 + 0326c32 commit 7516fcc

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/AvTranscoder/file/InputFile.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,15 @@ bool InputFile::readNextPacket(CodedData& data, const size_t streamIndex)
6262
if(ret < 0) // error or end of file
6363
{
6464
LOG_INFO("Stop reading the next frame of file '" << _filename << "', stream " << streamIndex << " ("
65-
<< getDescriptionFromErrorCode(ret) << ")")
66-
return false;
65+
<< getDescriptionFromErrorCode(ret) << ")");
66+
if(ret == AVERROR_EOF)
67+
{
68+
LOG_INFO("There is no more data to read.");
69+
return false;
70+
}
71+
72+
LOG_ERROR("Error while reading this stream.");
73+
throw std::runtime_error("Error while reading this stream.");
6774
}
6875

6976
// Add Stream info to the packet

src/AvTranscoder/file/InputFile.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ class AvExport InputFile
4343
/**
4444
* @brief Read the next packet of the specified stream
4545
* @param data: data of next packet read
46-
* @return if next packet was read succefully
46+
* @return if next packet was read successfully
47+
* @exception runtime_error launched if there is an error (other than End Of File) while reading the next packet
4748
**/
4849
bool readNextPacket(CodedData& data, const size_t streamIndex);
4950

0 commit comments

Comments
 (0)