aboutsummaryrefslogtreecommitdiffstats
path: root/src/queue.h
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-23 00:06:38 +0100
committerMax Kellermann <max@duempel.org>2009-01-23 00:06:38 +0100
commitaa9ffcd04d3100627a147f015919976681627627 (patch)
tree38211725a5011271ecc5ec8eba64f5cfd9999b9d /src/queue.h
parentf78cddb407dbd8c3f5a1860ca5052d6a5984b734 (diff)
downloadmpd-aa9ffcd04d3100627a147f015919976681627627.tar.gz
mpd-aa9ffcd04d3100627a147f015919976681627627.tar.xz
mpd-aa9ffcd04d3100627a147f015919976681627627.zip
queue: merged songs, songMod, positionToId into struct queue_item
Move everything which belongs together into one common struct. This simplifies the implementation of several queue operations.
Diffstat (limited to 'src/queue.h')
-rw-r--r--src/queue.h30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/queue.h b/src/queue.h
index 098424cdd..e27a470d9 100644
--- a/src/queue.h
+++ b/src/queue.h
@@ -34,6 +34,20 @@ enum {
};
/**
+ * One element of the queue: basically a song plus some queue specific
+ * information attached.
+ */
+struct queue_item {
+ struct song *song;
+
+ /** the unique id of this item in the queue */
+ unsigned id;
+
+ /** when was this item last changed? */
+ uint32_t version;
+};
+
+/**
* A queue of songs. This is the backend of the playlist: it contains
* an ordered list of songs.
*
@@ -54,17 +68,11 @@ struct queue {
uint32_t version;
/** all songs in "position" order */
- struct song **songs;
-
- /** holds version a song was modified on */
- uint32_t *songMod;
+ struct queue_item *items;
/** map order numbers to positions */
unsigned *order;
- /** map positions to song ids */
- unsigned *positionToId;
-
/** map song ids to posiitons */
int *idToPosition;
@@ -142,7 +150,7 @@ queue_position_to_id(const struct queue *queue, unsigned position)
{
assert(position < queue->length);
- return queue->positionToId[position];
+ return queue->items[position].id;
}
static inline unsigned
@@ -174,7 +182,7 @@ queue_get(const struct queue *queue, unsigned position)
{
assert(position < queue->length);
- return queue->songs[position];
+ return queue->items[position].song;
}
/**
@@ -197,8 +205,8 @@ queue_song_newer(const struct queue *queue, unsigned position,
assert(position < queue->length);
return version > queue->version ||
- queue->songMod[position] >= version ||
- queue->songMod[position] == 0;
+ queue->items[position].version >= version ||
+ queue->items[position].version == 0;
}
/**