diff options
author | Uwe Klotz <uklotz@mixxx.org> | 2021-01-14 00:41:08 +0100 |
---|---|---|
committer | Uwe Klotz <uklotz@mixxx.org> | 2021-01-14 02:13:49 +0100 |
commit | 546527b8492493b873962f691dbcd6c297f9c275 (patch) | |
tree | 02b7cca97965cdfdab8cc541f4988f3af3c75054 /src/sources | |
parent | a84d304a76370300ecf57b01583d6f92d8e1d1b2 (diff) |
Preserve precise stream info when (re-)importing file tags
Diffstat (limited to 'src/sources')
-rw-r--r-- | src/sources/soundsourceproxy.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/sources/soundsourceproxy.cpp b/src/sources/soundsourceproxy.cpp index 6bbc9d3981..9bebe1a604 100644 --- a/src/sources/soundsourceproxy.cpp +++ b/src/sources/soundsourceproxy.cpp @@ -537,6 +537,10 @@ void SoundSourceProxy::updateTrackFromSource( mergeImportedMetadata = true; } + // Safe for later to replace the unreliable and imprecise audio + // properties imported from file tags (see below). + const auto preciseStreamInfo = trackMetadata.getStreamInfo(); + // Embedded cover art is imported together with the track's metadata. // But only if the user has not selected external cover art for this // track! @@ -635,7 +639,24 @@ void SoundSourceProxy::updateTrackFromSource( << getUrl().toString(); } } + + // Preserve the precise stream info data (if available) that has been + // obtained from the actual audio stream. If the file content itself + // has been modified the stream info data will be updated next time + // when opening and decoding the audio stream. + if (preciseStreamInfo.isValid()) { + trackMetadata.setStreamInfo(preciseStreamInfo); + } else if (preciseStreamInfo.getSignalInfo().isValid()) { + // Special case: Only the bitrate might be invalid or unknown + trackMetadata.refStreamInfo().setSignalInfo( + preciseStreamInfo.getSignalInfo()); + if (preciseStreamInfo.getDuration() > mixxx::Duration::empty()) { + trackMetadata.refStreamInfo().setDuration(preciseStreamInfo.getDuration()); + } + } + m_pTrack->importMetadata(trackMetadata, metadataImported.second); + bool pendingBeatsImport = m_pTrack->getBeatsImportStatus() == Track::ImportStatus::Pending; bool pendingCueImport = m_pTrack->getCueImportStatus() == Track::ImportStatus::Pending; if (pendingBeatsImport || pendingCueImport) { |