Delete method ReadableWav::Eof, which was used incorrectly.
Bug: webrtc:6463 Change-Id: I160ff01c16045eba438f928b429eacdb5342e5a9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144026 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28409}
This commit is contained in:
parent
71809c67ce
commit
767efaba10
@ -39,7 +39,6 @@ class ReadableWavFile : public ReadableWav {
|
||||
size_t Read(void* buf, size_t num_bytes) override {
|
||||
return fread(buf, 1, num_bytes, file_);
|
||||
}
|
||||
bool Eof() const override { return feof(file_) != 0; }
|
||||
bool SeekForward(uint32_t num_bytes) override {
|
||||
return fseek(file_, num_bytes, SEEK_CUR) == 0;
|
||||
}
|
||||
|
||||
@ -108,21 +108,20 @@ static inline uint16_t BlockAlign(size_t num_channels,
|
||||
// Finds a chunk having the sought ID. If found, then |readable| points to the
|
||||
// first byte of the sought chunk data. If not found, the end of the file is
|
||||
// reached.
|
||||
void FindWaveChunk(ChunkHeader* chunk_header,
|
||||
bool FindWaveChunk(ChunkHeader* chunk_header,
|
||||
ReadableWav* readable,
|
||||
const std::string sought_chunk_id) {
|
||||
RTC_DCHECK_EQ(sought_chunk_id.size(), 4);
|
||||
while (!readable->Eof()) {
|
||||
while (true) {
|
||||
if (readable->Read(chunk_header, sizeof(*chunk_header)) !=
|
||||
sizeof(*chunk_header))
|
||||
return; // EOF.
|
||||
return false; // EOF.
|
||||
if (ReadFourCC(chunk_header->ID) == sought_chunk_id)
|
||||
return; // Sought chunk found.
|
||||
return true; // Sought chunk found.
|
||||
// Ignore current chunk by skipping its payload.
|
||||
if (!readable->SeekForward(chunk_header->Size))
|
||||
return; // EOF or error.
|
||||
return false; // EOF or error.
|
||||
}
|
||||
// EOF.
|
||||
}
|
||||
|
||||
bool ReadFmtChunkData(FmtSubchunk* fmt_subchunk, ReadableWav* readable) {
|
||||
@ -254,8 +253,7 @@ bool ReadWavHeader(ReadableWav* readable,
|
||||
// does not put requirements on the chunks order, it is uncommon to find the
|
||||
// "data" chunk before the "fmt " one. The code below fails if this is not the
|
||||
// case.
|
||||
FindWaveChunk(&header.fmt.header, readable, "fmt ");
|
||||
if (ReadFourCC(header.fmt.header.ID) != "fmt ") {
|
||||
if (!FindWaveChunk(&header.fmt.header, readable, "fmt ")) {
|
||||
RTC_LOG(LS_ERROR) << "Cannot find 'fmt ' chunk.";
|
||||
return false;
|
||||
}
|
||||
@ -263,12 +261,7 @@ bool ReadWavHeader(ReadableWav* readable,
|
||||
RTC_LOG(LS_ERROR) << "Cannot read 'fmt ' chunk.";
|
||||
return false;
|
||||
}
|
||||
if (readable->Eof()) {
|
||||
RTC_LOG(LS_ERROR) << "'fmt ' chunk placed after 'data' chunk.";
|
||||
return false;
|
||||
}
|
||||
FindWaveChunk(&header.data.header, readable, "data");
|
||||
if (ReadFourCC(header.data.header.ID) != "data") {
|
||||
if (!FindWaveChunk(&header.data.header, readable, "data")) {
|
||||
RTC_LOG(LS_ERROR) << "Cannot find 'data' chunk.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -22,8 +22,6 @@ class ReadableWav {
|
||||
public:
|
||||
// Returns the number of bytes read.
|
||||
virtual size_t Read(void* buf, size_t num_bytes) = 0;
|
||||
// Returns true if the end-of-file has been reached.
|
||||
virtual bool Eof() const = 0;
|
||||
virtual bool SeekForward(uint32_t num_bytes) = 0;
|
||||
virtual ~ReadableWav() = default;
|
||||
};
|
||||
|
||||
@ -33,9 +33,6 @@ class ReadableWavBuffer : public ReadableWav {
|
||||
}
|
||||
|
||||
size_t Read(void* buf, size_t num_bytes) override {
|
||||
// Verify we don't try to read outside of a properly sized header.
|
||||
if (size_ >= kWavHeaderSize)
|
||||
EXPECT_GE(size_, pos_ + num_bytes);
|
||||
EXPECT_FALSE(buf_exhausted_);
|
||||
|
||||
const size_t bytes_remaining = size_ - pos_;
|
||||
@ -51,8 +48,6 @@ class ReadableWavBuffer : public ReadableWav {
|
||||
return num_bytes;
|
||||
}
|
||||
|
||||
bool Eof() const override { return pos_ == size_; }
|
||||
|
||||
bool SeekForward(uint32_t num_bytes) override {
|
||||
// Verify we don't try to read outside of a properly sized header.
|
||||
if (size_ >= kWavHeaderSize)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user