2 * Copyright 2004-2005 Timo Hirvonen
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 #include <track_info.h>
36 /* next/prev track in artist/album/track tree */
37 struct list_head node
;
39 /* next/prev track in shuffle list */
40 struct list_head shuffle_node
;
42 /* next/prev track in sorted list */
43 struct list_head sorted_node
;
46 struct track_info
*info
;
56 struct list_head node
;
59 struct list_head track_head
;
61 struct artist
*artist
;
63 /* date of the first track added to this album */
68 /* next/prev artist */
69 struct list_head node
;
72 struct list_head album_head
;
75 /* albums visible for this artist in the tree_win? */
76 unsigned int expanded
: 1;
78 /* if streams == 1 && name == NULL then display <Stream> */
79 //unsigned int streams : 1;
94 /* PLAY_QUEUE_VIEW and BROWSER_VIEW are defined in ui_curses.h */
96 #define SHUFFLE_VIEW 1
100 struct list_head artist_head
;
101 struct list_head shuffle_head
;
102 struct list_head sorted_head
;
104 struct artist
*cur_artist
;
105 struct album
*cur_album
;
106 struct track
*cur_track
;
108 /* for sorted window */
113 struct window
*tree_win
;
114 struct window
*track_win
;
115 struct window
*shuffle_win
;
116 struct window
*sorted_win
;
118 /* one of the above windows */
119 struct window
*cur_win
;
121 enum play_mode play_mode
;
122 enum playlist_mode playlist_mode
;
124 unsigned int nr_tracks
;
125 unsigned int total_time
;
127 unsigned int status_changed
: 1;
128 unsigned int repeat
: 1;
130 pthread_mutex_t mutex
;
133 extern struct playlist playlist
;
134 extern struct searchable
*tree_searchable
;
135 extern struct searchable
*shuffle_searchable
;
136 extern struct searchable
*sorted_searchable
;
138 extern int pl_init(void);
139 extern int pl_exit(void);
141 /* set current track, these return track_info on success */
142 extern struct track_info
*pl_set_next(void);
143 extern struct track_info
*pl_set_prev(void);
144 extern struct track_info
*pl_set_selected(void);
146 extern void pl_add_track(struct track_info
*track_info
);
148 extern void pl_set_sort_keys(char **keys
);
149 extern void pl_clear(void);
150 extern void pl_set_filter(struct expr
*expr
);
151 extern void pl_remove(struct track_info
*ti
);
152 extern void pl_remove_sel(void);
153 extern void pl_toggle_expand_artist(void);
155 extern void pl_toggle_repeat(void);
156 extern void pl_toggle_playlist_mode(void);
157 extern void pl_toggle_play_mode(void);
158 extern void pl_set_repeat(int value
);
159 extern void pl_set_playlist_mode(enum playlist_mode playlist_mode
);
160 extern void pl_set_play_mode(enum play_mode play_mode
);
161 extern void pl_get_status(int *repeat
, enum playlist_mode
*playlist_mode
, enum play_mode
*play_mode
, int *total_time
);
163 /* these are unlocked */
164 extern void __pl_set_view(int view
);
166 extern void pl_toggle_active_window(void);
167 extern void pl_sel_current(void);
169 extern void pl_set_tree_win_nr_rows(int nr_rows
);
170 extern void pl_set_track_win_nr_rows(int nr_rows
);
171 extern void pl_set_shuffle_win_nr_rows(int nr_rows
);
172 extern void pl_set_sorted_win_nr_rows(int nr_rows
);
174 extern void pl_reshuffle(void);
177 * Run callback @cb for each selected track. Quit if @cb returns non-zero value.
179 * @cb: callback funtion
180 * @data: data argument for @cb
181 * @reverse: use reverse order?
183 * Returns: return value of last @cb call or 0 if @cb not called at all.
185 extern int __pl_for_each_selected(int (*cb
)(void *data
, struct track_info
*ti
), void *data
, int reverse
);
186 extern int pl_for_each_selected(int (*cb
)(void *data
, struct track_info
*ti
), void *data
, int reverse
);
187 extern int pl_for_each(int (*cb
)(void *data
, struct track_info
*ti
), void *data
);
189 #define pl_lock() cmus_mutex_lock(&playlist.mutex)
190 #define pl_unlock() cmus_mutex_unlock(&playlist.mutex)
192 static inline struct track
*iter_to_shuffle_track(const struct iter
*iter
)
194 BUG_ON(iter
->data0
!= &playlist
.shuffle_head
);
198 static inline struct track
*iter_to_sorted_track(const struct iter
*iter
)
200 BUG_ON(iter
->data0
!= &playlist
.sorted_head
);
204 static inline struct artist
*iter_to_artist(const struct iter
*iter
)
206 BUG_ON(iter
->data0
!= &playlist
.artist_head
);
210 static inline struct album
*iter_to_album(const struct iter
*iter
)
212 BUG_ON(iter
->data0
!= &playlist
.artist_head
);
216 static inline struct track
*iter_to_track(const struct iter
*iter
)