comparison src/audlegacy/playlist.h @ 4811:7bf7f83a217e

rename src/audacious src/audlegacy so that both audlegacy and audacious can coexist.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Wed, 26 Nov 2008 00:44:56 +0900
parents src/audacious/playlist.h@2eee464379dc
children 7ac9e8b91bbf
comparison
equal deleted inserted replaced
4810:c10e53092037 4811:7bf7f83a217e
1 /* Audacious - Cross-platform multimedia player
2 * Copyright (C) 2005-2007 William Pitcock, Tony Vroon, George Averill,
3 * Giacomo Lozito, Derek Pomery and Yoshiki Yazawa.
4 *
5 * XMMS - Cross-platform multimedia player
6 * Copyright (C) 1998-2003 Peter Alm, Mikael Alm, Olle Hallnas,
7 * Thomas Nilsson and 4Front Technologies
8 * Copyright (C) 1999-2003 Haavard Kvaalen
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; under version 3 of the License.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses>.
21 *
22 * The Audacious team does not consider modular code linking to
23 * Audacious or using our public API to be a derived work.
24 */
25 #ifndef AUDACIOUS_PLAYLIST_H
26 #define AUDACIOUS_PLAYLIST_H
27
28 /* XXX: Allow pre-0.2 libmowgli to build audacious. */
29 #ifdef TRUE
30 # undef TRUE
31 #endif
32
33 #ifdef FALSE
34 # undef FALSE
35 #endif
36
37 #include <mowgli.h>
38 #include <glib.h>
39 #include "audlegacy/tuple.h"
40 #include "audlegacy/tuple_formatter.h"
41
42 typedef struct _PlaylistEntry PlaylistEntry;
43 typedef struct _Playlist Playlist;
44
45 typedef enum {
46 PLAYLIST_SORT_PATH,
47 PLAYLIST_SORT_FILENAME,
48 PLAYLIST_SORT_TITLE,
49 PLAYLIST_SORT_ARTIST,
50 PLAYLIST_SORT_DATE,
51 PLAYLIST_SORT_TRACK,
52 PLAYLIST_SORT_PLAYLIST
53 } PlaylistSortType;
54
55 typedef enum {
56 PLAYLIST_DUPS_PATH,
57 PLAYLIST_DUPS_FILENAME,
58 PLAYLIST_DUPS_TITLE
59 } PlaylistDupsType;
60
61 #include "audlegacy/plugin.h"
62
63 G_BEGIN_DECLS
64
65 #define PLAYLIST_ENTRY(x) ((PlaylistEntry*)(x))
66 struct _PlaylistEntry {
67 gchar *filename;
68 gchar *title;
69 gint length;
70 gboolean selected;
71 InputPlugin *decoder;
72 Tuple *tuple; /* cached entry tuple, if available */
73 gboolean title_is_valid; /* set it to FALSE after title format changing to update title even if tuple is present --asphyx */
74 };
75
76 #define PLAYLIST(x) ((Playlist *)(x))
77
78 typedef enum {
79 PLAYLIST_PLAIN = 0,
80 PLAYLIST_STATIC = 1,
81 PLAYLIST_USE_RELATIVE = 1 << 1
82 } PlaylistAttribute;
83
84 struct _Playlist {
85 gchar *title;
86 gchar *filename;
87 gint length;
88 GList *entries;
89 GList *queue;
90 GList *shuffle;
91 PlaylistEntry *position; /* bleah */
92 gulong pl_total_time;
93 gulong pl_selection_time;
94 gboolean pl_total_more;
95 gboolean pl_selection_more;
96 gboolean loading_playlist;
97 GMutex *mutex; /* this is required for multiple playlist */
98 GList *tail; /* marker for the last element in playlist->entries */
99 gint attribute; /* PlaylistAttribute */
100 gulong serial; /* serial number */
101 };
102
103 typedef enum {
104 PLAYLIST_ASSOC_LINEAR,
105 PLAYLIST_ASSOC_QUEUE,
106 PLAYLIST_ASSOC_SHUFFLE
107 } PlaylistAssociation;
108
109 extern const guint n_titlestring_presets;
110
111 PlaylistEntry *playlist_entry_new(const gchar * filename,
112 const gchar * title, const gint len,
113 InputPlugin * dec);
114 void playlist_entry_free(PlaylistEntry * entry);
115
116 void playlist_entry_associate(Playlist * playlist, PlaylistEntry * entry,
117 PlaylistAssociation assoc);
118
119 void playlist_entry_associate_pos(Playlist * playlist, PlaylistEntry * entry,
120 PlaylistAssociation assoc, gint pos);
121
122 void playlist_init(void);
123 void playlist_add_playlist(Playlist *);
124 void playlist_remove_playlist(Playlist *);
125 void playlist_select_playlist(Playlist *);
126 void playlist_select_next(void);
127 void playlist_select_prev(void);
128 GList * playlist_get_playlists(void);
129
130 void playlist_clear_only(Playlist *playlist);
131 void playlist_clear(Playlist *playlist);
132 void playlist_delete(Playlist *playlist, gboolean crop);
133
134 gboolean playlist_add(Playlist *playlist, const gchar * filename);
135 gboolean playlist_ins(Playlist *playlist, const gchar * filename, gint pos);
136 guint playlist_add_dir(Playlist *playlist, const gchar * dir);
137 guint playlist_ins_dir(Playlist *playlist, const gchar * dir, gint pos, gboolean background);
138 guint playlist_add_url(Playlist *playlist, const gchar * url);
139 guint playlist_ins_url(Playlist *playlist, const gchar * string, gint pos);
140
141 void playlist_set_info(Playlist *playlist, const gchar * title, gint length, gint rate,
142 gint freq, gint nch);
143 void playlist_set_info_old_abi(const gchar * title, gint length, gint rate,
144 gint freq, gint nch);
145 void playlist_check_pos_current(Playlist *playlist);
146 void playlist_next(Playlist *playlist);
147 void playlist_prev(Playlist *playlist);
148 void playlist_queue(Playlist *playlist);
149 void playlist_queue_position(Playlist *playlist, guint pos);
150 void playlist_queue_remove(Playlist *playlist, guint pos);
151 gint playlist_queue_get_length(Playlist *playlist);
152 gboolean playlist_is_position_queued(Playlist *playlist, guint pos);
153 void playlist_clear_queue(Playlist *playlist);
154 gint playlist_get_queue_position(Playlist *playlist, PlaylistEntry * entry);
155 gint playlist_get_queue_position_number(Playlist *playlist, guint pos);
156 gint playlist_get_queue_qposition_number(Playlist *playlist, guint pos);
157 void playlist_eof_reached(Playlist *playlist);
158 void playlist_set_position(Playlist *playlist, guint pos);
159 gint playlist_get_length(Playlist *playlist);
160 gint playlist_get_position(Playlist *playlist);
161 gint playlist_get_position_nolock(Playlist *playlist);
162 gchar *playlist_get_info_text(Playlist *playlist);
163 gint playlist_get_current_length(Playlist *playlist);
164
165 gboolean playlist_save(Playlist *playlist, const gchar * filename);
166 gboolean playlist_load(Playlist *playlist, const gchar * filename);
167
168 void playlist_start_get_info_thread(void);
169 void playlist_stop_get_info_thread();
170 void playlist_start_get_info_scan(void);
171 void playlist_update_all_titles(void);
172
173 void playlist_sort(Playlist *playlist, PlaylistSortType type);
174 void playlist_sort_selected(Playlist *playlist, PlaylistSortType type);
175
176 void playlist_reverse(Playlist *playlist);
177 void playlist_random(Playlist *playlist);
178 void playlist_remove_duplicates(Playlist *playlist, PlaylistDupsType);
179 void playlist_remove_dead_files(Playlist *playlist);
180
181 void playlist_delete_index(Playlist *playlist, guint pos);
182
183 PlaylistEntry *playlist_get_entry_to_play(Playlist *playlist);
184
185 /* XXX this is for reverse compatibility --nenolod */
186 const gchar *playlist_get_filename_to_play(Playlist *playlist);
187
188 gchar *playlist_get_filename(Playlist *playlist, guint pos);
189 gchar *playlist_get_songtitle(Playlist *playlist, guint pos);
190 Tuple *playlist_get_tuple(Playlist *playlist, guint pos);
191 gint playlist_get_songtime(Playlist *playlist, guint pos);
192
193 GList *playlist_get_selected(Playlist *playlist);
194 int playlist_get_num_selected(Playlist *playlist);
195
196 void playlist_get_total_time(Playlist *playlist, gulong * total_time, gulong * selection_time,
197 gboolean * total_more,
198 gboolean * selection_more);
199
200 gint playlist_select_search(Playlist *playlist, Tuple *tuple, gint action);
201 void playlist_select_all(Playlist *playlist, gboolean set);
202 void playlist_select_range(Playlist *playlist, gint min, gint max, gboolean sel);
203 void playlist_select_invert_all(Playlist *playlist);
204 gboolean playlist_select_invert(Playlist *playlist, guint pos);
205
206 gboolean playlist_read_info_selection(Playlist *playlist);
207 void playlist_read_info(Playlist *playlist, guint pos);
208
209 void playlist_set_shuffle(gboolean shuffle);
210
211 void playlist_clear_selected(Playlist *playlist);
212
213 GList *get_playlist_nth(Playlist *playlist, guint);
214
215 gboolean playlist_set_current_name(Playlist *playlist, const gchar * title);
216 const gchar *playlist_get_current_name(Playlist *playlist);
217
218 gboolean playlist_filename_set(Playlist *playlist, const gchar * filename);
219 gchar *playlist_filename_get(Playlist *playlist);
220
221 Playlist *playlist_new(void);
222 void playlist_free(Playlist *playlist);
223 Playlist *playlist_new_from_selected(void);
224
225 gboolean is_playlist_name(const gchar * filename);
226
227 #define PLAYLIST_LOCK(pl) g_mutex_lock((pl)->mutex)
228 #define PLAYLIST_UNLOCK(pl) g_mutex_unlock((pl)->mutex)
229 #define PLAYLIST_INCR_SERIAL(pl) (pl)->serial++
230
231 G_LOCK_EXTERN(playlists);
232
233 extern void playlist_load_ins_file(Playlist *playlist, const gchar * filename,
234 const gchar * playlist_name, gint pos,
235 const gchar * title, gint len);
236
237 extern void playlist_load_ins_file_tuple(Playlist *playlist, const gchar * filename_p,
238 const gchar * playlist_name, gint pos,
239 Tuple *tuple);
240
241 Playlist *playlist_get_active(void);
242
243 gboolean playlist_playlists_equal(Playlist *p1, Playlist *p2);
244
245 extern const gchar *get_gentitle_format(void);
246
247 G_END_DECLS
248
249 #endif /* AUDACIOUS_PLAYLIST_H */