diff --git a/src/engine/cachingreaderchunk.cpp b/src/engine/cachingreaderchunk.cpp index 701fb00bf50..b337786ebcc 100644 --- a/src/engine/cachingreaderchunk.cpp +++ b/src/engine/cachingreaderchunk.cpp @@ -72,7 +72,8 @@ mixxx::IndexRange CachingReaderChunk::bufferSampleFrames( mixxx::WritableSampleFrames( sourceFrameIndexRange, mixxx::SampleBuffer::WritableSlice(m_sampleBuffer))); - DEBUG_ASSERT(m_bufferedSampleFrames.frameIndexRange() <= sourceFrameIndexRange); + DEBUG_ASSERT(m_bufferedSampleFrames.frameIndexRange().empty() || + m_bufferedSampleFrames.frameIndexRange() <= sourceFrameIndexRange); return m_bufferedSampleFrames.frameIndexRange(); } diff --git a/src/sources/soundsourceflac.cpp b/src/sources/soundsourceflac.cpp index 1a95ac168c5..bf174445703 100644 --- a/src/sources/soundsourceflac.cpp +++ b/src/sources/soundsourceflac.cpp @@ -143,9 +143,9 @@ ReadableSampleFrames SoundSourceFLAC::readSampleFramesClamped( m_sampleBuffer.clear(); invalidateCurFrameIndex(); if (FLAC__stream_decoder_seek_absolute(m_decoder, seekFrameIndex)) { + DEBUG_ASSERT(FLAC__STREAM_DECODER_SEEK_ERROR != FLAC__stream_decoder_get_state(m_decoder)); // Success: Set the new position m_curFrameIndex = seekFrameIndex; - DEBUG_ASSERT(FLAC__STREAM_DECODER_SEEK_ERROR != FLAC__stream_decoder_get_state(m_decoder)); } else { // Failure kLogger.warning() @@ -179,8 +179,14 @@ ReadableSampleFrames SoundSourceFLAC::readSampleFramesClamped( } else { // We have already reached the beginning of the file // and cannot move the seek position backwards any - // further! - break; // exit loop + // further! As a last resort try to reset the decoder. + kLogger.warning() + << "Resetting decoder after seek errors"; + if (!FLAC__stream_decoder_reset(m_decoder)) { + kLogger.critical() + << "Failed to reset decoder after seek errors"; + break; // exit loop + } } } } @@ -193,8 +199,12 @@ ReadableSampleFrames SoundSourceFLAC::readSampleFramesClamped( && (precedingFrames != readSampleFramesClamped( WritableSampleFrames(precedingFrames)).frameIndexRange())) { kLogger.warning() - << "Failed to skip preceding frames" + << "Resetting decoder after failure to skip preceding frames" << precedingFrames; + if (!FLAC__stream_decoder_reset(m_decoder)) { + kLogger.critical() + << "Failed to reset decoder after skip errors"; + } // Abort return ReadableSampleFrames( IndexRange::between(