Mercurial > audlegacy
annotate src/audacious/playlist.c @ 3971:b0ae5dbd2f53
- add subtune support to on demand probing.
- add new boolean member "have_subtune" to InputPlugin structure. plugins which support subtune shall set this.
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Sun, 18 Nov 2007 21:39:28 +0900 |
parents | efd7ec36483e |
children | 67f01143e613 |
rev | line source |
---|---|
2313 | 1 /* Audacious |
2 * Copyright (C) 2005-2007 Audacious team. | |
3 * | |
4 * BMP (C) GPL 2003 $top_src_dir/AUTHORS | |
5 * | |
6 * based on: | |
7 * | |
8 * XMMS - Cross-platform multimedia player | |
9 * Copyright (C) 1998-2003 Peter Alm, Mikael Alm, Olle Hallnas, | |
10 * Thomas Nilsson and 4Front Technologies | |
11 * Copyright (C) 1999-2003 Haavard Kvaalen | |
12 * | |
13 * This program is free software; you can redistribute it and/or modify | |
14 * it under the terms of the GNU General Public License as published by | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3097
diff
changeset
|
15 * the Free Software Foundation; under version 3 of the License. |
2313 | 16 * |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 * GNU General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3097
diff
changeset
|
23 * along with this program. If not, see <http://www.gnu.org/licenses>. |
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
24 * |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
25 * The Audacious team does not consider modular code linking to |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
26 * Audacious or using our public API to be a derived work. |
2313 | 27 */ |
28 | |
29 #ifdef HAVE_CONFIG_H | |
30 # include "config.h" | |
31 #endif | |
32 | |
33 #include "playlist.h" | |
34 | |
2633
c079e507869a
[svn] - use a managed heap for playlist entry node allocation.
nenolod
parents:
2614
diff
changeset
|
35 #include <mowgli.h> |
2313 | 36 #include <glib.h> |
37 #include <glib/gprintf.h> | |
38 #include <stdlib.h> | |
39 #include <string.h> | |
40 #include <time.h> | |
41 | |
42 #include <unistd.h> | |
43 #include <sys/types.h> | |
44 #include <sys/stat.h> | |
45 #include <sys/errno.h> | |
46 | |
47 #if defined(USE_REGEX_ONIGURUMA) | |
3460
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
48 # include <onigposix.h> |
2313 | 49 #elif defined(USE_REGEX_PCRE) |
3460
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
50 # include <pcreposix.h> |
2313 | 51 #else |
3460
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
52 # include <regex.h> |
2313 | 53 #endif |
54 | |
55 #include "input.h" | |
56 #include "main.h" | |
57 #include "ui_main.h" | |
2416
0fd7f4f969ad
[svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
2408
diff
changeset
|
58 #include "util.h" |
2717 | 59 #include "configdb.h" |
2313 | 60 #include "vfs.h" |
61 #include "ui_equalizer.h" | |
62 #include "playback.h" | |
63 #include "playlist.h" | |
64 #include "playlist_container.h" | |
2499
15a1f5ee4d1c
[svn] - playlist_manager -> ui_playlist_manager, since it's a UI component.
nenolod
parents:
2493
diff
changeset
|
65 #include "ui_playlist_manager.h" |
2313 | 66 #include "ui_playlist.h" |
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2328
diff
changeset
|
67 #include "strings.h" |
2313 | 68 #include "ui_fileinfo.h" |
69 | |
70 #include "debug.h" | |
71 | |
2407
1dc1d36d0347
[svn] - add hooks: playback begin, playback end, playlist reached end
nenolod
parents:
2380
diff
changeset
|
72 #include "hook.h" |
1dc1d36d0347
[svn] - add hooks: playback begin, playback end, playlist reached end
nenolod
parents:
2380
diff
changeset
|
73 |
3159
a2d552ea48f0
Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3132
diff
changeset
|
74 #include "playlist_evmessages.h" |
a2d552ea48f0
Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3132
diff
changeset
|
75 #include "playlist_evlisteners.h" |
3217 | 76 #include "ui_skinned_playlist.h" |
3159
a2d552ea48f0
Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3132
diff
changeset
|
77 |
2313 | 78 typedef gint (*PlaylistCompareFunc) (PlaylistEntry * a, PlaylistEntry * b); |
79 typedef void (*PlaylistSaveFunc) (FILE * file); | |
80 | |
81 /* If we manually change the song, p_p_b_j will show us where to go back to */ | |
82 PlaylistEntry *playlist_position_before_jump = NULL; | |
83 | |
84 static GList *playlists = NULL; | |
85 static GList *playlists_iter; | |
86 | |
87 /* If this is set to TRUE, we do not probe upon playlist add. | |
88 * | |
89 * Under Audacious 0.1.x, this was not a big deal because we used | |
90 * file extension introspection instead of looking for file format magic | |
91 * strings. | |
92 * | |
93 * Because we use file magic strings, we have to fstat a file being added | |
94 * to a playlist up to 1 * <number of input plugins installed> times. | |
95 * | |
96 * This can get really slow now that we're looking for files to add to a | |
97 * playlist. (Up to 5 minutes for 5000 songs, etcetera.) | |
98 * | |
99 * So, we obviously don't want to probe while opening a large playlist | |
100 * up. Hince the boolean below. | |
101 * | |
102 * January 7, 2006, William Pitcock <nenolod@nenolod.net> | |
103 */ | |
104 | |
105 | |
2328 | 106 //static gchar *playlist_current_name = NULL; |
2313 | 107 |
108 static gboolean playlist_get_info_scan_active = FALSE; | |
3460
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
109 GStaticRWLock playlist_get_info_rwlock = G_STATIC_RW_LOCK_INIT; |
2313 | 110 static gboolean playlist_get_info_going = FALSE; |
111 static GThread *playlist_get_info_thread; | |
112 | |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
113 extern GHashTable *ext_hash; |
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
114 |
2313 | 115 static gint path_compare(const gchar * a, const gchar * b); |
116 static gint playlist_compare_path(PlaylistEntry * a, PlaylistEntry * b); | |
117 static gint playlist_compare_filename(PlaylistEntry * a, PlaylistEntry * b); | |
118 static gint playlist_compare_title(PlaylistEntry * a, PlaylistEntry * b); | |
119 static gint playlist_compare_artist(PlaylistEntry * a, PlaylistEntry * b); | |
120 static time_t playlist_get_mtime(const gchar *filename); | |
121 static gint playlist_compare_date(PlaylistEntry * a, PlaylistEntry * b); | |
122 static gint playlist_compare_track(PlaylistEntry * a, PlaylistEntry * b); | |
123 static gint playlist_compare_playlist(PlaylistEntry * a, PlaylistEntry * b); | |
124 | |
125 static gint playlist_dupscmp_path(PlaylistEntry * a, PlaylistEntry * b); | |
126 static gint playlist_dupscmp_filename(PlaylistEntry * a, PlaylistEntry * b); | |
127 static gint playlist_dupscmp_title(PlaylistEntry * a, PlaylistEntry * b); | |
128 | |
129 static PlaylistCompareFunc playlist_compare_func_table[] = { | |
130 playlist_compare_path, | |
131 playlist_compare_filename, | |
132 playlist_compare_title, | |
133 playlist_compare_artist, | |
134 playlist_compare_date, | |
135 playlist_compare_track, | |
136 playlist_compare_playlist | |
137 }; | |
138 | |
139 static guint playlist_load_ins(Playlist * playlist, const gchar * filename, gint pos); | |
140 | |
141 static void playlist_generate_shuffle_list(Playlist *); | |
142 static void playlist_generate_shuffle_list_nolock(Playlist *); | |
143 | |
144 static void playlist_recalc_total_time_nolock(Playlist *); | |
145 static void playlist_recalc_total_time(Playlist *); | |
146 static gboolean playlist_entry_get_info(PlaylistEntry * entry); | |
147 | |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
148 |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
149 #define EXT_TRUE 1 |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
150 #define EXT_FALSE 0 |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
151 #define EXT_HAVE_SUBTUNE 2 |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
152 |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
153 static gint filter_by_extension(const gchar *filename); |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
154 static gboolean is_http(const gchar *filename); |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
155 |
2633
c079e507869a
[svn] - use a managed heap for playlist entry node allocation.
nenolod
parents:
2614
diff
changeset
|
156 static mowgli_heap_t *playlist_entry_heap = NULL; |
c079e507869a
[svn] - use a managed heap for playlist entry node allocation.
nenolod
parents:
2614
diff
changeset
|
157 |
2313 | 158 /* *********************** playlist entry code ********************** */ |
159 | |
160 PlaylistEntry * | |
161 playlist_entry_new(const gchar * filename, | |
162 const gchar * title, | |
163 const gint length, | |
164 InputPlugin * dec) | |
165 { | |
166 PlaylistEntry *entry; | |
167 | |
2633
c079e507869a
[svn] - use a managed heap for playlist entry node allocation.
nenolod
parents:
2614
diff
changeset
|
168 entry = mowgli_heap_alloc(playlist_entry_heap); |
2313 | 169 entry->filename = g_strdup(filename); |
170 entry->title = str_to_utf8(title); | |
171 entry->length = length; | |
172 entry->selected = FALSE; | |
173 entry->decoder = dec; | |
174 | |
175 /* only do this if we have a decoder, otherwise it just takes too long */ | |
176 if (entry->decoder) | |
177 playlist_entry_get_info(entry); | |
178 | |
179 return entry; | |
180 } | |
181 | |
182 void | |
183 playlist_entry_free(PlaylistEntry * entry) | |
184 { | |
185 if (!entry) | |
186 return; | |
187 | |
188 if (entry->tuple != NULL) { | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
189 mowgli_object_unref(entry->tuple); |
2313 | 190 entry->tuple = NULL; |
191 } | |
192 | |
3510
b2a82a73a788
Few bits of pre-integration shit.
Matti Hamalainen <ccr@tnsp.org>
parents:
3507
diff
changeset
|
193 g_free(entry->filename); |
b2a82a73a788
Few bits of pre-integration shit.
Matti Hamalainen <ccr@tnsp.org>
parents:
3507
diff
changeset
|
194 g_free(entry->title); |
2633
c079e507869a
[svn] - use a managed heap for playlist entry node allocation.
nenolod
parents:
2614
diff
changeset
|
195 mowgli_heap_free(playlist_entry_heap, entry); |
2313 | 196 } |
197 | |
198 static gboolean | |
199 playlist_entry_get_info(PlaylistEntry * entry) | |
200 { | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
201 Tuple *tuple = NULL; |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
202 ProbeResult *pr = NULL; |
2313 | 203 time_t modtime; |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
204 const gchar *formatter; |
2313 | 205 |
206 g_return_val_if_fail(entry != NULL, FALSE); | |
207 | |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
208 if (entry->tuple == NULL || tuple_get_int(entry->tuple, FIELD_MTIME, NULL) > 0 || |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
209 tuple_get_int(entry->tuple, FIELD_MTIME, NULL) == -1) |
2636 | 210 modtime = playlist_get_mtime(entry->filename); |
2313 | 211 else |
2636 | 212 modtime = 0; /* URI -nenolod */ |
2313 | 213 |
2668
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
214 if (str_has_prefix_nocase(entry->filename, "http:") && |
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
215 g_thread_self() != playlist_get_info_thread) |
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
216 return FALSE; |
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
217 |
3635 | 218 if (entry->decoder == NULL) { |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
219 pr = input_check_file(entry->filename, FALSE); |
3128
343504d43afc
Fix warnings.
William Pitcock <nenolod@atheme-project.org>
parents:
3127
diff
changeset
|
220 if (pr) |
3635 | 221 entry->decoder = pr->ip; |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
222 } |
2313 | 223 |
224 /* renew tuple if file mtime is newer than tuple mtime. */ | |
3635 | 225 if (entry->tuple){ |
226 if (tuple_get_int(entry->tuple, FIELD_MTIME, NULL) == modtime) | |
2313 | 227 return TRUE; |
228 else { | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
229 mowgli_object_unref(entry->tuple); |
2313 | 230 entry->tuple = NULL; |
231 } | |
232 } | |
233 | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
234 if (pr != NULL && pr->tuple != NULL) |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
235 tuple = pr->tuple; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
236 else if (entry->decoder != NULL && entry->decoder->get_song_tuple != NULL) |
2313 | 237 tuple = entry->decoder->get_song_tuple(entry->filename); |
238 | |
239 if (tuple == NULL) | |
240 return FALSE; | |
241 | |
242 /* attach mtime */ | |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
243 tuple_associate_int(tuple, FIELD_MTIME, NULL, modtime); |
2313 | 244 |
245 /* entry is still around */ | |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
246 formatter = tuple_get_string(tuple, FIELD_FORMATTER, NULL); |
3349
01a241d35146
add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3348
diff
changeset
|
247 entry->title = tuple_formatter_make_title_string(tuple, formatter ? |
3334
ea806daf3ef0
rename xmms_get_gentitle_format() to get_gentitle_format().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3327
diff
changeset
|
248 formatter : get_gentitle_format()); |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
249 entry->length = tuple_get_int(tuple, FIELD_LENGTH, NULL); |
2313 | 250 entry->tuple = tuple; |
251 | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
252 g_free(pr); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
253 |
2313 | 254 return TRUE; |
255 } | |
256 | |
257 /* *********************** playlist selector code ************************* */ | |
258 | |
259 void | |
260 playlist_init(void) | |
261 { | |
262 Playlist *initial_pl; | |
263 | |
2633
c079e507869a
[svn] - use a managed heap for playlist entry node allocation.
nenolod
parents:
2614
diff
changeset
|
264 /* create a heap with 1024 playlist entry nodes preallocated. --nenolod */ |
c079e507869a
[svn] - use a managed heap for playlist entry node allocation.
nenolod
parents:
2614
diff
changeset
|
265 playlist_entry_heap = mowgli_heap_create(sizeof(PlaylistEntry), 1024, |
c079e507869a
[svn] - use a managed heap for playlist entry node allocation.
nenolod
parents:
2614
diff
changeset
|
266 BH_NOW); |
c079e507869a
[svn] - use a managed heap for playlist entry node allocation.
nenolod
parents:
2614
diff
changeset
|
267 |
2313 | 268 /* FIXME: is this really necessary? REQUIRE_STATIC_LOCK(playlists); */ |
269 | |
270 initial_pl = playlist_new(); | |
271 | |
272 playlist_add_playlist(initial_pl); | |
3159
a2d552ea48f0
Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3132
diff
changeset
|
273 |
a2d552ea48f0
Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3132
diff
changeset
|
274 playlist_evlistener_init(); |
2313 | 275 } |
276 | |
277 void | |
278 playlist_add_playlist(Playlist *playlist) | |
279 { | |
280 playlists = g_list_append(playlists, playlist); | |
281 | |
282 if (playlists_iter == NULL) | |
283 playlists_iter = playlists; | |
284 | |
285 playlist_manager_update(); | |
286 } | |
287 | |
288 void | |
289 playlist_remove_playlist(Playlist *playlist) | |
290 { | |
3473
3b26640f9fd6
Don't stop playback when deleting a non-active playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3401
diff
changeset
|
291 gboolean active; |
3b26640f9fd6
Don't stop playback when deleting a non-active playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3401
diff
changeset
|
292 active = (playlist && playlist == playlist_get_active()); |
2820 | 293 /* users suppose playback will be stopped on removing playlist */ |
3473
3b26640f9fd6
Don't stop playback when deleting a non-active playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3401
diff
changeset
|
294 if (active && playback_get_playing()) { |
2820 | 295 ip_data.stop = TRUE; |
296 playback_stop(); | |
297 ip_data.stop = FALSE; | |
298 mainwin_clear_song_info(); | |
299 } | |
300 | |
2313 | 301 /* trying to free the last playlist simply clears and resets it */ |
302 if (g_list_length(playlists) < 2) { | |
303 playlist_clear(playlist); | |
304 playlist_set_current_name(playlist, NULL); | |
3477
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
305 playlist_filename_set(playlist, NULL); |
2313 | 306 return; |
307 } | |
308 | |
3473
3b26640f9fd6
Don't stop playback when deleting a non-active playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3401
diff
changeset
|
309 if (active) playlist_select_next(); |
2313 | 310 |
311 /* upon removal, a playlist should be cleared and freed */ | |
312 playlists = g_list_remove(playlists, playlist); | |
313 playlist_clear(playlist); | |
314 playlist_free(playlist); | |
315 | |
316 if (playlists_iter == NULL) | |
317 playlists_iter = playlists; | |
318 | |
319 playlist_manager_update(); | |
320 } | |
321 | |
322 GList * | |
323 playlist_get_playlists(void) | |
324 { | |
325 return playlists; | |
326 } | |
327 | |
328 void | |
329 playlist_select_next(void) | |
330 { | |
331 if (playlists_iter == NULL) | |
332 playlists_iter = playlists; | |
333 | |
334 playlists_iter = g_list_next(playlists_iter); | |
335 | |
336 if (playlists_iter == NULL) | |
337 playlists_iter = playlists; | |
338 | |
339 playlistwin_update_list(playlist_get_active()); | |
3621
2d6106656276
Notify playlist manager of more changes
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3583
diff
changeset
|
340 playlist_manager_update(); |
2313 | 341 } |
342 | |
343 void | |
344 playlist_select_prev(void) | |
345 { | |
346 if (playlists_iter == NULL) | |
347 playlists_iter = playlists; | |
348 | |
349 playlists_iter = g_list_previous(playlists_iter); | |
350 | |
351 if (playlists_iter == NULL) | |
352 playlists_iter = playlists; | |
353 | |
354 playlistwin_update_list(playlist_get_active()); | |
3621
2d6106656276
Notify playlist manager of more changes
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3583
diff
changeset
|
355 playlist_manager_update(); |
2313 | 356 } |
357 | |
358 void | |
359 playlist_select_playlist(Playlist *playlist) | |
360 { | |
361 playlists_iter = g_list_find(playlists, playlist); | |
362 | |
363 if (playlists_iter == NULL) | |
364 playlists_iter = playlists; | |
365 | |
366 playlistwin_update_list(playlist); | |
3621
2d6106656276
Notify playlist manager of more changes
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3583
diff
changeset
|
367 playlist_manager_update(); |
2313 | 368 } |
369 | |
370 /* *********************** playlist code ********************** */ | |
371 | |
372 const gchar * | |
373 playlist_get_current_name(Playlist *playlist) | |
374 { | |
375 return playlist->title; | |
376 } | |
377 | |
3477
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
378 /* This function now sets the playlist title, not the playlist filename. |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
379 * See playlist_filename_set */ |
2313 | 380 gboolean |
3477
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
381 playlist_set_current_name(Playlist *playlist, const gchar * title) |
2313 | 382 { |
3635 | 383 gchar *oldtitle = playlist->title; |
3477
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
384 |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
385 if (!title) { |
2313 | 386 playlist->title = NULL; |
3635 | 387 g_free(oldtitle); |
3621
2d6106656276
Notify playlist manager of more changes
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3583
diff
changeset
|
388 playlist_manager_update(); |
2313 | 389 return FALSE; |
390 } | |
391 | |
3477
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
392 playlist->title = str_to_utf8(title); |
3635 | 393 g_free(oldtitle); |
3621
2d6106656276
Notify playlist manager of more changes
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3583
diff
changeset
|
394 playlist_manager_update(); |
2313 | 395 return TRUE; |
396 } | |
397 | |
3477
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
398 /* Setting the filename allows the original playlist to be modified later */ |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
399 gboolean |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
400 playlist_filename_set(Playlist *playlist, const gchar * filename) |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
401 { |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
402 gchar *old; |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
403 old = playlist->filename; |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
404 |
3635 | 405 if (!filename) { |
3477
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
406 playlist->filename = NULL; |
3635 | 407 g_free(old); |
3477
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
408 return FALSE; |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
409 } |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
410 |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
411 playlist->filename = filename_to_utf8(filename); |
3635 | 412 g_free(old); |
3477
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
413 return TRUE; |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
414 } |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
415 |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
416 gchar * |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
417 playlist_filename_get(Playlist *playlist) |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
418 { |
3635 | 419 if (!playlist->filename) return NULL; |
3477
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
420 return g_filename_from_utf8(playlist->filename, -1, NULL, NULL, NULL); |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
421 } |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
422 |
2313 | 423 static GList * |
424 find_playlist_position_list(Playlist *playlist) | |
425 { | |
426 REQUIRE_LOCK(playlist->mutex); | |
427 | |
428 if (!playlist->position) { | |
429 if (cfg.shuffle) | |
430 return playlist->shuffle; | |
431 else | |
432 return playlist->entries; | |
433 } | |
434 | |
435 if (cfg.shuffle) | |
436 return g_list_find(playlist->shuffle, playlist->position); | |
437 else | |
438 return g_list_find(playlist->entries, playlist->position); | |
439 } | |
440 | |
441 static void | |
442 play_queued(Playlist *playlist) | |
443 { | |
444 GList *tmp = playlist->queue; | |
445 | |
3635 | 446 REQUIRE_LOCK(playlist->mutex); |
2313 | 447 |
448 playlist->position = playlist->queue->data; | |
449 playlist->queue = g_list_remove_link(playlist->queue, playlist->queue); | |
450 g_list_free_1(tmp); | |
451 } | |
452 | |
453 void | |
3460
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
454 playlist_clear_only(Playlist *playlist) |
2313 | 455 { |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
456 PLAYLIST_LOCK(playlist); |
2313 | 457 |
458 g_list_foreach(playlist->entries, (GFunc) playlist_entry_free, NULL); | |
459 g_list_free(playlist->entries); | |
460 playlist->position = NULL; | |
461 playlist->entries = NULL; | |
2549
ef59b072a5d2
[svn] - update playlist->tail when an entry has been removed.
yaz
parents:
2548
diff
changeset
|
462 playlist->tail = NULL; |
2637
420ce282920d
[svn] - clear playlist attribute when playlist_clear() is called.
yaz
parents:
2636
diff
changeset
|
463 playlist->attribute = PLAYLIST_PLAIN; |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
464 playlist->serial = 0; |
2313 | 465 |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
466 PLAYLIST_UNLOCK(playlist); |
3460
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
467 } |
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
468 |
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
469 void |
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
470 playlist_clear(Playlist *playlist) |
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
471 { |
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
472 if (!playlist) |
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
473 return; |
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
474 |
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
475 playlist_clear_only(playlist); |
2313 | 476 playlist_generate_shuffle_list(playlist); |
477 playlistwin_update_list(playlist); | |
478 playlist_recalc_total_time(playlist); | |
3923
e9fd46b0893b
- redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3922
diff
changeset
|
479 PLAYLIST_INCR_SERIAL(playlist); |
2313 | 480 playlist_manager_update(); |
481 } | |
482 | |
483 static void | |
484 playlist_delete_node(Playlist * playlist, GList * node, gboolean * set_info_text, | |
485 gboolean * restart_playing) | |
486 { | |
487 PlaylistEntry *entry; | |
488 GList *playing_song = NULL; | |
489 | |
490 REQUIRE_LOCK(playlist->mutex); | |
491 | |
492 /* We call g_list_find manually here because we don't want an item | |
493 * in the shuffle_list */ | |
494 | |
495 if (playlist->position) | |
496 playing_song = g_list_find(playlist->entries, playlist->position); | |
497 | |
498 entry = PLAYLIST_ENTRY(node->data); | |
499 | |
500 if (playing_song == node) { | |
501 *set_info_text = TRUE; | |
502 | |
503 if (playback_get_playing()) { | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
504 PLAYLIST_UNLOCK(playlist); |
2313 | 505 ip_data.stop = TRUE; |
506 playback_stop(); | |
507 ip_data.stop = FALSE; | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
508 PLAYLIST_LOCK(playlist); |
2313 | 509 *restart_playing = TRUE; |
510 } | |
511 | |
512 playing_song = find_playlist_position_list(playlist); | |
513 | |
514 if (g_list_next(playing_song)) | |
515 playlist->position = g_list_next(playing_song)->data; | |
516 else if (g_list_previous(playing_song)) | |
517 playlist->position = g_list_previous(playing_song)->data; | |
518 else | |
519 playlist->position = NULL; | |
520 | |
521 /* Make sure the entry did not disappear under us */ | |
522 if (g_list_index(playlist->entries, entry) == -1) | |
523 return; | |
524 | |
525 } | |
526 else if (g_list_position(playlist->entries, playing_song) > | |
527 g_list_position(playlist->entries, node)) { | |
528 *set_info_text = TRUE; | |
529 } | |
530 | |
531 playlist->shuffle = g_list_remove(playlist->shuffle, entry); | |
532 playlist->queue = g_list_remove(playlist->queue, entry); | |
533 playlist->entries = g_list_remove_link(playlist->entries, node); | |
2549
ef59b072a5d2
[svn] - update playlist->tail when an entry has been removed.
yaz
parents:
2548
diff
changeset
|
534 playlist->tail = g_list_last(playlist->entries); |
2313 | 535 playlist_entry_free(entry); |
536 g_list_free_1(node); | |
537 | |
538 playlist_recalc_total_time_nolock(playlist); | |
3923
e9fd46b0893b
- redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3922
diff
changeset
|
539 PLAYLIST_INCR_SERIAL(playlist); |
2313 | 540 } |
541 | |
542 void | |
543 playlist_delete_index(Playlist *playlist, guint pos) | |
544 { | |
545 gboolean restart_playing = FALSE, set_info_text = FALSE; | |
546 GList *node; | |
547 | |
548 if (!playlist) | |
549 return; | |
550 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
551 PLAYLIST_LOCK(playlist); |
2313 | 552 |
553 node = g_list_nth(playlist->entries, pos); | |
554 | |
555 if (!node) { | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
556 PLAYLIST_UNLOCK(playlist); |
2313 | 557 return; |
558 } | |
559 | |
560 playlist_delete_node(playlist, node, &set_info_text, &restart_playing); | |
561 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
562 PLAYLIST_UNLOCK(playlist); |
2313 | 563 |
564 playlist_recalc_total_time(playlist); | |
3923
e9fd46b0893b
- redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3922
diff
changeset
|
565 PLAYLIST_INCR_SERIAL(playlist); |
2313 | 566 |
567 playlistwin_update_list(playlist); | |
568 if (restart_playing) { | |
3348
2a081105513c
-Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents:
3346
diff
changeset
|
569 if (playlist->position) |
2313 | 570 playback_initiate(); |
3635 | 571 else |
2313 | 572 mainwin_clear_song_info(); |
573 } | |
574 | |
575 playlist_manager_update(); | |
576 } | |
577 | |
578 void | |
579 playlist_delete_filenames(Playlist * playlist, GList * filenames) | |
580 { | |
581 GList *node, *fnode; | |
582 gboolean set_info_text = FALSE, restart_playing = FALSE; | |
583 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
584 PLAYLIST_LOCK(playlist); |
2313 | 585 |
586 for (fnode = filenames; fnode; fnode = g_list_next(fnode)) { | |
587 node = playlist->entries; | |
588 | |
589 while (node) { | |
590 GList *next = g_list_next(node); | |
591 PlaylistEntry *entry = node->data; | |
592 | |
593 if (!strcmp(entry->filename, fnode->data)) | |
594 playlist_delete_node(playlist, node, &set_info_text, &restart_playing); | |
595 | |
596 node = next; | |
597 } | |
598 } | |
599 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
600 PLAYLIST_UNLOCK(playlist); |
2792
790bb0954b93
[svn] - move playlist_recalc_total_time() out of the giant playlist lock in playlist_delete_filenames(). reported by dotzen, closes #908.
nenolod
parents:
2776
diff
changeset
|
601 |
2313 | 602 playlist_recalc_total_time(playlist); |
3923
e9fd46b0893b
- redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3922
diff
changeset
|
603 PLAYLIST_INCR_SERIAL(playlist); |
2313 | 604 playlistwin_update_list(playlist); |
605 | |
606 if (restart_playing) { | |
3348
2a081105513c
-Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents:
3346
diff
changeset
|
607 if (playlist->position) |
2313 | 608 playback_initiate(); |
3635 | 609 else |
2313 | 610 mainwin_clear_song_info(); |
611 } | |
612 | |
613 playlist_manager_update(); | |
614 } | |
615 | |
616 void | |
617 playlist_delete(Playlist * playlist, gboolean crop) | |
618 { | |
619 gboolean restart_playing = FALSE, set_info_text = FALSE; | |
620 GList *node, *next_node; | |
621 PlaylistEntry *entry; | |
622 | |
623 g_return_if_fail(playlist != NULL); | |
624 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
625 PLAYLIST_LOCK(playlist); |
2313 | 626 |
627 node = playlist->entries; | |
628 | |
629 while (node) { | |
630 entry = PLAYLIST_ENTRY(node->data); | |
631 | |
632 next_node = g_list_next(node); | |
633 | |
634 if ((entry->selected && !crop) || (!entry->selected && crop)) { | |
635 playlist_delete_node(playlist, node, &set_info_text, &restart_playing); | |
636 } | |
637 | |
638 node = next_node; | |
639 } | |
640 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
641 PLAYLIST_UNLOCK(playlist); |
2313 | 642 |
643 playlist_recalc_total_time(playlist); | |
3923
e9fd46b0893b
- redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3922
diff
changeset
|
644 PLAYLIST_INCR_SERIAL(playlist); |
2313 | 645 |
646 if (restart_playing) { | |
3348
2a081105513c
-Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents:
3346
diff
changeset
|
647 if (playlist->position) |
2313 | 648 playback_initiate(); |
3635 | 649 else |
2313 | 650 mainwin_clear_song_info(); |
651 } | |
652 | |
653 playlistwin_update_list(playlist); | |
654 playlist_manager_update(); | |
655 } | |
656 | |
657 static void | |
658 __playlist_ins_with_info(Playlist * playlist, | |
2545
610d85b8a22b
[svn] - on loading a playlist with tuple, invoke the scanner thread only if mtime is -1.
yaz
parents:
2504
diff
changeset
|
659 const gchar * filename, |
2313 | 660 gint pos, |
661 const gchar * title, | |
662 gint len, | |
2545
610d85b8a22b
[svn] - on loading a playlist with tuple, invoke the scanner thread only if mtime is -1.
yaz
parents:
2504
diff
changeset
|
663 InputPlugin * dec) |
2313 | 664 { |
665 g_return_if_fail(filename != NULL); | |
666 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
667 PLAYLIST_LOCK(playlist); |
2313 | 668 playlist->entries = g_list_insert(playlist->entries, |
669 playlist_entry_new(filename, title, len, dec), | |
670 pos); | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
671 PLAYLIST_UNLOCK(playlist); |
2313 | 672 |
673 g_mutex_lock(mutex_scan); | |
674 playlist_get_info_scan_active = TRUE; | |
675 g_mutex_unlock(mutex_scan); | |
676 g_cond_signal(cond_scan); | |
3923
e9fd46b0893b
- redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3922
diff
changeset
|
677 PLAYLIST_INCR_SERIAL(playlist); |
2313 | 678 } |
679 | |
680 static void | |
681 __playlist_ins_with_info_tuple(Playlist * playlist, | |
682 const gchar * filename, | |
683 gint pos, | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
684 Tuple *tuple, |
2313 | 685 InputPlugin * dec) |
686 { | |
687 PlaylistEntry *entry; | |
3778
b4fe7d2a0d0d
Use a more describing variable name.
Matti Hamalainen <ccr@tnsp.org>
parents:
3733
diff
changeset
|
688 Tuple *parent_tuple = NULL; |
3784 | 689 gint nsubtunes = 0, subtune = 0; |
3636
65b750891387
Possibly fix a lockup problem.
Matti Hamalainen <ccr@tnsp.org>
parents:
3635
diff
changeset
|
690 gboolean add_flag = TRUE; |
2313 | 691 |
692 g_return_if_fail(playlist != NULL); | |
693 g_return_if_fail(filename != NULL); | |
694 | |
3635 | 695 if (tuple != NULL) { |
696 nsubtunes = tuple->nsubtunes; | |
3784 | 697 if (nsubtunes > 0) { |
3778
b4fe7d2a0d0d
Use a more describing variable name.
Matti Hamalainen <ccr@tnsp.org>
parents:
3733
diff
changeset
|
698 parent_tuple = tuple; |
3784 | 699 subtune = 1; |
700 } | |
3782
a3fc112b10f1
Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry
Matti Hamalainen <ccr@tnsp.org>
parents:
3780
diff
changeset
|
701 } |
a3fc112b10f1
Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry
Matti Hamalainen <ccr@tnsp.org>
parents:
3780
diff
changeset
|
702 |
a3fc112b10f1
Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry
Matti Hamalainen <ccr@tnsp.org>
parents:
3780
diff
changeset
|
703 for (; add_flag && subtune <= nsubtunes; subtune++) { |
3550
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
704 gchar *filename_entry; |
3635 | 705 |
706 if (nsubtunes > 0) { | |
3640
d5309028af21
Simplify adding of all sub-tunes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3638
diff
changeset
|
707 filename_entry = g_strdup_printf("%s?%d", filename, |
3782
a3fc112b10f1
Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry
Matti Hamalainen <ccr@tnsp.org>
parents:
3780
diff
changeset
|
708 parent_tuple->subtunes ? parent_tuple->subtunes[subtune - 1] : subtune); |
3640
d5309028af21
Simplify adding of all sub-tunes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3638
diff
changeset
|
709 |
3635 | 710 /* We're dealing with subtune, let's ask again tuple information |
711 * to plugin, by passing the ?subtune suffix; this way we get | |
712 * specific subtune information in the tuple, if available. | |
713 */ | |
3550
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
714 tuple = dec->get_song_tuple(filename_entry); |
3635 | 715 } else |
3550
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
716 filename_entry = g_strdup(filename); |
3583 | 717 |
718 | |
3550
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
719 entry = playlist_entry_new(filename_entry, |
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
720 tuple ? tuple_get_string(tuple, FIELD_TITLE, NULL) : NULL, |
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
721 tuple ? tuple_get_int(tuple, FIELD_LENGTH, NULL) : -1, dec); |
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
722 g_free(filename_entry); |
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
723 |
3784 | 724 PLAYLIST_LOCK(playlist); |
725 | |
3636
65b750891387
Possibly fix a lockup problem.
Matti Hamalainen <ccr@tnsp.org>
parents:
3635
diff
changeset
|
726 if (!playlist->tail) |
3550
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
727 playlist->tail = g_list_last(playlist->entries); |
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
728 |
3782
a3fc112b10f1
Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry
Matti Hamalainen <ccr@tnsp.org>
parents:
3780
diff
changeset
|
729 if (pos == -1) { // the common case |
3550
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
730 GList *element; |
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
731 element = g_list_alloc(); |
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
732 element->data = entry; |
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
733 element->prev = playlist->tail; // NULL is allowed here. |
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
734 element->next = NULL; |
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
735 |
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
736 if(!playlist->entries) { // this is the first element |
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
737 playlist->entries = element; |
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
738 playlist->tail = element; |
3635 | 739 } else { // the rests |
3636
65b750891387
Possibly fix a lockup problem.
Matti Hamalainen <ccr@tnsp.org>
parents:
3635
diff
changeset
|
740 if (playlist->tail != NULL) { |
65b750891387
Possibly fix a lockup problem.
Matti Hamalainen <ccr@tnsp.org>
parents:
3635
diff
changeset
|
741 playlist->tail->next = element; |
65b750891387
Possibly fix a lockup problem.
Matti Hamalainen <ccr@tnsp.org>
parents:
3635
diff
changeset
|
742 playlist->tail = element; |
65b750891387
Possibly fix a lockup problem.
Matti Hamalainen <ccr@tnsp.org>
parents:
3635
diff
changeset
|
743 } else |
65b750891387
Possibly fix a lockup problem.
Matti Hamalainen <ccr@tnsp.org>
parents:
3635
diff
changeset
|
744 add_flag = FALSE; |
3550
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
745 } |
3782
a3fc112b10f1
Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry
Matti Hamalainen <ccr@tnsp.org>
parents:
3780
diff
changeset
|
746 } else |
a3fc112b10f1
Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry
Matti Hamalainen <ccr@tnsp.org>
parents:
3780
diff
changeset
|
747 playlist->entries = g_list_insert(playlist->entries, entry, pos++); |
a3fc112b10f1
Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry
Matti Hamalainen <ccr@tnsp.org>
parents:
3780
diff
changeset
|
748 |
3550
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
749 if (tuple != NULL) { |
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
750 const gchar *formatter = tuple_get_string(tuple, FIELD_FORMATTER, NULL); |
3635 | 751 entry->title = tuple_formatter_make_title_string(tuple, |
752 formatter ? formatter : get_gentitle_format()); | |
3550
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
753 entry->length = tuple_get_int(tuple, FIELD_LENGTH, NULL); |
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
754 entry->tuple = tuple; |
6b0be1d088e6
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents:
3512
diff
changeset
|
755 } |
3782
a3fc112b10f1
Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry
Matti Hamalainen <ccr@tnsp.org>
parents:
3780
diff
changeset
|
756 |
a3fc112b10f1
Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry
Matti Hamalainen <ccr@tnsp.org>
parents:
3780
diff
changeset
|
757 PLAYLIST_UNLOCK(playlist); |
2313 | 758 } |
3782
a3fc112b10f1
Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry
Matti Hamalainen <ccr@tnsp.org>
parents:
3780
diff
changeset
|
759 |
3778
b4fe7d2a0d0d
Use a more describing variable name.
Matti Hamalainen <ccr@tnsp.org>
parents:
3733
diff
changeset
|
760 if (parent_tuple) |
b4fe7d2a0d0d
Use a more describing variable name.
Matti Hamalainen <ccr@tnsp.org>
parents:
3733
diff
changeset
|
761 tuple_free(parent_tuple); |
2313 | 762 |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
763 if (!tuple || (tuple && tuple_get_int(tuple, FIELD_MTIME, NULL) == -1)) { |
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
764 // kick the scanner thread when tuple == NULL or mtime = -1 (uninitialized) |
2545
610d85b8a22b
[svn] - on loading a playlist with tuple, invoke the scanner thread only if mtime is -1.
yaz
parents:
2504
diff
changeset
|
765 g_mutex_lock(mutex_scan); |
610d85b8a22b
[svn] - on loading a playlist with tuple, invoke the scanner thread only if mtime is -1.
yaz
parents:
2504
diff
changeset
|
766 playlist_get_info_scan_active = TRUE; |
610d85b8a22b
[svn] - on loading a playlist with tuple, invoke the scanner thread only if mtime is -1.
yaz
parents:
2504
diff
changeset
|
767 g_mutex_unlock(mutex_scan); |
610d85b8a22b
[svn] - on loading a playlist with tuple, invoke the scanner thread only if mtime is -1.
yaz
parents:
2504
diff
changeset
|
768 g_cond_signal(cond_scan); |
610d85b8a22b
[svn] - on loading a playlist with tuple, invoke the scanner thread only if mtime is -1.
yaz
parents:
2504
diff
changeset
|
769 } |
3923
e9fd46b0893b
- redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3922
diff
changeset
|
770 PLAYLIST_INCR_SERIAL(playlist); |
2313 | 771 } |
772 | |
773 gboolean | |
774 playlist_ins(Playlist * playlist, const gchar * filename, gint pos) | |
775 { | |
776 gchar buf[64], *p; | |
777 gint r; | |
778 VFSFile *file; | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
779 ProbeResult *pr = NULL; |
2667
8c56926de2ad
[svn] - probe remote sources (hardcoded to http://, https://) in the background.
nenolod
parents:
2637
diff
changeset
|
780 InputPlugin *dec = NULL; |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
781 Tuple *tuple = NULL; |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
782 gint ext_flag; |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
783 gboolean http_flag; |
2313 | 784 |
785 g_return_val_if_fail(playlist != NULL, FALSE); | |
786 g_return_val_if_fail(filename != NULL, FALSE); | |
787 | |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
788 /* load playlist */ |
2313 | 789 if (is_playlist_name(filename)) { |
790 playlist->loading_playlist = TRUE; | |
791 playlist_load_ins(playlist, filename, pos); | |
792 playlist->loading_playlist = FALSE; | |
793 return TRUE; | |
794 } | |
795 | |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
796 ext_flag = filter_by_extension(filename); |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
797 http_flag = is_http(filename); |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
798 |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
799 /* playlist file or remote uri */ |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
800 if (playlist->loading_playlist == TRUE || http_flag == TRUE) { |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
801 dec = NULL; |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
802 } |
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
803 |
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
804 /* local file and on-demand probing is on */ |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
805 else if (cfg.playlist_detect == TRUE && ext_flag != EXT_HAVE_SUBTUNE) { |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
806 dec = NULL; |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
807 if(cfg.use_extension_probing && ext_flag == EXT_FALSE) |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
808 return FALSE; |
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
809 } |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
810 |
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
811 /* find decorder for local file */ |
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
812 else { |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
813 pr = input_check_file(filename, TRUE); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
814 |
3635 | 815 if (pr) { |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
816 dec = pr->ip; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
817 tuple = pr->tuple; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
818 } |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
819 g_free(pr); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
820 } |
2313 | 821 |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
822 /* add filename to playlist */ |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
823 if (cfg.playlist_detect == TRUE || |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
824 playlist->loading_playlist == TRUE || |
3635 | 825 (playlist->loading_playlist == FALSE && dec != NULL) || |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
826 (playlist->loading_playlist == FALSE && !is_playlist_name(filename) && http_flag) ) { |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
827 |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
828 __playlist_ins_with_info_tuple(playlist, filename, pos, tuple, dec); |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
829 |
2545
610d85b8a22b
[svn] - on loading a playlist with tuple, invoke the scanner thread only if mtime is -1.
yaz
parents:
2504
diff
changeset
|
830 playlist_generate_shuffle_list(playlist); |
610d85b8a22b
[svn] - on loading a playlist with tuple, invoke the scanner thread only if mtime is -1.
yaz
parents:
2504
diff
changeset
|
831 playlistwin_update_list(playlist); |
3621
2d6106656276
Notify playlist manager of more changes
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3583
diff
changeset
|
832 playlist_manager_update(); |
2313 | 833 return TRUE; |
834 } | |
835 | |
836 /* Some files (typically produced by some cgi-scripts) don't have | |
837 * the correct extension. Try to recognize these files by looking | |
838 * at their content. We only check for http entries since it does | |
839 * not make sense to have file entries in a playlist fetched from | |
840 * the net. */ | |
841 | |
842 /* Some strange people put fifo's with the .mp3 extension, so we | |
843 * need to make sure it's a real file (otherwise fread() may block | |
844 * and stall the entire program) */ | |
845 | |
846 /* FIXME: bah, FIFOs actually pass this regular file test */ | |
847 if (!vfs_file_test(filename, G_FILE_TEST_IS_REGULAR)) | |
848 return FALSE; | |
849 | |
3635 | 850 if ((file = vfs_fopen(filename, "rb")) == NULL) |
2313 | 851 return FALSE; |
852 | |
853 r = vfs_fread(buf, 1, sizeof(buf), file); | |
854 vfs_fclose(file); | |
855 | |
856 for (p = buf; r-- > 0 && (*p == '\r' || *p == '\n'); p++); | |
857 | |
858 if (r > 5 && str_has_prefix_nocase(p, "http:")) { | |
859 playlist_load_ins(playlist, filename, pos); | |
860 return TRUE; | |
861 } | |
862 | |
2493
b7f48f00a342
[svn] - patch from Mark Glines to ad https:// URI support to playlists.
nenolod
parents:
2489
diff
changeset
|
863 if (r > 6 && str_has_prefix_nocase(p, "https:")) { |
b7f48f00a342
[svn] - patch from Mark Glines to ad https:// URI support to playlists.
nenolod
parents:
2489
diff
changeset
|
864 playlist_load_ins(playlist, filename, pos); |
b7f48f00a342
[svn] - patch from Mark Glines to ad https:// URI support to playlists.
nenolod
parents:
2489
diff
changeset
|
865 return TRUE; |
b7f48f00a342
[svn] - patch from Mark Glines to ad https:// URI support to playlists.
nenolod
parents:
2489
diff
changeset
|
866 } |
b7f48f00a342
[svn] - patch from Mark Glines to ad https:// URI support to playlists.
nenolod
parents:
2489
diff
changeset
|
867 |
2313 | 868 return FALSE; |
869 } | |
870 | |
871 /* FIXME: The next few functions are specific to Unix | |
872 * filesystems. Either abstract it away, or don't even bother checking | |
873 * at such low level */ | |
874 | |
875 typedef struct { | |
876 dev_t dev; | |
877 ino_t ino; | |
878 } DeviceInode; | |
879 | |
880 static DeviceInode * | |
881 devino_new(dev_t device, | |
882 ino_t inode) | |
883 { | |
884 DeviceInode *devino = g_new0(DeviceInode, 1); | |
885 | |
3635 | 886 if (devino) { |
2313 | 887 devino->dev = device; |
888 devino->ino = inode; | |
889 } | |
890 | |
891 return devino; | |
892 } | |
893 | |
894 static guint | |
895 devino_hash(gconstpointer key) | |
896 { | |
897 const DeviceInode *d = key; | |
898 return d->ino; | |
899 } | |
900 | |
901 static gint | |
902 devino_compare(gconstpointer a, | |
903 gconstpointer b) | |
904 { | |
905 const DeviceInode *da = a, *db = b; | |
906 return (da->dev == db->dev && da->ino == db->ino); | |
907 } | |
908 | |
909 static gboolean | |
910 devino_destroy(gpointer key, | |
911 gpointer value, | |
912 gpointer data) | |
913 { | |
914 g_free(key); | |
915 return TRUE; | |
916 } | |
917 | |
918 static gboolean | |
919 file_is_hidden(const gchar * filename) | |
920 { | |
921 g_return_val_if_fail(filename != NULL, FALSE); | |
2570 | 922 return (g_basename(filename)[0] == '.'); |
2313 | 923 } |
924 | |
925 static GList * | |
926 playlist_dir_find_files(const gchar * path, | |
927 gboolean background, | |
928 GHashTable * htab) | |
929 { | |
930 GDir *dir; | |
931 GList *list = NULL, *ilist; | |
932 const gchar *dir_entry; | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
933 ProbeResult *pr = NULL; |
2313 | 934 |
935 struct stat statbuf; | |
936 DeviceInode *devino; | |
937 | |
3079
72766f2e8713
recursive directory scan for add file dialog works again
Giacomo Lozito <james@develia.org>
parents:
2994
diff
changeset
|
938 if (!path) |
72766f2e8713
recursive directory scan for add file dialog works again
Giacomo Lozito <james@develia.org>
parents:
2994
diff
changeset
|
939 return NULL; |
72766f2e8713
recursive directory scan for add file dialog works again
Giacomo Lozito <james@develia.org>
parents:
2994
diff
changeset
|
940 |
2993
83727fbfec54
Use vfs_file_test() where appropriate.
William Pitcock <nenolod@atheme-project.org>
parents:
2978
diff
changeset
|
941 if (!vfs_file_test(path, G_FILE_TEST_IS_DIR)) |
2313 | 942 return NULL; |
943 | |
944 stat(path, &statbuf); | |
945 devino = devino_new(statbuf.st_dev, statbuf.st_ino); | |
946 | |
947 if (g_hash_table_lookup(htab, devino)) { | |
948 g_free(devino); | |
949 return NULL; | |
950 } | |
951 | |
952 g_hash_table_insert(htab, devino, GINT_TO_POINTER(1)); | |
953 | |
2994
750c530b1bf5
playlist_dir_find_files(): Return list of URIs.
William Pitcock <nenolod@atheme-project.org>
parents:
2993
diff
changeset
|
954 /* XXX: what the hell is this for? --nenolod */ |
2313 | 955 if ((ilist = input_scan_dir(path))) { |
956 GList *node; | |
957 for (node = ilist; node; node = g_list_next(node)) { | |
958 gchar *name = g_build_filename(path, node->data, NULL); | |
959 list = g_list_prepend(list, name); | |
960 g_free(node->data); | |
961 } | |
962 g_list_free(ilist); | |
963 return list; | |
964 } | |
965 | |
3079
72766f2e8713
recursive directory scan for add file dialog works again
Giacomo Lozito <james@develia.org>
parents:
2994
diff
changeset
|
966 /* g_dir_open does not handle URI, so path should come here not-urified. --giacomo */ |
2313 | 967 if (!(dir = g_dir_open(path, 0, NULL))) |
968 return NULL; | |
969 | |
970 while ((dir_entry = g_dir_read_name(dir))) { | |
2994
750c530b1bf5
playlist_dir_find_files(): Return list of URIs.
William Pitcock <nenolod@atheme-project.org>
parents:
2993
diff
changeset
|
971 gchar *filename, *tmp; |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
972 gint ext_flag; |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
973 gboolean http_flag; |
2313 | 974 |
975 if (file_is_hidden(dir_entry)) | |
976 continue; | |
977 | |
2994
750c530b1bf5
playlist_dir_find_files(): Return list of URIs.
William Pitcock <nenolod@atheme-project.org>
parents:
2993
diff
changeset
|
978 tmp = g_build_filename(path, dir_entry, NULL); |
750c530b1bf5
playlist_dir_find_files(): Return list of URIs.
William Pitcock <nenolod@atheme-project.org>
parents:
2993
diff
changeset
|
979 filename = g_filename_to_uri(tmp, NULL, NULL); |
750c530b1bf5
playlist_dir_find_files(): Return list of URIs.
William Pitcock <nenolod@atheme-project.org>
parents:
2993
diff
changeset
|
980 g_free(tmp); |
2313 | 981 |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
982 ext_flag = filter_by_extension(filename); |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
983 http_flag = is_http(filename); |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
984 |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
985 if (vfs_file_test(filename, G_FILE_TEST_IS_DIR)) { /* directory */ |
2313 | 986 GList *sub; |
3079
72766f2e8713
recursive directory scan for add file dialog works again
Giacomo Lozito <james@develia.org>
parents:
2994
diff
changeset
|
987 gchar *dirfilename = g_filename_from_uri(filename, NULL, NULL); |
72766f2e8713
recursive directory scan for add file dialog works again
Giacomo Lozito <james@develia.org>
parents:
2994
diff
changeset
|
988 sub = playlist_dir_find_files(dirfilename, background, htab); |
72766f2e8713
recursive directory scan for add file dialog works again
Giacomo Lozito <james@develia.org>
parents:
2994
diff
changeset
|
989 g_free(dirfilename); |
2313 | 990 g_free(filename); |
991 list = g_list_concat(list, sub); | |
992 } | |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
993 else if (cfg.playlist_detect && ext_flag != EXT_HAVE_SUBTUNE) { /* local file, no probing, no subtune */ |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
994 if(cfg.use_extension_probing) { |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
995 if(ext_flag == EXT_TRUE) |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
996 list = g_list_prepend(list, filename); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
997 } |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
998 else |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
999 list = g_list_prepend(list, filename); |
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
1000 } |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1001 else if ((pr = input_check_file(filename, TRUE)) != NULL) /* local file, probing or have subtune */ |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1002 { |
2313 | 1003 list = g_list_prepend(list, filename); |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1004 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1005 g_free(pr); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1006 pr = NULL; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1007 } |
2313 | 1008 else |
1009 g_free(filename); | |
1010 | |
1011 while (background && gtk_events_pending()) | |
1012 gtk_main_iteration(); | |
1013 } | |
1014 g_dir_close(dir); | |
1015 | |
1016 return list; | |
1017 } | |
1018 | |
1019 gboolean | |
1020 playlist_add(Playlist * playlist, const gchar * filename) | |
1021 { | |
1022 return playlist_ins(playlist, filename, -1); | |
1023 } | |
1024 | |
1025 guint | |
1026 playlist_add_dir(Playlist * playlist, const gchar * directory) | |
1027 { | |
1028 return playlist_ins_dir(playlist, directory, -1, TRUE); | |
1029 } | |
1030 | |
1031 guint | |
1032 playlist_add_url(Playlist * playlist, const gchar * url) | |
1033 { | |
3337
99f34db2c3fc
- fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3334
diff
changeset
|
1034 guint entries; |
99f34db2c3fc
- fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3334
diff
changeset
|
1035 entries = playlist_ins_url(playlist, url, -1); |
99f34db2c3fc
- fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3334
diff
changeset
|
1036 return entries; |
2313 | 1037 } |
1038 | |
1039 guint | |
1040 playlist_ins_dir(Playlist * playlist, const gchar * path, | |
1041 gint pos, | |
1042 gboolean background) | |
1043 { | |
1044 guint entries = 0; | |
1045 GList *list, *node; | |
1046 GHashTable *htab; | |
2978
f4971c7d6384
Remove inlined urldecoding functions and use g_filename_from_uri() instead where appropriate.
William Pitcock <nenolod@atheme-project.org>
parents:
2976
diff
changeset
|
1047 gchar *path2 = g_filename_from_uri(path, NULL, NULL); |
2313 | 1048 |
2580
48288757d7c7
[svn] - fix a regression introduced by the DnD fix.
nenolod
parents:
2579
diff
changeset
|
1049 if (path2 == NULL) |
48288757d7c7
[svn] - fix a regression introduced by the DnD fix.
nenolod
parents:
2579
diff
changeset
|
1050 path2 = g_strdup(path); |
48288757d7c7
[svn] - fix a regression introduced by the DnD fix.
nenolod
parents:
2579
diff
changeset
|
1051 |
2313 | 1052 htab = g_hash_table_new(devino_hash, devino_compare); |
1053 | |
2579 | 1054 list = playlist_dir_find_files(path2, background, htab); |
2313 | 1055 list = g_list_sort(list, (GCompareFunc) path_compare); |
1056 | |
1057 g_hash_table_foreach_remove(htab, devino_destroy, NULL); | |
1058 | |
1059 for (node = list; node; node = g_list_next(node)) { | |
3129
f416657ee9b7
Call playlist_ins() instead of __playlist_ins().
William Pitcock <nenolod@atheme-project.org>
parents:
3128
diff
changeset
|
1060 playlist_ins(playlist, node->data, pos); |
2313 | 1061 g_free(node->data); |
1062 entries++; | |
1063 if (pos >= 0) | |
1064 pos++; | |
1065 } | |
1066 | |
1067 g_list_free(list); | |
2579 | 1068 g_free(path2); |
2313 | 1069 |
1070 playlist_recalc_total_time(playlist); | |
1071 playlist_generate_shuffle_list(playlist); | |
1072 playlistwin_update_list(playlist); | |
1073 playlist_manager_update(); | |
1074 return entries; | |
1075 } | |
1076 | |
1077 guint | |
1078 playlist_ins_url(Playlist * playlist, const gchar * string, | |
1079 gint pos) | |
1080 { | |
1081 gchar *tmp; | |
3337
99f34db2c3fc
- fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3334
diff
changeset
|
1082 gint entries = 0; |
2313 | 1083 gchar *decoded = NULL; |
1084 | |
1085 g_return_val_if_fail(playlist != NULL, 0); | |
1086 g_return_val_if_fail(string != NULL, 0); | |
1087 | |
1088 while (*string) { | |
1089 GList *node; | |
3337
99f34db2c3fc
- fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3334
diff
changeset
|
1090 guint i = 0; |
2313 | 1091 tmp = strchr(string, '\n'); |
1092 if (tmp) { | |
1093 if (*(tmp - 1) == '\r') | |
1094 *(tmp - 1) = '\0'; | |
1095 *tmp = '\0'; | |
1096 } | |
1097 | |
1098 decoded = g_strdup(string); | |
1099 | |
2575 | 1100 if (vfs_file_test(decoded, G_FILE_TEST_IS_DIR)) { |
2313 | 1101 i = playlist_ins_dir(playlist, decoded, pos, FALSE); |
1102 } | |
1103 else { | |
1104 if (is_playlist_name(decoded)) { | |
1105 i = playlist_load_ins(playlist, decoded, pos); | |
1106 } | |
3337
99f34db2c3fc
- fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3334
diff
changeset
|
1107 else if (playlist_ins(playlist, decoded, pos)) { |
2313 | 1108 i = 1; |
1109 } | |
1110 } | |
1111 | |
1112 g_free(decoded); | |
1113 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1114 PLAYLIST_LOCK(playlist); |
2313 | 1115 node = g_list_nth(playlist->entries, pos); |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1116 PLAYLIST_UNLOCK(playlist); |
2313 | 1117 |
1118 entries += i; | |
1119 | |
1120 if (pos >= 0) | |
1121 pos += i; | |
1122 if (!tmp) | |
1123 break; | |
1124 | |
1125 string = tmp + 1; | |
1126 } | |
1127 | |
1128 playlist_recalc_total_time(playlist); | |
3923
e9fd46b0893b
- redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3922
diff
changeset
|
1129 PLAYLIST_INCR_SERIAL(playlist); //probably necessary because there is no underlying __playlist_ins --yaz |
2313 | 1130 playlist_generate_shuffle_list(playlist); |
1131 playlistwin_update_list(playlist); | |
1132 | |
1133 playlist_manager_update(); | |
1134 | |
1135 return entries; | |
1136 } | |
1137 | |
1138 void | |
1139 playlist_set_info_old_abi(const gchar * title, gint length, gint rate, | |
1140 gint freq, gint nch) | |
1141 { | |
1142 Playlist *playlist = playlist_get_active(); | |
3159
a2d552ea48f0
Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3132
diff
changeset
|
1143 PlaylistEventInfoChange *msg; |
3165
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3159
diff
changeset
|
1144 gchar *text; |
2313 | 1145 |
3197
5dd8bc77a590
now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3165
diff
changeset
|
1146 if(length == -1) { |
5dd8bc77a590
now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3165
diff
changeset
|
1147 event_queue("hide seekbar", (gpointer)0xdeadbeef); // event_queue hates NULL --yaz |
5dd8bc77a590
now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3165
diff
changeset
|
1148 } |
5dd8bc77a590
now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3165
diff
changeset
|
1149 |
2313 | 1150 g_return_if_fail(playlist != NULL); |
1151 | |
1152 if (playlist->position) { | |
1153 g_free(playlist->position->title); | |
1154 playlist->position->title = g_strdup(title); | |
1155 playlist->position->length = length; | |
2488
c5075a79f1aa
[svn] make input->set_info overwrite tuple->track_name. it allows input
yaz
parents:
2480
diff
changeset
|
1156 |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
1157 // overwrite tuple::title, mainly for streaming. it may incur side effects. --yaz |
3635 | 1158 if (playlist->position->tuple && tuple_get_int(playlist->position->tuple, FIELD_LENGTH, NULL) == -1){ |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
1159 tuple_disassociate(playlist->position->tuple, FIELD_TITLE, NULL); |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
1160 tuple_associate_string(playlist->position->tuple, FIELD_TITLE, NULL, title); |
2488
c5075a79f1aa
[svn] make input->set_info overwrite tuple->track_name. it allows input
yaz
parents:
2480
diff
changeset
|
1161 } |
2313 | 1162 } |
1163 | |
3922
23e5b148ae7c
to get rid of annoying side effects, an independent function for playlist serial increment has been provided.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3921
diff
changeset
|
1164 playlist_recalc_total_time(playlist); |
2313 | 1165 |
3159
a2d552ea48f0
Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3132
diff
changeset
|
1166 /* broadcast a PlaylistEventInfoChange message. */ |
a2d552ea48f0
Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3132
diff
changeset
|
1167 msg = g_new0(PlaylistEventInfoChange, 1); |
a2d552ea48f0
Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3132
diff
changeset
|
1168 msg->bitrate = rate; |
a2d552ea48f0
Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3132
diff
changeset
|
1169 msg->samplerate = freq; |
a2d552ea48f0
Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3132
diff
changeset
|
1170 msg->channels = nch; |
a2d552ea48f0
Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3132
diff
changeset
|
1171 |
a2d552ea48f0
Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents:
3132
diff
changeset
|
1172 event_queue("playlist info change", msg); |
2460 | 1173 |
3165
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3159
diff
changeset
|
1174 text = playlist_get_info_text(playlist); |
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3159
diff
changeset
|
1175 event_queue("title change", text); |
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3159
diff
changeset
|
1176 |
2460 | 1177 if ( playlist->position ) |
1178 hook_call( "playlist set info" , playlist->position ); | |
2313 | 1179 } |
1180 | |
1181 void | |
1182 playlist_set_info(Playlist * playlist, const gchar * title, gint length, gint rate, | |
1183 gint freq, gint nch) | |
1184 { | |
1185 g_return_if_fail(playlist != NULL); | |
1186 | |
1187 if (playlist->position) { | |
1188 g_free(playlist->position->title); | |
1189 playlist->position->title = g_strdup(title); | |
1190 playlist->position->length = length; | |
1191 } | |
1192 | |
1193 playlist_recalc_total_time(playlist); | |
3923
e9fd46b0893b
- redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3922
diff
changeset
|
1194 PLAYLIST_INCR_SERIAL(playlist); //tentative --yaz |
2313 | 1195 |
1196 mainwin_set_song_info(rate, freq, nch); | |
2460 | 1197 |
3635 | 1198 if (playlist->position) |
2460 | 1199 hook_call( "playlist set info" , playlist->position ); |
2313 | 1200 } |
1201 | |
1202 void | |
1203 playlist_check_pos_current(Playlist *playlist) | |
1204 { | |
1205 gint pos, row, bottom; | |
1206 | |
1207 if (!playlist) | |
1208 return; | |
1209 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1210 PLAYLIST_LOCK(playlist); |
2313 | 1211 if (!playlist->position || !playlistwin_list) { |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1212 PLAYLIST_UNLOCK(playlist); |
2313 | 1213 return; |
1214 } | |
1215 | |
1216 pos = g_list_index(playlist->entries, playlist->position); | |
1217 | |
1218 if (playlistwin_item_visible(pos)) { | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1219 PLAYLIST_UNLOCK(playlist); |
2313 | 1220 return; |
1221 } | |
1222 | |
2671
e9b379528fbc
[svn] - playlist_get_length_nolock() -> playlist_get_length(), no need for
nenolod
parents:
2670
diff
changeset
|
1223 bottom = MAX(0, playlist_get_length(playlist) - |
3217 | 1224 UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible); |
1225 row = CLAMP(pos - UI_SKINNED_PLAYLIST(playlistwin_list)->num_visible / 2, 0, bottom); | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1226 PLAYLIST_UNLOCK(playlist); |
2313 | 1227 playlistwin_set_toprow(row); |
1228 g_cond_signal(cond_scan); | |
1229 } | |
1230 | |
1231 void | |
1232 playlist_next(Playlist *playlist) | |
1233 { | |
1234 GList *plist_pos_list; | |
1235 gboolean restart_playing = FALSE; | |
3635 | 1236 |
2480
bb2f191895ce
[svn] - fixed crash when skipping to next song with an empty playlist
marvin
parents:
2460
diff
changeset
|
1237 if (!playlist_get_length(playlist)) |
2313 | 1238 return; |
1239 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1240 PLAYLIST_LOCK(playlist); |
2313 | 1241 |
3635 | 1242 if ((playlist_position_before_jump != NULL) && playlist->queue == NULL) { |
2313 | 1243 playlist->position = playlist_position_before_jump; |
1244 playlist_position_before_jump = NULL; | |
1245 } | |
1246 | |
1247 plist_pos_list = find_playlist_position_list(playlist); | |
1248 | |
1249 if (!cfg.repeat && !g_list_next(plist_pos_list) && playlist->queue == NULL) { | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1250 PLAYLIST_UNLOCK(playlist); |
2313 | 1251 return; |
1252 } | |
1253 | |
1254 if (playback_get_playing()) { | |
1255 /* We need to stop before changing playlist_position */ | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1256 PLAYLIST_UNLOCK(playlist); |
2313 | 1257 ip_data.stop = TRUE; |
1258 playback_stop(); | |
1259 ip_data.stop = FALSE; | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1260 PLAYLIST_LOCK(playlist); |
2313 | 1261 restart_playing = TRUE; |
1262 } | |
1263 | |
1264 plist_pos_list = find_playlist_position_list(playlist); | |
1265 if (playlist->queue != NULL) | |
1266 play_queued(playlist); | |
1267 else if (g_list_next(plist_pos_list)) | |
1268 playlist->position = g_list_next(plist_pos_list)->data; | |
1269 else if (cfg.repeat) { | |
1270 playlist->position = NULL; | |
1271 playlist_generate_shuffle_list_nolock(playlist); | |
1272 if (cfg.shuffle) | |
1273 playlist->position = playlist->shuffle->data; | |
1274 else | |
1275 playlist->position = playlist->entries->data; | |
1276 } | |
3635 | 1277 |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1278 PLAYLIST_UNLOCK(playlist); |
3635 | 1279 |
2313 | 1280 playlist_check_pos_current(playlist); |
1281 | |
3348
2a081105513c
-Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents:
3346
diff
changeset
|
1282 if (restart_playing) |
2313 | 1283 playback_initiate(); |
3246
2127f7108033
- fixed some cases where the playlist wasn't redrawn
mf0102 <0102@gmx.at>
parents:
3217
diff
changeset
|
1284 |
2127f7108033
- fixed some cases where the playlist wasn't redrawn
mf0102 <0102@gmx.at>
parents:
3217
diff
changeset
|
1285 playlistwin_update_list(playlist); |
3621
2d6106656276
Notify playlist manager of more changes
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3583
diff
changeset
|
1286 playlist_manager_update(); |
2313 | 1287 } |
1288 | |
1289 void | |
1290 playlist_prev(Playlist *playlist) | |
1291 { | |
1292 GList *plist_pos_list; | |
1293 gboolean restart_playing = FALSE; | |
1294 | |
2480
bb2f191895ce
[svn] - fixed crash when skipping to next song with an empty playlist
marvin
parents:
2460
diff
changeset
|
1295 if (!playlist_get_length(playlist)) |
2313 | 1296 return; |
1297 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1298 PLAYLIST_LOCK(playlist); |
2313 | 1299 |
3635 | 1300 if ((playlist_position_before_jump != NULL) && playlist->queue == NULL) { |
2313 | 1301 playlist->position = playlist_position_before_jump; |
1302 playlist_position_before_jump = NULL; | |
1303 } | |
1304 | |
1305 plist_pos_list = find_playlist_position_list(playlist); | |
1306 | |
1307 if (!cfg.repeat && !g_list_previous(plist_pos_list)) { | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1308 PLAYLIST_UNLOCK(playlist); |
2313 | 1309 return; |
1310 } | |
1311 | |
1312 if (playback_get_playing()) { | |
1313 /* We need to stop before changing playlist_position */ | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1314 PLAYLIST_UNLOCK(playlist); |
2313 | 1315 ip_data.stop = TRUE; |
1316 playback_stop(); | |
1317 ip_data.stop = FALSE; | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1318 PLAYLIST_LOCK(playlist); |
2313 | 1319 restart_playing = TRUE; |
1320 } | |
1321 | |
1322 plist_pos_list = find_playlist_position_list(playlist); | |
1323 if (g_list_previous(plist_pos_list)) { | |
1324 playlist->position = g_list_previous(plist_pos_list)->data; | |
1325 } | |
1326 else if (cfg.repeat) { | |
1327 GList *node; | |
1328 playlist->position = NULL; | |
1329 playlist_generate_shuffle_list_nolock(playlist); | |
1330 if (cfg.shuffle) | |
1331 node = g_list_last(playlist->shuffle); | |
1332 else | |
1333 node = g_list_last(playlist->entries); | |
1334 if (node) | |
1335 playlist->position = node->data; | |
1336 } | |
1337 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1338 PLAYLIST_UNLOCK(playlist); |
2313 | 1339 |
1340 playlist_check_pos_current(playlist); | |
1341 | |
3348
2a081105513c
-Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents:
3346
diff
changeset
|
1342 if (restart_playing) |
2313 | 1343 playback_initiate(); |
3348
2a081105513c
-Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents:
3346
diff
changeset
|
1344 else |
2313 | 1345 playlistwin_update_list(playlist); |
3621
2d6106656276
Notify playlist manager of more changes
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3583
diff
changeset
|
1346 |
2d6106656276
Notify playlist manager of more changes
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3583
diff
changeset
|
1347 playlist_manager_update(); |
2313 | 1348 } |
1349 | |
1350 void | |
1351 playlist_queue(Playlist *playlist) | |
1352 { | |
1353 GList *list = playlist_get_selected(playlist); | |
1354 GList *it = list; | |
1355 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1356 PLAYLIST_LOCK(playlist); |
2313 | 1357 |
3635 | 1358 if ((cfg.shuffle) && (playlist_position_before_jump == NULL)) { |
2313 | 1359 /* Shuffling and this is our first manual jump. */ |
1360 playlist_position_before_jump = playlist->position; | |
1361 } | |
1362 | |
1363 while (it) { | |
1364 GList *next = g_list_next(it); | |
1365 GList *tmp; | |
1366 | |
1367 /* XXX: WTF? --nenolod */ | |
1368 it->data = g_list_nth_data(playlist->entries, GPOINTER_TO_INT(it->data)); | |
1369 if ((tmp = g_list_find(playlist->queue, it->data))) { | |
1370 playlist->queue = g_list_remove_link(playlist->queue, tmp); | |
1371 g_list_free_1(tmp); | |
1372 list = g_list_remove_link(list, it); | |
1373 g_list_free_1(it); | |
1374 } | |
1375 | |
1376 it = next; | |
1377 } | |
1378 | |
1379 playlist->queue = g_list_concat(playlist->queue, list); | |
1380 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1381 PLAYLIST_UNLOCK(playlist); |
2313 | 1382 |
1383 playlist_recalc_total_time(playlist); | |
1384 playlistwin_update_list(playlist); | |
1385 } | |
1386 | |
1387 void | |
1388 playlist_queue_position(Playlist *playlist, guint pos) | |
1389 { | |
1390 GList *tmp; | |
1391 PlaylistEntry *entry; | |
1392 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1393 PLAYLIST_LOCK(playlist); |
2313 | 1394 |
1395 if ((cfg.shuffle) && (playlist_position_before_jump == NULL)) | |
1396 { | |
1397 /* Shuffling and this is our first manual jump. */ | |
1398 playlist_position_before_jump = playlist->position; | |
1399 } | |
1400 | |
1401 entry = g_list_nth_data(playlist->entries, pos); | |
1402 if ((tmp = g_list_find(playlist->queue, entry))) { | |
1403 playlist->queue = g_list_remove_link(playlist->queue, tmp); | |
1404 g_list_free_1(tmp); | |
1405 } | |
1406 else | |
1407 playlist->queue = g_list_append(playlist->queue, entry); | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1408 PLAYLIST_UNLOCK(playlist); |
2313 | 1409 |
1410 playlist_recalc_total_time(playlist); | |
1411 playlistwin_update_list(playlist); | |
1412 } | |
1413 | |
1414 gboolean | |
1415 playlist_is_position_queued(Playlist *playlist, guint pos) | |
1416 { | |
1417 PlaylistEntry *entry; | |
3867
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3863
diff
changeset
|
1418 GList *tmp = NULL; |
2313 | 1419 |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1420 PLAYLIST_LOCK(playlist); |
2313 | 1421 entry = g_list_nth_data(playlist->entries, pos); |
1422 tmp = g_list_find(playlist->queue, entry); | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1423 PLAYLIST_UNLOCK(playlist); |
2313 | 1424 |
1425 return tmp != NULL; | |
1426 } | |
1427 | |
1428 gint | |
1429 playlist_get_queue_position_number(Playlist *playlist, guint pos) | |
1430 { | |
1431 PlaylistEntry *entry; | |
1432 gint tmp; | |
1433 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1434 PLAYLIST_LOCK(playlist); |
2313 | 1435 entry = g_list_nth_data(playlist->entries, pos); |
1436 tmp = g_list_index(playlist->queue, entry); | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1437 PLAYLIST_UNLOCK(playlist); |
2313 | 1438 |
1439 return tmp; | |
1440 } | |
1441 | |
1442 gint | |
1443 playlist_get_queue_qposition_number(Playlist *playlist, guint pos) | |
1444 { | |
1445 PlaylistEntry *entry; | |
1446 gint tmp; | |
1447 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1448 PLAYLIST_LOCK(playlist); |
2313 | 1449 entry = g_list_nth_data(playlist->queue, pos); |
1450 tmp = g_list_index(playlist->entries, entry); | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1451 PLAYLIST_UNLOCK(playlist); |
2313 | 1452 |
1453 return tmp; | |
1454 } | |
1455 | |
1456 void | |
1457 playlist_clear_queue(Playlist *playlist) | |
1458 { | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1459 PLAYLIST_LOCK(playlist); |
2313 | 1460 g_list_free(playlist->queue); |
1461 playlist->queue = NULL; | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1462 PLAYLIST_UNLOCK(playlist); |
2313 | 1463 |
1464 playlist_recalc_total_time(playlist); | |
1465 playlistwin_update_list(playlist); | |
1466 } | |
1467 | |
1468 void | |
1469 playlist_queue_remove(Playlist *playlist, guint pos) | |
1470 { | |
1471 void *entry; | |
1472 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1473 PLAYLIST_LOCK(playlist); |
2313 | 1474 entry = g_list_nth_data(playlist->entries, pos); |
1475 playlist->queue = g_list_remove(playlist->queue, entry); | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1476 PLAYLIST_UNLOCK(playlist); |
2313 | 1477 |
1478 playlistwin_update_list(playlist); | |
1479 } | |
1480 | |
1481 gint | |
1482 playlist_get_queue_position(Playlist *playlist, PlaylistEntry * entry) | |
1483 { | |
1484 return g_list_index(playlist->queue, entry); | |
1485 } | |
1486 | |
1487 void | |
1488 playlist_set_position(Playlist *playlist, guint pos) | |
1489 { | |
1490 GList *node; | |
1491 gboolean restart_playing = FALSE; | |
1492 | |
1493 if (!playlist) | |
1494 return; | |
1495 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1496 PLAYLIST_LOCK(playlist); |
2313 | 1497 |
1498 node = g_list_nth(playlist->entries, pos); | |
1499 if (!node) { | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1500 PLAYLIST_UNLOCK(playlist); |
2313 | 1501 return; |
1502 } | |
1503 | |
1504 if (playback_get_playing()) { | |
1505 /* We need to stop before changing playlist_position */ | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1506 PLAYLIST_UNLOCK(playlist); |
2313 | 1507 ip_data.stop = TRUE; |
1508 playback_stop(); | |
1509 ip_data.stop = FALSE; | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1510 PLAYLIST_LOCK(playlist); |
2313 | 1511 restart_playing = TRUE; |
1512 } | |
1513 | |
1514 if ((cfg.shuffle) && (playlist_position_before_jump == NULL)) | |
1515 { | |
1516 /* Shuffling and this is our first manual jump. */ | |
1517 playlist_position_before_jump = playlist->position; | |
1518 } | |
3246
2127f7108033
- fixed some cases where the playlist wasn't redrawn
mf0102 <0102@gmx.at>
parents:
3217
diff
changeset
|
1519 |
2313 | 1520 playlist->position = node->data; |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1521 PLAYLIST_UNLOCK(playlist); |
2313 | 1522 playlist_check_pos_current(playlist); |
1523 | |
3348
2a081105513c
-Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents:
3346
diff
changeset
|
1524 if (restart_playing) |
2313 | 1525 playback_initiate(); |
3348
2a081105513c
-Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents:
3346
diff
changeset
|
1526 else |
2313 | 1527 playlistwin_update_list(playlist); |
1528 } | |
1529 | |
1530 void | |
1531 playlist_eof_reached(Playlist *playlist) | |
1532 { | |
1533 GList *plist_pos_list; | |
1534 | |
1535 if ((cfg.no_playlist_advance && !cfg.repeat) || cfg.stopaftersong) | |
1536 ip_data.stop = TRUE; | |
1537 playback_stop(); | |
1538 if ((cfg.no_playlist_advance && !cfg.repeat) || cfg.stopaftersong) | |
1539 ip_data.stop = FALSE; | |
1540 | |
2408
b380e84148bb
[svn] - rename some hooks so that they are more logical
nenolod
parents:
2407
diff
changeset
|
1541 hook_call("playback end", playlist->position); |
2407
1dc1d36d0347
[svn] - add hooks: playback begin, playback end, playlist reached end
nenolod
parents:
2380
diff
changeset
|
1542 |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1543 PLAYLIST_LOCK(playlist); |
2313 | 1544 |
1545 if ((playlist_position_before_jump != NULL) && playlist->queue == NULL) | |
1546 { | |
1547 playlist->position = playlist_position_before_jump; | |
1548 playlist_position_before_jump = NULL; | |
1549 } | |
3246
2127f7108033
- fixed some cases where the playlist wasn't redrawn
mf0102 <0102@gmx.at>
parents:
3217
diff
changeset
|
1550 |
2313 | 1551 plist_pos_list = find_playlist_position_list(playlist); |
1552 | |
1553 if (cfg.no_playlist_advance) { | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1554 PLAYLIST_UNLOCK(playlist); |
2313 | 1555 mainwin_clear_song_info(); |
1556 if (cfg.repeat) | |
1557 playback_initiate(); | |
1558 return; | |
1559 } | |
1560 | |
1561 if (cfg.stopaftersong) { | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1562 PLAYLIST_UNLOCK(playlist); |
2313 | 1563 mainwin_clear_song_info(); |
1564 mainwin_set_stopaftersong(FALSE); | |
1565 return; | |
1566 } | |
1567 | |
1568 if (playlist->queue != NULL) { | |
1569 play_queued(playlist); | |
1570 } | |
1571 else if (!g_list_next(plist_pos_list)) { | |
1572 if (cfg.shuffle) { | |
1573 playlist->position = NULL; | |
1574 playlist_generate_shuffle_list_nolock(playlist); | |
1575 } | |
2380 | 1576 else if (playlist->entries != NULL) |
2313 | 1577 playlist->position = playlist->entries->data; |
1578 | |
1579 if (!cfg.repeat) { | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1580 PLAYLIST_UNLOCK(playlist); |
2408
b380e84148bb
[svn] - rename some hooks so that they are more logical
nenolod
parents:
2407
diff
changeset
|
1581 hook_call("playlist end reached", playlist->position); |
2313 | 1582 mainwin_clear_song_info(); |
1583 return; | |
1584 } | |
1585 } | |
1586 else | |
1587 playlist->position = g_list_next(plist_pos_list)->data; | |
1588 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1589 PLAYLIST_UNLOCK(playlist); |
2313 | 1590 |
1591 playlist_check_pos_current(playlist); | |
1592 playback_initiate(); | |
1593 playlistwin_update_list(playlist); | |
1594 } | |
1595 | |
1596 gint | |
1597 playlist_queue_get_length(Playlist *playlist) | |
1598 { | |
1599 gint length; | |
1600 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1601 PLAYLIST_LOCK(playlist); |
2313 | 1602 length = g_list_length(playlist->queue); |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1603 PLAYLIST_UNLOCK(playlist); |
2313 | 1604 |
1605 return length; | |
1606 } | |
1607 | |
1608 gint | |
2671
e9b379528fbc
[svn] - playlist_get_length_nolock() -> playlist_get_length(), no need for
nenolod
parents:
2670
diff
changeset
|
1609 playlist_get_length(Playlist *playlist) |
2313 | 1610 { |
1611 return g_list_length(playlist->entries); | |
1612 } | |
1613 | |
1614 gchar * | |
1615 playlist_get_info_text(Playlist *playlist) | |
1616 { | |
1617 gchar *text, *title, *numbers, *length; | |
1618 | |
1619 g_return_val_if_fail(playlist != NULL, NULL); | |
1620 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1621 PLAYLIST_LOCK(playlist); |
2313 | 1622 if (!playlist->position) { |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1623 PLAYLIST_UNLOCK(playlist); |
2313 | 1624 return NULL; |
1625 } | |
1626 | |
1627 /* FIXME: there should not be a need to do additional conversion, | |
1628 * if playlist is properly maintained */ | |
1629 if (playlist->position->title) { | |
1630 title = str_to_utf8(playlist->position->title); | |
1631 } | |
1632 else { | |
3635 | 1633 gchar *realfn = g_filename_from_uri(playlist->position->filename, NULL, NULL); |
1634 gchar *basename = g_path_get_basename(realfn ? realfn : playlist->position->filename); | |
2313 | 1635 title = filename_to_utf8(basename); |
3635 | 1636 g_free(realfn); |
1637 g_free(basename); | |
2313 | 1638 } |
1639 | |
1640 /* | |
1641 * If the user don't want numbers in the playlist, don't | |
1642 * display them in other parts of XMMS | |
1643 */ | |
1644 | |
1645 if (cfg.show_numbers_in_pl) | |
1646 numbers = g_strdup_printf("%d. ", playlist_get_position_nolock(playlist) + 1); | |
1647 else | |
1648 numbers = g_strdup(""); | |
1649 | |
1650 if (playlist->position->length != -1) | |
1651 length = g_strdup_printf(" (%d:%-2.2d)", | |
1652 playlist->position->length / 60000, | |
1653 (playlist->position->length / 1000) % 60); | |
1654 else | |
1655 length = g_strdup(""); | |
1656 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1657 PLAYLIST_UNLOCK(playlist); |
2313 | 1658 |
1659 text = convert_title_text(g_strconcat(numbers, title, length, NULL)); | |
1660 | |
1661 g_free(numbers); | |
1662 g_free(title); | |
1663 g_free(length); | |
1664 | |
1665 return text; | |
1666 } | |
1667 | |
1668 gint | |
1669 playlist_get_current_length(Playlist * playlist) | |
1670 { | |
1671 gint len = 0; | |
1672 | |
1673 if (!playlist) | |
1674 return 0; | |
1675 | |
1676 if (playlist->position) | |
1677 len = playlist->position->length; | |
1678 | |
1679 return len; | |
1680 } | |
1681 | |
1682 gboolean | |
1683 playlist_save(Playlist * playlist, const gchar * filename) | |
1684 { | |
1685 PlaylistContainer *plc = NULL; | |
3476
9152829f3c19
Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3474
diff
changeset
|
1686 GList *old_iter; |
2313 | 1687 gchar *ext; |
1688 | |
1689 g_return_val_if_fail(playlist != NULL, FALSE); | |
1690 g_return_val_if_fail(filename != NULL, FALSE); | |
1691 | |
1692 ext = strrchr(filename, '.') + 1; | |
1693 | |
1694 if ((plc = playlist_container_find(ext)) == NULL) | |
1695 return FALSE; | |
1696 | |
1697 if (plc->plc_write == NULL) | |
1698 return FALSE; | |
1699 | |
3476
9152829f3c19
Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3474
diff
changeset
|
1700 /* Save the right playlist to disk */ |
9152829f3c19
Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3474
diff
changeset
|
1701 if (playlist != playlist_get_active()) { |
9152829f3c19
Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3474
diff
changeset
|
1702 old_iter = playlists_iter; |
9152829f3c19
Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3474
diff
changeset
|
1703 playlists_iter = g_list_find(playlists, playlist); |
9152829f3c19
Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3474
diff
changeset
|
1704 if(!playlists_iter) playlists_iter = old_iter; |
9152829f3c19
Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3474
diff
changeset
|
1705 plc->plc_write(filename, 0); |
9152829f3c19
Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3474
diff
changeset
|
1706 playlists_iter = old_iter; |
9152829f3c19
Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3474
diff
changeset
|
1707 } else { |
9152829f3c19
Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3474
diff
changeset
|
1708 plc->plc_write(filename, 0); |
9152829f3c19
Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3474
diff
changeset
|
1709 } |
2313 | 1710 |
1711 return TRUE; | |
1712 } | |
1713 | |
1714 gboolean | |
1715 playlist_load(Playlist * playlist, const gchar * filename) | |
1716 { | |
3337
99f34db2c3fc
- fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3334
diff
changeset
|
1717 guint ret = 0; |
2313 | 1718 g_return_val_if_fail(playlist != NULL, FALSE); |
1719 | |
1720 playlist->loading_playlist = TRUE; | |
3477
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
1721 if(!playlist_get_length(playlist)) { |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
1722 /* Loading new playlist */ |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
1723 playlist_filename_set(playlist, filename); |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
1724 } |
2313 | 1725 ret = playlist_load_ins(playlist, filename, -1); |
1726 playlist->loading_playlist = FALSE; | |
1727 | |
3337
99f34db2c3fc
- fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3334
diff
changeset
|
1728 return ret ? TRUE : FALSE; |
2313 | 1729 } |
1730 | |
1731 void | |
1732 playlist_load_ins_file(Playlist *playlist, | |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
1733 const gchar * filename_p, |
2313 | 1734 const gchar * playlist_name, gint pos, |
1735 const gchar * title, gint len) | |
1736 { | |
1737 gchar *filename; | |
1738 gchar *tmp, *path; | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1739 ProbeResult *pr = NULL; |
2313 | 1740 |
1741 g_return_if_fail(filename_p != NULL); | |
1742 g_return_if_fail(playlist != NULL); | |
1743 g_return_if_fail(playlist_name != NULL); | |
1744 | |
1745 filename = g_strchug(g_strdup(filename_p)); | |
1746 | |
3635 | 1747 if (cfg.convert_slash) |
3087
030b956c73b2
Fix a bug in backslash to slash conversion. Closes #1006.
William Pitcock <nenolod@atheme-project.org>
parents:
3081
diff
changeset
|
1748 while ((tmp = strchr(filename, '\\')) != NULL) |
030b956c73b2
Fix a bug in backslash to slash conversion. Closes #1006.
William Pitcock <nenolod@atheme-project.org>
parents:
3081
diff
changeset
|
1749 *tmp = '/'; |
2313 | 1750 |
1751 if (filename[0] != '/' && !strstr(filename, "://")) { | |
1752 path = g_strdup(playlist_name); | |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1753 |
2313 | 1754 if ((tmp = strrchr(path, '/'))) |
1755 *tmp = '\0'; | |
1756 else { | |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1757 gint ext_flag = filter_by_extension(filename); |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1758 gboolean http_flag = is_http(filename); |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1759 |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1760 /* playlist file or remote uri */ |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1761 if (playlist->loading_playlist == TRUE || http_flag == TRUE) { |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1762 pr = NULL; |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1763 } |
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1764 /* local file and on-demand probing is on */ |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1765 else if (cfg.playlist_detect == TRUE && ext_flag != EXT_HAVE_SUBTUNE) { |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1766 pr = NULL; |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1767 if(cfg.use_extension_probing && ext_flag == EXT_FALSE) |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
1768 return; |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
1769 } |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1770 /* find decorder for local file */ |
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1771 else { |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
1772 pr = input_check_file(filename, TRUE); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
1773 } |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1774 |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1775 __playlist_ins_with_info(playlist, filename, pos, title, len, pr ? pr->ip : NULL); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1776 g_free(pr); |
2313 | 1777 return; |
1778 } | |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1779 |
2313 | 1780 tmp = g_build_filename(path, filename, NULL); |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1781 gint ext_flag = filter_by_extension(tmp); |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1782 gboolean http_flag = is_http(tmp); |
2313 | 1783 |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1784 /* playlist file or remote uri */ |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1785 if (playlist->loading_playlist == TRUE || http_flag == TRUE) { |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
1786 pr = NULL; |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1787 } |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1788 /* local file and no probing, no subtune */ |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1789 else if (cfg.playlist_detect == TRUE && ext_flag != EXT_HAVE_SUBTUNE) { |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1790 pr = NULL; |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1791 if(cfg.use_extension_probing && ext_flag == EXT_FALSE) |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
1792 return; |
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
1793 } |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1794 /* find decoder for local file */ |
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1795 else { |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
1796 pr = input_check_file(tmp, TRUE); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
1797 } |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1798 |
3128
343504d43afc
Fix warnings.
William Pitcock <nenolod@atheme-project.org>
parents:
3127
diff
changeset
|
1799 __playlist_ins_with_info(playlist, tmp, pos, title, len, pr ? pr->ip : NULL); |
2313 | 1800 g_free(tmp); |
1801 g_free(path); | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1802 g_free(pr); |
2313 | 1803 } |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1804 else { |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1805 gint ext_flag = filter_by_extension(filename); |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1806 gboolean http_flag = is_http(filename); |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1807 |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1808 /* playlist file or remote uri */ |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1809 if (playlist->loading_playlist == TRUE || http_flag == TRUE) { |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1810 pr = NULL; |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1811 } |
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1812 /* local file and on-demand probing is on */ |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1813 else if (cfg.playlist_detect == TRUE && ext_flag != EXT_HAVE_SUBTUNE) { |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1814 pr = NULL; |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1815 if(cfg.use_extension_probing && ext_flag == EXT_FALSE) |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
1816 return; |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
1817 } |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1818 /* find decoder for local file */ |
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1819 else { |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
1820 pr = input_check_file(filename, TRUE); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
1821 } |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1822 __playlist_ins_with_info(playlist, filename, pos, title, len, pr ? pr->ip : NULL); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1823 g_free(pr); |
2313 | 1824 } |
1825 | |
1826 g_free(filename); | |
1827 } | |
1828 | |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1829 |
2313 | 1830 void |
1831 playlist_load_ins_file_tuple(Playlist * playlist, | |
1832 const gchar * filename_p, | |
1833 const gchar * playlist_name, | |
1834 gint pos, | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
1835 Tuple *tuple) |
2313 | 1836 { |
1837 gchar *filename; | |
1838 gchar *tmp, *path; | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1839 ProbeResult *pr = NULL; /* for decoder cache */ |
2313 | 1840 |
1841 g_return_if_fail(filename_p != NULL); | |
1842 g_return_if_fail(playlist_name != NULL); | |
1843 g_return_if_fail(playlist != NULL); | |
1844 | |
1845 filename = g_strchug(g_strdup(filename_p)); | |
1846 | |
3635 | 1847 if (cfg.convert_slash) |
3087
030b956c73b2
Fix a bug in backslash to slash conversion. Closes #1006.
William Pitcock <nenolod@atheme-project.org>
parents:
3081
diff
changeset
|
1848 while ((tmp = strchr(filename, '\\')) != NULL) |
030b956c73b2
Fix a bug in backslash to slash conversion. Closes #1006.
William Pitcock <nenolod@atheme-project.org>
parents:
3081
diff
changeset
|
1849 *tmp = '/'; |
2313 | 1850 |
1851 if (filename[0] != '/' && !strstr(filename, "://")) { | |
1852 path = g_strdup(playlist_name); | |
1853 if ((tmp = strrchr(path, '/'))) | |
1854 *tmp = '\0'; | |
1855 else { | |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1856 gint ext_flag = filter_by_extension(filename); |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1857 gboolean http_flag = is_http(filename); |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1858 |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1859 if (playlist->loading_playlist == TRUE || http_flag == TRUE) { |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1860 pr = NULL; |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1861 } |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1862 else if (cfg.playlist_detect == TRUE && ext_flag != EXT_HAVE_SUBTUNE) { |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1863 pr = NULL; |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1864 if(cfg.use_extension_probing && ext_flag == EXT_FALSE) |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
1865 return; |
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
1866 } |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1867 else { |
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1868 pr = input_check_file(filename, TRUE); |
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1869 } |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1870 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1871 __playlist_ins_with_info_tuple(playlist, filename, pos, tuple, pr ? pr->ip : NULL); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1872 g_free(pr); |
2313 | 1873 return; |
1874 } | |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1875 |
2313 | 1876 tmp = g_build_filename(path, filename, NULL); |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1877 gint ext_flag = filter_by_extension(tmp); |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1878 gboolean http_flag = is_http(tmp); |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1879 |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1880 if (playlist->loading_playlist == TRUE || http_flag == TRUE) { |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1881 pr = NULL; |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1882 } |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1883 else if (cfg.playlist_detect == TRUE && ext_flag != EXT_HAVE_SUBTUNE) { |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1884 pr = NULL; |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1885 if(cfg.use_extension_probing && ext_flag == EXT_FALSE) |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
1886 return; |
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
1887 } |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1888 else { |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
1889 pr = input_check_file(filename, TRUE); |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1890 } |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1891 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1892 __playlist_ins_with_info_tuple(playlist, tmp, pos, tuple, pr ? pr->ip : NULL); |
2313 | 1893 g_free(tmp); |
1894 g_free(path); | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1895 g_free(pr); |
2313 | 1896 } |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
1897 else { |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1898 if (playlist->loading_playlist == TRUE || |
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1899 str_has_prefix_nocase(filename, "http://") || |
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1900 str_has_prefix_nocase(filename, "https://")) { |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1901 pr = NULL; |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1902 } |
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1903 else if (cfg.playlist_detect == TRUE) { |
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1904 pr = NULL; |
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1905 if(cfg.use_extension_probing && !filter_by_extension(filename)) |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
1906 return; |
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
1907 } |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1908 else { |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
1909 pr = input_check_file(filename, TRUE); |
3967
efd7ec36483e
revise check code to handle http:// properly.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
1910 } |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1911 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1912 __playlist_ins_with_info_tuple(playlist, filename, pos, tuple, pr ? pr->ip : NULL); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
1913 g_free(pr); |
2313 | 1914 } |
1915 | |
1916 g_free(filename); | |
1917 } | |
1918 | |
1919 static guint | |
1920 playlist_load_ins(Playlist * playlist, const gchar * filename, gint pos) | |
1921 { | |
1922 PlaylistContainer *plc; | |
3383
e2e875f3d02b
Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3382
diff
changeset
|
1923 GList *old_iter; |
2313 | 1924 gchar *ext; |
3337
99f34db2c3fc
- fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3334
diff
changeset
|
1925 gint old_len, new_len; |
99f34db2c3fc
- fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3334
diff
changeset
|
1926 |
2313 | 1927 g_return_val_if_fail(playlist != NULL, 0); |
1928 g_return_val_if_fail(filename != NULL, 0); | |
1929 | |
1930 ext = strrchr(filename, '.') + 1; | |
1931 plc = playlist_container_find(ext); | |
1932 | |
1933 g_return_val_if_fail(plc != NULL, 0); | |
1934 g_return_val_if_fail(plc->plc_read != NULL, 0); | |
1935 | |
3337
99f34db2c3fc
- fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3334
diff
changeset
|
1936 old_len = playlist_get_length(playlist); |
3383
e2e875f3d02b
Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3382
diff
changeset
|
1937 /* make sure it adds files to the right playlist */ |
e2e875f3d02b
Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3382
diff
changeset
|
1938 if (playlist != playlist_get_active()) { |
e2e875f3d02b
Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3382
diff
changeset
|
1939 old_iter = playlists_iter; |
e2e875f3d02b
Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3382
diff
changeset
|
1940 playlists_iter = g_list_find(playlists, playlist); |
3478
481a4a88d3ec
Use old iterator when new one isn't found
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3477
diff
changeset
|
1941 if (!playlists_iter) playlists_iter = old_iter; |
3383
e2e875f3d02b
Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3382
diff
changeset
|
1942 plc->plc_read(filename, pos); |
e2e875f3d02b
Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3382
diff
changeset
|
1943 playlists_iter = old_iter; |
e2e875f3d02b
Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3382
diff
changeset
|
1944 } else { |
e2e875f3d02b
Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3382
diff
changeset
|
1945 plc->plc_read(filename, pos); |
e2e875f3d02b
Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3382
diff
changeset
|
1946 } |
3337
99f34db2c3fc
- fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3334
diff
changeset
|
1947 new_len = playlist_get_length(playlist); |
2313 | 1948 |
1949 playlist_generate_shuffle_list(playlist); | |
1950 playlistwin_update_list(playlist); | |
3621
2d6106656276
Notify playlist manager of more changes
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3583
diff
changeset
|
1951 playlist_manager_update(); |
3923
e9fd46b0893b
- redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3922
diff
changeset
|
1952 |
e9fd46b0893b
- redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3922
diff
changeset
|
1953 playlist_recalc_total_time(playlist); //tentative --yaz |
e9fd46b0893b
- redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3922
diff
changeset
|
1954 PLAYLIST_INCR_SERIAL(playlist); |
e9fd46b0893b
- redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3922
diff
changeset
|
1955 |
3337
99f34db2c3fc
- fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3334
diff
changeset
|
1956 return new_len - old_len; |
2313 | 1957 } |
1958 | |
1959 GList * | |
1960 get_playlist_nth(Playlist *playlist, guint nth) | |
1961 { | |
1962 g_warning("deprecated function get_playlist_nth() was called"); | |
1963 REQUIRE_LOCK(playlist->mutex); | |
1964 return g_list_nth(playlist->entries, nth); | |
1965 } | |
1966 | |
1967 gint | |
1968 playlist_get_position_nolock(Playlist *playlist) | |
1969 { | |
1970 if (playlist && playlist->position) | |
1971 return g_list_index(playlist->entries, playlist->position); | |
1972 return 0; | |
1973 } | |
1974 | |
1975 gint | |
1976 playlist_get_position(Playlist *playlist) | |
1977 { | |
1978 gint pos; | |
1979 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1980 PLAYLIST_LOCK(playlist); |
2313 | 1981 pos = playlist_get_position_nolock(playlist); |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1982 PLAYLIST_UNLOCK(playlist); |
2313 | 1983 |
1984 return pos; | |
1985 } | |
1986 | |
1987 gchar * | |
1988 playlist_get_filename(Playlist *playlist, guint pos) | |
1989 { | |
1990 gchar *filename; | |
1991 PlaylistEntry *entry; | |
1992 GList *node; | |
1993 | |
1994 if (!playlist) | |
1995 return NULL; | |
1996 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
1997 PLAYLIST_LOCK(playlist); |
2313 | 1998 node = g_list_nth(playlist->entries, pos); |
1999 if (!node) { | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2000 PLAYLIST_UNLOCK(playlist); |
2313 | 2001 return NULL; |
2002 } | |
2003 entry = node->data; | |
2004 | |
2005 filename = g_strdup(entry->filename); | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2006 PLAYLIST_UNLOCK(playlist); |
2313 | 2007 |
2008 return filename; | |
2009 } | |
2010 | |
2011 gchar * | |
2012 playlist_get_songtitle(Playlist *playlist, guint pos) | |
2013 { | |
2014 gchar *title = NULL; | |
2015 PlaylistEntry *entry; | |
2016 GList *node; | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2017 time_t mtime; |
2313 | 2018 |
2019 if (!playlist) | |
2020 return NULL; | |
2021 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2022 PLAYLIST_LOCK(playlist); |
2313 | 2023 |
2024 if (!(node = g_list_nth(playlist->entries, pos))) { | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2025 PLAYLIST_UNLOCK(playlist); |
2313 | 2026 return NULL; |
2027 } | |
2028 | |
2029 entry = node->data; | |
2030 | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2031 if (entry->tuple) |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2032 mtime = tuple_get_int(entry->tuple, FIELD_MTIME, NULL); |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2033 else |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2034 mtime = 0; |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2035 |
2313 | 2036 /* FIXME: simplify this logic */ |
2037 if ((entry->title == NULL && entry->length == -1) || | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2038 (entry->tuple && mtime != 0 && (mtime == -1 || mtime != playlist_get_mtime(entry->filename)))) |
2313 | 2039 { |
2040 if (playlist_entry_get_info(entry)) | |
2041 title = entry->title; | |
2042 } | |
2043 else { | |
2044 title = entry->title; | |
2045 } | |
2046 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2047 PLAYLIST_UNLOCK(playlist); |
2313 | 2048 |
2049 if (!title) { | |
3081
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3079
diff
changeset
|
2050 gchar *realfn = NULL; |
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3079
diff
changeset
|
2051 realfn = g_filename_from_uri(entry->filename, NULL, NULL); |
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3079
diff
changeset
|
2052 title = g_path_get_basename(realfn ? realfn : entry->filename); |
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3079
diff
changeset
|
2053 g_free(realfn); realfn = NULL; |
2313 | 2054 return str_replace(title, filename_to_utf8(title)); |
2055 } | |
2056 | |
2057 return str_to_utf8(title); | |
2058 } | |
2059 | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2060 Tuple * |
2313 | 2061 playlist_get_tuple(Playlist *playlist, guint pos) |
2062 { | |
2063 PlaylistEntry *entry; | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2064 Tuple *tuple = NULL; |
2313 | 2065 GList *node; |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2066 time_t mtime; |
2313 | 2067 |
2068 if (!playlist) | |
2069 return NULL; | |
2070 | |
2071 if (!(node = g_list_nth(playlist->entries, pos))) { | |
2072 return NULL; | |
2073 } | |
2074 | |
2075 entry = (PlaylistEntry *) node->data; | |
2076 | |
2077 tuple = entry->tuple; | |
2078 | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2079 if (tuple) |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2080 mtime = tuple_get_int(tuple, FIELD_MTIME, NULL); |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2081 else |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2082 mtime = 0; |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2083 |
2313 | 2084 // if no tuple or tuple with old mtime, get new one. |
2085 if (tuple == NULL || | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2086 (entry->tuple && mtime != 0 && (mtime == -1 || mtime != playlist_get_mtime(entry->filename)))) |
2313 | 2087 { |
2088 playlist_entry_get_info(entry); | |
2089 tuple = entry->tuple; | |
2090 } | |
2091 | |
2092 return tuple; | |
2093 } | |
2094 | |
2095 gint | |
2096 playlist_get_songtime(Playlist *playlist, guint pos) | |
2097 { | |
2098 gint song_time = -1; | |
2099 PlaylistEntry *entry; | |
2100 GList *node; | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2101 time_t mtime; |
2313 | 2102 |
2103 if (!playlist) | |
2104 return -1; | |
2105 | |
3635 | 2106 if (!(node = g_list_nth(playlist->entries, pos))) |
2313 | 2107 return -1; |
2108 | |
2109 entry = node->data; | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2110 |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2111 if (entry->tuple) |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2112 mtime = tuple_get_int(entry->tuple, FIELD_MTIME, NULL); |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2113 else |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2114 mtime = 0; |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2115 |
2313 | 2116 if (entry->tuple == NULL || |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2117 (mtime != 0 && (mtime == -1 || mtime != playlist_get_mtime(entry->filename)))) { |
2313 | 2118 |
2119 if (playlist_entry_get_info(entry)) | |
2120 song_time = entry->length; | |
3635 | 2121 } else |
2313 | 2122 song_time = entry->length; |
2123 | |
2124 return song_time; | |
2125 } | |
2126 | |
2127 static gint | |
2128 playlist_compare_track(PlaylistEntry * a, | |
2129 PlaylistEntry * b) | |
2130 { | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2131 gint tracknumber_a; |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2132 gint tracknumber_b; |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2133 |
2313 | 2134 g_return_val_if_fail(a != NULL, 0); |
2135 g_return_val_if_fail(b != NULL, 0); | |
2136 | |
2614
deb09bfd716b
[svn] - now sort by track number and sort by title work even if on display metadata loading is specified.
yaz
parents:
2580
diff
changeset
|
2137 if(!a->tuple) |
deb09bfd716b
[svn] - now sort by track number and sort by title work even if on display metadata loading is specified.
yaz
parents:
2580
diff
changeset
|
2138 playlist_entry_get_info(a); |
deb09bfd716b
[svn] - now sort by track number and sort by title work even if on display metadata loading is specified.
yaz
parents:
2580
diff
changeset
|
2139 if(!b->tuple) |
deb09bfd716b
[svn] - now sort by track number and sort by title work even if on display metadata loading is specified.
yaz
parents:
2580
diff
changeset
|
2140 playlist_entry_get_info(b); |
deb09bfd716b
[svn] - now sort by track number and sort by title work even if on display metadata loading is specified.
yaz
parents:
2580
diff
changeset
|
2141 |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2142 if (a->tuple == NULL) |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2143 return 0; |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2144 if (b->tuple == NULL) |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2145 return 0; |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2146 |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2147 tracknumber_a = tuple_get_int(a->tuple, FIELD_TRACK_NUMBER, NULL); |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2148 tracknumber_b = tuple_get_int(b->tuple, FIELD_TRACK_NUMBER, NULL); |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2149 |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2150 return (tracknumber_a && tracknumber_b ? |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2151 tracknumber_a - tracknumber_b : 0); |
2313 | 2152 } |
2153 | |
3638
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2154 static void |
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2155 playlist_get_entry_title(PlaylistEntry * e, const gchar ** title) |
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2156 { |
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2157 if (e->title) |
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2158 *title = e->title; |
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2159 else { |
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2160 if (strrchr(e->filename, '/')) |
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2161 *title = strrchr(e->filename, '/') + 1; |
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2162 else |
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2163 *title = e->filename; |
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2164 } |
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2165 } |
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2166 |
2313 | 2167 static gint |
2168 playlist_compare_playlist(PlaylistEntry * a, | |
2169 PlaylistEntry * b) | |
2170 { | |
2171 const gchar *a_title = NULL, *b_title = NULL; | |
2172 | |
2173 g_return_val_if_fail(a != NULL, 0); | |
2174 g_return_val_if_fail(b != NULL, 0); | |
3638
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2175 |
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2176 playlist_get_entry_title(a, &a_title); |
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2177 playlist_get_entry_title(b, &b_title); |
2313 | 2178 |
2179 return strcasecmp(a_title, b_title); | |
2180 } | |
2181 | |
2182 static gint | |
2183 playlist_compare_title(PlaylistEntry * a, | |
2184 PlaylistEntry * b) | |
2185 { | |
2186 const gchar *a_title = NULL, *b_title = NULL; | |
2187 | |
2188 g_return_val_if_fail(a != NULL, 0); | |
2189 g_return_val_if_fail(b != NULL, 0); | |
2190 | |
3638
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2191 if (a->tuple == NULL) |
2614
deb09bfd716b
[svn] - now sort by track number and sort by title work even if on display metadata loading is specified.
yaz
parents:
2580
diff
changeset
|
2192 playlist_entry_get_info(a); |
3638
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2193 if (b->tuple == NULL) |
2614
deb09bfd716b
[svn] - now sort by track number and sort by title work even if on display metadata loading is specified.
yaz
parents:
2580
diff
changeset
|
2194 playlist_entry_get_info(b); |
deb09bfd716b
[svn] - now sort by track number and sort by title work even if on display metadata loading is specified.
yaz
parents:
2580
diff
changeset
|
2195 |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2196 if (a->tuple != NULL) |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2197 a_title = tuple_get_string(a->tuple, FIELD_TITLE, NULL); |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2198 if (b->tuple != NULL) |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2199 b_title = tuple_get_string(b->tuple, FIELD_TITLE, NULL); |
2313 | 2200 |
2201 if (a_title != NULL && b_title != NULL) | |
2202 return strcasecmp(a_title, b_title); | |
2203 | |
3638
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2204 playlist_get_entry_title(a, &a_title); |
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2205 playlist_get_entry_title(b, &b_title); |
2313 | 2206 |
2207 return strcasecmp(a_title, b_title); | |
2208 } | |
2209 | |
2210 static gint | |
2211 playlist_compare_artist(PlaylistEntry * a, | |
2212 PlaylistEntry * b) | |
2213 { | |
2214 const gchar *a_artist = NULL, *b_artist = NULL; | |
2215 | |
2216 g_return_val_if_fail(a != NULL, 0); | |
2217 g_return_val_if_fail(b != NULL, 0); | |
2218 | |
2219 if (a->tuple != NULL) | |
2220 playlist_entry_get_info(a); | |
2221 | |
2222 if (b->tuple != NULL) | |
2223 playlist_entry_get_info(b); | |
2224 | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2225 if (a->tuple != NULL) { |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2226 a_artist = tuple_get_string(a->tuple, FIELD_ARTIST, NULL); |
2683
d2ffabee3ced
[svn] Modified playlist_compare_artist so that a leading "the" in an artist's
magma
parents:
2671
diff
changeset
|
2227 if (str_has_prefix_nocase(a_artist, "the ")) |
d2ffabee3ced
[svn] Modified playlist_compare_artist so that a leading "the" in an artist's
magma
parents:
2671
diff
changeset
|
2228 a_artist += 4; |
d2ffabee3ced
[svn] Modified playlist_compare_artist so that a leading "the" in an artist's
magma
parents:
2671
diff
changeset
|
2229 } |
d2ffabee3ced
[svn] Modified playlist_compare_artist so that a leading "the" in an artist's
magma
parents:
2671
diff
changeset
|
2230 |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2231 if (b->tuple != NULL) { |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2232 b_artist = tuple_get_string(b->tuple, FIELD_ARTIST, NULL); |
2683
d2ffabee3ced
[svn] Modified playlist_compare_artist so that a leading "the" in an artist's
magma
parents:
2671
diff
changeset
|
2233 if (str_has_prefix_nocase(b_artist, "the ")) |
d2ffabee3ced
[svn] Modified playlist_compare_artist so that a leading "the" in an artist's
magma
parents:
2671
diff
changeset
|
2234 b_artist += 4; |
d2ffabee3ced
[svn] Modified playlist_compare_artist so that a leading "the" in an artist's
magma
parents:
2671
diff
changeset
|
2235 } |
2313 | 2236 |
2237 if (a_artist != NULL && b_artist != NULL) | |
2238 return strcasecmp(a_artist, b_artist); | |
2239 | |
2240 return 0; | |
2241 } | |
2242 | |
2243 static gint | |
2244 playlist_compare_filename(PlaylistEntry * a, | |
2245 PlaylistEntry * b) | |
2246 { | |
2247 gchar *a_filename, *b_filename; | |
2248 | |
2249 g_return_val_if_fail(a != NULL, 0); | |
2250 g_return_val_if_fail(b != NULL, 0); | |
2251 | |
2252 if (strrchr(a->filename, '/')) | |
2253 a_filename = strrchr(a->filename, '/') + 1; | |
2254 else | |
2255 a_filename = a->filename; | |
2256 | |
2257 if (strrchr(b->filename, '/')) | |
2258 b_filename = strrchr(b->filename, '/') + 1; | |
2259 else | |
2260 b_filename = b->filename; | |
2261 | |
2262 | |
2263 return strcasecmp(a_filename, b_filename); | |
2264 } | |
2265 | |
2266 static gint | |
2267 path_compare(const gchar * a, const gchar * b) | |
2268 { | |
2269 gchar *posa, *posb; | |
2270 gint len, ret; | |
2271 | |
2272 posa = strrchr(a, '/'); | |
2273 posb = strrchr(b, '/'); | |
2274 | |
2275 /* | |
2276 * Sort directories before files | |
2277 */ | |
2278 if (posa && posb && (posa - a != posb - b)) { | |
2279 if (posa - a > posb - b) { | |
2280 len = posb - b; | |
2281 ret = -1; | |
2282 } | |
2283 else { | |
2284 len = posa - a; | |
2285 ret = 1; | |
2286 } | |
2287 if (!strncasecmp(a, b, len)) | |
2288 return ret; | |
2289 } | |
2290 return strcasecmp(a, b); | |
2291 } | |
2292 | |
2293 static gint | |
2294 playlist_compare_path(PlaylistEntry * a, | |
2295 PlaylistEntry * b) | |
2296 { | |
2297 return path_compare(a->filename, b->filename); | |
2298 } | |
2299 | |
2300 | |
2301 static time_t | |
2302 playlist_get_mtime(const gchar *filename) | |
2303 { | |
2304 struct stat buf; | |
2305 gint rv; | |
3081
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3079
diff
changeset
|
2306 gchar *realfn = NULL; |
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3079
diff
changeset
|
2307 |
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3079
diff
changeset
|
2308 /* stat() does not accept file:// --yaz */ |
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3079
diff
changeset
|
2309 realfn = g_filename_from_uri(filename, NULL, NULL); |
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3079
diff
changeset
|
2310 rv = stat(realfn ? realfn : filename, &buf); |
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3079
diff
changeset
|
2311 g_free(realfn); realfn = NULL; |
2313 | 2312 |
2313 if (rv == 0) { | |
2314 return buf.st_mtime; | |
2315 } else { | |
2316 return 0; //error | |
2317 } | |
2318 } | |
2319 | |
2320 | |
2321 static gint | |
2322 playlist_compare_date(PlaylistEntry * a, | |
2323 PlaylistEntry * b) | |
2324 { | |
2325 struct stat buf; | |
2326 time_t modtime; | |
2327 | |
2328 gint rv; | |
2329 | |
2330 | |
2331 rv = stat(a->filename, &buf); | |
2332 | |
2333 if (rv == 0) { | |
2334 modtime = buf.st_mtime; | |
2335 rv = stat(b->filename, &buf); | |
2336 | |
2337 if (stat(b->filename, &buf) == 0) { | |
2338 if (buf.st_mtime == modtime) | |
2339 return 0; | |
2340 else | |
2341 return (buf.st_mtime - modtime) > 0 ? -1 : 1; | |
2342 } | |
2343 else | |
2344 return -1; | |
2345 } | |
2346 else if (!lstat(b->filename, &buf)) | |
2347 return 1; | |
2348 else | |
2349 return playlist_compare_filename(a, b); | |
2350 } | |
2351 | |
2352 | |
2353 void | |
2354 playlist_sort(Playlist *playlist, PlaylistSortType type) | |
2355 { | |
2356 playlist_remove_dead_files(playlist); | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2357 PLAYLIST_LOCK(playlist); |
2313 | 2358 playlist->entries = |
2359 g_list_sort(playlist->entries, | |
2360 (GCompareFunc) playlist_compare_func_table[type]); | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2361 PLAYLIST_UNLOCK(playlist); |
2313 | 2362 } |
2363 | |
2364 static GList * | |
2365 playlist_sort_selected_generic(GList * list, GCompareFunc cmpfunc) | |
2366 { | |
2367 GList *list1, *list2; | |
2368 GList *tmp_list = NULL; | |
2369 GList *index_list = NULL; | |
2370 | |
2371 /* | |
2372 * We take all the selected entries out of the playlist, | |
2373 * sorts them, and then put them back in again. | |
2374 */ | |
2375 | |
2376 list1 = g_list_last(list); | |
2377 | |
2378 while (list1) { | |
2379 list2 = g_list_previous(list1); | |
2380 if (PLAYLIST_ENTRY(list1->data)->selected) { | |
2381 gpointer idx; | |
2382 idx = GINT_TO_POINTER(g_list_position(list, list1)); | |
2383 index_list = g_list_prepend(index_list, idx); | |
2384 list = g_list_remove_link(list, list1); | |
2385 tmp_list = g_list_concat(list1, tmp_list); | |
2386 } | |
2387 list1 = list2; | |
2388 } | |
2389 | |
2390 tmp_list = g_list_sort(tmp_list, cmpfunc); | |
2391 list1 = tmp_list; | |
2392 list2 = index_list; | |
2393 | |
2394 while (list2) { | |
2395 if (!list1) { | |
2396 g_critical(G_STRLOC ": Error during list sorting. " | |
2397 "Possibly dropped some playlist-entries."); | |
2398 break; | |
2399 } | |
2400 | |
2401 list = g_list_insert(list, list1->data, GPOINTER_TO_INT(list2->data)); | |
2402 | |
2403 list2 = g_list_next(list2); | |
2404 list1 = g_list_next(list1); | |
2405 } | |
2406 | |
2407 g_list_free(index_list); | |
2408 g_list_free(tmp_list); | |
2409 | |
2410 return list; | |
2411 } | |
2412 | |
2413 void | |
2414 playlist_sort_selected(Playlist *playlist, PlaylistSortType type) | |
2415 { | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2416 PLAYLIST_LOCK(playlist); |
2313 | 2417 playlist->entries = playlist_sort_selected_generic(playlist->entries, (GCompareFunc) |
2418 playlist_compare_func_table | |
2419 [type]); | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2420 PLAYLIST_UNLOCK(playlist); |
2313 | 2421 } |
2422 | |
2423 void | |
2424 playlist_reverse(Playlist *playlist) | |
2425 { | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2426 PLAYLIST_LOCK(playlist); |
2313 | 2427 playlist->entries = g_list_reverse(playlist->entries); |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2428 PLAYLIST_UNLOCK(playlist); |
2313 | 2429 } |
2430 | |
2431 static GList * | |
2432 playlist_shuffle_list(Playlist *playlist, GList * list) | |
2433 { | |
2434 /* | |
2435 * Note that this doesn't make a copy of the original list. | |
2436 * The pointer to the original list is not valid after this | |
2437 * fuction is run. | |
2438 */ | |
2439 gint len = g_list_length(list); | |
2440 gint i, j; | |
2441 GList *node, **ptrs; | |
2442 | |
2443 if (!playlist) | |
2444 return NULL; | |
2445 | |
2446 REQUIRE_LOCK(playlist->mutex); | |
2447 | |
2448 if (!len) | |
2449 return NULL; | |
2450 | |
2451 ptrs = g_new(GList *, len); | |
2452 | |
2453 for (node = list, i = 0; i < len; node = g_list_next(node), i++) | |
2454 ptrs[i] = node; | |
2455 | |
2456 j = g_random_int_range(0, len); | |
2457 list = ptrs[j]; | |
2458 ptrs[j]->next = NULL; | |
2459 ptrs[j] = ptrs[0]; | |
2460 | |
2461 for (i = 1; i < len; i++) { | |
2462 j = g_random_int_range(0, len - i); | |
2463 list->prev = ptrs[i + j]; | |
2464 ptrs[i + j]->next = list; | |
2465 list = ptrs[i + j]; | |
2466 ptrs[i + j] = ptrs[i]; | |
2467 } | |
2468 list->prev = NULL; | |
2469 | |
2470 g_free(ptrs); | |
2471 | |
2472 return list; | |
2473 } | |
2474 | |
2475 void | |
2476 playlist_random(Playlist *playlist) | |
2477 { | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2478 PLAYLIST_LOCK(playlist); |
2313 | 2479 playlist->entries = playlist_shuffle_list(playlist, playlist->entries); |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2480 PLAYLIST_UNLOCK(playlist); |
2313 | 2481 } |
2482 | |
2483 GList * | |
2484 playlist_get_selected(Playlist *playlist) | |
2485 { | |
2486 GList *node, *list = NULL; | |
2487 gint i = 0; | |
2488 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2489 PLAYLIST_LOCK(playlist); |
2313 | 2490 for (node = playlist->entries; node; node = g_list_next(node), i++) { |
2491 PlaylistEntry *entry = node->data; | |
2492 if (entry->selected) | |
2493 list = g_list_prepend(list, GINT_TO_POINTER(i)); | |
2494 } | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2495 PLAYLIST_UNLOCK(playlist); |
2313 | 2496 return g_list_reverse(list); |
2497 } | |
2498 | |
2499 void | |
2500 playlist_clear_selected(Playlist *playlist) | |
2501 { | |
2502 GList *node = NULL; | |
2503 gint i = 0; | |
2504 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2505 PLAYLIST_LOCK(playlist); |
2313 | 2506 for (node = playlist->entries; node; node = g_list_next(node), i++) { |
2507 PLAYLIST_ENTRY(node->data)->selected = FALSE; | |
2508 } | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2509 PLAYLIST_UNLOCK(playlist); |
2313 | 2510 playlist_recalc_total_time(playlist); |
2511 playlist_manager_update(); | |
2512 } | |
2513 | |
2514 gint | |
2515 playlist_get_num_selected(Playlist *playlist) | |
2516 { | |
2517 GList *node; | |
2518 gint num = 0; | |
2519 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2520 PLAYLIST_LOCK(playlist); |
2313 | 2521 for (node = playlist->entries; node; node = g_list_next(node)) { |
2522 PlaylistEntry *entry = node->data; | |
2523 if (entry->selected) | |
2524 num++; | |
2525 } | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2526 PLAYLIST_UNLOCK(playlist); |
2313 | 2527 return num; |
2528 } | |
2529 | |
2530 | |
2531 static void | |
2532 playlist_generate_shuffle_list(Playlist *playlist) | |
2533 { | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2534 PLAYLIST_LOCK(playlist); |
2313 | 2535 playlist_generate_shuffle_list_nolock(playlist); |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2536 PLAYLIST_UNLOCK(playlist); |
2313 | 2537 } |
2538 | |
2539 static void | |
2540 playlist_generate_shuffle_list_nolock(Playlist *playlist) | |
2541 { | |
2542 GList *node; | |
2543 gint numsongs; | |
2544 | |
2545 if (!cfg.shuffle || !playlist) | |
2546 return; | |
2547 | |
2548 REQUIRE_LOCK(playlist->mutex); | |
2549 | |
2550 if (playlist->shuffle) { | |
2551 g_list_free(playlist->shuffle); | |
2552 playlist->shuffle = NULL; | |
2553 } | |
2554 | |
2555 playlist->shuffle = playlist_shuffle_list(playlist, g_list_copy(playlist->entries)); | |
2556 numsongs = g_list_length(playlist->shuffle); | |
2557 | |
2558 if (playlist->position) { | |
2559 gint i = g_list_index(playlist->shuffle, playlist->position); | |
2560 node = g_list_nth(playlist->shuffle, i); | |
2561 playlist->shuffle = g_list_remove_link(playlist->shuffle, node); | |
2562 playlist->shuffle = g_list_prepend(playlist->shuffle, node->data); | |
2563 } | |
2564 } | |
2565 | |
2566 void | |
2567 playlist_fileinfo(Playlist *playlist, guint pos) | |
2568 { | |
2569 gchar *path = NULL; | |
2570 GList *node; | |
2571 PlaylistEntry *entry = NULL; | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2572 Tuple *tuple = NULL; |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
2573 ProbeResult *pr = NULL; |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2574 time_t mtime; |
2313 | 2575 |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2576 PLAYLIST_LOCK(playlist); |
2313 | 2577 |
2578 if ((node = g_list_nth(playlist->entries, pos))) | |
2579 { | |
2580 entry = node->data; | |
2581 tuple = entry->tuple; | |
2582 path = g_strdup(entry->filename); | |
2583 } | |
2584 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2585 PLAYLIST_UNLOCK(playlist); |
2313 | 2586 |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2587 if (entry->tuple) |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2588 mtime = tuple_get_int(entry->tuple, FIELD_MTIME, NULL); |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2589 else |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2590 mtime = 0; |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2591 |
2313 | 2592 /* No tuple? Try to set this entry up properly. --nenolod */ |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2593 if (entry->tuple == NULL || mtime == -1 || |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2594 mtime == 0 || mtime != playlist_get_mtime(entry->filename)) |
2313 | 2595 { |
2596 playlist_entry_get_info(entry); | |
2597 tuple = entry->tuple; | |
2598 } | |
2599 | |
2600 if (tuple != NULL) | |
2601 { | |
2602 if (entry->decoder == NULL) | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
2603 { |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
2604 pr = input_check_file(entry->filename, FALSE); /* try to find a decoder */ |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
2605 entry->decoder = pr ? pr->ip : NULL; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
2606 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
2607 g_free(pr); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
2608 } |
2313 | 2609 |
2610 if (entry->decoder != NULL && entry->decoder->file_info_box == NULL) | |
2611 fileinfo_show_for_tuple(tuple); | |
2612 else if (entry->decoder != NULL && entry->decoder->file_info_box != NULL) | |
2613 entry->decoder->file_info_box(path); | |
2614 else | |
2615 fileinfo_show_for_path(path); | |
2616 g_free(path); | |
2617 } | |
2618 else if (path != NULL) | |
2619 { | |
2620 if (entry != NULL && entry->decoder != NULL && entry->decoder->file_info_box != NULL) | |
2621 entry->decoder->file_info_box(path); | |
2622 else | |
2623 fileinfo_show_for_path(path); | |
2624 g_free(path); | |
2625 } | |
2626 } | |
2627 | |
2628 void | |
2629 playlist_fileinfo_current(Playlist *playlist) | |
2630 { | |
2631 gchar *path = NULL; | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
2632 Tuple *tuple = NULL; |
2313 | 2633 |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2634 PLAYLIST_LOCK(playlist); |
2313 | 2635 |
2636 if (playlist->entries && playlist->position) | |
2637 { | |
2638 path = g_strdup(playlist->position->filename); | |
2639 if (( playlist->position->tuple == NULL ) || ( playlist->position->decoder == NULL )) | |
2640 playlist_entry_get_info(playlist->position); | |
2641 tuple = playlist->position->tuple; | |
2642 } | |
2643 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2644 PLAYLIST_UNLOCK(playlist); |
2313 | 2645 |
2646 if (tuple != NULL) | |
2647 { | |
2648 if (playlist->position->decoder != NULL && playlist->position->decoder->file_info_box == NULL) | |
2649 fileinfo_show_for_tuple(tuple); | |
2650 else if (playlist->position->decoder != NULL && playlist->position->decoder->file_info_box != NULL) | |
2651 playlist->position->decoder->file_info_box(path); | |
2652 else | |
2653 fileinfo_show_for_path(path); | |
2654 g_free(path); | |
2655 } | |
2656 else if (path != NULL) | |
2657 { | |
2658 if (playlist->position != NULL && playlist->position->decoder != NULL && playlist->position->decoder->file_info_box != NULL) | |
2659 playlist->position->decoder->file_info_box(path); | |
2660 else | |
2661 fileinfo_show_for_path(path); | |
2662 g_free(path); | |
2663 } | |
2664 } | |
2665 | |
2666 | |
2667 static gboolean | |
2668 playlist_get_info_is_going(void) | |
2669 { | |
2670 gboolean result; | |
2671 | |
3460
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2672 g_static_rw_lock_reader_lock(&playlist_get_info_rwlock); |
2313 | 2673 result = playlist_get_info_going; |
3460
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2674 g_static_rw_lock_reader_unlock(&playlist_get_info_rwlock); |
2313 | 2675 |
2676 return result; | |
2677 } | |
2678 | |
3460
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2679 |
2313 | 2680 static gpointer |
2681 playlist_get_info_func(gpointer arg) | |
2682 { | |
2683 GList *node; | |
2684 gboolean update_playlistwin = FALSE; | |
2685 | |
2686 while (playlist_get_info_is_going()) { | |
2687 PlaylistEntry *entry; | |
2688 Playlist *playlist = playlist_get_active(); | |
2689 | |
2690 // on_load | |
3460
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2691 if (cfg.use_pl_metadata && cfg.get_info_on_load && |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
2692 playlist_get_info_scan_active) { |
2313 | 2693 |
2694 for (node = playlist->entries; node; node = g_list_next(node)) { | |
2695 entry = node->data; | |
2696 | |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
2697 if(playlist->attribute & PLAYLIST_STATIC || // live lock fix |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2698 (entry->tuple && tuple_get_int(entry->tuple, FIELD_LENGTH, NULL) > -1 && |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2699 tuple_get_int(entry->tuple, FIELD_MTIME, NULL) != -1)) { |
2313 | 2700 update_playlistwin = TRUE; |
2701 continue; | |
2702 } | |
2703 | |
2704 if (!playlist_entry_get_info(entry)) { | |
2705 if (g_list_index(playlist->entries, entry) == -1) | |
2706 /* Entry disappeared while we looked it up. | |
2707 Restart. */ | |
2708 node = playlist->entries; | |
2709 } | |
3733
da090f448c88
fix for livelock reported by joker...
William Pitcock <nenolod@atheme.org>
parents:
3640
diff
changeset
|
2710 else if ((entry->tuple != NULL || entry->title != NULL) && |
da090f448c88
fix for livelock reported by joker...
William Pitcock <nenolod@atheme.org>
parents:
3640
diff
changeset
|
2711 tuple_get_int(entry->tuple, FIELD_LENGTH, NULL) > -1 && |
da090f448c88
fix for livelock reported by joker...
William Pitcock <nenolod@atheme.org>
parents:
3640
diff
changeset
|
2712 tuple_get_int(entry->tuple, FIELD_MTIME, NULL) != -1) { |
2313 | 2713 update_playlistwin = TRUE; |
2714 break; | |
2715 } | |
2716 } | |
2717 | |
2718 if (!node) { | |
2719 g_mutex_lock(mutex_scan); | |
2720 playlist_get_info_scan_active = FALSE; | |
2721 g_mutex_unlock(mutex_scan); | |
2722 } | |
2723 } // on_load | |
2724 | |
2725 // on_demand | |
2726 else if (!cfg.get_info_on_load && | |
2727 cfg.get_info_on_demand && | |
2728 cfg.playlist_visible && | |
2729 !cfg.playlist_shaded && | |
2730 cfg.use_pl_metadata) { | |
2731 | |
2732 g_mutex_lock(mutex_scan); | |
2733 playlist_get_info_scan_active = FALSE; | |
2734 g_mutex_unlock(mutex_scan); | |
2735 | |
2668
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
2736 for (node = g_list_nth(playlist->entries, playlistwin_get_toprow()); |
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
2737 node && playlistwin_item_visible(g_list_position(playlist->entries, node)); |
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
2738 node = g_list_next(node)) { |
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
2739 |
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
2740 entry = node->data; |
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
2741 |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
2742 if(playlist->attribute & PLAYLIST_STATIC || |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2743 (entry->tuple && tuple_get_int(entry->tuple, FIELD_LENGTH, NULL) > -1 && |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2744 tuple_get_int(entry->tuple, FIELD_MTIME, NULL) != -1)) { |
2668
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
2745 update_playlistwin = TRUE; |
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
2746 continue; |
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
2747 } |
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
2748 |
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
2749 if (!playlist_entry_get_info(entry)) { |
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
2750 if (g_list_index(playlist->entries, entry) == -1) |
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
2751 /* Entry disapeared while we |
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
2752 looked it up. Restart. */ |
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
2753 node = g_list_nth(playlist->entries, |
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
2754 playlistwin_get_toprow()); |
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
2755 } |
3733
da090f448c88
fix for livelock reported by joker...
William Pitcock <nenolod@atheme.org>
parents:
3640
diff
changeset
|
2756 else if ((entry->tuple != NULL || entry->title != NULL) && |
da090f448c88
fix for livelock reported by joker...
William Pitcock <nenolod@atheme.org>
parents:
3640
diff
changeset
|
2757 tuple_get_int(entry->tuple, FIELD_LENGTH, NULL) > -1 && |
da090f448c88
fix for livelock reported by joker...
William Pitcock <nenolod@atheme.org>
parents:
3640
diff
changeset
|
2758 tuple_get_int(entry->tuple, FIELD_MTIME, NULL) != -1) { |
2668
d5da5d37ec8b
[svn] - unlock many playlist operations that do not really need locking
nenolod
parents:
2667
diff
changeset
|
2759 update_playlistwin = TRUE; |
3733
da090f448c88
fix for livelock reported by joker...
William Pitcock <nenolod@atheme.org>
parents:
3640
diff
changeset
|
2760 } |
2313 | 2761 } |
2762 } // on_demand | |
3460
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2763 else if (cfg.get_info_on_demand && |
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2764 (!cfg.playlist_visible || cfg.playlist_shaded || !cfg.use_pl_metadata)) |
2313 | 2765 { |
2766 g_mutex_lock(mutex_scan); | |
2767 playlist_get_info_scan_active = FALSE; | |
2768 g_mutex_unlock(mutex_scan); | |
2769 } | |
2770 else /* not on_demand and not on_load... | |
2771 NOTE: this shouldn't happen anymore, sanity check in bmp_config_load now */ | |
2772 { | |
2773 g_mutex_lock(mutex_scan); | |
2774 playlist_get_info_scan_active = FALSE; | |
2775 g_mutex_unlock(mutex_scan); | |
2776 } | |
2777 | |
2778 if (update_playlistwin) { | |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
2779 event_queue("playlistwin update list", playlist_get_active()); |
2313 | 2780 update_playlistwin = FALSE; |
2781 } | |
2782 | |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
2783 if (playlist_get_info_scan_active) { |
2313 | 2784 continue; |
2785 } | |
2786 | |
2787 g_mutex_lock(mutex_scan); | |
2788 g_cond_wait(cond_scan, mutex_scan); | |
2789 g_mutex_unlock(mutex_scan); | |
2790 | |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
2791 // g_print("scanner invoked\n"); |
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
2792 |
2313 | 2793 } // while |
2794 | |
2795 g_thread_exit(NULL); | |
2796 return NULL; | |
2797 } | |
2798 | |
2799 void | |
2800 playlist_start_get_info_thread(void) | |
2801 { | |
3460
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2802 g_static_rw_lock_writer_lock(&playlist_get_info_rwlock); |
2313 | 2803 playlist_get_info_going = TRUE; |
3460
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2804 g_static_rw_lock_writer_unlock(&playlist_get_info_rwlock); |
2313 | 2805 |
2806 playlist_get_info_thread = g_thread_create(playlist_get_info_func, | |
2807 NULL, TRUE, NULL); | |
2808 } | |
2809 | |
2810 void | |
2811 playlist_stop_get_info_thread(void) | |
2812 { | |
3460
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2813 g_static_rw_lock_writer_lock(&playlist_get_info_rwlock); |
2313 | 2814 playlist_get_info_going = FALSE; |
3460
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2815 g_static_rw_lock_writer_unlock(&playlist_get_info_rwlock); |
2313 | 2816 |
2817 g_cond_broadcast(cond_scan); | |
2818 g_thread_join(playlist_get_info_thread); | |
2819 } | |
2820 | |
2821 void | |
2822 playlist_start_get_info_scan(void) | |
2823 { | |
2824 g_mutex_lock(mutex_scan); | |
2825 playlist_get_info_scan_active = TRUE; | |
2826 g_mutex_unlock(mutex_scan); | |
3460
0fcff78c0c2c
Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
2827 |
2313 | 2828 g_cond_signal(cond_scan); |
2829 } | |
2830 | |
2831 void | |
2832 playlist_remove_dead_files(Playlist *playlist) | |
2833 { | |
2834 GList *node, *next_node; | |
2835 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2836 PLAYLIST_LOCK(playlist); |
2313 | 2837 |
2838 for (node = playlist->entries; node; node = next_node) { | |
2839 PlaylistEntry *entry = PLAYLIST_ENTRY(node->data); | |
2840 next_node = g_list_next(node); | |
2841 | |
2842 if (!entry || !entry->filename) { | |
2843 g_message(G_STRLOC ": Playlist entry is invalid!"); | |
2844 continue; | |
2845 } | |
2846 | |
2847 /* FIXME: What about 'file:///'? */ | |
2848 /* Don't kill URLs */ | |
2849 if (strstr(entry->filename, "://")) | |
2850 continue; | |
2851 | |
2852 /* FIXME: Should test for readability */ | |
2853 if (vfs_file_test(entry->filename, G_FILE_TEST_EXISTS)) | |
2854 continue; | |
2855 | |
2856 if (entry == playlist->position) { | |
2857 /* Don't remove the currently playing song */ | |
2858 if (playback_get_playing()) | |
2859 continue; | |
2860 | |
2861 if (next_node) | |
2862 playlist->position = PLAYLIST_ENTRY(next_node->data); | |
2863 else | |
2864 playlist->position = NULL; | |
2865 } | |
2866 | |
2867 playlist_entry_free(entry); | |
2868 playlist->entries = g_list_delete_link(playlist->entries, node); | |
2869 } | |
2870 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2871 PLAYLIST_UNLOCK(playlist); |
2313 | 2872 |
2873 playlist_generate_shuffle_list(playlist); | |
2874 playlistwin_update_list(playlist); | |
2875 playlist_recalc_total_time(playlist); | |
3923
e9fd46b0893b
- redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3922
diff
changeset
|
2876 PLAYLIST_INCR_SERIAL(playlist); |
2313 | 2877 playlist_manager_update(); |
2878 } | |
2879 | |
2880 | |
2881 static gint | |
2882 playlist_dupscmp_title(PlaylistEntry * a, | |
2883 PlaylistEntry * b) | |
2884 { | |
2885 const gchar *a_title, *b_title; | |
2886 | |
2887 g_return_val_if_fail(a != NULL, 0); | |
2888 g_return_val_if_fail(b != NULL, 0); | |
2889 | |
3638
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2890 playlist_get_entry_title(a, &a_title); |
8d2f06fc841c
Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
3636
diff
changeset
|
2891 playlist_get_entry_title(b, &b_title); |
2313 | 2892 |
2893 return strcmp(a_title, b_title); | |
2894 } | |
2895 | |
2896 static gint | |
2897 playlist_dupscmp_filename(PlaylistEntry * a, | |
2898 PlaylistEntry * b ) | |
2899 { | |
2900 gchar *a_filename, *b_filename; | |
2901 | |
2902 g_return_val_if_fail(a != NULL, 0); | |
2903 g_return_val_if_fail(b != NULL, 0); | |
2904 | |
2905 if (strrchr(a->filename, '/')) | |
2906 a_filename = strrchr(a->filename, '/') + 1; | |
2907 else | |
2908 a_filename = a->filename; | |
2909 | |
2910 if (strrchr(b->filename, '/')) | |
2911 b_filename = strrchr(b->filename, '/') + 1; | |
2912 else | |
2913 b_filename = b->filename; | |
2914 | |
2915 return strcmp(a_filename, b_filename); | |
2916 } | |
2917 | |
2918 static gint | |
2919 playlist_dupscmp_path(PlaylistEntry * a, | |
2920 PlaylistEntry * b) | |
2921 { | |
2922 /* simply compare the entire filename string */ | |
2923 return strcmp(a->filename, b->filename); | |
2924 } | |
2925 | |
2926 void | |
2927 playlist_remove_duplicates(Playlist *playlist, PlaylistDupsType type) | |
2928 { | |
2929 GList *node, *next_node; | |
2930 GList *node_cmp, *next_node_cmp; | |
2931 gint (*dups_compare_func)(PlaylistEntry * , PlaylistEntry *); | |
2932 | |
2933 switch ( type ) | |
2934 { | |
2935 case PLAYLIST_DUPS_TITLE: | |
2936 dups_compare_func = playlist_dupscmp_title; | |
2937 break; | |
2938 case PLAYLIST_DUPS_PATH: | |
2939 dups_compare_func = playlist_dupscmp_path; | |
2940 break; | |
2941 case PLAYLIST_DUPS_FILENAME: | |
2942 default: | |
2943 dups_compare_func = playlist_dupscmp_filename; | |
2944 break; | |
2945 } | |
2946 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2947 PLAYLIST_LOCK(playlist); |
2313 | 2948 |
2949 for (node = playlist->entries; node; node = next_node) { | |
2950 PlaylistEntry *entry = PLAYLIST_ENTRY(node->data); | |
2951 next_node = g_list_next(node); | |
2952 | |
2953 if (!entry || !entry->filename) { | |
2954 g_message(G_STRLOC ": Playlist entry is invalid!"); | |
2955 continue; | |
2956 } | |
2957 | |
2958 for (node_cmp = next_node; node_cmp; node_cmp = next_node_cmp) { | |
2959 PlaylistEntry *entry_cmp = PLAYLIST_ENTRY(node_cmp->data); | |
2960 next_node_cmp = g_list_next(node_cmp); | |
2961 | |
2962 if (!entry_cmp || !entry_cmp->filename) { | |
2963 g_message(G_STRLOC ": Playlist entry is invalid!"); | |
2964 continue; | |
2965 } | |
2966 | |
2967 /* compare using the chosen dups_compare_func */ | |
2968 if ( !dups_compare_func( entry , entry_cmp ) ) { | |
2969 | |
2970 if (entry_cmp == playlist->position) { | |
2971 /* Don't remove the currently playing song */ | |
2972 if (playback_get_playing()) | |
2973 continue; | |
2974 | |
2975 if (next_node_cmp) | |
2976 playlist->position = PLAYLIST_ENTRY(next_node_cmp->data); | |
2977 else | |
2978 playlist->position = NULL; | |
2979 } | |
2980 | |
2981 /* check if this was the next item of the external | |
2982 loop; if true, replace it with the next of the next*/ | |
2983 if ( node_cmp == next_node ) | |
2984 next_node = g_list_next(next_node); | |
2985 | |
2986 playlist_entry_free(entry_cmp); | |
2987 playlist->entries = g_list_delete_link(playlist->entries, node_cmp); | |
2988 } | |
2989 } | |
2990 } | |
2991 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
2992 PLAYLIST_UNLOCK(playlist); |
2313 | 2993 |
2994 playlistwin_update_list(playlist); | |
2995 playlist_recalc_total_time(playlist); | |
3923
e9fd46b0893b
- redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3922
diff
changeset
|
2996 PLAYLIST_INCR_SERIAL(playlist); |
2313 | 2997 |
2998 playlist_manager_update(); | |
2999 } | |
3000 | |
3001 void | |
3002 playlist_get_total_time(Playlist * playlist, | |
3003 gulong * total_time, | |
3004 gulong * selection_time, | |
3005 gboolean * total_more, | |
3006 gboolean * selection_more) | |
3007 { | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3008 PLAYLIST_LOCK(playlist); |
2313 | 3009 *total_time = playlist->pl_total_time; |
3010 *selection_time = playlist->pl_selection_time; | |
3011 *total_more = playlist->pl_total_more; | |
3012 *selection_more = playlist->pl_selection_more; | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3013 PLAYLIST_UNLOCK(playlist); |
2313 | 3014 } |
3015 | |
3922
23e5b148ae7c
to get rid of annoying side effects, an independent function for playlist serial increment has been provided.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3921
diff
changeset
|
3016 static void |
2313 | 3017 playlist_recalc_total_time_nolock(Playlist *playlist) |
3018 { | |
3019 GList *list; | |
3020 PlaylistEntry *entry; | |
3021 | |
3022 REQUIRE_LOCK(playlist->mutex); | |
3023 | |
3024 playlist->pl_total_time = 0; | |
3025 playlist->pl_selection_time = 0; | |
3026 playlist->pl_total_more = FALSE; | |
3027 playlist->pl_selection_more = FALSE; | |
3028 | |
3029 for (list = playlist->entries; list; list = g_list_next(list)) { | |
3030 entry = list->data; | |
3031 | |
3032 if (entry->length != -1) | |
3033 playlist->pl_total_time += entry->length / 1000; | |
3034 else | |
3035 playlist->pl_total_more = TRUE; | |
3036 | |
3037 if (entry->selected) { | |
3038 if (entry->length != -1) | |
3039 playlist->pl_selection_time += entry->length / 1000; | |
3040 else | |
3041 playlist->pl_selection_more = TRUE; | |
3042 } | |
3043 } | |
3044 } | |
3045 | |
3046 static void | |
3047 playlist_recalc_total_time(Playlist *playlist) | |
3048 { | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3049 PLAYLIST_LOCK(playlist); |
2313 | 3050 playlist_recalc_total_time_nolock(playlist); |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3051 PLAYLIST_UNLOCK(playlist); |
2313 | 3052 } |
3053 | |
3054 gint | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3246
diff
changeset
|
3055 playlist_select_search( Playlist *playlist , Tuple *tuple , gint action ) |
2313 | 3056 { |
3057 GList *entry_list = NULL, *found_list = NULL, *sel_list = NULL; | |
3058 gboolean is_first_search = TRUE; | |
3059 gint num_of_entries_found = 0; | |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
3060 const gchar *regex_pattern; |
3863
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3061 const gchar *track_name; |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3062 const gchar *album_name; |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3063 const gchar *performer; |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3064 const gchar *file_name; |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
3065 |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
3066 #if defined(USE_REGEX_ONIGURUMA) |
2313 | 3067 /* set encoding for Oniguruma regex to UTF-8 */ |
3068 reg_set_encoding( REG_POSIX_ENCODING_UTF8 ); | |
3069 onig_set_default_syntax( ONIG_SYNTAX_POSIX_BASIC ); | |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
3070 #endif |
2313 | 3071 |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3072 PLAYLIST_LOCK(playlist); |
2313 | 3073 |
3863
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3074 if ( (regex_pattern = tuple_get_string(tuple, FIELD_TITLE, NULL)) != NULL && |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3075 (*regex_pattern != '\0') ) |
2313 | 3076 { |
3077 /* match by track_name */ | |
3078 regex_t regex; | |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
3079 #if defined(USE_REGEX_PCRE) |
2313 | 3080 if ( regcomp( ®ex , regex_pattern , REG_NOSUB | REG_ICASE | REG_UTF8 ) == 0 ) |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
3081 #else |
2313 | 3082 if ( regcomp( ®ex , regex_pattern , REG_NOSUB | REG_ICASE ) == 0 ) |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
3083 #endif |
2313 | 3084 { |
3085 GList *tfound_list = NULL; | |
3086 if ( is_first_search == TRUE ) entry_list = playlist->entries; | |
3087 else entry_list = found_list; /* use found_list */ | |
3088 for ( ; entry_list ; entry_list = g_list_next(entry_list) ) | |
3089 { | |
3090 PlaylistEntry *entry = entry_list->data; | |
3863
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3091 if ( entry->tuple != NULL ) |
2313 | 3092 { |
3863
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3093 track_name = tuple_get_string( entry->tuple, FIELD_TITLE, NULL ); |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3094 if (( track_name != NULL ) && |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3095 ( regexec( ®ex , track_name , 0 , NULL , 0 ) == 0 ) ) |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3096 { |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3097 tfound_list = g_list_append( tfound_list , entry ); |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3098 } |
2313 | 3099 } |
3100 } | |
3101 g_list_free( found_list ); /* wipe old found_list */ | |
3102 found_list = tfound_list; /* move tfound_list in found_list */ | |
3103 regfree( ®ex ); | |
3104 } | |
3105 is_first_search = FALSE; | |
3106 } | |
3107 | |
3863
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3108 if ( (regex_pattern = tuple_get_string(tuple, FIELD_ALBUM, NULL)) != NULL && |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3109 (*regex_pattern != '\0') ) |
2313 | 3110 { |
3111 /* match by album_name */ | |
3112 regex_t regex; | |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
3113 #if defined(USE_REGEX_PCRE) |
2313 | 3114 if ( regcomp( ®ex , regex_pattern , REG_NOSUB | REG_ICASE | REG_UTF8 ) == 0 ) |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
3115 #else |
2313 | 3116 if ( regcomp( ®ex , regex_pattern , REG_NOSUB | REG_ICASE ) == 0 ) |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
3117 #endif |
2313 | 3118 { |
3119 GList *tfound_list = NULL; | |
3120 if ( is_first_search == TRUE ) entry_list = playlist->entries; | |
3121 else entry_list = found_list; /* use found_list */ | |
3122 for ( ; entry_list ; entry_list = g_list_next(entry_list) ) | |
3123 { | |
3124 PlaylistEntry *entry = entry_list->data; | |
3863
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3125 if ( entry->tuple != NULL ) |
2313 | 3126 { |
3863
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3127 album_name = tuple_get_string( entry->tuple, FIELD_ALBUM, NULL ); |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3128 if ( ( album_name != NULL ) && |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3129 ( regexec( ®ex , album_name , 0 , NULL , 0 ) == 0 ) ) |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3130 { |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3131 tfound_list = g_list_append( tfound_list , entry ); |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3132 } |
2313 | 3133 } |
3134 } | |
3135 g_list_free( found_list ); /* wipe old found_list */ | |
3136 found_list = tfound_list; /* move tfound_list in found_list */ | |
3137 regfree( ®ex ); | |
3138 } | |
3139 is_first_search = FALSE; | |
3140 } | |
3141 | |
3863
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3142 if ( (regex_pattern = tuple_get_string(tuple, FIELD_ARTIST, NULL)) != NULL && |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3143 (*regex_pattern != '\0') ) |
2313 | 3144 { |
3145 /* match by performer */ | |
3146 regex_t regex; | |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
3147 #if defined(USE_REGEX_PCRE) |
2313 | 3148 if ( regcomp( ®ex , regex_pattern , REG_NOSUB | REG_ICASE | REG_UTF8 ) == 0 ) |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
3149 #else |
2313 | 3150 if ( regcomp( ®ex , regex_pattern , REG_NOSUB | REG_ICASE ) == 0 ) |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
3151 #endif |
2313 | 3152 { |
3153 GList *tfound_list = NULL; | |
3154 if ( is_first_search == TRUE ) entry_list = playlist->entries; | |
3155 else entry_list = found_list; /* use found_list */ | |
3156 for ( ; entry_list ; entry_list = g_list_next(entry_list) ) | |
3157 { | |
3158 PlaylistEntry *entry = entry_list->data; | |
3863
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3159 if ( entry->tuple != NULL ) |
2313 | 3160 { |
3863
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3161 performer = tuple_get_string( entry->tuple, FIELD_ARTIST, NULL ); |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3162 if ( ( entry->tuple != NULL ) && ( performer != NULL ) && |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3163 ( regexec( ®ex , performer , 0 , NULL , 0 ) == 0 ) ) |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3164 { |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3165 tfound_list = g_list_append( tfound_list , entry ); |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3166 } |
2313 | 3167 } |
3168 } | |
3169 g_list_free( found_list ); /* wipe old found_list */ | |
3170 found_list = tfound_list; /* move tfound_list in found_list */ | |
3171 regfree( ®ex ); | |
3172 } | |
3173 is_first_search = FALSE; | |
3174 } | |
3175 | |
3863
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3176 if ( (regex_pattern = tuple_get_string(tuple, FIELD_FILE_NAME, NULL)) != NULL && |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3177 (*regex_pattern != '\0') ) |
2313 | 3178 { |
3179 /* match by file_name */ | |
3180 regex_t regex; | |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
3181 #if defined(USE_REGEX_PCRE) |
2313 | 3182 if ( regcomp( ®ex , regex_pattern , REG_NOSUB | REG_ICASE | REG_UTF8 ) == 0 ) |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
3183 #else |
2313 | 3184 if ( regcomp( ®ex , regex_pattern , REG_NOSUB | REG_ICASE ) == 0 ) |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
3185 #endif |
2313 | 3186 { |
3187 GList *tfound_list = NULL; | |
3188 if ( is_first_search == TRUE ) entry_list = playlist->entries; | |
3189 else entry_list = found_list; /* use found_list */ | |
3190 for ( ; entry_list ; entry_list = g_list_next(entry_list) ) | |
3191 { | |
3192 PlaylistEntry *entry = entry_list->data; | |
3863
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3193 if ( entry->tuple != NULL ) |
2313 | 3194 { |
3863
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3195 file_name = tuple_get_string( entry->tuple, FIELD_FILE_NAME, NULL ); |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3196 if ( ( file_name != NULL ) && |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3197 ( regexec( ®ex , file_name , 0 , NULL , 0 ) == 0 ) ) |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3198 { |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3199 tfound_list = g_list_append( tfound_list , entry ); |
dd5c459c5f2d
fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents:
3784
diff
changeset
|
3200 } |
2313 | 3201 } |
3202 } | |
3203 g_list_free( found_list ); /* wipe old found_list */ | |
3204 found_list = tfound_list; /* move tfound_list in found_list */ | |
3205 regfree( ®ex ); | |
3206 } | |
3207 is_first_search = FALSE; | |
3208 } | |
3209 | |
3210 /* NOTE: action = 0 -> default behaviour, select all matching entries */ | |
3211 /* if some entries are still in found_list, those | |
3212 are what the user is searching for; select them */ | |
3213 for ( sel_list = found_list ; sel_list ; sel_list = g_list_next(sel_list) ) | |
3214 { | |
3215 PlaylistEntry *entry = sel_list->data; | |
3216 entry->selected = TRUE; | |
3217 num_of_entries_found++; | |
3218 } | |
3219 | |
3220 g_list_free( found_list ); | |
3221 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3222 PLAYLIST_UNLOCK(playlist); |
2313 | 3223 playlist_recalc_total_time(playlist); |
3923
e9fd46b0893b
- redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3922
diff
changeset
|
3224 // PLAYLIST_INCR_SERIAL(playlist); //unnecessary? --yaz |
2313 | 3225 |
3226 return num_of_entries_found; | |
3227 } | |
3228 | |
3229 void | |
3230 playlist_select_all(Playlist *playlist, gboolean set) | |
3231 { | |
3232 GList *list; | |
3233 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3234 PLAYLIST_LOCK(playlist); |
2313 | 3235 |
3236 for (list = playlist->entries; list; list = g_list_next(list)) { | |
3237 PlaylistEntry *entry = list->data; | |
3238 entry->selected = set; | |
3239 } | |
3240 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3241 PLAYLIST_UNLOCK(playlist); |
3922
23e5b148ae7c
to get rid of annoying side effects, an independent function for playlist serial increment has been provided.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3921
diff
changeset
|
3242 playlist_recalc_total_time(playlist); |
2313 | 3243 } |
3244 | |
3245 void | |
3246 playlist_select_invert_all(Playlist *playlist) | |
3247 { | |
3248 GList *list; | |
3249 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3250 PLAYLIST_LOCK(playlist); |
2313 | 3251 |
3252 for (list = playlist->entries; list; list = g_list_next(list)) { | |
3253 PlaylistEntry *entry = list->data; | |
3254 entry->selected = !entry->selected; | |
3255 } | |
3256 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3257 PLAYLIST_UNLOCK(playlist); |
2313 | 3258 playlist_recalc_total_time(playlist); |
3259 } | |
3260 | |
3261 gboolean | |
3262 playlist_select_invert(Playlist *playlist, guint pos) | |
3263 { | |
3264 GList *list; | |
3265 gboolean invert_ok = FALSE; | |
3266 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3267 PLAYLIST_LOCK(playlist); |
2313 | 3268 |
3269 if ((list = g_list_nth(playlist->entries, pos))) { | |
3270 PlaylistEntry *entry = list->data; | |
3271 entry->selected = !entry->selected; | |
3272 invert_ok = TRUE; | |
3273 } | |
3274 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3275 PLAYLIST_UNLOCK(playlist); |
3922
23e5b148ae7c
to get rid of annoying side effects, an independent function for playlist serial increment has been provided.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3921
diff
changeset
|
3276 playlist_recalc_total_time(playlist); |
2313 | 3277 |
3278 return invert_ok; | |
3279 } | |
3280 | |
3281 | |
3282 void | |
3283 playlist_select_range(Playlist *playlist, gint min_pos, gint max_pos, gboolean select) | |
3284 { | |
3285 GList *list; | |
3286 gint i; | |
3287 | |
3288 if (min_pos > max_pos) | |
3289 SWAP(min_pos, max_pos); | |
3290 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3291 PLAYLIST_LOCK(playlist); |
2313 | 3292 |
3293 list = g_list_nth(playlist->entries, min_pos); | |
3294 for (i = min_pos; i <= max_pos && list; i++) { | |
3295 PlaylistEntry *entry = list->data; | |
3296 entry->selected = select; | |
3297 list = g_list_next(list); | |
3298 } | |
3299 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3300 PLAYLIST_UNLOCK(playlist); |
2313 | 3301 |
3302 playlist_recalc_total_time(playlist); | |
3303 } | |
3304 | |
3305 gboolean | |
3306 playlist_read_info_selection(Playlist *playlist) | |
3307 { | |
3308 GList *node; | |
3309 gboolean retval = FALSE; | |
3310 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3311 PLAYLIST_LOCK(playlist); |
2313 | 3312 |
3313 for (node = playlist->entries; node; node = g_list_next(node)) { | |
3314 PlaylistEntry *entry = node->data; | |
3315 if (!entry->selected) | |
3316 continue; | |
3317 | |
3318 retval = TRUE; | |
3319 | |
3320 str_replace_in(&entry->title, NULL); | |
3321 entry->length = -1; | |
3322 | |
3323 /* invalidate mtime to reread */ | |
3324 if (entry->tuple != NULL) | |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3401
diff
changeset
|
3325 tuple_associate_int(entry->tuple, FIELD_MTIME, NULL, -1); /* -1 denotes "non-initialized". now 0 is for stream etc. yaz */ |
2313 | 3326 |
3327 if (!playlist_entry_get_info(entry)) { | |
3328 if (g_list_index(playlist->entries, entry) == -1) | |
3329 /* Entry disappeared while we looked it up. Restart. */ | |
3330 node = playlist->entries; | |
3331 } | |
3332 } | |
3333 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3334 PLAYLIST_UNLOCK(playlist); |
2313 | 3335 |
3336 playlistwin_update_list(playlist); | |
3337 playlist_recalc_total_time(playlist); | |
3923
e9fd46b0893b
- redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3922
diff
changeset
|
3338 PLAYLIST_INCR_SERIAL(playlist); //tentative --yaz |
2313 | 3339 |
3340 return retval; | |
3341 } | |
3342 | |
3343 void | |
3344 playlist_read_info(Playlist *playlist, guint pos) | |
3345 { | |
3346 GList *node; | |
3347 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3348 PLAYLIST_LOCK(playlist); |
2313 | 3349 |
3350 if ((node = g_list_nth(playlist->entries, pos))) { | |
3351 PlaylistEntry *entry = node->data; | |
3352 str_replace_in(&entry->title, NULL); | |
3353 entry->length = -1; | |
3354 playlist_entry_get_info(entry); | |
3355 } | |
3356 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3357 PLAYLIST_UNLOCK(playlist); |
2313 | 3358 |
3359 playlistwin_update_list(playlist); | |
3360 playlist_recalc_total_time(playlist); | |
3923
e9fd46b0893b
- redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3922
diff
changeset
|
3361 PLAYLIST_INCR_SERIAL(playlist); //tentative --yaz |
2313 | 3362 } |
3363 | |
3364 Playlist * | |
3365 playlist_get_active(void) | |
3366 { | |
3367 if (playlists_iter != NULL) | |
3368 return (Playlist *) playlists_iter->data; | |
3369 | |
2736 | 3370 if (playlists) |
3371 return (Playlist *) playlists->data; | |
3372 | |
3373 return NULL; | |
2313 | 3374 } |
3375 | |
3376 void | |
3377 playlist_set_shuffle(gboolean shuffle) | |
3378 { | |
3379 Playlist *playlist = playlist_get_active(); | |
3380 if (!playlist) | |
3381 return; | |
3382 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3383 PLAYLIST_LOCK(playlist); |
2313 | 3384 |
3385 playlist_position_before_jump = NULL; | |
3386 | |
3387 cfg.shuffle = shuffle; | |
3388 playlist_generate_shuffle_list_nolock(playlist); | |
3389 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3390 PLAYLIST_UNLOCK(playlist); |
2313 | 3391 } |
3392 | |
3393 Playlist * | |
3394 playlist_new(void) | |
3395 { | |
3396 Playlist *playlist = g_new0(Playlist, 1); | |
3397 playlist->mutex = g_mutex_new(); | |
3398 playlist->loading_playlist = FALSE; | |
3477
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
3399 playlist->title = NULL; |
57f4971b7086
New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3476
diff
changeset
|
3400 playlist->filename = NULL; |
2313 | 3401 playlist_clear(playlist); |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
3402 playlist->tail = NULL; |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
3403 playlist->attribute = PLAYLIST_PLAIN; |
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
3404 playlist->serial = 0; |
2313 | 3405 |
3406 return playlist; | |
3407 } | |
3408 | |
3409 void | |
3410 playlist_free(Playlist *playlist) | |
3411 { | |
3467
5a6896b6000f
Implement playlist_get_info_scanning() with mutex locking.
Matti Hamalainen <ccr@tnsp.org>
parents:
3460
diff
changeset
|
3412 if (!playlist) |
5a6896b6000f
Implement playlist_get_info_scanning() with mutex locking.
Matti Hamalainen <ccr@tnsp.org>
parents:
3460
diff
changeset
|
3413 return; |
5a6896b6000f
Implement playlist_get_info_scanning() with mutex locking.
Matti Hamalainen <ccr@tnsp.org>
parents:
3460
diff
changeset
|
3414 |
2313 | 3415 g_mutex_free( playlist->mutex ); |
3416 g_free( playlist ); | |
3920
c2b2828186ba
- serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
3417 playlist = NULL; //XXX lead to crash? --yaz |
2313 | 3418 } |
3419 | |
3420 Playlist * | |
3421 playlist_new_from_selected(void) | |
3422 { | |
3423 Playlist *newpl = playlist_new(); | |
3424 Playlist *playlist = playlist_get_active(); | |
3425 GList *list = playlist_get_selected(playlist); | |
3426 | |
3427 playlist_add_playlist( newpl ); | |
3428 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3429 PLAYLIST_LOCK(playlist); |
2313 | 3430 |
3431 while ( list != NULL ) | |
3432 { | |
3433 PlaylistEntry *entry = g_list_nth_data(playlist->entries, GPOINTER_TO_INT(list->data)); | |
3434 if ( entry->filename != NULL ) /* paranoid? oh well... */ | |
3435 playlist_add( newpl , entry->filename ); | |
3436 list = g_list_next(list); | |
3437 } | |
3438 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3439 PLAYLIST_UNLOCK(playlist); |
2313 | 3440 |
3441 playlist_recalc_total_time(newpl); | |
3442 playlistwin_update_list(playlist); | |
3621
2d6106656276
Notify playlist manager of more changes
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3583
diff
changeset
|
3443 playlist_manager_update(); |
2313 | 3444 |
3445 return newpl; | |
3446 } | |
3447 | |
3448 const gchar * | |
3449 playlist_get_filename_to_play(Playlist *playlist) | |
3450 { | |
3451 const gchar *filename = NULL; | |
3452 | |
3453 if (!playlist) | |
3454 return NULL; | |
3455 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3456 PLAYLIST_LOCK(playlist); |
2313 | 3457 |
3458 if (!playlist->position) { | |
3459 if (cfg.shuffle) | |
3460 playlist->position = playlist->shuffle->data; | |
3461 else | |
3462 playlist->position = playlist->entries->data; | |
3463 } | |
3464 | |
3465 filename = playlist->position->filename; | |
3466 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3467 PLAYLIST_UNLOCK(playlist); |
2313 | 3468 |
3469 return filename; | |
3470 } | |
3471 | |
3472 PlaylistEntry * | |
3473 playlist_get_entry_to_play(Playlist *playlist) | |
3474 { | |
3475 if (!playlist) | |
3476 return NULL; | |
3477 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3478 PLAYLIST_LOCK(playlist); |
2313 | 3479 |
3480 if (!playlist->position) { | |
3481 if (cfg.shuffle) | |
3482 playlist->position = playlist->shuffle->data; | |
3483 else | |
3484 playlist->position = playlist->entries->data; | |
3485 } | |
3486 | |
3468
440877c9360e
Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents:
3467
diff
changeset
|
3487 PLAYLIST_UNLOCK(playlist); |
2313 | 3488 |
3489 return playlist->position; | |
3490 } | |
3474
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3491 |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3492 gboolean |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3493 playlist_playlists_equal(Playlist *p1, Playlist *p2) |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3494 { |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3495 GList *l1, *l2; |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3496 PlaylistEntry *e1, *e2; |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3497 if (!p1 || !p2) return FALSE; |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3498 l1 = p1->entries; |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3499 l2 = p2->entries; |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3500 do { |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3501 if (!l1 && !l2) break; |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3502 if (!l1 || !l2) return FALSE; /* different length */ |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3503 e1 = (PlaylistEntry *) l1->data; |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3504 e2 = (PlaylistEntry *) l2->data; |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3505 if (strcmp(e1->filename, e2->filename) != 0) return FALSE; |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3506 l1 = l1->next; |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3507 l2 = l2->next; |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3508 } while(1); |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3509 return TRUE; |
adc785ee517b
Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents:
3473
diff
changeset
|
3510 } |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
3511 |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3512 static gint |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
3513 filter_by_extension(const gchar *uri) |
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
3514 { |
3945
0b93c2b0cd59
make filter_by_extension() case insensitive.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3934
diff
changeset
|
3515 gchar *base, *ext, *lext, *filename; |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
3516 gchar *tmp = g_filename_from_uri(uri, NULL, NULL); |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3517 gint rv; |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3518 GList **lhandle, *node; |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3519 InputPlugin *ip; |
3945
0b93c2b0cd59
make filter_by_extension() case insensitive.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3934
diff
changeset
|
3520 |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
3521 filename = g_strdup(tmp ? tmp : uri); |
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
3522 g_free(tmp); |
3947
eb20411bb9e1
fixed bug in extension filtering function
mf0102 <0102@gmx.at>
parents:
3945
diff
changeset
|
3523 |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
3524 base = g_path_get_basename(filename); |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
3525 ext = strrchr(base, '.'); |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
3526 |
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
3527 if(!ext) { |
3947
eb20411bb9e1
fixed bug in extension filtering function
mf0102 <0102@gmx.at>
parents:
3945
diff
changeset
|
3528 g_free(base); |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3529 return 0; |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
3530 } |
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
3531 |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
3532 lext = g_ascii_strdown(ext+1, -1); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3947
diff
changeset
|
3533 g_free(base); |
3945
0b93c2b0cd59
make filter_by_extension() case insensitive.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3934
diff
changeset
|
3534 |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3535 lhandle = g_hash_table_lookup(ext_hash, lext); |
3945
0b93c2b0cd59
make filter_by_extension() case insensitive.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3934
diff
changeset
|
3536 g_free(lext); |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3537 |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3538 if(!lhandle) { |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3539 return EXT_FALSE; |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3540 } |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3541 |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3542 for(node = *lhandle; node; node = g_list_next(node)) { |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3543 ip = (InputPlugin *)node->data; |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3544 |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3545 if(ip->have_subtune == TRUE) { |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3546 return EXT_HAVE_SUBTUNE; |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3547 } |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3548 else |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3549 rv = EXT_TRUE; |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3550 } |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3551 |
3945
0b93c2b0cd59
make filter_by_extension() case insensitive.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3934
diff
changeset
|
3552 return rv; |
3934
e924c9ee3958
when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3923
diff
changeset
|
3553 } |
3971
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3554 |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3555 static gboolean |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3556 is_http(const gchar *uri) |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3557 { |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3558 gboolean rv = FALSE; |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3559 |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3560 if(str_has_prefix_nocase(uri, "http://") || |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3561 str_has_prefix_nocase(uri, "https://")) { |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3562 rv = TRUE; |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3563 } |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3564 |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3565 return rv; |
b0ae5dbd2f53
- add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3967
diff
changeset
|
3566 } |