MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / submitSequence

Method submitSequence

external/floppybridge/src/RotationExtractor.cpp:210–307  ·  view source on GitHub ↗

Submit a single sequence to the list

Source from the content-addressed store, hash-verified

208
209// Submit a single sequence to the list
210void RotationExtractor::submitSequence(const MFMSequenceInfo& sequence, const bool isIndex, const bool discardEarlySamples) {
211 // we reject the first 20uSec of data. Makes things so much more stable
212 if (discardEarlySamples) {
213 m_timeReceived += sequence.timeNS;
214 if (m_timeReceived < 20000) return;
215 }
216
217 // And stop if we have too much. Shouldn't happen
218 if (m_sequencePos >= MAX_REVOLUTION_SEQUENCES)
219 return;
220
221 // See if we can calculate the time it takes to get a single revolution from the disk
222 if ((m_revolutionTime == 0) && (!m_useIndex) && (!m_useSimpleMode)) {
223 if (isIndex) {
224 if (m_sequenceIndex == INDEX_NOT_FOUND) m_sequenceIndex = 0; else m_nextSequenceIndex = m_sequencePos;
225 }
226
227 if (m_sequenceIndex != INDEX_NOT_FOUND) {
228 // Store the sequence only if we found the first index
229 m_sequences[m_sequencePos++] = sequence;
230 m_currentTime += sequence.timeNS;
231
232 if (m_nextSequenceIndex == INDEX_NOT_FOUND)
233 m_revolutionTimeCounting += sequence.timeNS;
234 else {
235 m_revolutionTime = m_revolutionTimeCounting;
236
237 // Set the nearly complete marker to be at 90%. That would only need approx another 20ms to complete
238 m_revolutionTimeNearlyComplete = (uint32_t)(m_revolutionTime * 0.9f);
239 }
240 }
241 return;
242 }
243
244 // Handle index search
245 if (isIndex) {
246 if (m_sequenceIndex == INDEX_NOT_FOUND) {
247 m_sequenceIndex = m_sequencePos;
248 }
249 else {
250 m_nextSequenceIndex = m_sequencePos;
251 }
252 }
253
254 // Do different things depending on the mode in use
255 if (m_useIndex) {
256 if (m_sequenceIndex == INDEX_NOT_FOUND) {
257 // Store the data in the circular buffer
258 m_initialSequences[m_initialSequencesWritePos] = sequence;
259 m_initialSequencesWritePos = (m_initialSequencesWritePos + 1) % (OVERLAP_SEQUENCE_MATCHES * OVERLAP_EXTRA_BUFFER);
260 if (m_initialSequencesLength < OVERLAP_SEQUENCE_MATCHES * OVERLAP_EXTRA_BUFFER) m_initialSequencesLength++;
261 m_revolutionReady = false;
262 }
263 else {
264 // Was the FIRST index detected?
265 if ((isIndex) && (m_nextSequenceIndex == INDEX_NOT_FOUND) && (m_initialSequencesLength == OVERLAP_SEQUENCE_MATCHES * OVERLAP_EXTRA_BUFFER)) {
266 // Ok, shunt the buffer we have onto the output, this is a short buffer of samples collected before INDEX was detected.
267 m_sequencePos = m_initialSequencesLength;

Callers 3

addToExtractorMethod · 0.80
readDataMethod · 0.80
readRotationMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected