aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Song.cxx27
-rw-r--r--src/decoder_control.c3
-rw-r--r--src/song.h8
3 files changed, 37 insertions, 1 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)
{
diff --git a/src/decoder_control.c b/src/decoder_control.c
index 2a2d8ac66..8bf21365c 100644
--- a/src/decoder_control.c
+++ b/src/decoder_control.c
@@ -20,6 +20,7 @@
#include "config.h"
#include "decoder_control.h"
#include "pipe.h"
+#include "song.h"
#include <assert.h>
@@ -111,7 +112,7 @@ decoder_is_current_song(const struct decoder_control *dc,
case DECODE_STATE_START:
case DECODE_STATE_DECODE:
- return dc->song == song;
+ return song_equals(dc->song, song);
}
assert(false);
diff --git a/src/song.h b/src/song.h
index 1834b36ed..366ffc1a1 100644
--- a/src/song.h
+++ b/src/song.h
@@ -21,6 +21,7 @@
#define MPD_SONG_H
#include "util/list.h"
+#include "gcc.h"
#include <stddef.h>
#include <stdbool.h>
@@ -100,6 +101,13 @@ song_is_file(const struct song *song)
return song_in_database(song) || song->uri[0] == '/';
}
+/**
+ * Returns true if both objects refer to the same physical song.
+ */
+gcc_pure
+bool
+song_equals(const struct song *a, const struct song *b);
+
bool
song_file_update(struct song *song);