aboutsummaryrefslogtreecommitdiff
path: root/src/song.h
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-08-15 22:44:21 +0200
committerMax Kellermann <max@duempel.org>2012-08-15 23:07:24 +0200
commit916a02017333ac32b8058d3c397eeb4ec85b742b (patch)
treed68e24237cf924eb7c077407cb415968010e2cac /src/song.h
parentc2e4fe983da690907316dac9cd1838fc713dec1b (diff)
Song: add function song_dup_detached()
Initial support for "detached" songs that come from the database, but are private copies.
Diffstat (limited to 'src/song.h')
-rw-r--r--src/song.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/song.h b/src/song.h
index 366ffc1a..a09b69df 100644
--- a/src/song.h
+++ b/src/song.h
@@ -23,6 +23,7 @@
#include "util/list.h"
#include "gcc.h"
+#include <assert.h>
#include <stddef.h>
#include <stdbool.h>
#include <sys/time.h>
@@ -59,6 +60,12 @@ 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 */
@@ -86,6 +93,15 @@ song_file_load(const char *path, struct directory *parent);
struct song *
song_replace_uri(struct song *song, 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);
@@ -101,6 +117,15 @@ 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.
*/