Merge branch 'tag-compare' of https://github.com/geneticdrift/MPD
This commit is contained in:
src
@ -239,6 +239,10 @@ DecoderBridge::UpdateStreamTag(InputStream *is) noexcept
|
|||||||
/* discard the song tag; we don't need it */
|
/* discard the song tag; we don't need it */
|
||||||
song_tag.reset();
|
song_tag.reset();
|
||||||
|
|
||||||
|
if (stream_tag && tag && *stream_tag == *tag)
|
||||||
|
/* not changed */
|
||||||
|
return false;
|
||||||
|
|
||||||
stream_tag = std::move(tag);
|
stream_tag = std::move(tag);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -904,13 +904,15 @@ PlayerControl::LockUpdateSongTag(DetachedSong &song,
|
|||||||
streams may change tags dynamically */
|
streams may change tags dynamically */
|
||||||
return;
|
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
|
/* the main thread will update the playlist version when he
|
||||||
receives this event */
|
receives this event */
|
||||||
listener.OnPlayerTagModified();
|
listener.OnPlayerTagModified();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#define MPD_TAG_ITEM_HXX
|
#define MPD_TAG_ITEM_HXX
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
enum TagType : uint8_t;
|
enum TagType : uint8_t;
|
||||||
|
|
||||||
@ -22,6 +23,15 @@ struct TagItem {
|
|||||||
*/
|
*/
|
||||||
char value[1];
|
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() = default;
|
||||||
TagItem(const TagItem &other) = delete;
|
TagItem(const TagItem &other) = delete;
|
||||||
TagItem &operator=(const TagItem &other) = delete;
|
TagItem &operator=(const TagItem &other) = delete;
|
||||||
|
@ -7,6 +7,15 @@
|
|||||||
|
|
||||||
#include <cassert>
|
#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
|
void
|
||||||
Tag::Clear() noexcept
|
Tag::Clear() noexcept
|
||||||
{
|
{
|
||||||
|
@ -65,6 +65,8 @@ struct Tag {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator==(const Tag &other) const noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to the move operator, but move only the #TagItem
|
* Similar to the move operator, but move only the #TagItem
|
||||||
* array.
|
* array.
|
||||||
|
@ -82,6 +82,10 @@ public:
|
|||||||
return DereferenceIterator{original - n};
|
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
|
/* this is a template to allow comparisons with sentinel end
|
||||||
iterators */
|
iterators */
|
||||||
template<typename IT2>
|
template<typename IT2>
|
||||||
|
@ -101,6 +101,10 @@ public:
|
|||||||
return iterator{cursor - n};
|
return iterator{cursor - n};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr auto operator-(const iterator& other) const noexcept {
|
||||||
|
return std::distance(other.cursor, cursor);
|
||||||
|
}
|
||||||
|
|
||||||
reference operator*() const noexcept {
|
reference operator*() const noexcept {
|
||||||
return *cursor;
|
return *cursor;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user