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