summaryrefslogtreecommitdiffstats
path: root/src/sources
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2021-05-13 18:16:33 +0200
committerUwe Klotz <uklotz@mixxx.org>2021-05-13 18:54:04 +0200
commit834980c4d1e6a3a02aa4a40b7e29b3da8ef9c2d8 (patch)
tree4700d7926eb2dd9898ef610e214caadfa22460ea /src/sources
parent788b3a361f20f82ffa4574ccdf56c059302d5ea8 (diff)
Indicate if modified/unmodified when importing track metadata
Diffstat (limited to 'src/sources')
-rw-r--r--src/sources/soundsourceproxy.cpp26
-rw-r--r--src/sources/soundsourceproxy.h7
2 files changed, 21 insertions, 12 deletions
diff --git a/src/sources/soundsourceproxy.cpp b/src/sources/soundsourceproxy.cpp
index 7893f67037..ca7d8e630c 100644
--- a/src/sources/soundsourceproxy.cpp
+++ b/src/sources/soundsourceproxy.cpp
@@ -304,7 +304,9 @@ SoundSourceProxy::allProviderRegistrationsForUrl(
//static
ExportTrackMetadataResult
-SoundSourceProxy::exportTrackMetadataBeforeSaving(Track* pTrack, UserSettingsPointer pConfig) {
+SoundSourceProxy::exportTrackMetadataBeforeSaving(
+ Track* pTrack,
+ const UserSettingsPointer& pConfig) {
DEBUG_ASSERT(pTrack);
const auto fileInfo = pTrack->getFileInfo();
mixxx::MetadataSourcePointer pMetadataSource;
@@ -333,7 +335,7 @@ SoundSourceProxy::exportTrackMetadataBeforeSaving(Track* pTrack, UserSettingsPoi
} else {
kLogger.warning()
<< "Unable to export track metadata into file"
- << fileInfo.location();
+ << fileInfo;
return ExportTrackMetadataResult::Skipped;
}
}
@@ -512,19 +514,19 @@ SoundSourceProxy::importTrackMetadataAndCoverImage(
pCoverImage);
}
-void SoundSourceProxy::updateTrackFromSource(
+bool SoundSourceProxy::updateTrackFromSource(
UpdateTrackFromSourceMode mode) {
DEBUG_ASSERT(m_pTrack);
if (getUrl().isEmpty()) {
// Silently skip tracks without a corresponding file
- return; // abort
+ return false; // abort
}
if (!m_pSoundSource) {
kLogger.warning()
<< "Unable to update track from unsupported file type"
<< getUrl().toString();
- return; // abort
+ return false; // abort
}
// The SoundSource provides the actual type of the corresponding file
@@ -569,7 +571,7 @@ void SoundSourceProxy::updateTrackFromSource(
<< getUrl().toString();
}
} else {
- // (Re-)import embedded cover art
+ // Request reimport of embedded cover art
pCoverImg = &coverImg;
}
}
@@ -595,9 +597,11 @@ void SoundSourceProxy::updateTrackFromSource(
if (metadataImported.first == mixxx::MetadataSource::ImportResult::Succeeded) {
// Partial import of properties that are not (yet) stored
// in the database
- m_pTrack->mergeImportedMetadata(trackMetadata);
- } // else: Nothing to do if no metadata has been imported
- return;
+ return m_pTrack->mergeImportedMetadata(trackMetadata);
+ } else {
+ // Nothing to do if no metadata has been imported
+ return false;
+ }
}
// Full import
@@ -674,7 +678,7 @@ void SoundSourceProxy::updateTrackFromSource(
// Do not continue with unknown and maybe invalid metadata!
if (metadataImported.first != mixxx::MetadataSource::ImportResult::Succeeded) {
- return;
+ return false;
}
m_pTrack->importMetadata(trackMetadata, metadataImported.second);
@@ -706,6 +710,8 @@ void SoundSourceProxy::updateTrackFromSource(
DEBUG_ASSERT(coverInfo.source == CoverInfo::GUESSED);
m_pTrack->setCoverInfo(coverInfo);
}
+
+ return true;
}
mixxx::AudioSourcePointer SoundSourceProxy::openAudioSource(
diff --git a/src/sources/soundsourceproxy.h b/src/sources/soundsourceproxy.h
index 485daacd40..0a26cac367 100644
--- a/src/sources/soundsourceproxy.h
+++ b/src/sources/soundsourceproxy.h
@@ -139,7 +139,9 @@ class SoundSourceProxy {
/// too many possible reasons for failure to consider that cannot be handled
/// properly. The application log will contain warning messages for a detailed
/// analysis in case unexpected behavior has been reported.
- void updateTrackFromSource(
+ ///
+ /// Returns true if the track has been modified and false otherwise.
+ bool updateTrackFromSource(
UpdateTrackFromSourceMode mode = UpdateTrackFromSourceMode::Default);
/// Opening the audio source through the proxy will update the
@@ -167,7 +169,8 @@ class SoundSourceProxy {
friend class TrackCollectionManager;
static ExportTrackMetadataResult exportTrackMetadataBeforeSaving(
- Track* pTrack, UserSettingsPointer pConfig);
+ Track* pTrack,
+ const UserSettingsPointer& pConfig);
// Special case: Construction from a url is needed
// for writing metadata immediately before the TIO is destroyed.