diff --git a/src/library/autodj/autodjprocessor.cpp b/src/library/autodj/autodjprocessor.cpp index 851d6e13efb..59145626715 100644 --- a/src/library/autodj/autodjprocessor.cpp +++ b/src/library/autodj/autodjprocessor.cpp @@ -1116,7 +1116,19 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck, pToDeck->startPos = introStart; } } else if (outroLength > 0 && introLength <= 0) { - pFromDeck->fadeBeginPos = outroStart; + if (outroLength + introStart < pToDeck->fadeBeginPos) { + pFromDeck->fadeBeginPos = outroStart; + } else { + // This happens if the toDeck track has no intro set and the + // outro of the fromDeck track is longer than the whole toDeck + // track + outroLength = pToDeck->fadeBeginPos - introStart; + VERIFY_OR_DEBUG_ASSERT(outroLength > 0) { + // We seek to intro start above in this case so this never happens + outroLength = 1; + } + pFromDeck->fadeBeginPos = outroEnd - outroLength; + } pFromDeck->fadeEndPos = outroEnd; pToDeck->startPos = introStart; } else if (introLength > 0 && outroLength <= 0) { @@ -1159,7 +1171,19 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck, } pToDeck->startPos = introStart; } else if (outroLength > 0 && introLength <= 0) { - pFromDeck->fadeBeginPos = outroStart; + if (outroLength + introStart < pToDeck->fadeBeginPos) { + pFromDeck->fadeBeginPos = outroStart; + } else { + // This happens if the toDeck track has no intro set and the + // outro of the fromDeck track is longer than the whole toDeck + // track + outroLength = pToDeck->fadeBeginPos - introStart; + VERIFY_OR_DEBUG_ASSERT(outroLength > 0) { + // We seek to intro start above in this case so this never happens + outroLength = 1; + } + pFromDeck->fadeBeginPos = outroEnd - outroLength; + } pFromDeck->fadeEndPos = outroEnd; pToDeck->startPos = introStart; } else if (introLength > 0 && outroLength <= 0) {