diff --git a/src/sources/soundsourceproxy.cpp b/src/sources/soundsourceproxy.cpp index f94c4f1f44b..69d94ea1982 100644 --- a/src/sources/soundsourceproxy.cpp +++ b/src/sources/soundsourceproxy.cpp @@ -542,15 +542,6 @@ bool SoundSourceProxy::updateTrackFromSource( bool metadataSynchronized = false; mixxx::TrackMetadata trackMetadata = m_pTrack->getMetadata(&metadataSynchronized); - // If the file tags have already been parsed at least once, the - // existing track metadata should not be updated implicitly, i.e. - // if the user did not explicitly choose to (re-)import metadata - // explicitly from this file. - bool mergeExtraMetadataFromSource = false; - if (metadataSynchronized && mode == UpdateTrackFromSourceMode::Once) { - // No (re-)import needed or desired, only merge missing properties - mergeExtraMetadataFromSource = true; - } // Save for later to replace the unreliable and imprecise audio // properties imported from file tags (see below). @@ -562,7 +553,17 @@ bool SoundSourceProxy::updateTrackFromSource( QImage coverImg; DEBUG_ASSERT(coverImg.isNull()); QImage* pCoverImg = nullptr; // pointer also serves as a flag - if (!mergeExtraMetadataFromSource) { + + // If the file tags have already been parsed at least once, the + // existing track metadata should not be updated implicitly, i.e. + // if the user did not explicitly choose to (re-)import metadata + // explicitly from this file. + bool mergeExtraMetadataFromSource = false; + if (metadataSynchronized && mode == UpdateTrackFromSourceMode::Once) { + // No (re-)import needed or desired, only merge missing properties + mergeExtraMetadataFromSource = true; + } else { + // Import the cover initially or when a reimport has been requested const auto coverInfo = m_pTrack->getCoverInfo(); if (coverInfo.source == CoverInfo::USER_SELECTED && coverInfo.type == CoverInfo::FILE) { @@ -579,10 +580,12 @@ bool SoundSourceProxy::updateTrackFromSource( } // Parse the tags stored in the audio file - auto metadataImported = - m_pSoundSource->importTrackMetadataAndCoverImage( - &trackMetadata, pCoverImg); - if (metadataImported.first == mixxx::MetadataSource::ImportResult::Failed) { + auto metadataImportedFromSource = + importTrackMetadataAndCoverImage( + &trackMetadata, + pCoverImg); + if (metadataImportedFromSource.first == + mixxx::MetadataSource::ImportResult::Failed) { kLogger.warning() << "Failed to import track metadata" << (pCoverImg ? "and embedded cover art" : "") @@ -596,7 +599,7 @@ bool SoundSourceProxy::updateTrackFromSource( if (mergeExtraMetadataFromSource) { // No reimport of embedded cover image desired in this case DEBUG_ASSERT(!pCoverImg); - if (metadataImported.first == mixxx::MetadataSource::ImportResult::Succeeded) { + if (metadataImportedFromSource.first == mixxx::MetadataSource::ImportResult::Succeeded) { // Partial import of properties that are not (yet) stored // in the database return m_pTrack->mergeExtraMetadataFromSource(trackMetadata); @@ -669,26 +672,28 @@ bool SoundSourceProxy::updateTrackFromSource( if (trackMetadata.refTrackInfo().parseArtistTitleFromFileName( fileInfo.fileName(), splitArtistTitle)) { // Pretend that metadata import succeeded - metadataImported.first = mixxx::MetadataSource::ImportResult::Succeeded; - if (metadataImported.second.isNull()) { + metadataImportedFromSource.first = mixxx::MetadataSource::ImportResult::Succeeded; + if (metadataImportedFromSource.second.isNull()) { // Since this is also some kind of metadata import, we mark the // track's metadata as synchronized with the time stamp of the file. - metadataImported.second = fileInfo.lastModified(); + metadataImportedFromSource.second = fileInfo.lastModified(); } } } // Do not continue with unknown and maybe invalid metadata! - if (metadataImported.first != mixxx::MetadataSource::ImportResult::Succeeded) { + if (metadataImportedFromSource.first != mixxx::MetadataSource::ImportResult::Succeeded) { return false; } m_pTrack->replaceMetadataFromSource( std::move(trackMetadata), - metadataImported.second); + metadataImportedFromSource.second); - bool pendingBeatsImport = m_pTrack->getBeatsImportStatus() == Track::ImportStatus::Pending; - bool pendingCueImport = m_pTrack->getCueImportStatus() == Track::ImportStatus::Pending; + const bool pendingBeatsImport = + m_pTrack->getBeatsImportStatus() == Track::ImportStatus::Pending; + const bool pendingCueImport = + m_pTrack->getCueImportStatus() == Track::ImportStatus::Pending; if (pendingBeatsImport || pendingCueImport) { // Try to open the audio source once to determine the actual // stream properties for finishing the pending import.