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