core/queue: Move queue_remove_all() out of the queue struct
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
ea00b406e5
commit
acc78a6667
|
@ -32,7 +32,7 @@ unsigned int TempQueue :: add(struct track *track)
|
|||
|
||||
void TempQueue :: del(struct track *track)
|
||||
{
|
||||
queue :: del(track);
|
||||
queue_remove_all(this, track);
|
||||
deck :: write();
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ struct track *deck :: next()
|
|||
if (!track)
|
||||
track = queue_next(collection :: get_queue());
|
||||
if (track) {
|
||||
recent_queue.del(track);
|
||||
queue_remove_all(&recent_queue, track);
|
||||
queue_add(&recent_queue, track);
|
||||
recent_queue.q_cur = 0;
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ static void validate_library(void *data)
|
|||
|
||||
path = track_path(track);
|
||||
if (g_file_test(path, G_FILE_TEST_EXISTS) == false) {
|
||||
library_q.del(track);
|
||||
queue_remove_all(&library_q, track);
|
||||
track_remove(track);
|
||||
}
|
||||
g_free(path);
|
||||
|
@ -225,7 +225,7 @@ void collection :: set_enabled(struct library *library, bool enabled)
|
|||
if (enabled)
|
||||
queue_add(&library_q, track);
|
||||
else
|
||||
library_q.del(track);
|
||||
queue_remove_all(&library_q, track);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,8 @@ void playlist :: init()
|
|||
return;
|
||||
|
||||
set_for_each(&ent->ie_set, &it)
|
||||
collection :: get_queue()->del(track_get(it.it_val));
|
||||
queue_remove_all(collection :: get_queue(),
|
||||
track_get(it.it_val));
|
||||
}
|
||||
|
||||
bool playlist :: has(struct track *track, const std::string &name)
|
||||
|
@ -107,7 +108,7 @@ void playlist :: add(struct track *track, const std::string &name)
|
|||
if (cur_plist == name)
|
||||
queue_add(&playlist_q, track);
|
||||
if (name == "Banned")
|
||||
collection :: get_queue()->del(track);
|
||||
queue_remove_all(collection :: get_queue(), track);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +116,7 @@ void playlist :: del(struct track *track, const std::string &name)
|
|||
{
|
||||
index_remove(&playlist_db, name.c_str(), track->tr_dbe.dbe_index);
|
||||
if (cur_plist == name)
|
||||
playlist_q.del(track);
|
||||
queue_remove_all(&playlist_q, track);
|
||||
if (name == "Banned")
|
||||
queue_add(collection :: get_queue(), track);
|
||||
}
|
||||
|
|
|
@ -141,11 +141,12 @@ void queue_remove(struct queue *queue, unsigned int index)
|
|||
queue->q_cur--;
|
||||
}
|
||||
|
||||
void queue :: del(struct track *track)
|
||||
void queue_remove_all(struct queue *queue, struct track *track)
|
||||
{
|
||||
for (unsigned int i = 0; i < q_tracks.size(); i++) {
|
||||
while ((i < q_tracks.size()) && (q_tracks[i] == track))
|
||||
queue_remove(this, i);
|
||||
for (unsigned int i = 0; i < queue->q_tracks.size(); i++) {
|
||||
while (i < queue->q_tracks.size() &&
|
||||
queue->q_tracks[i] == track)
|
||||
queue_remove(queue, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ static void remove_banned_tracks()
|
|||
return;
|
||||
|
||||
set_for_each(&ent->ie_set, &it)
|
||||
collection :: get_queue()->del(track_get(it.it_val));
|
||||
queue_remove_all(collection :: get_queue(), track_get(it.it_val));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -108,14 +108,6 @@ struct queue {
|
|||
* @param file File to read Queue data from.
|
||||
*/
|
||||
void read(file &);
|
||||
|
||||
|
||||
/**
|
||||
* Remove all instances of a track from the queue.
|
||||
*
|
||||
* @param track Track to remove from the queue.
|
||||
*/
|
||||
virtual void del(struct track *);
|
||||
};
|
||||
|
||||
|
||||
|
@ -154,6 +146,9 @@ unsigned int queue_add(struct queue *, struct track *);
|
|||
/* Called to remove a track from the queue by index. */
|
||||
void queue_remove(struct queue *, unsigned int);
|
||||
|
||||
/* Called to remove all instances of the track from the queue. */
|
||||
void queue_remove_all(struct queue *, struct track *);
|
||||
|
||||
/* Called to tell the queue that a track has been updated. */
|
||||
void queue_updated(struct queue *, struct track *);
|
||||
|
||||
|
|
|
@ -168,11 +168,11 @@ static void test_stress(unsigned int N)
|
|||
test_equal(q.q_length, ex_length);
|
||||
test_equal(queue_size(&q), ex_size);
|
||||
|
||||
/* Queue :: del(struct track *) */
|
||||
/* queue_remove_all() */
|
||||
track = track_get(0);
|
||||
ex_length -= track->tr_length * (N / 13);
|
||||
ex_size -= (N / 13);
|
||||
q.del(track);
|
||||
queue_remove_all(&q, track);
|
||||
test_equal(q.q_length, ex_length);
|
||||
test_equal(queue_size(&q), ex_size);
|
||||
|
||||
|
|
Loading…
Reference in New Issue