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