aboutsummaryrefslogtreecommitdiffstats
path: root/src/Song.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-08-09 21:20:24 +0200
committerMax Kellermann <max@duempel.org>2012-08-15 23:06:59 +0200
commitc2e4fe983da690907316dac9cd1838fc713dec1b (patch)
treedee356597f2d63fe66c92b6a49a7ada1e75010e4 /src/Song.cxx
parent81e898375bed0eeed43170629972d8cbc8e4231e (diff)
downloadmpd-c2e4fe983da690907316dac9cd1838fc713dec1b.tar.gz
mpd-c2e4fe983da690907316dac9cd1838fc713dec1b.tar.xz
mpd-c2e4fe983da690907316dac9cd1838fc713dec1b.zip
Song: add function song_equals()
decoder_is_current_song() now recognizes different instances of the same physical song.
Diffstat (limited to 'src/Song.cxx')
-rw-r--r--src/Song.cxx27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/Song.cxx b/src/Song.cxx
index 006ef8aaa..3dfdc0c74 100644
--- a/src/Song.cxx
+++ b/src/Song.cxx
@@ -84,6 +84,33 @@ song_free(struct song *song)
g_free(song);
}
+gcc_pure
+static inline bool
+directory_equals(const struct directory &a, const struct directory &b)
+{
+ return strcmp(a.path, b.path) == 0;
+}
+
+gcc_pure
+static inline bool
+directory_is_same(const struct directory *a, const struct directory *b)
+{
+ return a == b ||
+ (a != nullptr && b != nullptr &&
+ directory_equals(*a, *b));
+
+}
+
+bool
+song_equals(const struct song *a, const struct song *b)
+{
+ assert(a != nullptr);
+ assert(b != nullptr);
+
+ return directory_is_same(a->parent, b->parent) &&
+ strcmp(a->uri, b->uri) == 0;
+}
+
char *
song_get_uri(const struct song *song)
{