2 * Copyright 2005-2006 Timo Hirvonen
5 #include "play_queue.h"
10 struct editable pq_editable
;
12 static void pq_free_track(struct list_head
*item
)
14 struct simple_track
*track
= to_simple_track(item
);
16 track_info_unref(track
->info
);
20 void play_queue_init(void)
22 editable_init(&pq_editable
, pq_free_track
);
25 void play_queue_append(struct track_info
*ti
)
27 struct simple_track
*t
= simple_track_new(ti
);
29 editable_add(&pq_editable
, t
);
32 void play_queue_prepend(struct track_info
*ti
)
34 struct simple_track
*t
= simple_track_new(ti
);
36 list_add(&t
->node
, &pq_editable
.head
);
37 pq_editable
.nr_tracks
++;
38 if (t
->info
->duration
!= -1)
39 pq_editable
.total_time
+= t
->info
->duration
;
40 window_changed(pq_editable
.win
);
43 struct track_info
*play_queue_remove(void)
45 struct list_head
*item
;
46 struct simple_track
*t
;
47 struct track_info
*info
;
50 item
= pq_editable
.head
.next
;
51 if (item
== &pq_editable
.head
)
54 t
= to_simple_track(item
);
56 editable_track_to_iter(&pq_editable
, t
, &iter
);
57 window_row_vanishes(pq_editable
.win
, &iter
);
59 pq_editable
.nr_marked
-= t
->marked
;
60 pq_editable
.nr_tracks
--;