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