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