Update temporary metadata when tags are changed

This commit is contained in:
Jonas Kvinge
2019-12-21 21:55:24 +01:00
parent 97bc980611
commit 882c94110e
3 changed files with 14 additions and 0 deletions

View File

@@ -76,6 +76,18 @@ void PlaylistItem::SetTemporaryMetadata(const Song &metadata) {
temp_metadata_ = metadata;
}
void PlaylistItem::UpdateTemporaryMetadata(const Song &metadata) {
Song old_metadata = temp_metadata_;
temp_metadata_ = metadata;
// Keep samplerate, bitdepth and bitrate from the old metadata if it's not present in the new.
if (temp_metadata_.samplerate() <= 0 && old_metadata.samplerate() > 0) temp_metadata_.set_samplerate(old_metadata.samplerate());
if (temp_metadata_.bitdepth() <= 0 && old_metadata.bitdepth() > 0) temp_metadata_.set_bitdepth(old_metadata.bitdepth());
if (temp_metadata_.bitrate() <= 0 && old_metadata.bitrate() > 0) temp_metadata_.set_bitrate(old_metadata.bitrate());
}
void PlaylistItem::ClearTemporaryMetadata() {
temp_metadata_ = Song();
}