diff options
author | Uwe Klotz <uklotz@mixxx.org> | 2021-03-19 19:43:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-19 19:43:12 +0100 |
commit | 31953aa8ef4372ff77666bd267200dcf83f0ea11 (patch) | |
tree | cb8737bba59f3fdfa1da473a7ef9df9ecd6aaf59 | |
parent | 7866dea6e4ad38392040ea37739feba4ae8cceae (diff) | |
parent | ae796a0f9b9ce7e548236f45e4ff2344634cd064 (diff) |
Merge pull request #3729 from Holzhaus/serato-cue-import-keep-other
Do not discard cue types that can't be imported by SeratoCueImporter (lp1920087)
-rw-r--r-- | src/track/cueinfoimporter.cpp | 10 | ||||
-rw-r--r-- | src/track/cueinfoimporter.h | 3 | ||||
-rw-r--r-- | src/track/serato/cueinfoimporter.cpp | 12 | ||||
-rw-r--r-- | src/track/serato/cueinfoimporter.h | 2 | ||||
-rw-r--r-- | src/track/track.cpp | 11 |
5 files changed, 37 insertions, 1 deletions
diff --git a/src/track/cueinfoimporter.cpp b/src/track/cueinfoimporter.cpp index 8f8012962d..e975588e72 100644 --- a/src/track/cueinfoimporter.cpp +++ b/src/track/cueinfoimporter.cpp @@ -6,6 +6,16 @@ CueInfoImporter::CueInfoImporter(const QList<CueInfo>& cueInfos) : m_cueInfos(cueInfos) { } +bool CueInfoImporter::hasCueOfType(CueType cueType) const { + for (const CueInfo& cueInfo : qAsConst(m_cueInfos)) { + if (cueInfo.getType() == cueType) { + return true; + } + } + + return false; +} + double CueInfoImporter::guessTimingOffsetMillis( const QString& filePath, const audio::SignalInfo& signalInfo) const { diff --git a/src/track/cueinfoimporter.h b/src/track/cueinfoimporter.h index 54304c60d9..4de334a1d8 100644 --- a/src/track/cueinfoimporter.h +++ b/src/track/cueinfoimporter.h @@ -14,6 +14,9 @@ class CueInfoImporter { explicit CueInfoImporter(const QList<CueInfo>& cueInfos); virtual ~CueInfoImporter() = default; + /// Returns true if the importer has any cue(s) of the given cueType. + virtual bool hasCueOfType(CueType cueType) const; + /// Returns audio signal dependent timing offset correction. /// The default implementation just returns 0, but this can be overridden /// in subclasses. diff --git a/src/track/serato/cueinfoimporter.cpp b/src/track/serato/cueinfoimporter.cpp index 30aaeee56a..e1f81b335c 100644 --- a/src/track/serato/cueinfoimporter.cpp +++ b/src/track/serato/cueinfoimporter.cpp @@ -4,6 +4,18 @@ namespace mixxx { +bool SeratoCueInfoImporter::hasCueOfType(CueType cueType) const { + // Make this a little more efficient by skipping cue types this importer + // will never contain. + switch (cueType) { + case CueType::HotCue: + case CueType::Loop: + return CueInfoImporter::hasCueOfType(cueType); + default: + return false; + } +} + /// This method simply calls SeratoTags::guessTimingOffsetMillis() and returns /// its result. We also need the timing offset for exporting our cues to /// Serato, so the actual cue offset calculation remains a static method of diff --git a/src/track/serato/cueinfoimporter.h b/src/track/serato/cueinfoimporter.h index 1310e8bba8..a068dc1402 100644 --- a/src/track/serato/cueinfoimporter.h +++ b/src/track/serato/cueinfoimporter.h @@ -10,6 +10,8 @@ class SeratoCueInfoImporter : public CueInfoImporter { ~SeratoCueInfoImporter() override = default; + bool hasCueOfType(CueType cueType) const override; + double guessTimingOffsetMillis( const QString& filePath, const audio::SignalInfo& signalInfo) const override; diff --git a/src/track/track.cpp b/src/track/track.cpp index 3e7a3ad74a..9d734c2017 100644 --- a/src/track/track.cpp +++ b/src/track/track.cpp @@ -1108,7 +1108,16 @@ bool Track::importPendingCueInfosWhileLocked() { m_record.getMetadata().getStreamInfo().getSignalInfo().getSampleRate()); const auto trackId = m_record.getId(); QList<CuePointer> cuePoints; - cuePoints.reserve(m_pCueInfoImporterPending->size()); + cuePoints.reserve(m_pCueInfoImporterPending->size() + m_cuePoints.size()); + + // Preserve all existing cues with types that are not available for + // importing. + for (const CuePointer& pCue : qAsConst(m_cuePoints)) { + if (!m_pCueInfoImporterPending->hasCueOfType(pCue->getType())) { + cuePoints.append(pCue); + } + } + const auto cueInfos = m_pCueInfoImporterPending->importCueInfosAndApplyTimingOffset( getLocation(), m_record.getStreamInfoFromSource()->getSignalInfo()); |