This commit is contained in:
Max Kellermann 2025-01-29 17:21:54 +01:00
commit f6bd49ba61
7 changed files with 40 additions and 5 deletions

@ -239,6 +239,10 @@ DecoderBridge::UpdateStreamTag(InputStream *is) noexcept
/* discard the song tag; we don't need it */
song_tag.reset();
if (stream_tag && tag && *stream_tag == *tag)
/* not changed */
return false;
stream_tag = std::move(tag);
return true;
}

@ -904,13 +904,15 @@ PlayerControl::LockUpdateSongTag(DetachedSong &song,
streams may change tags dynamically */
return;
song.SetTag(new_tag);
if (new_tag != song.GetTag()) {
song.SetTag(new_tag);
LockSetTaggedSong(song);
LockSetTaggedSong(song);
/* the main thread will update the playlist version when he
receives this event */
listener.OnPlayerTagModified();
/* the main thread will update the playlist version when he
receives this event */
listener.OnPlayerTagModified();
}
}
inline void

@ -5,6 +5,7 @@
#define MPD_TAG_ITEM_HXX
#include <cstdint>
#include <cstring>
enum TagType : uint8_t;
@ -22,6 +23,15 @@ struct TagItem {
*/
char value[1];
bool operator==(const TagItem &other) const noexcept {
return (this == &other) ? true :
type == other.type && std::strcmp(value, other.value) == 0;
}
private:
/* making the constructor private
to only allow construction by TagPoolItem. */
friend struct TagPoolItem;
TagItem() = default;
TagItem(const TagItem &other) = delete;
TagItem &operator=(const TagItem &other) = delete;

@ -7,6 +7,15 @@
#include <cassert>
bool
Tag::operator==(const Tag &other) const noexcept {
return (this == &other) ? true :
duration == other.duration
&& has_playlist == other.has_playlist
&& num_items == other.num_items
&& std::equal(begin(), end(), other.begin(), other.end());
}
void
Tag::Clear() noexcept
{

@ -65,6 +65,8 @@ struct Tag {
return *this;
}
bool operator==(const Tag &other) const noexcept;
/**
* Similar to the move operator, but move only the #TagItem
* array.

@ -82,6 +82,10 @@ public:
return DereferenceIterator{original - n};
}
constexpr auto operator-(const DereferenceIterator<IT, VT>& other) const noexcept {
return std::distance(other.original, original);
}
/* this is a template to allow comparisons with sentinel end
iterators */
template<typename IT2>

@ -101,6 +101,10 @@ public:
return iterator{cursor - n};
}
constexpr auto operator-(const iterator& other) const noexcept {
return std::distance(other.cursor, cursor);
}
reference operator*() const noexcept {
return *cursor;
}