core/queue: Replace on_track_removed() with qop_removed()
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
df06b444cf
commit
da0c96ac51
|
@ -47,6 +47,17 @@ static inline unsigned int __queue_added(struct queue *queue,
|
|||
return pos;
|
||||
}
|
||||
|
||||
static inline void __queue_removed(struct queue *queue,
|
||||
struct track *track,
|
||||
unsigned int pos)
|
||||
{
|
||||
queue->q_length -= track->tr_length;
|
||||
if (queue->q_cur == pos)
|
||||
queue->q_cur--;
|
||||
if (queue->q_ops)
|
||||
queue->q_ops->qop_removed(queue, pos);
|
||||
}
|
||||
|
||||
static inline void __queue_save(struct queue *queue, enum queue_flags flag)
|
||||
{
|
||||
if (queue->q_ops && queue_has_flag(queue, flag))
|
||||
|
@ -118,12 +129,9 @@ unsigned int queue_add(struct queue *queue, struct track *track)
|
|||
|
||||
void queue_remove(struct queue *queue, unsigned int index)
|
||||
{
|
||||
queue->q_length -= queue->q_tracks[index]->tr_length;
|
||||
struct track *track = queue->q_tracks[index];
|
||||
queue->q_tracks.erase(queue->q_tracks.begin() + index);
|
||||
queue->q_notify->on_track_removed(index);
|
||||
|
||||
if (queue->q_cur == index)
|
||||
queue->q_cur--;
|
||||
__queue_removed(queue, track, index);
|
||||
}
|
||||
|
||||
void queue_remove_all(struct queue *queue, struct track *track)
|
||||
|
|
|
@ -54,8 +54,14 @@ static void collection_added(struct queue *queue, unsigned int pos)
|
|||
collection_tab->on_track_added(pos);
|
||||
}
|
||||
|
||||
static void collection_removed(struct queue *queue, unsigned int pos)
|
||||
{
|
||||
collection_tab->on_track_removed(pos);
|
||||
}
|
||||
|
||||
struct queue_ops collection_ops = {
|
||||
collection_added,
|
||||
collection_removed,
|
||||
collection :: save,
|
||||
};
|
||||
|
||||
|
|
|
@ -40,8 +40,14 @@ static void history_added(struct queue *queue, unsigned int pos)
|
|||
history_tab->on_track_added(pos);
|
||||
}
|
||||
|
||||
static void history_removed(struct queue *queue, unsigned int pos)
|
||||
{
|
||||
history_tab->on_track_removed(pos);
|
||||
}
|
||||
|
||||
struct queue_ops history_ops = {
|
||||
history_added,
|
||||
history_removed,
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
|
|
@ -149,8 +149,14 @@ static void playlist_added(struct queue *queue, unsigned int pos)
|
|||
p_tab->on_track_added(pos);
|
||||
}
|
||||
|
||||
static void playlist_removed(struct queue *queue, unsigned int pos)
|
||||
{
|
||||
p_tab->on_track_removed(pos);
|
||||
}
|
||||
|
||||
struct queue_ops playlist_ops = {
|
||||
playlist_added,
|
||||
playlist_removed,
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
|
|
@ -26,8 +26,15 @@ static void tempq_added(struct queue *queue, unsigned int pos)
|
|||
deck :: write();
|
||||
}
|
||||
|
||||
static void tempq_removed(struct queue *queue, unsigned int pos)
|
||||
{
|
||||
find_tab(queue)->on_track_removed(pos);
|
||||
deck :: write();
|
||||
}
|
||||
|
||||
struct queue_ops tempq_ops = {
|
||||
tempq_added,
|
||||
tempq_removed,
|
||||
deck :: save,
|
||||
};
|
||||
|
||||
|
|
|
@ -34,13 +34,6 @@ class QNotifier {
|
|||
public:
|
||||
QNotifier() {}; /**< Notifier constructor. */
|
||||
|
||||
/**
|
||||
* Called when a track is removed from a queue.
|
||||
*
|
||||
* @param pos Position in the queue that the track was removed from.
|
||||
*/
|
||||
virtual void on_track_removed(unsigned int) = 0;
|
||||
|
||||
/**
|
||||
* Called when a track has been updated.
|
||||
*
|
||||
|
@ -54,6 +47,9 @@ struct queue_ops {
|
|||
/* Called to tell a higher layer that a track has been added. */
|
||||
void (*qop_added)(struct queue *, unsigned int);
|
||||
|
||||
/* Called to tell a higher layer that a track has been removed. */
|
||||
void (*qop_removed)(struct queue *, unsigned int);
|
||||
|
||||
/* Called to have a higher layer save the queue. */
|
||||
void (*qop_save)(struct queue *, enum queue_flags);
|
||||
};
|
||||
|
|
|
@ -20,7 +20,6 @@ unsigned int count_updated = 0;
|
|||
static class TestNotifier : public QNotifier {
|
||||
public:
|
||||
TestNotifier() : QNotifier() {}
|
||||
void on_track_removed(unsigned int i) { count_deleted++; }
|
||||
void on_track_updated(unsigned int i) { count_updated++; }
|
||||
} test_notifier;
|
||||
|
||||
|
@ -30,6 +29,11 @@ static void queue_op_added(struct queue *queue, unsigned int pos)
|
|||
count_added++;
|
||||
}
|
||||
|
||||
static void queue_op_removed(struct queue *queue, unsigned int pos)
|
||||
{
|
||||
count_deleted++;
|
||||
}
|
||||
|
||||
static void queue_op_save(struct queue *queue, enum queue_flags flag)
|
||||
{
|
||||
if (flag == Q_SAVE_FLAGS)
|
||||
|
@ -41,6 +45,7 @@ static void queue_op_save(struct queue *queue, enum queue_flags flag)
|
|||
|
||||
static const struct queue_ops test_ops = {
|
||||
queue_op_added,
|
||||
queue_op_removed,
|
||||
queue_op_save,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue