aboutsummaryrefslogtreecommitdiffstats
path: root/src/song.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/song.h')
-rw-r--r--src/song.h65
1 files changed, 54 insertions, 11 deletions
diff --git a/src/song.h b/src/song.h
index 8b97d45d0..39f916a6a 100644
--- a/src/song.h
+++ b/src/song.h
@@ -21,7 +21,9 @@
#define MPD_SONG_H
#include "util/list.h"
+#include "gcc.h"
+#include <assert.h>
#include <stddef.h>
#include <stdbool.h>
#include <sys/time.h>
@@ -58,6 +60,14 @@ struct song {
char uri[sizeof(int)];
};
+/**
+ * A dummy #directory instance that is used for "detached" song
+ * copies.
+ */
+extern struct directory detached_root;
+
+G_BEGIN_DECLS
+
/** allocate a new song with a remote URL */
struct song *
song_remote_new(const char *uri);
@@ -83,9 +93,52 @@ song_file_load(const char *path, struct directory *parent);
struct song *
song_replace_uri(struct song *song, const char *uri);
+/**
+ * Creates a "detached" song object.
+ */
+struct song *
+song_detached_new(const char *uri);
+
+/**
+ * Creates a duplicate of the song object. If the object is in the
+ * database, it creates a "detached" copy of this song, see
+ * song_is_detached().
+ */
+gcc_malloc
+struct song *
+song_dup_detached(const struct song *src);
+
void
song_free(struct song *song);
+static inline bool
+song_in_database(const struct song *song)
+{
+ return song->parent != NULL;
+}
+
+static inline bool
+song_is_file(const struct song *song)
+{
+ return song_in_database(song) || song->uri[0] == '/';
+}
+
+static inline bool
+song_is_detached(const struct song *song)
+{
+ assert(song != NULL);
+ assert(song_in_database(song));
+
+ return song->parent == &detached_root;
+}
+
+/**
+ * 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);
@@ -105,16 +158,6 @@ song_get_uri(const struct song *song);
double
song_get_duration(const struct song *song);
-static inline bool
-song_in_database(const struct song *song)
-{
- return song->parent != NULL;
-}
-
-static inline bool
-song_is_file(const struct song *song)
-{
- return song_in_database(song) || song->uri[0] == '/';
-}
+G_END_DECLS
#endif