Don't spin in an infinite loop if the decoder tries to find a data record and

the matcher fails to find anything, leaving the seek point unchanged.
This commit is contained in:
David Given
2021-12-10 19:56:00 +00:00
parent 2584a25527
commit 3d1ee7a43e
4 changed files with 11 additions and 0 deletions

View File

@@ -114,6 +114,8 @@ public:
auto idbits = readRawBits(16); auto idbits = readRawBits(16);
const Bytes idbytes = decodeFmMfm(idbits); const Bytes idbytes = decodeFmMfm(idbits);
uint8_t id = idbytes.slice(0, 1)[0]; uint8_t id = idbytes.slice(0, 1)[0];
if (eof())
return RecordType::UNKNOWN_RECORD;
seek(here); seek(here);
switch (id) switch (id)

View File

@@ -107,6 +107,7 @@ std::unique_ptr<TrackDataFlux> AbstractDecoder::decodeToSectors(
break; break;
if (fmr.eof()) if (fmr.eof())
break; break;
fmr.skipToEvent(F_BIT_PULSE);
} }
recordStart = fmr.tell(); recordStart = fmr.tell();
if (r == DATA_RECORD) if (r == DATA_RECORD)

View File

@@ -57,6 +57,9 @@ public:
void seek(const Fluxmap::Position& pos) void seek(const Fluxmap::Position& pos)
{ return _fmr->seek(pos); } { return _fmr->seek(pos); }
bool eof() const
{ return _fmr->eof(); }
virtual std::set<unsigned> requiredSectors(unsigned cylinder, unsigned head) const; virtual std::set<unsigned> requiredSectors(unsigned cylinder, unsigned head) const;
protected: protected:

View File

@@ -3,6 +3,7 @@
#include "bytes.h" #include "bytes.h"
#include "protocol.h" #include "protocol.h"
#include "fmt/format.h"
class RawBits; class RawBits;
@@ -17,6 +18,10 @@ public:
nanoseconds_t ns() const nanoseconds_t ns() const
{ return ticks * NS_PER_TICK; } { return ticks * NS_PER_TICK; }
operator std::string () {
return fmt::format("[b:{}, t:{}, z:{}]", bytes, ticks, zeroes);
}
}; };
public: public: