Mercurial > audlegacy
annotate audacious/playlist.c @ 2170:d0312301163f trunk
[svn] fixed bug #699 about playlist->queue with patch provided by bug reporter
author | giacomo |
---|---|
date | Mon, 18 Dec 2006 14:47:48 -0800 |
parents | caaf4b1a8487 |
children | d1804718c5cc |
rev | line source |
---|---|
0 | 1 /* BMP (C) GPL 2003 $top_src_dir/AUTHORS |
2 * | |
3 * based on: | |
4 * | |
5 * XMMS - Cross-platform multimedia player | |
6 * Copyright (C) 1998-2003 Peter Alm, Mikael Alm, Olle Hallnas, | |
7 * Thomas Nilsson and 4Front Technologies | |
8 * Copyright (C) 1999-2003 Haavard Kvaalen | |
9 * | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
2105
f18a5b617c34
[svn] - move to GPLv2-only. Based on my interpretation of the license, we are
nenolod
parents:
2099
diff
changeset
|
13 * the Free Software Foundation; under version 2 of the License. |
0 | 14 * |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
1459 | 22 * Foundation, Inc., 59 Tmple Place - Suite 330, Boston, MA 02110-1301, USA. |
0 | 23 */ |
24 | |
25 #ifdef HAVE_CONFIG_H | |
26 # include "config.h" | |
27 #endif | |
28 | |
29 #include "playlist.h" | |
30 | |
31 #include <glib.h> | |
32 #include <glib/gprintf.h> | |
33 #include <stdlib.h> | |
34 #include <string.h> | |
35 #include <time.h> | |
36 | |
37 #include <unistd.h> | |
38 #include <sys/types.h> | |
39 #include <sys/stat.h> | |
40 #include <sys/errno.h> | |
2168
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
41 |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
42 #if defined(USE_REGEX_ONIGURUMA) |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
43 #include <onigposix.h> |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
44 #elif defined(USE_REGEX_PCRE) |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
45 #include <pcreposix.h> |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
46 #else |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
47 #include <regex.h> |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
48 #endif |
0 | 49 |
50 #include "input.h" | |
51 #include "main.h" | |
1653 | 52 #include "mainwin.h" |
0 | 53 #include "libaudacious/util.h" |
54 #include "libaudacious/configdb.h" | |
2146
e0e50e151bab
[svn] - move vfs from libaudacious to main audacious
nenolod
parents:
2143
diff
changeset
|
55 #include "vfs.h" |
2073 | 56 #include "libaudacious/urldecode.h" |
1653 | 57 #include "equalizer.h" |
538
e4e897d20791
[svn] remove libaudcore, we never did anything with it
nenolod
parents:
418
diff
changeset
|
58 #include "playback.h" |
0 | 59 #include "playlist.h" |
1550 | 60 #include "playlist_container.h" |
1653 | 61 #include "ui_playlist.h" |
0 | 62 #include "util.h" |
1269 | 63 #include "ui_fileinfo.h" |
0 | 64 |
65 #include "debug.h" | |
66 | |
1251 | 67 typedef gint (*PlaylistCompareFunc) (PlaylistEntry * a, PlaylistEntry * b); |
0 | 68 typedef void (*PlaylistSaveFunc) (FILE * file); |
69 | |
2040
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
70 /* If we manually change the song, p_p_b_j will show us where to go back to */ |
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
71 PlaylistEntry *playlist_position_before_jump = NULL; |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
72 |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
73 static GList *playlists = NULL; |
2120
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
74 static GList *playlists_iter; |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
75 |
397
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
76 /* If this is set to TRUE, we do not probe upon playlist add. |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
77 * |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
78 * Under Audacious 0.1.x, this was not a big deal because we used |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
79 * file extension introspection instead of looking for file format magic |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
80 * strings. |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
81 * |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
82 * Because we use file magic strings, we have to fstat a file being added |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
83 * to a playlist up to 1 * <number of input plugins installed> times. |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
84 * |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
85 * This can get really slow now that we're looking for files to add to a |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
86 * playlist. (Up to 5 minutes for 5000 songs, etcetera.) |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
87 * |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
88 * So, we obviously don't want to probe while opening a large playlist |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
89 * up. Hince the boolean below. |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
90 * |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
91 * January 7, 2006, William Pitcock <nenolod@nenolod.net> |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
92 */ |
0 | 93 |
94 G_LOCK_DEFINE(playlist_get_info_going); | |
95 | |
96 static gchar *playlist_current_name = NULL; | |
97 | |
98 static gboolean playlist_get_info_scan_active = FALSE; | |
99 static gboolean playlist_get_info_going = FALSE; | |
100 static GThread *playlist_get_info_thread; | |
101 | |
102 static gint path_compare(const gchar * a, const gchar * b); | |
1251 | 103 static gint playlist_compare_path(PlaylistEntry * a, PlaylistEntry * b); |
104 static gint playlist_compare_filename(PlaylistEntry * a, PlaylistEntry * b); | |
105 static gint playlist_compare_title(PlaylistEntry * a, PlaylistEntry * b); | |
106 static gint playlist_compare_artist(PlaylistEntry * a, PlaylistEntry * b); | |
1588
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
107 static time_t playlist_get_mtime(const gchar *filename); |
1251 | 108 static gint playlist_compare_date(PlaylistEntry * a, PlaylistEntry * b); |
1415 | 109 static gint playlist_compare_track(PlaylistEntry * a, PlaylistEntry * b); |
1430
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
110 static gint playlist_compare_playlist(PlaylistEntry * a, PlaylistEntry * b); |
1251 | 111 |
112 static gint playlist_dupscmp_path(PlaylistEntry * a, PlaylistEntry * b); | |
113 static gint playlist_dupscmp_filename(PlaylistEntry * a, PlaylistEntry * b); | |
114 static gint playlist_dupscmp_title(PlaylistEntry * a, PlaylistEntry * b); | |
852
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
115 |
0 | 116 static PlaylistCompareFunc playlist_compare_func_table[] = { |
117 playlist_compare_path, | |
118 playlist_compare_filename, | |
119 playlist_compare_title, | |
1251 | 120 playlist_compare_artist, |
1415 | 121 playlist_compare_date, |
1430
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
122 playlist_compare_track, |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
123 playlist_compare_playlist |
0 | 124 }; |
125 | |
2083 | 126 static guint playlist_load_ins(Playlist * playlist, const gchar * filename, gint pos); |
0 | 127 |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
128 static void playlist_generate_shuffle_list(Playlist *); |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
129 static void playlist_generate_shuffle_list_nolock(Playlist *); |
0 | 130 |
2085 | 131 static void playlist_recalc_total_time_nolock(Playlist *); |
132 static void playlist_recalc_total_time(Playlist *); | |
1825 | 133 static gboolean playlist_entry_get_info(PlaylistEntry * entry); |
0 | 134 |
2120
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
135 /* *********************** playlist entry code ********************** */ |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
136 |
0 | 137 PlaylistEntry * |
138 playlist_entry_new(const gchar * filename, | |
139 const gchar * title, | |
355
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
140 const gint length, |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
141 InputPlugin * dec) |
0 | 142 { |
143 PlaylistEntry *entry; | |
144 | |
145 entry = g_new0(PlaylistEntry, 1); | |
146 entry->filename = g_strdup(filename); | |
147 entry->title = str_to_utf8(title); | |
148 entry->length = length; | |
149 entry->selected = FALSE; | |
355
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
150 entry->decoder = dec; |
0 | 151 |
1825 | 152 /* only do this if we have a decoder, otherwise it just takes too long */ |
1824 | 153 if (entry->decoder) |
1825 | 154 playlist_entry_get_info(entry); |
1824 | 155 |
0 | 156 return entry; |
157 } | |
158 | |
159 void | |
160 playlist_entry_free(PlaylistEntry * entry) | |
161 { | |
162 if (!entry) | |
163 return; | |
164 | |
1588
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
165 if (entry->tuple != NULL) { |
1232 | 166 bmp_title_input_free(entry->tuple); |
1588
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
167 entry->tuple = NULL; |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
168 } |
1232 | 169 |
170 if (entry->filename != NULL) | |
171 g_free(entry->filename); | |
172 | |
173 if (entry->title != NULL) | |
174 g_free(entry->title); | |
175 | |
0 | 176 g_free(entry); |
177 } | |
178 | |
179 static gboolean | |
180 playlist_entry_get_info(PlaylistEntry * entry) | |
181 { | |
1232 | 182 TitleInput *tuple; |
1711
c7c1e346bb55
[svn] - no more busy loop if a file in playlist disappears.
yaz
parents:
1706
diff
changeset
|
183 time_t modtime; |
0 | 184 |
185 g_return_val_if_fail(entry != NULL, FALSE); | |
186 | |
1841
7d0cd3fab6a2
[svn] - mtime=-1 has been introduced to represent "uninitialized".
yaz
parents:
1834
diff
changeset
|
187 if (entry->tuple == NULL || entry->tuple->mtime > 0 || entry->tuple->mtime == -1) |
1824 | 188 modtime = playlist_get_mtime(entry->filename); |
189 else | |
190 modtime = 0; /* URI -nenolod */ | |
1711
c7c1e346bb55
[svn] - no more busy loop if a file in playlist disappears.
yaz
parents:
1706
diff
changeset
|
191 |
1690
bb1323938306
[svn] - fix for issue that was fixed in r1946 and then appeared again later :)
giacomo
parents:
1653
diff
changeset
|
192 if (entry->decoder == NULL) |
bb1323938306
[svn] - fix for issue that was fixed in r1946 and then appeared again later :)
giacomo
parents:
1653
diff
changeset
|
193 entry->decoder = input_check_file(entry->filename, FALSE); |
bb1323938306
[svn] - fix for issue that was fixed in r1946 and then appeared again later :)
giacomo
parents:
1653
diff
changeset
|
194 |
1588
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
195 /* renew tuple if file mtime is newer than tuple mtime. */ |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
196 if(entry->tuple){ |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
197 if(entry->tuple->mtime == modtime) |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
198 return TRUE; |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
199 else { |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
200 bmp_title_input_free(entry->tuple); |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
201 entry->tuple = NULL; |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
202 } |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
203 } |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
204 |
1232 | 205 if (entry->decoder == NULL || entry->decoder->get_song_tuple == NULL) |
206 tuple = input_get_song_tuple(entry->filename); | |
207 else | |
208 tuple = entry->decoder->get_song_tuple(entry->filename); | |
209 | |
210 if (tuple == NULL) | |
0 | 211 return FALSE; |
212 | |
1588
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
213 /* attach mtime */ |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
214 tuple->mtime = modtime; |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
215 |
0 | 216 /* entry is still around */ |
1356 | 217 entry->title = xmms_get_titlestring(tuple->formatter != NULL ? tuple->formatter : xmms_get_gentitle_format(), tuple); |
1232 | 218 entry->length = tuple->length; |
219 entry->tuple = tuple; | |
0 | 220 |
221 return TRUE; | |
222 } | |
223 | |
2120
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
224 /* *********************** playlist selector code ************************* */ |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
225 |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
226 void |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
227 playlist_init(void) |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
228 { |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
229 Playlist *initial_pl; |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
230 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
231 /* FIXME: is this really necessary? REQUIRE_STATIC_LOCK(playlists); */ |
2120
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
232 |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
233 initial_pl = playlist_new(); |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
234 |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
235 playlist_add_playlist(initial_pl); |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
236 } |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
237 |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
238 void |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
239 playlist_add_playlist(Playlist *playlist) |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
240 { |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
241 playlists = g_list_append(playlists, playlist); |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
242 |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
243 if (playlists_iter == NULL) |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
244 playlists_iter = playlists; |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
245 } |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
246 |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
247 void |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
248 playlist_remove_playlist(Playlist *playlist) |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
249 { |
2142
959722e6e277
[svn] - clear and free a playlist passed to playlist_remove_playlist
giacomo
parents:
2141
diff
changeset
|
250 /* upon removal, a playlist should be cleared and freed */ |
2120
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
251 playlists = g_list_remove(playlists, playlist); |
2142
959722e6e277
[svn] - clear and free a playlist passed to playlist_remove_playlist
giacomo
parents:
2141
diff
changeset
|
252 playlist_clear(playlist); |
959722e6e277
[svn] - clear and free a playlist passed to playlist_remove_playlist
giacomo
parents:
2141
diff
changeset
|
253 playlist_free(playlist); |
2120
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
254 |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
255 if (playlists_iter == NULL) |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
256 playlists_iter = playlists; |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
257 } |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
258 |
2141
06a86fdd4fb7
[svn] added playlist_free and ensure that each created playlist is freed in mainwin_quit_cb; the list of playlists is freed there as well
giacomo
parents:
2140
diff
changeset
|
259 GList * |
06a86fdd4fb7
[svn] added playlist_free and ensure that each created playlist is freed in mainwin_quit_cb; the list of playlists is freed there as well
giacomo
parents:
2140
diff
changeset
|
260 playlist_get_playlists(void) |
06a86fdd4fb7
[svn] added playlist_free and ensure that each created playlist is freed in mainwin_quit_cb; the list of playlists is freed there as well
giacomo
parents:
2140
diff
changeset
|
261 { |
06a86fdd4fb7
[svn] added playlist_free and ensure that each created playlist is freed in mainwin_quit_cb; the list of playlists is freed there as well
giacomo
parents:
2140
diff
changeset
|
262 return playlists; |
06a86fdd4fb7
[svn] added playlist_free and ensure that each created playlist is freed in mainwin_quit_cb; the list of playlists is freed there as well
giacomo
parents:
2140
diff
changeset
|
263 } |
06a86fdd4fb7
[svn] added playlist_free and ensure that each created playlist is freed in mainwin_quit_cb; the list of playlists is freed there as well
giacomo
parents:
2140
diff
changeset
|
264 |
2123
97e2cbd87df0
[svn] - add playlist_select_next(), playlist_select_prev()
nenolod
parents:
2122
diff
changeset
|
265 void |
97e2cbd87df0
[svn] - add playlist_select_next(), playlist_select_prev()
nenolod
parents:
2122
diff
changeset
|
266 playlist_select_next(void) |
97e2cbd87df0
[svn] - add playlist_select_next(), playlist_select_prev()
nenolod
parents:
2122
diff
changeset
|
267 { |
2124
83c9caf0c554
[svn] - add some basic code for the manipulation of temporary playlists
nenolod
parents:
2123
diff
changeset
|
268 if (playlists_iter == NULL) |
83c9caf0c554
[svn] - add some basic code for the manipulation of temporary playlists
nenolod
parents:
2123
diff
changeset
|
269 playlists_iter = playlists; |
83c9caf0c554
[svn] - add some basic code for the manipulation of temporary playlists
nenolod
parents:
2123
diff
changeset
|
270 |
83c9caf0c554
[svn] - add some basic code for the manipulation of temporary playlists
nenolod
parents:
2123
diff
changeset
|
271 playlists_iter = g_list_next(playlists_iter); |
2123
97e2cbd87df0
[svn] - add playlist_select_next(), playlist_select_prev()
nenolod
parents:
2122
diff
changeset
|
272 |
97e2cbd87df0
[svn] - add playlist_select_next(), playlist_select_prev()
nenolod
parents:
2122
diff
changeset
|
273 if (playlists_iter == NULL) |
97e2cbd87df0
[svn] - add playlist_select_next(), playlist_select_prev()
nenolod
parents:
2122
diff
changeset
|
274 playlists_iter = playlists; |
97e2cbd87df0
[svn] - add playlist_select_next(), playlist_select_prev()
nenolod
parents:
2122
diff
changeset
|
275 |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
276 playlistwin_update_list(playlist_get_active()); |
2123
97e2cbd87df0
[svn] - add playlist_select_next(), playlist_select_prev()
nenolod
parents:
2122
diff
changeset
|
277 } |
97e2cbd87df0
[svn] - add playlist_select_next(), playlist_select_prev()
nenolod
parents:
2122
diff
changeset
|
278 |
97e2cbd87df0
[svn] - add playlist_select_next(), playlist_select_prev()
nenolod
parents:
2122
diff
changeset
|
279 void |
97e2cbd87df0
[svn] - add playlist_select_next(), playlist_select_prev()
nenolod
parents:
2122
diff
changeset
|
280 playlist_select_prev(void) |
97e2cbd87df0
[svn] - add playlist_select_next(), playlist_select_prev()
nenolod
parents:
2122
diff
changeset
|
281 { |
2124
83c9caf0c554
[svn] - add some basic code for the manipulation of temporary playlists
nenolod
parents:
2123
diff
changeset
|
282 if (playlists_iter == NULL) |
83c9caf0c554
[svn] - add some basic code for the manipulation of temporary playlists
nenolod
parents:
2123
diff
changeset
|
283 playlists_iter = playlists; |
83c9caf0c554
[svn] - add some basic code for the manipulation of temporary playlists
nenolod
parents:
2123
diff
changeset
|
284 |
83c9caf0c554
[svn] - add some basic code for the manipulation of temporary playlists
nenolod
parents:
2123
diff
changeset
|
285 playlists_iter = g_list_previous(playlists_iter); |
2123
97e2cbd87df0
[svn] - add playlist_select_next(), playlist_select_prev()
nenolod
parents:
2122
diff
changeset
|
286 |
97e2cbd87df0
[svn] - add playlist_select_next(), playlist_select_prev()
nenolod
parents:
2122
diff
changeset
|
287 if (playlists_iter == NULL) |
97e2cbd87df0
[svn] - add playlist_select_next(), playlist_select_prev()
nenolod
parents:
2122
diff
changeset
|
288 playlists_iter = playlists; |
97e2cbd87df0
[svn] - add playlist_select_next(), playlist_select_prev()
nenolod
parents:
2122
diff
changeset
|
289 |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
290 playlistwin_update_list(playlist_get_active()); |
2123
97e2cbd87df0
[svn] - add playlist_select_next(), playlist_select_prev()
nenolod
parents:
2122
diff
changeset
|
291 } |
97e2cbd87df0
[svn] - add playlist_select_next(), playlist_select_prev()
nenolod
parents:
2122
diff
changeset
|
292 |
2127
63af5b9c5026
[svn] - add playlist_select_playlist() to select a literal playlist
nenolod
parents:
2126
diff
changeset
|
293 void |
63af5b9c5026
[svn] - add playlist_select_playlist() to select a literal playlist
nenolod
parents:
2126
diff
changeset
|
294 playlist_select_playlist(Playlist *playlist) |
63af5b9c5026
[svn] - add playlist_select_playlist() to select a literal playlist
nenolod
parents:
2126
diff
changeset
|
295 { |
63af5b9c5026
[svn] - add playlist_select_playlist() to select a literal playlist
nenolod
parents:
2126
diff
changeset
|
296 if (playlists_iter == NULL) |
63af5b9c5026
[svn] - add playlist_select_playlist() to select a literal playlist
nenolod
parents:
2126
diff
changeset
|
297 playlists_iter = playlists; |
63af5b9c5026
[svn] - add playlist_select_playlist() to select a literal playlist
nenolod
parents:
2126
diff
changeset
|
298 |
63af5b9c5026
[svn] - add playlist_select_playlist() to select a literal playlist
nenolod
parents:
2126
diff
changeset
|
299 playlists_iter = g_list_find(playlists, playlist); |
63af5b9c5026
[svn] - add playlist_select_playlist() to select a literal playlist
nenolod
parents:
2126
diff
changeset
|
300 |
63af5b9c5026
[svn] - add playlist_select_playlist() to select a literal playlist
nenolod
parents:
2126
diff
changeset
|
301 if (playlists_iter == NULL) |
63af5b9c5026
[svn] - add playlist_select_playlist() to select a literal playlist
nenolod
parents:
2126
diff
changeset
|
302 playlists_iter = playlists; |
63af5b9c5026
[svn] - add playlist_select_playlist() to select a literal playlist
nenolod
parents:
2126
diff
changeset
|
303 |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
304 playlistwin_update_list(playlist); |
2127
63af5b9c5026
[svn] - add playlist_select_playlist() to select a literal playlist
nenolod
parents:
2126
diff
changeset
|
305 } |
63af5b9c5026
[svn] - add playlist_select_playlist() to select a literal playlist
nenolod
parents:
2126
diff
changeset
|
306 |
2120
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
307 /* *********************** playlist code ********************** */ |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
308 |
0 | 309 const gchar * |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
310 playlist_get_current_name(Playlist *playlist) |
0 | 311 { |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
312 return playlist->title; |
0 | 313 } |
314 | |
315 gboolean | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
316 playlist_set_current_name(Playlist *playlist, const gchar * filename) |
0 | 317 { |
2120
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
318 if (playlist->title) |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
319 g_free(playlist->title); |
0 | 320 |
321 if (!filename) { | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
322 playlist->title = NULL; |
0 | 323 return FALSE; |
324 } | |
325 | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
326 playlist->title = g_strdup(filename); |
0 | 327 return TRUE; |
328 } | |
329 | |
330 static GList * | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
331 find_playlist_position_list(Playlist *playlist) |
0 | 332 { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
333 REQUIRE_LOCK(playlist->mutex); |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
334 |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
335 if (!playlist->position) { |
0 | 336 if (cfg.shuffle) |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
337 return playlist->shuffle; |
0 | 338 else |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
339 return playlist->entries; |
0 | 340 } |
341 | |
342 if (cfg.shuffle) | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
343 return g_list_find(playlist->shuffle, playlist->position); |
0 | 344 else |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
345 return g_list_find(playlist->entries, playlist->position); |
0 | 346 } |
347 | |
348 static void | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
349 play_queued(Playlist *playlist) |
0 | 350 { |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
351 GList *tmp = playlist->queue; |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
352 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
353 REQUIRE_LOCK( playlist->mutex ); |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
354 |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
355 playlist->position = playlist->queue->data; |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
356 playlist->queue = g_list_remove_link(playlist->queue, playlist->queue); |
0 | 357 g_list_free_1(tmp); |
358 } | |
359 | |
360 void | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
361 playlist_clear(Playlist *playlist) |
0 | 362 { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
363 if (!playlist) |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
364 return; |
0 | 365 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
366 PLAYLIST_LOCK( playlist->mutex ); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
367 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
368 g_list_foreach(playlist->entries, (GFunc) playlist_entry_free, NULL); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
369 g_list_free(playlist->entries); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
370 playlist->position = NULL; |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
371 playlist->entries = NULL; |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
372 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
373 PLAYLIST_UNLOCK( playlist->mutex ); |
0 | 374 |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
375 playlist_generate_shuffle_list(playlist); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
376 playlistwin_update_list(playlist); |
2085 | 377 playlist_recalc_total_time(playlist); |
0 | 378 } |
379 | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
380 static void |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
381 playlist_delete_node(Playlist * playlist, GList * node, gboolean * set_info_text, |
0 | 382 gboolean * restart_playing) |
383 { | |
384 PlaylistEntry *entry; | |
385 GList *playing_song = NULL; | |
386 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
387 REQUIRE_LOCK(playlist->mutex); |
0 | 388 |
389 /* We call g_list_find manually here because we don't want an item | |
390 * in the shuffle_list */ | |
391 | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
392 if (playlist->position) |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
393 playing_song = g_list_find(playlist->entries, playlist->position); |
0 | 394 |
395 entry = PLAYLIST_ENTRY(node->data); | |
396 | |
397 if (playing_song == node) { | |
398 *set_info_text = TRUE; | |
399 | |
400 if (bmp_playback_get_playing()) { | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
401 PLAYLIST_UNLOCK(playlist->mutex); |
905 | 402 ip_data.stop = TRUE; |
0 | 403 bmp_playback_stop(); |
905 | 404 ip_data.stop = FALSE; |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
405 PLAYLIST_LOCK(playlist->mutex); |
0 | 406 *restart_playing = TRUE; |
407 } | |
408 | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
409 playing_song = find_playlist_position_list(playlist); |
0 | 410 |
411 if (g_list_next(playing_song)) | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
412 playlist->position = g_list_next(playing_song)->data; |
0 | 413 else if (g_list_previous(playing_song)) |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
414 playlist->position = g_list_previous(playing_song)->data; |
0 | 415 else |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
416 playlist->position = NULL; |
0 | 417 |
418 /* Make sure the entry did not disappear under us */ | |
2081
b98891c9e155
[svn] - update playlist_delete_filenames() and friends
nenolod
parents:
2080
diff
changeset
|
419 if (g_list_index(playlist->entries, entry) == -1) |
0 | 420 return; |
421 | |
422 } | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
423 else if (g_list_position(playlist->entries, playing_song) > |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
424 g_list_position(playlist->entries, node)) { |
0 | 425 *set_info_text = TRUE; |
426 } | |
427 | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
428 playlist->shuffle = g_list_remove(playlist->shuffle, entry); |
2170
d0312301163f
[svn] fixed bug #699 about playlist->queue with patch provided by bug reporter
giacomo
parents:
2168
diff
changeset
|
429 playlist->queue = g_list_remove(playlist->queue, entry); |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
430 playlist->entries = g_list_remove_link(playlist->entries, node); |
0 | 431 playlist_entry_free(entry); |
432 g_list_free_1(node); | |
433 | |
2085 | 434 playlist_recalc_total_time_nolock(playlist); |
0 | 435 } |
436 | |
437 void | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
438 playlist_delete_index(Playlist *playlist, guint pos) |
0 | 439 { |
440 gboolean restart_playing = FALSE, set_info_text = FALSE; | |
441 GList *node; | |
442 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
443 if (!playlist) |
0 | 444 return; |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
445 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
446 PLAYLIST_LOCK(playlist->mutex); |
0 | 447 |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
448 node = g_list_nth(playlist->entries, pos); |
0 | 449 |
450 if (!node) { | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
451 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 452 return; |
453 } | |
454 | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
455 playlist_delete_node(playlist, node, &set_info_text, &restart_playing); |
0 | 456 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
457 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 458 |
2085 | 459 playlist_recalc_total_time(playlist); |
0 | 460 |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
461 playlistwin_update_list(playlist); |
0 | 462 if (restart_playing) { |
2096 | 463 if (playlist->position) { |
0 | 464 bmp_playback_initiate(); |
465 } | |
466 else { | |
467 mainwin_clear_song_info(); | |
468 } | |
469 } | |
470 else if (set_info_text) { | |
471 mainwin_set_info_text(); | |
472 } | |
473 } | |
474 | |
475 void | |
2081
b98891c9e155
[svn] - update playlist_delete_filenames() and friends
nenolod
parents:
2080
diff
changeset
|
476 playlist_delete_filenames(Playlist * playlist, GList * filenames) |
0 | 477 { |
478 GList *node, *fnode; | |
479 gboolean set_info_text = FALSE, restart_playing = FALSE; | |
480 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
481 PLAYLIST_LOCK(playlist->mutex); |
0 | 482 |
483 for (fnode = filenames; fnode; fnode = g_list_next(fnode)) { | |
2082 | 484 node = playlist->entries; |
0 | 485 |
486 while (node) { | |
487 GList *next = g_list_next(node); | |
488 PlaylistEntry *entry = node->data; | |
489 | |
490 if (!strcmp(entry->filename, fnode->data)) | |
2081
b98891c9e155
[svn] - update playlist_delete_filenames() and friends
nenolod
parents:
2080
diff
changeset
|
491 playlist_delete_node(playlist, node, &set_info_text, &restart_playing); |
0 | 492 |
493 node = next; | |
494 } | |
495 } | |
496 | |
2085 | 497 playlist_recalc_total_time(playlist); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
498 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 499 |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
500 playlistwin_update_list(playlist); |
0 | 501 |
502 if (restart_playing) { | |
2096 | 503 if (playlist->position) { |
0 | 504 bmp_playback_initiate(); |
505 } | |
506 else { | |
507 mainwin_clear_song_info(); | |
508 } | |
509 } | |
510 else if (set_info_text) { | |
511 mainwin_set_info_text(); | |
512 } | |
513 | |
514 } | |
515 | |
516 void | |
2081
b98891c9e155
[svn] - update playlist_delete_filenames() and friends
nenolod
parents:
2080
diff
changeset
|
517 playlist_delete(Playlist * playlist, gboolean crop) |
0 | 518 { |
519 gboolean restart_playing = FALSE, set_info_text = FALSE; | |
520 GList *node, *next_node; | |
521 PlaylistEntry *entry; | |
522 | |
2081
b98891c9e155
[svn] - update playlist_delete_filenames() and friends
nenolod
parents:
2080
diff
changeset
|
523 g_return_if_fail(playlist != NULL); |
b98891c9e155
[svn] - update playlist_delete_filenames() and friends
nenolod
parents:
2080
diff
changeset
|
524 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
525 PLAYLIST_LOCK(playlist->mutex); |
0 | 526 |
2081
b98891c9e155
[svn] - update playlist_delete_filenames() and friends
nenolod
parents:
2080
diff
changeset
|
527 node = playlist->entries; |
0 | 528 |
529 while (node) { | |
530 entry = PLAYLIST_ENTRY(node->data); | |
531 | |
532 next_node = g_list_next(node); | |
533 | |
534 if ((entry->selected && !crop) || (!entry->selected && crop)) { | |
2081
b98891c9e155
[svn] - update playlist_delete_filenames() and friends
nenolod
parents:
2080
diff
changeset
|
535 playlist_delete_node(playlist, node, &set_info_text, &restart_playing); |
0 | 536 } |
537 | |
538 node = next_node; | |
539 } | |
540 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
541 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 542 |
2085 | 543 playlist_recalc_total_time(playlist); |
0 | 544 |
545 if (set_info_text) { | |
546 mainwin_set_info_text(); | |
547 } | |
548 | |
549 if (restart_playing) { | |
2096 | 550 if (playlist->position) { |
0 | 551 bmp_playback_initiate(); |
552 } | |
553 else { | |
554 mainwin_clear_song_info(); | |
555 } | |
556 } | |
557 | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
558 playlistwin_update_list(playlist); |
0 | 559 } |
560 | |
561 static void | |
2082 | 562 __playlist_ins_with_info(Playlist * playlist, |
563 const gchar * filename, | |
0 | 564 gint pos, |
565 const gchar * title, | |
355
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
566 gint len, |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
567 InputPlugin * dec) |
0 | 568 { |
569 g_return_if_fail(filename != NULL); | |
570 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
571 PLAYLIST_LOCK(playlist->mutex); |
2082 | 572 playlist->entries = g_list_insert(playlist->entries, |
355
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
573 playlist_entry_new(filename, title, len, dec), |
0 | 574 pos); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
575 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 576 |
2026 | 577 g_mutex_lock(mutex_scan); |
0 | 578 playlist_get_info_scan_active = TRUE; |
2026 | 579 g_mutex_unlock(mutex_scan); |
580 g_cond_signal(cond_scan); | |
0 | 581 } |
582 | |
583 static void | |
2082 | 584 __playlist_ins_with_info_tuple(Playlist * playlist, |
585 const gchar * filename, | |
1584 | 586 gint pos, |
587 TitleInput *tuple, | |
588 InputPlugin * dec) | |
589 { | |
590 GList *node; | |
591 PlaylistEntry *entry; | |
592 | |
2082 | 593 g_return_if_fail(playlist != NULL); |
1584 | 594 g_return_if_fail(filename != NULL); |
595 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
596 PLAYLIST_LOCK(playlist->mutex); |
2082 | 597 playlist->entries = g_list_insert(playlist->entries, |
1584 | 598 playlist_entry_new(filename, tuple->track_name, tuple->length, dec), |
599 pos); | |
600 | |
2082 | 601 if (pos < 0) |
602 pos = g_list_length(playlist->entries) - 1; /* last element. */ | |
603 | |
604 node = g_list_nth(playlist->entries, pos); | |
1584 | 605 entry = PLAYLIST_ENTRY(node->data); |
606 | |
1587
c073fd82ded6
[svn] - Don't explode when loading http streams from xspf files.
nhjm449
parents:
1584
diff
changeset
|
607 if (tuple != NULL) { |
c073fd82ded6
[svn] - Don't explode when loading http streams from xspf files.
nhjm449
parents:
1584
diff
changeset
|
608 entry->title = xmms_get_titlestring(tuple->formatter != NULL ? tuple->formatter : xmms_get_gentitle_format(), tuple); |
c073fd82ded6
[svn] - Don't explode when loading http streams from xspf files.
nhjm449
parents:
1584
diff
changeset
|
609 entry->length = tuple->length; |
c073fd82ded6
[svn] - Don't explode when loading http streams from xspf files.
nhjm449
parents:
1584
diff
changeset
|
610 entry->tuple = tuple; |
c073fd82ded6
[svn] - Don't explode when loading http streams from xspf files.
nhjm449
parents:
1584
diff
changeset
|
611 } |
1584 | 612 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
613 PLAYLIST_UNLOCK(playlist->mutex); |
1584 | 614 |
2026 | 615 g_mutex_lock(mutex_scan); |
1584 | 616 playlist_get_info_scan_active = TRUE; |
2026 | 617 g_mutex_unlock(mutex_scan); |
618 g_cond_signal(cond_scan); | |
1584 | 619 } |
620 | |
621 static void | |
2082 | 622 __playlist_ins(Playlist * playlist, const gchar * filename, gint pos, InputPlugin *dec) |
0 | 623 { |
2082 | 624 __playlist_ins_with_info(playlist, filename, pos, NULL, -1, dec); |
2085 | 625 playlist_recalc_total_time(playlist); |
0 | 626 } |
627 | |
628 gboolean | |
2082 | 629 playlist_ins(Playlist * playlist, const gchar * filename, gint pos) |
0 | 630 { |
631 gchar buf[64], *p; | |
632 gint r; | |
633 VFSFile *file; | |
355
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
634 InputPlugin *dec; |
0 | 635 |
2082 | 636 g_return_val_if_fail(playlist != NULL, FALSE); |
637 g_return_val_if_fail(filename != NULL, FALSE); | |
638 | |
0 | 639 if (is_playlist_name(filename)) { |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
640 playlist->loading_playlist = TRUE; |
2083 | 641 playlist_load_ins(playlist, filename, pos); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
642 playlist->loading_playlist = FALSE; |
0 | 643 return TRUE; |
644 } | |
645 | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
646 if (playlist->loading_playlist == TRUE || cfg.playlist_detect == TRUE) |
397
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
647 dec = NULL; |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
648 else |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
649 dec = input_check_file(filename, TRUE); |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
650 |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
651 if (cfg.playlist_detect == TRUE || playlist->loading_playlist == TRUE || (playlist->loading_playlist == FALSE && dec != NULL)) |
397
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
652 { |
2082 | 653 __playlist_ins(playlist, filename, pos, dec); |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
654 playlist_generate_shuffle_list(playlist); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
655 playlistwin_update_list(playlist); |
0 | 656 return TRUE; |
657 } | |
658 | |
659 /* Some files (typically produced by some cgi-scripts) don't have | |
660 * the correct extension. Try to recognize these files by looking | |
661 * at their content. We only check for http entries since it does | |
662 * not make sense to have file entries in a playlist fetched from | |
663 * the net. */ | |
664 | |
665 /* Some strange people put fifo's with the .mp3 extension, so we | |
666 * need to make sure it's a real file (otherwise fread() may block | |
667 * and stall the entire program) */ | |
668 | |
669 /* FIXME: bah, FIFOs actually pass this regular file test */ | |
670 if (!vfs_file_test(filename, G_FILE_TEST_IS_REGULAR)) | |
671 return FALSE; | |
672 | |
673 if (!(file = vfs_fopen(filename, "rb"))) | |
674 return FALSE; | |
675 | |
676 r = vfs_fread(buf, 1, sizeof(buf), file); | |
677 vfs_fclose(file); | |
678 | |
679 for (p = buf; r-- > 0 && (*p == '\r' || *p == '\n'); p++); | |
680 | |
681 if (r > 5 && str_has_prefix_nocase(p, "http:")) { | |
2083 | 682 playlist_load_ins(playlist, filename, pos); |
0 | 683 return TRUE; |
684 } | |
685 | |
686 return FALSE; | |
687 } | |
688 | |
689 /* FIXME: The next few functions are specific to Unix | |
690 * filesystems. Either abstract it away, or don't even bother checking | |
691 * at such low level */ | |
692 | |
693 typedef struct { | |
694 dev_t dev; | |
695 ino_t ino; | |
696 } DeviceInode; | |
697 | |
698 static DeviceInode * | |
699 devino_new(dev_t device, | |
700 ino_t inode) | |
701 { | |
702 DeviceInode *devino = g_new0(DeviceInode, 1); | |
703 | |
704 if (devino) | |
705 { | |
706 devino->dev = device; | |
707 devino->ino = inode; | |
708 } | |
709 | |
710 return devino; | |
711 } | |
712 | |
713 static guint | |
714 devino_hash(gconstpointer key) | |
715 { | |
716 const DeviceInode *d = key; | |
717 return d->ino; | |
718 } | |
719 | |
720 static gint | |
721 devino_compare(gconstpointer a, | |
722 gconstpointer b) | |
723 { | |
724 const DeviceInode *da = a, *db = b; | |
725 return (da->dev == db->dev && da->ino == db->ino); | |
726 } | |
727 | |
728 static gboolean | |
729 devino_destroy(gpointer key, | |
730 gpointer value, | |
731 gpointer data) | |
732 { | |
733 g_free(key); | |
734 return TRUE; | |
735 } | |
736 | |
737 static gboolean | |
738 file_is_hidden(const gchar * filename) | |
739 { | |
740 // FIXME: remove the const cast | |
741 g_return_val_if_fail(filename != NULL, FALSE); | |
742 return (g_basename((gchar *) filename)[0] == '.'); | |
743 } | |
744 | |
745 static GList * | |
746 playlist_dir_find_files(const gchar * path, | |
747 gboolean background, | |
748 GHashTable * htab) | |
749 { | |
750 GDir *dir; | |
751 GList *list = NULL, *ilist; | |
752 const gchar *dir_entry; | |
753 | |
754 struct stat statbuf; | |
755 DeviceInode *devino; | |
756 | |
757 if (!g_file_test(path, G_FILE_TEST_IS_DIR)) | |
758 return NULL; | |
759 | |
760 stat(path, &statbuf); | |
761 devino = devino_new(statbuf.st_dev, statbuf.st_ino); | |
762 | |
763 if (g_hash_table_lookup(htab, devino)) { | |
764 g_free(devino); | |
765 return NULL; | |
766 } | |
767 | |
768 g_hash_table_insert(htab, devino, GINT_TO_POINTER(1)); | |
769 | |
770 if ((ilist = input_scan_dir(path))) { | |
771 GList *node; | |
772 for (node = ilist; node; node = g_list_next(node)) { | |
773 gchar *name = g_build_filename(path, node->data, NULL); | |
774 list = g_list_prepend(list, name); | |
775 g_free(node->data); | |
776 } | |
777 g_list_free(ilist); | |
778 return list; | |
779 } | |
780 | |
781 if (!(dir = g_dir_open(path, 0, NULL))) | |
782 return NULL; | |
783 | |
784 while ((dir_entry = g_dir_read_name(dir))) { | |
785 gchar *filename; | |
786 | |
787 if (file_is_hidden(dir_entry)) | |
788 continue; | |
789 | |
790 filename = g_build_filename(path, dir_entry, NULL); | |
791 | |
792 if (g_file_test(filename, G_FILE_TEST_IS_DIR)) { | |
793 GList *sub; | |
794 sub = playlist_dir_find_files(filename, background, htab); | |
795 g_free(filename); | |
796 list = g_list_concat(list, sub); | |
797 } | |
1165 | 798 else if (cfg.playlist_detect == TRUE) |
799 list = g_list_prepend(list, filename); | |
0 | 800 else if (input_check_file(filename, TRUE)) |
801 list = g_list_prepend(list, filename); | |
802 else | |
803 g_free(filename); | |
804 | |
805 while (background && gtk_events_pending()) | |
806 gtk_main_iteration(); | |
807 } | |
808 g_dir_close(dir); | |
809 | |
810 return list; | |
811 } | |
812 | |
813 gboolean | |
2082 | 814 playlist_add(Playlist * playlist, const gchar * filename) |
0 | 815 { |
2082 | 816 return playlist_ins(playlist, filename, -1); |
0 | 817 } |
818 | |
819 guint | |
2083 | 820 playlist_add_dir(Playlist * playlist, const gchar * directory) |
0 | 821 { |
2083 | 822 return playlist_ins_dir(playlist, directory, -1, TRUE); |
0 | 823 } |
824 | |
825 guint | |
2083 | 826 playlist_add_url(Playlist * playlist, const gchar * url) |
0 | 827 { |
2083 | 828 return playlist_ins_url(playlist, url, -1); |
0 | 829 } |
830 | |
831 guint | |
2083 | 832 playlist_ins_dir(Playlist * playlist, const gchar * path, |
0 | 833 gint pos, |
834 gboolean background) | |
835 { | |
836 guint entries = 0; | |
837 GList *list, *node; | |
838 GHashTable *htab; | |
839 | |
840 htab = g_hash_table_new(devino_hash, devino_compare); | |
841 | |
842 list = playlist_dir_find_files(path, background, htab); | |
843 list = g_list_sort(list, (GCompareFunc) path_compare); | |
844 | |
845 g_hash_table_foreach_remove(htab, devino_destroy, NULL); | |
846 | |
847 for (node = list; node; node = g_list_next(node)) { | |
2083 | 848 __playlist_ins(playlist, node->data, pos, NULL); |
0 | 849 g_free(node->data); |
850 entries++; | |
851 if (pos >= 0) | |
852 pos++; | |
853 } | |
854 | |
855 g_list_free(list); | |
856 | |
2085 | 857 playlist_recalc_total_time(playlist); |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
858 playlist_generate_shuffle_list(playlist); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
859 playlistwin_update_list(playlist); |
0 | 860 return entries; |
861 } | |
862 | |
863 guint | |
2083 | 864 playlist_ins_url(Playlist * playlist, const gchar * string, |
0 | 865 gint pos) |
866 { | |
867 gchar *tmp; | |
868 gint i = 1, entries = 0; | |
869 gboolean first = TRUE; | |
870 guint firstpos = 0; | |
871 gboolean success = FALSE; | |
872 gchar *decoded = NULL; | |
873 | |
2083 | 874 g_return_val_if_fail(playlist != NULL, 0); |
0 | 875 g_return_val_if_fail(string != NULL, 0); |
876 | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
877 playlistwin_update_list(playlist); |
0 | 878 |
879 while (*string) { | |
880 GList *node; | |
881 tmp = strchr(string, '\n'); | |
882 if (tmp) { | |
883 if (*(tmp - 1) == '\r') | |
884 *(tmp - 1) = '\0'; | |
885 *tmp = '\0'; | |
886 } | |
887 | |
2010
5f19843a038b
[svn] - xmms_urldecode_path() is no longer needed due to NewVFS layer.
nenolod
parents:
1991
diff
changeset
|
888 decoded = g_strdup(string); |
0 | 889 |
890 if (g_file_test(decoded, G_FILE_TEST_IS_DIR)) { | |
2083 | 891 i = playlist_ins_dir(playlist, decoded, pos, FALSE); |
0 | 892 } |
893 else { | |
894 if (is_playlist_name(decoded)) { | |
2083 | 895 i = playlist_load_ins(playlist, decoded, pos); |
0 | 896 } |
897 else { | |
2083 | 898 success = playlist_ins(playlist, decoded, pos); |
0 | 899 i = 1; |
900 } | |
901 } | |
902 | |
903 g_free(decoded); | |
904 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
905 PLAYLIST_LOCK(playlist->mutex); |
2121
185db04b815f
[svn] - remove all improper uses of playlist_get()
nenolod
parents:
2120
diff
changeset
|
906 node = g_list_nth(playlist->entries, pos); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
907 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 908 |
909 entries += i; | |
910 | |
911 if (first) { | |
912 first = FALSE; | |
913 firstpos = pos; | |
914 } | |
915 | |
916 if (pos >= 0) | |
917 pos += i; | |
918 if (!tmp) | |
919 break; | |
920 | |
921 string = tmp + 1; | |
922 } | |
923 | |
2085 | 924 playlist_recalc_total_time(playlist); |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
925 playlist_generate_shuffle_list(playlist); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
926 playlistwin_update_list(playlist); |
0 | 927 |
928 return entries; | |
929 } | |
930 | |
931 void | |
2098
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
932 playlist_set_info_old_abi(const gchar * title, gint length, gint rate, |
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
933 gint freq, gint nch) |
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
934 { |
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
935 Playlist *playlist = playlist_get_active(); |
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
936 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
937 PLAYLIST_LOCK(playlist->mutex); |
2098
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
938 |
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
939 g_return_if_fail(playlist != NULL); |
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
940 |
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
941 if (playlist->position) { |
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
942 g_free(playlist->position->title); |
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
943 playlist->position->title = g_strdup(title); |
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
944 playlist->position->length = length; |
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
945 } |
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
946 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
947 PLAYLIST_UNLOCK(playlist->mutex); |
2098
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
948 |
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
949 playlist_recalc_total_time(playlist); |
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
950 |
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
951 mainwin_set_song_info(rate, freq, nch); |
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
952 } |
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
953 |
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
954 void |
2083 | 955 playlist_set_info(Playlist * playlist, const gchar * title, gint length, gint rate, |
0 | 956 gint freq, gint nch) |
957 { | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
958 PLAYLIST_LOCK(playlist->mutex); |
0 | 959 |
2083 | 960 g_return_if_fail(playlist != NULL); |
961 | |
962 if (playlist->position) { | |
2098
425963ded156
[svn] - provide the old ABI for plugins (intermediate layer).
nenolod
parents:
2097
diff
changeset
|
963 g_free(playlist->position->title); |
2083 | 964 playlist->position->title = g_strdup(title); |
965 playlist->position->length = length; | |
0 | 966 } |
967 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
968 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 969 |
2085 | 970 playlist_recalc_total_time(playlist); |
0 | 971 |
1653 | 972 mainwin_set_song_info(rate, freq, nch); |
0 | 973 } |
974 | |
975 void | |
2084 | 976 playlist_check_pos_current(Playlist *playlist) |
0 | 977 { |
978 gint pos, row, bottom; | |
979 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
980 if (!playlist) |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
981 return; |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
982 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
983 PLAYLIST_LOCK(playlist->mutex); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
984 if (!playlist->position || !playlistwin_list) { |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
985 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 986 return; |
987 } | |
988 | |
2084 | 989 pos = g_list_index(playlist->entries, playlist->position); |
0 | 990 |
991 if (playlistwin_item_visible(pos)) { | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
992 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 993 return; |
994 } | |
995 | |
2084 | 996 bottom = MAX(0, playlist_get_length_nolock(playlist) - |
0 | 997 playlistwin_list->pl_num_visible); |
998 row = CLAMP(pos - playlistwin_list->pl_num_visible / 2, 0, bottom); | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
999 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1000 playlistwin_set_toprow(row); |
2026 | 1001 g_cond_signal(cond_scan); |
0 | 1002 } |
1003 | |
1004 void | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1005 playlist_next(Playlist *playlist) |
0 | 1006 { |
1007 GList *plist_pos_list; | |
1008 gboolean restart_playing = FALSE; | |
1009 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1010 if (!playlist) |
0 | 1011 return; |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1012 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1013 PLAYLIST_LOCK(playlist->mutex); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1014 |
2084 | 1015 if ((playlist_position_before_jump != NULL) && playlist->queue == NULL) |
2040
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1016 { |
2084 | 1017 playlist->position = playlist_position_before_jump; |
1018 playlist_position_before_jump = NULL; | |
2040
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1019 } |
0 | 1020 |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1021 plist_pos_list = find_playlist_position_list(playlist); |
0 | 1022 |
2084 | 1023 if (!cfg.repeat && !g_list_next(plist_pos_list) && playlist->queue == NULL) { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1024 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1025 return; |
1026 } | |
1027 | |
1028 if (bmp_playback_get_playing()) { | |
1029 /* We need to stop before changing playlist_position */ | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1030 PLAYLIST_UNLOCK(playlist->mutex); |
895
1b919783797e
[svn] - should fix the ability to change songs while paused
nhjm449
parents:
853
diff
changeset
|
1031 ip_data.stop = TRUE; |
0 | 1032 bmp_playback_stop(); |
895
1b919783797e
[svn] - should fix the ability to change songs while paused
nhjm449
parents:
853
diff
changeset
|
1033 ip_data.stop = FALSE; |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1034 PLAYLIST_LOCK(playlist->mutex); |
0 | 1035 restart_playing = TRUE; |
1036 } | |
1037 | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1038 plist_pos_list = find_playlist_position_list(playlist); |
2084 | 1039 if (playlist->queue != NULL) |
1040 play_queued(playlist); | |
0 | 1041 else if (g_list_next(plist_pos_list)) |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1042 playlist->position = g_list_next(plist_pos_list)->data; |
0 | 1043 else if (cfg.repeat) { |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1044 playlist->position = NULL; |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1045 playlist_generate_shuffle_list_nolock(playlist); |
0 | 1046 if (cfg.shuffle) |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1047 playlist->position = playlist->shuffle->data; |
0 | 1048 else |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1049 playlist->position = playlist->entries->data; |
0 | 1050 } |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1051 PLAYLIST_UNLOCK(playlist->mutex); |
2084 | 1052 playlist_check_pos_current(playlist); |
0 | 1053 |
1054 if (restart_playing) | |
1055 bmp_playback_initiate(); | |
1056 else { | |
1057 mainwin_set_info_text(); | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1058 playlistwin_update_list(playlist); |
0 | 1059 } |
1060 } | |
1061 | |
1062 void | |
2084 | 1063 playlist_prev(Playlist *playlist) |
0 | 1064 { |
1065 GList *plist_pos_list; | |
1066 gboolean restart_playing = FALSE; | |
1067 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1068 if (!playlist) |
0 | 1069 return; |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1070 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1071 PLAYLIST_LOCK(playlist->mutex); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1072 |
2084 | 1073 if ((playlist_position_before_jump != NULL) && playlist->queue == NULL) |
2040
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1074 { |
2096 | 1075 playlist->position = playlist_position_before_jump; |
2084 | 1076 playlist_position_before_jump = NULL; |
2040
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1077 } |
0 | 1078 |
2084 | 1079 plist_pos_list = find_playlist_position_list(playlist); |
0 | 1080 |
1081 if (!cfg.repeat && !g_list_previous(plist_pos_list)) { | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1082 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1083 return; |
1084 } | |
1085 | |
1086 if (bmp_playback_get_playing()) { | |
1087 /* We need to stop before changing playlist_position */ | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1088 PLAYLIST_UNLOCK(playlist->mutex); |
895
1b919783797e
[svn] - should fix the ability to change songs while paused
nhjm449
parents:
853
diff
changeset
|
1089 ip_data.stop = TRUE; |
0 | 1090 bmp_playback_stop(); |
895
1b919783797e
[svn] - should fix the ability to change songs while paused
nhjm449
parents:
853
diff
changeset
|
1091 ip_data.stop = FALSE; |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1092 PLAYLIST_LOCK(playlist->mutex); |
0 | 1093 restart_playing = TRUE; |
1094 } | |
1095 | |
2084 | 1096 plist_pos_list = find_playlist_position_list(playlist); |
0 | 1097 if (g_list_previous(plist_pos_list)) { |
2096 | 1098 playlist->position = g_list_previous(plist_pos_list)->data; |
0 | 1099 } |
1100 else if (cfg.repeat) { | |
1101 GList *node; | |
2096 | 1102 playlist->position = NULL; |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1103 playlist_generate_shuffle_list_nolock(playlist); |
0 | 1104 if (cfg.shuffle) |
2084 | 1105 node = g_list_last(playlist->shuffle); |
0 | 1106 else |
2084 | 1107 node = g_list_last(playlist->entries); |
0 | 1108 if (node) |
2096 | 1109 playlist->position = node->data; |
0 | 1110 } |
1111 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1112 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1113 |
2084 | 1114 playlist_check_pos_current(playlist); |
0 | 1115 |
1116 if (restart_playing) | |
1117 bmp_playback_initiate(); | |
1118 else { | |
1119 mainwin_set_info_text(); | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1120 playlistwin_update_list(playlist); |
0 | 1121 } |
1122 } | |
1123 | |
1124 void | |
2084 | 1125 playlist_queue(Playlist *playlist) |
0 | 1126 { |
2084 | 1127 GList *list = playlist_get_selected(playlist); |
0 | 1128 GList *it = list; |
1129 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1130 PLAYLIST_LOCK(playlist->mutex); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1131 |
2040
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1132 if ((cfg.shuffle) && (playlist_position_before_jump == NULL)) |
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1133 { |
2084 | 1134 /* Shuffling and this is our first manual jump. */ |
1135 playlist_position_before_jump = playlist->position; | |
2040
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1136 } |
0 | 1137 |
1138 while (it) { | |
1139 GList *next = g_list_next(it); | |
1140 GList *tmp; | |
1141 | |
2084 | 1142 /* XXX: WTF? --nenolod */ |
1143 it->data = g_list_nth_data(playlist->entries, GPOINTER_TO_INT(it->data)); | |
1144 if ((tmp = g_list_find(playlist->queue, it->data))) { | |
1145 playlist->queue = g_list_remove_link(playlist->queue, tmp); | |
0 | 1146 g_list_free_1(tmp); |
1147 list = g_list_remove_link(list, it); | |
1148 g_list_free_1(it); | |
1149 } | |
1150 | |
1151 it = next; | |
1152 } | |
1153 | |
2084 | 1154 playlist->queue = g_list_concat(playlist->queue, list); |
0 | 1155 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1156 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1157 |
2085 | 1158 playlist_recalc_total_time(playlist); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1159 playlistwin_update_list(playlist); |
0 | 1160 } |
1161 | |
1162 void | |
2084 | 1163 playlist_queue_position(Playlist *playlist, guint pos) |
0 | 1164 { |
1165 GList *tmp; | |
1166 PlaylistEntry *entry; | |
1167 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1168 PLAYLIST_LOCK(playlist->mutex); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1169 |
2040
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1170 if ((cfg.shuffle) && (playlist_position_before_jump == NULL)) |
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1171 { |
2084 | 1172 /* Shuffling and this is our first manual jump. */ |
1173 playlist_position_before_jump = playlist->position; | |
2040
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1174 } |
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1175 |
2084 | 1176 entry = g_list_nth_data(playlist->entries, pos); |
1177 if ((tmp = g_list_find(playlist->queue, entry))) { | |
1178 playlist->queue = g_list_remove_link(playlist->queue, tmp); | |
0 | 1179 g_list_free_1(tmp); |
1180 } | |
1181 else | |
2084 | 1182 playlist->queue = g_list_append(playlist->queue, entry); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1183 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1184 |
2085 | 1185 playlist_recalc_total_time(playlist); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1186 playlistwin_update_list(playlist); |
0 | 1187 } |
1188 | |
1189 gboolean | |
2084 | 1190 playlist_is_position_queued(Playlist *playlist, guint pos) |
0 | 1191 { |
1192 PlaylistEntry *entry; | |
1193 GList *tmp; | |
1194 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1195 PLAYLIST_LOCK(playlist->mutex); |
2084 | 1196 entry = g_list_nth_data(playlist->entries, pos); |
1197 tmp = g_list_find(playlist->queue, entry); | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1198 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1199 |
1200 return tmp != NULL; | |
1201 } | |
1202 | |
984 | 1203 gint |
2084 | 1204 playlist_get_queue_position_number(Playlist *playlist, guint pos) |
984 | 1205 { |
1206 PlaylistEntry *entry; | |
1207 gint tmp; | |
1208 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1209 PLAYLIST_LOCK(playlist->mutex); |
2084 | 1210 entry = g_list_nth_data(playlist->entries, pos); |
1211 tmp = g_list_index(playlist->queue, entry); | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1212 PLAYLIST_UNLOCK(playlist->mutex); |
984 | 1213 |
1214 return tmp; | |
1215 } | |
1216 | |
1217 gint | |
2084 | 1218 playlist_get_queue_qposition_number(Playlist *playlist, guint pos) |
984 | 1219 { |
1220 PlaylistEntry *entry; | |
1221 gint tmp; | |
1222 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1223 PLAYLIST_LOCK(playlist->mutex); |
2084 | 1224 entry = g_list_nth_data(playlist->queue, pos); |
1225 tmp = g_list_index(playlist->entries, entry); | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1226 PLAYLIST_UNLOCK(playlist->mutex); |
984 | 1227 |
1228 return tmp; | |
1229 } | |
1230 | |
0 | 1231 void |
2084 | 1232 playlist_clear_queue(Playlist *playlist) |
0 | 1233 { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1234 PLAYLIST_LOCK(playlist->mutex); |
2084 | 1235 g_list_free(playlist->queue); |
1236 playlist->queue = NULL; | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1237 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1238 |
2085 | 1239 playlist_recalc_total_time(playlist); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1240 playlistwin_update_list(playlist); |
0 | 1241 } |
1242 | |
1243 void | |
2084 | 1244 playlist_queue_remove(Playlist *playlist, guint pos) |
0 | 1245 { |
1246 void *entry; | |
1247 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1248 PLAYLIST_LOCK(playlist->mutex); |
2084 | 1249 entry = g_list_nth_data(playlist->entries, pos); |
1250 playlist->queue = g_list_remove(playlist->queue, entry); | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1251 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1252 |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1253 playlistwin_update_list(playlist); |
0 | 1254 } |
1255 | |
1256 gint | |
2084 | 1257 playlist_get_queue_position(Playlist *playlist, PlaylistEntry * entry) |
0 | 1258 { |
2084 | 1259 return g_list_index(playlist->queue, entry); |
0 | 1260 } |
1261 | |
1262 void | |
2084 | 1263 playlist_set_position(Playlist *playlist, guint pos) |
0 | 1264 { |
1265 GList *node; | |
1266 gboolean restart_playing = FALSE; | |
1267 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1268 if (!playlist) |
0 | 1269 return; |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1270 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1271 PLAYLIST_LOCK(playlist->mutex); |
0 | 1272 |
2084 | 1273 node = g_list_nth(playlist->entries, pos); |
0 | 1274 if (!node) { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1275 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1276 return; |
1277 } | |
1278 | |
1279 if (bmp_playback_get_playing()) { | |
1280 /* We need to stop before changing playlist_position */ | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1281 PLAYLIST_UNLOCK(playlist->mutex); |
923 | 1282 ip_data.stop = TRUE; |
0 | 1283 bmp_playback_stop(); |
923 | 1284 ip_data.stop = FALSE; |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1285 PLAYLIST_LOCK(playlist->mutex); |
0 | 1286 restart_playing = TRUE; |
1287 } | |
1288 | |
2040
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1289 if ((cfg.shuffle) && (playlist_position_before_jump == NULL)) |
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1290 { |
2084 | 1291 /* Shuffling and this is our first manual jump. */ |
1292 playlist_position_before_jump = playlist->position; | |
2040
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1293 } |
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1294 |
2084 | 1295 playlist->position = node->data; |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1296 PLAYLIST_UNLOCK(playlist->mutex); |
2084 | 1297 playlist_check_pos_current(playlist); |
0 | 1298 |
1299 if (restart_playing) | |
1300 bmp_playback_initiate(); | |
1301 else { | |
1302 mainwin_set_info_text(); | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1303 playlistwin_update_list(playlist); |
0 | 1304 } |
1305 } | |
1306 | |
1307 void | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1308 playlist_eof_reached(Playlist *playlist) |
0 | 1309 { |
1310 GList *plist_pos_list; | |
1311 | |
904
2cb51ff37e8d
[svn] - stop the psuedo output plugin when using 'no playlist advance' or 'stop after current song'
nhjm449
parents:
898
diff
changeset
|
1312 if ((cfg.no_playlist_advance && !cfg.repeat) || cfg.stopaftersong) |
2cb51ff37e8d
[svn] - stop the psuedo output plugin when using 'no playlist advance' or 'stop after current song'
nhjm449
parents:
898
diff
changeset
|
1313 ip_data.stop = TRUE; |
0 | 1314 bmp_playback_stop(); |
904
2cb51ff37e8d
[svn] - stop the psuedo output plugin when using 'no playlist advance' or 'stop after current song'
nhjm449
parents:
898
diff
changeset
|
1315 if ((cfg.no_playlist_advance && !cfg.repeat) || cfg.stopaftersong) |
2cb51ff37e8d
[svn] - stop the psuedo output plugin when using 'no playlist advance' or 'stop after current song'
nhjm449
parents:
898
diff
changeset
|
1316 ip_data.stop = FALSE; |
0 | 1317 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1318 PLAYLIST_LOCK(playlist->mutex); |
2040
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1319 |
2084 | 1320 if ((playlist_position_before_jump != NULL) && playlist->queue == NULL) |
2040
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1321 { |
2084 | 1322 playlist->position = playlist_position_before_jump; |
1323 playlist_position_before_jump = NULL; | |
2040
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1324 } |
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
1325 |
2084 | 1326 plist_pos_list = find_playlist_position_list(playlist); |
0 | 1327 |
1328 if (cfg.no_playlist_advance) { | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1329 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1330 mainwin_clear_song_info(); |
1331 if (cfg.repeat) | |
1332 bmp_playback_initiate(); | |
1333 return; | |
1334 } | |
1335 | |
898 | 1336 if (cfg.stopaftersong) { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1337 PLAYLIST_UNLOCK(playlist->mutex); |
898 | 1338 mainwin_clear_song_info(); |
1339 mainwin_set_stopaftersong(FALSE); | |
1340 return; | |
1341 } | |
1342 | |
2084 | 1343 if (playlist->queue != NULL) { |
1344 play_queued(playlist); | |
0 | 1345 } |
1346 else if (!g_list_next(plist_pos_list)) { | |
1347 if (cfg.shuffle) { | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1348 playlist->position = NULL; |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1349 playlist_generate_shuffle_list_nolock(playlist); |
0 | 1350 } |
1351 else | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1352 playlist->position = playlist->entries->data; |
0 | 1353 |
1354 if (!cfg.repeat) { | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1355 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1356 mainwin_clear_song_info(); |
1357 mainwin_set_info_text(); | |
1358 return; | |
1359 } | |
1360 } | |
1361 else | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1362 playlist->position = g_list_next(plist_pos_list)->data; |
0 | 1363 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1364 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1365 |
2084 | 1366 playlist_check_pos_current(playlist); |
0 | 1367 bmp_playback_initiate(); |
1368 mainwin_set_info_text(); | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1369 playlistwin_update_list(playlist); |
0 | 1370 } |
1371 | |
1372 gint | |
2084 | 1373 playlist_get_length(Playlist *playlist) |
0 | 1374 { |
1375 gint retval; | |
1376 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1377 PLAYLIST_LOCK(playlist->mutex); |
2084 | 1378 retval = playlist_get_length_nolock(playlist); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1379 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1380 |
1381 return retval; | |
1382 } | |
1383 | |
1384 gint | |
2084 | 1385 playlist_queue_get_length(Playlist *playlist) |
0 | 1386 { |
1387 gint length; | |
1388 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1389 PLAYLIST_LOCK(playlist->mutex); |
2084 | 1390 length = g_list_length(playlist->queue); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1391 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1392 |
1393 return length; | |
1394 } | |
1395 | |
1396 gint | |
2084 | 1397 playlist_get_length_nolock(Playlist *playlist) |
0 | 1398 { |
2084 | 1399 return g_list_length(playlist->entries); |
0 | 1400 } |
1401 | |
1402 gchar * | |
2084 | 1403 playlist_get_info_text(Playlist *playlist) |
0 | 1404 { |
1405 gchar *text, *title, *numbers, *length; | |
1406 | |
2084 | 1407 g_return_val_if_fail(playlist != NULL, NULL); |
1408 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1409 PLAYLIST_LOCK(playlist->mutex); |
2084 | 1410 if (!playlist->position) { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1411 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1412 return NULL; |
1413 } | |
1414 | |
1415 /* FIXME: there should not be a need to do additional conversion, | |
1416 * if playlist is properly maintained */ | |
2084 | 1417 if (playlist->position->title) { |
1418 title = str_to_utf8(playlist->position->title); | |
0 | 1419 } |
1420 else { | |
2084 | 1421 gchar *basename = g_path_get_basename(playlist->position->filename); |
0 | 1422 title = filename_to_utf8(basename); |
1423 g_free(basename); | |
1424 } | |
1425 | |
1426 /* | |
1427 * If the user don't want numbers in the playlist, don't | |
1428 * display them in other parts of XMMS | |
1429 */ | |
1430 | |
1431 if (cfg.show_numbers_in_pl) | |
2084 | 1432 numbers = g_strdup_printf("%d. ", playlist_get_position_nolock(playlist) + 1); |
0 | 1433 else |
1434 numbers = g_strdup(""); | |
1435 | |
2096 | 1436 if (playlist->position->length != -1) |
0 | 1437 length = g_strdup_printf(" (%d:%-2.2d)", |
2084 | 1438 playlist->position->length / 60000, |
1439 (playlist->position->length / 1000) % 60); | |
0 | 1440 else |
1441 length = g_strdup(""); | |
1442 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1443 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1444 |
1445 text = convert_title_text(g_strconcat(numbers, title, length, NULL)); | |
1446 | |
1447 g_free(numbers); | |
1448 g_free(title); | |
1449 g_free(length); | |
1450 | |
1451 return text; | |
1452 } | |
1453 | |
1454 gint | |
2084 | 1455 playlist_get_current_length(Playlist * playlist) |
0 | 1456 { |
1457 gint len = 0; | |
1458 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1459 if (!playlist) |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1460 return 0; |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1461 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1462 PLAYLIST_LOCK(playlist->mutex); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1463 if (playlist->position) |
2084 | 1464 len = playlist->position->length; |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1465 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1466 |
1467 return len; | |
1468 } | |
1469 | |
1470 gboolean | |
2083 | 1471 playlist_save(Playlist * playlist, const gchar * filename) |
0 | 1472 { |
1553 | 1473 PlaylistContainer *plc = NULL; |
1474 gchar *ext; | |
0 | 1475 |
2083 | 1476 g_return_val_if_fail(playlist != NULL, FALSE); |
0 | 1477 g_return_val_if_fail(filename != NULL, FALSE); |
1478 | |
1553 | 1479 ext = strrchr(filename, '.') + 1; |
1480 | |
2083 | 1481 playlist_set_current_name(playlist, filename); |
0 | 1482 |
1553 | 1483 if ((plc = playlist_container_find(ext)) == NULL) |
0 | 1484 return FALSE; |
1485 | |
1555 | 1486 if (plc->plc_write == NULL) |
1487 return FALSE; | |
1488 | |
1553 | 1489 plc->plc_write(filename, 0); |
1490 | |
1491 return TRUE; | |
0 | 1492 } |
1493 | |
1494 gboolean | |
2083 | 1495 playlist_load(Playlist * playlist, const gchar * filename) |
0 | 1496 { |
397
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
1497 gboolean ret = FALSE; |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1498 g_return_val_if_fail(playlist != NULL, FALSE); |
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1499 |
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1500 playlist->loading_playlist = TRUE; |
2084 | 1501 ret = playlist_load_ins(playlist, filename, -1); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1502 playlist->loading_playlist = FALSE; |
397
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
1503 |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
1504 return ret; |
0 | 1505 } |
1506 | |
1554 | 1507 void |
2084 | 1508 playlist_load_ins_file(Playlist *playlist, |
1509 const gchar * filename_p, | |
0 | 1510 const gchar * playlist_name, gint pos, |
1511 const gchar * title, gint len) | |
1512 { | |
1513 gchar *filename; | |
1514 gchar *tmp, *path; | |
355
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
1515 InputPlugin *dec; /* for decoder cache */ |
0 | 1516 |
1517 g_return_if_fail(filename_p != NULL); | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1518 g_return_if_fail(playlist != NULL); |
0 | 1519 g_return_if_fail(playlist_name != NULL); |
1520 | |
633
bf9bc9a514ba
[svn] Use g_strchug instead of g_strstrip during playlist load. Trailing whitespace can be a valid occurance. Closes bug #282.
chainsaw
parents:
538
diff
changeset
|
1521 filename = g_strchug(g_strdup(filename_p)); |
0 | 1522 |
2019
d3a62e1075e2
[svn] Allow \ to / conversion to be switched on & off, by external contributor Chris Kehler <cbkehler@sympatico.ca>.
chainsaw
parents:
2010
diff
changeset
|
1523 if(cfg.convert_slash) |
944
03d141f44b4d
[svn] Convert \ path separators to /. Support was already present, but was not enabled before. Closes bug #461.
chainsaw
parents:
923
diff
changeset
|
1524 while ((tmp = strchr(filename, '\\')) != NULL) |
03d141f44b4d
[svn] Convert \ path separators to /. Support was already present, but was not enabled before. Closes bug #461.
chainsaw
parents:
923
diff
changeset
|
1525 *tmp = '/'; |
0 | 1526 |
1527 if (filename[0] != '/' && !strstr(filename, "://")) { | |
1528 path = g_strdup(playlist_name); | |
1529 if ((tmp = strrchr(path, '/'))) | |
1530 *tmp = '\0'; | |
1531 else { | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1532 if (playlist->loading_playlist != TRUE || cfg.playlist_detect == FALSE) |
397
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
1533 dec = input_check_file(filename, FALSE); |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
1534 else |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
1535 dec = NULL; |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
1536 |
2084 | 1537 __playlist_ins_with_info(playlist, filename, pos, title, len, dec); |
0 | 1538 return; |
1539 } | |
1540 tmp = g_build_filename(path, filename, NULL); | |
397
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
1541 |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1542 if (playlist->loading_playlist != TRUE && cfg.playlist_detect != TRUE) |
397
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
1543 dec = input_check_file(tmp, FALSE); |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
1544 else |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
1545 dec = NULL; |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
1546 |
2084 | 1547 __playlist_ins_with_info(playlist, tmp, pos, title, len, dec); |
0 | 1548 g_free(tmp); |
1549 g_free(path); | |
1550 } | |
1551 else | |
355
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
1552 { |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1553 if (playlist->loading_playlist != TRUE && cfg.playlist_detect != TRUE) |
397
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
1554 dec = input_check_file(filename, FALSE); |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
1555 else |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
1556 dec = NULL; |
4fa1244ad483
[svn] Do not generate a cache when loading a playlist.
nenolod
parents:
383
diff
changeset
|
1557 |
2084 | 1558 __playlist_ins_with_info(playlist, filename, pos, title, len, dec); |
355
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
1559 } |
0 | 1560 |
1561 g_free(filename); | |
1562 } | |
1563 | |
1584 | 1564 void |
2084 | 1565 playlist_load_ins_file_tuple(Playlist * playlist, |
1566 const gchar * filename_p, | |
1584 | 1567 const gchar * playlist_name, |
1568 gint pos, | |
1569 TitleInput *tuple) | |
1570 { | |
1571 gchar *filename; | |
1572 gchar *tmp, *path; | |
1573 InputPlugin *dec; /* for decoder cache */ | |
1574 | |
1575 g_return_if_fail(filename_p != NULL); | |
1576 g_return_if_fail(playlist_name != NULL); | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1577 g_return_if_fail(playlist != NULL); |
1584 | 1578 |
1579 filename = g_strchug(g_strdup(filename_p)); | |
1580 | |
1581 while ((tmp = strchr(filename, '\\')) != NULL) | |
1582 *tmp = '/'; | |
1583 | |
1584 if (filename[0] != '/' && !strstr(filename, "://")) { | |
1585 path = g_strdup(playlist_name); | |
1586 if ((tmp = strrchr(path, '/'))) | |
1587 *tmp = '\0'; | |
1588 else { | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1589 if (playlist->loading_playlist != TRUE || cfg.playlist_detect == FALSE) |
1584 | 1590 dec = input_check_file(filename, FALSE); |
1591 else | |
1592 dec = NULL; | |
1593 | |
2084 | 1594 __playlist_ins_with_info_tuple(playlist, filename, pos, tuple, dec); |
1584 | 1595 return; |
1596 } | |
1597 tmp = g_build_filename(path, filename, NULL); | |
1598 | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1599 if (playlist->loading_playlist != TRUE && cfg.playlist_detect != TRUE) |
1584 | 1600 dec = input_check_file(tmp, FALSE); |
1601 else | |
1602 dec = NULL; | |
1603 | |
2084 | 1604 __playlist_ins_with_info_tuple(playlist, tmp, pos, tuple, dec); |
1584 | 1605 g_free(tmp); |
1606 g_free(path); | |
1607 } | |
1608 else | |
1609 { | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1610 if (playlist->loading_playlist != TRUE && cfg.playlist_detect != TRUE) |
1584 | 1611 dec = input_check_file(filename, FALSE); |
1612 else | |
1613 dec = NULL; | |
1614 | |
2084 | 1615 __playlist_ins_with_info_tuple(playlist, filename, pos, tuple, dec); |
1584 | 1616 } |
1617 | |
1618 g_free(filename); | |
1619 } | |
1620 | |
0 | 1621 static guint |
2083 | 1622 playlist_load_ins(Playlist * playlist, const gchar * filename, gint pos) |
0 | 1623 { |
1554 | 1624 PlaylistContainer *plc; |
1625 gchar *ext; | |
0 | 1626 |
2083 | 1627 g_return_val_if_fail(playlist != NULL, 0); |
0 | 1628 g_return_val_if_fail(filename != NULL, 0); |
1629 | |
1554 | 1630 ext = strrchr(filename, '.') + 1; |
1631 plc = playlist_container_find(ext); | |
1632 | |
1633 g_return_val_if_fail(plc != NULL, 0); | |
1634 g_return_val_if_fail(plc->plc_read != NULL, 0); | |
1635 | |
1560
5840d797ea02
[svn] - hmm, calling plc->load() might be a good idea!
nenolod
parents:
1559
diff
changeset
|
1636 plc->plc_read(filename, pos); |
5840d797ea02
[svn] - hmm, calling plc->load() might be a good idea!
nenolod
parents:
1559
diff
changeset
|
1637 |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1638 playlist_generate_shuffle_list(playlist); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
1639 playlistwin_update_list(playlist); |
1554 | 1640 |
1641 return 1; | |
0 | 1642 } |
1643 | |
1644 GList * | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1645 get_playlist_nth(Playlist *playlist, guint nth) |
0 | 1646 { |
2135
dd29f8fd029d
[svn] - log a warning if deprecated functions from <= 1.2 are used
nenolod
parents:
2130
diff
changeset
|
1647 g_warning("deprecated function get_playlist_nth() was called"); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1648 REQUIRE_LOCK(playlist->mutex); |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1649 return g_list_nth(playlist->entries, nth); |
0 | 1650 } |
1651 | |
1652 gint | |
2084 | 1653 playlist_get_position_nolock(Playlist *playlist) |
0 | 1654 { |
2096 | 1655 if (playlist && playlist->position) |
2084 | 1656 return g_list_index(playlist->entries, playlist->position); |
0 | 1657 return 0; |
1658 } | |
1659 | |
1660 gint | |
2084 | 1661 playlist_get_position(Playlist *playlist) |
0 | 1662 { |
1663 gint pos; | |
1664 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1665 PLAYLIST_LOCK(playlist->mutex); |
2084 | 1666 pos = playlist_get_position_nolock(playlist); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1667 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1668 |
1669 return pos; | |
1670 } | |
1671 | |
1672 gchar * | |
2084 | 1673 playlist_get_filename(Playlist *playlist, guint pos) |
0 | 1674 { |
1675 gchar *filename; | |
1676 PlaylistEntry *entry; | |
1677 GList *node; | |
1678 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1679 if (!playlist) |
0 | 1680 return NULL; |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1681 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1682 PLAYLIST_LOCK(playlist->mutex); |
2084 | 1683 node = g_list_nth(playlist->entries, pos); |
0 | 1684 if (!node) { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1685 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1686 return NULL; |
1687 } | |
1688 entry = node->data; | |
1689 | |
1690 filename = g_strdup(entry->filename); | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1691 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1692 |
1693 return filename; | |
1694 } | |
1695 | |
1696 gchar * | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1697 playlist_get_songtitle(Playlist *playlist, guint pos) |
0 | 1698 { |
1699 gchar *title = NULL; | |
1700 PlaylistEntry *entry; | |
1701 GList *node; | |
1702 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1703 if (!playlist) |
0 | 1704 return NULL; |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1705 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1706 PLAYLIST_LOCK(playlist->mutex); |
0 | 1707 |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1708 if (!(node = g_list_nth(playlist->entries, pos))) { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1709 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1710 return NULL; |
1711 } | |
1712 | |
1713 entry = node->data; | |
1714 | |
1715 /* FIXME: simplify this logic */ | |
1841
7d0cd3fab6a2
[svn] - mtime=-1 has been introduced to represent "uninitialized".
yaz
parents:
1834
diff
changeset
|
1716 if ((entry->title == NULL && entry->length == -1) || |
7d0cd3fab6a2
[svn] - mtime=-1 has been introduced to represent "uninitialized".
yaz
parents:
1834
diff
changeset
|
1717 (entry->tuple && entry->tuple->mtime != 0 && (entry->tuple->mtime == -1 || entry->tuple->mtime != playlist_get_mtime(entry->filename)))) |
7d0cd3fab6a2
[svn] - mtime=-1 has been introduced to represent "uninitialized".
yaz
parents:
1834
diff
changeset
|
1718 { |
0 | 1719 if (playlist_entry_get_info(entry)) |
1720 title = entry->title; | |
1721 } | |
1722 else { | |
1723 title = entry->title; | |
1724 } | |
1725 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1726 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1727 |
1728 if (!title) { | |
1729 title = g_path_get_basename(entry->filename); | |
1730 return str_replace(title, filename_to_utf8(title)); | |
1731 } | |
1732 | |
1733 return str_to_utf8(title); | |
1734 } | |
1735 | |
1235 | 1736 TitleInput * |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1737 playlist_get_tuple(Playlist *playlist, guint pos) |
1235 | 1738 { |
1739 PlaylistEntry *entry; | |
1740 TitleInput *tuple = NULL; | |
1741 GList *node; | |
1742 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1743 if (!playlist) |
1235 | 1744 return NULL; |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1745 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1746 PLAYLIST_LOCK(playlist->mutex); |
1235 | 1747 |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1748 if (!(node = g_list_nth(playlist->entries, pos))) { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1749 PLAYLIST_UNLOCK(playlist->mutex); |
1235 | 1750 return NULL; |
1751 } | |
1752 | |
1753 entry = (PlaylistEntry *) node->data; | |
1754 | |
1755 tuple = entry->tuple; | |
1756 | |
1588
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
1757 // if no tuple or tuple with old mtime, get new one. |
1841
7d0cd3fab6a2
[svn] - mtime=-1 has been introduced to represent "uninitialized".
yaz
parents:
1834
diff
changeset
|
1758 if (tuple == NULL || |
7d0cd3fab6a2
[svn] - mtime=-1 has been introduced to represent "uninitialized".
yaz
parents:
1834
diff
changeset
|
1759 (entry->tuple && entry->tuple->mtime != 0 && (entry->tuple->mtime == -1 || entry->tuple->mtime != playlist_get_mtime(entry->filename)))) |
7d0cd3fab6a2
[svn] - mtime=-1 has been introduced to represent "uninitialized".
yaz
parents:
1834
diff
changeset
|
1760 { |
1237
17630223d25b
[svn] - if a PlaylistEntry does not have a cached tuple, generate it on demand.
nenolod
parents:
1235
diff
changeset
|
1761 playlist_entry_get_info(entry); |
17630223d25b
[svn] - if a PlaylistEntry does not have a cached tuple, generate it on demand.
nenolod
parents:
1235
diff
changeset
|
1762 tuple = entry->tuple; |
17630223d25b
[svn] - if a PlaylistEntry does not have a cached tuple, generate it on demand.
nenolod
parents:
1235
diff
changeset
|
1763 } |
17630223d25b
[svn] - if a PlaylistEntry does not have a cached tuple, generate it on demand.
nenolod
parents:
1235
diff
changeset
|
1764 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1765 PLAYLIST_UNLOCK(playlist->mutex); |
1235 | 1766 |
1767 return tuple; | |
1768 } | |
1769 | |
0 | 1770 gint |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1771 playlist_get_songtime(Playlist *playlist, guint pos) |
0 | 1772 { |
1773 gint song_time = -1; | |
1774 PlaylistEntry *entry; | |
1775 GList *node; | |
1776 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1777 if (!playlist) |
0 | 1778 return -1; |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1779 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1780 PLAYLIST_LOCK(playlist->mutex); |
0 | 1781 |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
1782 if (!(node = g_list_nth(playlist->entries, pos))) { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1783 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1784 return -1; |
1785 } | |
1786 | |
1787 entry = node->data; | |
1841
7d0cd3fab6a2
[svn] - mtime=-1 has been introduced to represent "uninitialized".
yaz
parents:
1834
diff
changeset
|
1788 if (entry->tuple == NULL || |
7d0cd3fab6a2
[svn] - mtime=-1 has been introduced to represent "uninitialized".
yaz
parents:
1834
diff
changeset
|
1789 (entry->tuple->mtime != 0 && (entry->tuple->mtime == -1 || entry->tuple->mtime != playlist_get_mtime(entry->filename)))) { |
1588
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
1790 |
0 | 1791 if (playlist_entry_get_info(entry)) |
1792 song_time = entry->length; | |
1793 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1794 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1795 } |
1796 else { | |
1797 song_time = entry->length; | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
1798 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 1799 } |
1800 | |
1801 return song_time; | |
1802 } | |
1803 | |
1804 static gint | |
1415 | 1805 playlist_compare_track(PlaylistEntry * a, |
1806 PlaylistEntry * b) | |
1807 { | |
1808 g_return_val_if_fail(a != NULL, 0); | |
1809 g_return_val_if_fail(b != NULL, 0); | |
1810 | |
1811 g_return_val_if_fail(a->tuple != NULL, 0); | |
1812 g_return_val_if_fail(b->tuple != NULL, 0); | |
1813 | |
1814 return (a->tuple->track_number - b->tuple->track_number); | |
1815 } | |
1816 | |
1817 static gint | |
1430
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1818 playlist_compare_playlist(PlaylistEntry * a, |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1819 PlaylistEntry * b) |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1820 { |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1821 const gchar *a_title = NULL, *b_title = NULL; |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1822 |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1823 g_return_val_if_fail(a != NULL, 0); |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1824 g_return_val_if_fail(b != NULL, 0); |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1825 |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1826 if (a->title != NULL) |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1827 a_title = a->title; |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1828 else { |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1829 if (strrchr(a->filename, '/')) |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1830 a_title = strrchr(a->filename, '/') + 1; |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1831 else |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1832 a_title = a->filename; |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1833 } |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1834 |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1835 if (b->title != NULL) |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1836 b_title = b->title; |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1837 else { |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1838 if (strrchr(a->filename, '/')) |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1839 b_title = strrchr(b->filename, '/') + 1; |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1840 else |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1841 b_title = b->filename; |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1842 } |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1843 |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1844 return strcasecmp(a_title, b_title); |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1845 } |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1846 |
740c08db08d9
[svn] via Christian Birchinger <joker -at- netswarm.net>:
nenolod
parents:
1415
diff
changeset
|
1847 static gint |
1251 | 1848 playlist_compare_title(PlaylistEntry * a, |
1849 PlaylistEntry * b) | |
0 | 1850 { |
1250 | 1851 const gchar *a_title = NULL, *b_title = NULL; |
0 | 1852 |
1853 g_return_val_if_fail(a != NULL, 0); | |
1854 g_return_val_if_fail(b != NULL, 0); | |
1855 | |
1250 | 1856 if (a->tuple != NULL && a->tuple->track_name != NULL) |
1857 a_title = a->tuple->track_name; | |
1858 if (b->tuple != NULL && b->tuple->track_name != NULL) | |
1859 b_title = b->tuple->track_name; | |
1860 | |
1251 | 1861 if (a_title != NULL && b_title != NULL) |
1250 | 1862 return strcasecmp(a_title, b_title); |
1863 | |
1864 if (a->title != NULL) | |
0 | 1865 a_title = a->title; |
1866 else { | |
1867 if (strrchr(a->filename, '/')) | |
1868 a_title = strrchr(a->filename, '/') + 1; | |
1869 else | |
1870 a_title = a->filename; | |
1871 } | |
1872 | |
1250 | 1873 if (b->title != NULL) |
0 | 1874 b_title = b->title; |
1875 else { | |
1876 if (strrchr(a->filename, '/')) | |
1877 b_title = strrchr(b->filename, '/') + 1; | |
1878 else | |
1879 b_title = b->filename; | |
1880 } | |
1881 | |
1882 return strcasecmp(a_title, b_title); | |
1883 } | |
1884 | |
1885 static gint | |
1251 | 1886 playlist_compare_artist(PlaylistEntry * a, |
1887 PlaylistEntry * b) | |
1888 { | |
1889 const gchar *a_artist = NULL, *b_artist = NULL; | |
1890 | |
1891 g_return_val_if_fail(a != NULL, 0); | |
1892 g_return_val_if_fail(b != NULL, 0); | |
1893 | |
1894 if (a->tuple != NULL) | |
1895 playlist_entry_get_info(a); | |
1896 | |
1897 if (b->tuple != NULL) | |
1898 playlist_entry_get_info(b); | |
1899 | |
1253
665dfbf5e9a1
[svn] - playlist_compare_artist(): more sanity checking.
nenolod
parents:
1251
diff
changeset
|
1900 if (a->tuple != NULL && a->tuple->performer != NULL) |
1251 | 1901 a_artist = a->tuple->performer; |
1253
665dfbf5e9a1
[svn] - playlist_compare_artist(): more sanity checking.
nenolod
parents:
1251
diff
changeset
|
1902 if (b->tuple != NULL && b->tuple->performer != NULL) |
1251 | 1903 b_artist = b->tuple->performer; |
1904 | |
1905 if (a_artist != NULL && b_artist != NULL) | |
1906 return strcasecmp(a_artist, b_artist); | |
1907 | |
1253
665dfbf5e9a1
[svn] - playlist_compare_artist(): more sanity checking.
nenolod
parents:
1251
diff
changeset
|
1908 return 0; |
1251 | 1909 } |
1910 | |
1911 static gint | |
1912 playlist_compare_filename(PlaylistEntry * a, | |
1913 PlaylistEntry * b) | |
0 | 1914 { |
1915 gchar *a_filename, *b_filename; | |
1916 | |
1917 g_return_val_if_fail(a != NULL, 0); | |
1918 g_return_val_if_fail(b != NULL, 0); | |
1919 | |
1920 if (strrchr(a->filename, '/')) | |
1921 a_filename = strrchr(a->filename, '/') + 1; | |
1922 else | |
1923 a_filename = a->filename; | |
1924 | |
1925 if (strrchr(b->filename, '/')) | |
1926 b_filename = strrchr(b->filename, '/') + 1; | |
1927 else | |
1928 b_filename = b->filename; | |
1929 | |
1930 | |
1931 return strcasecmp(a_filename, b_filename); | |
1932 } | |
1933 | |
1934 static gint | |
1935 path_compare(const gchar * a, const gchar * b) | |
1936 { | |
1937 gchar *posa, *posb; | |
1938 gint len, ret; | |
1939 | |
1940 posa = strrchr(a, '/'); | |
1941 posb = strrchr(b, '/'); | |
1942 | |
1943 /* | |
1944 * Sort directories before files | |
1945 */ | |
1946 if (posa && posb && (posa - a != posb - b)) { | |
1947 if (posa - a > posb - b) { | |
1948 len = posb - b; | |
1949 ret = -1; | |
1950 } | |
1951 else { | |
1952 len = posa - a; | |
1953 ret = 1; | |
1954 } | |
1955 if (!strncasecmp(a, b, len)) | |
1956 return ret; | |
1957 } | |
1958 return strcasecmp(a, b); | |
1959 } | |
1960 | |
1961 static gint | |
1251 | 1962 playlist_compare_path(PlaylistEntry * a, |
1963 PlaylistEntry * b) | |
0 | 1964 { |
1965 return path_compare(a->filename, b->filename); | |
1966 } | |
1967 | |
1588
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
1968 |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
1969 static time_t |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
1970 playlist_get_mtime(const gchar *filename) |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
1971 { |
1706 | 1972 struct stat buf; |
1588
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
1973 gint rv; |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
1974 |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
1975 rv = stat(filename, &buf); |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
1976 |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
1977 if (rv == 0) { |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
1978 return buf.st_mtime; |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
1979 } else { |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
1980 return 0; //error |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
1981 } |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
1982 } |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
1983 |
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
1984 |
0 | 1985 static gint |
1251 | 1986 playlist_compare_date(PlaylistEntry * a, |
1987 PlaylistEntry * b) | |
0 | 1988 { |
1989 struct stat buf; | |
1990 time_t modtime; | |
1991 | |
1992 gint rv; | |
1993 | |
1994 | |
1995 rv = stat(a->filename, &buf); | |
1996 | |
1997 if (rv == 0) { | |
1998 modtime = buf.st_mtime; | |
1999 rv = stat(b->filename, &buf); | |
2000 | |
2001 if (stat(b->filename, &buf) == 0) { | |
2002 if (buf.st_mtime == modtime) | |
2003 return 0; | |
2004 else | |
2005 return (buf.st_mtime - modtime) > 0 ? -1 : 1; | |
2006 } | |
2007 else | |
2008 return -1; | |
2009 } | |
2010 else if (!lstat(b->filename, &buf)) | |
2011 return 1; | |
2012 else | |
2013 return playlist_compare_filename(a, b); | |
2014 } | |
2015 | |
2016 | |
2017 void | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2018 playlist_sort(Playlist *playlist, PlaylistSortType type) |
0 | 2019 { |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2020 playlist_remove_dead_files(playlist); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2021 PLAYLIST_LOCK(playlist->mutex); |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2022 playlist->entries = |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2023 g_list_sort(playlist->entries, |
0 | 2024 (GCompareFunc) playlist_compare_func_table[type]); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2025 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 2026 } |
2027 | |
2028 static GList * | |
2029 playlist_sort_selected_generic(GList * list, GCompareFunc cmpfunc) | |
2030 { | |
2031 GList *list1, *list2; | |
2032 GList *tmp_list = NULL; | |
2033 GList *index_list = NULL; | |
2034 | |
2035 /* | |
2036 * We take all the selected entries out of the playlist, | |
2037 * sorts them, and then put them back in again. | |
2038 */ | |
2039 | |
2040 list1 = g_list_last(list); | |
2041 | |
2042 while (list1) { | |
2043 list2 = g_list_previous(list1); | |
2044 if (PLAYLIST_ENTRY(list1->data)->selected) { | |
2045 gpointer idx; | |
2046 idx = GINT_TO_POINTER(g_list_position(list, list1)); | |
2047 index_list = g_list_prepend(index_list, idx); | |
2048 list = g_list_remove_link(list, list1); | |
2049 tmp_list = g_list_concat(list1, tmp_list); | |
2050 } | |
2051 list1 = list2; | |
2052 } | |
2053 | |
2054 tmp_list = g_list_sort(tmp_list, cmpfunc); | |
2055 list1 = tmp_list; | |
2056 list2 = index_list; | |
2057 | |
2058 while (list2) { | |
2059 if (!list1) { | |
2060 g_critical(G_STRLOC ": Error during list sorting. " | |
2061 "Possibly dropped some playlist-entries."); | |
2062 break; | |
2063 } | |
2064 | |
2065 list = g_list_insert(list, list1->data, GPOINTER_TO_INT(list2->data)); | |
2066 | |
2067 list2 = g_list_next(list2); | |
2068 list1 = g_list_next(list1); | |
2069 } | |
2070 | |
2071 g_list_free(index_list); | |
2072 g_list_free(tmp_list); | |
2073 | |
2074 return list; | |
2075 } | |
2076 | |
2077 void | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2078 playlist_sort_selected(Playlist *playlist, PlaylistSortType type) |
0 | 2079 { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2080 PLAYLIST_LOCK(playlist->mutex); |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2081 playlist->entries = playlist_sort_selected_generic(playlist->entries, (GCompareFunc) |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2082 playlist_compare_func_table |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2083 [type]); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2084 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 2085 } |
2086 | |
2087 void | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2088 playlist_reverse(Playlist *playlist) |
0 | 2089 { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2090 PLAYLIST_LOCK(playlist->mutex); |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2091 playlist->entries = g_list_reverse(playlist->entries); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2092 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 2093 } |
2094 | |
2095 static GList * | |
2143
f7eeb54c6467
[svn] - changed playlist_shuffle_list to pick a playlist as parameter instead of calling playlist_get_active
giacomo
parents:
2142
diff
changeset
|
2096 playlist_shuffle_list(Playlist *playlist, GList * list) |
0 | 2097 { |
2098 /* | |
2099 * Note that this doesn't make a copy of the original list. | |
2100 * The pointer to the original list is not valid after this | |
2101 * fuction is run. | |
2102 */ | |
2103 gint len = g_list_length(list); | |
2104 gint i, j; | |
2105 GList *node, **ptrs; | |
2143
f7eeb54c6467
[svn] - changed playlist_shuffle_list to pick a playlist as parameter instead of calling playlist_get_active
giacomo
parents:
2142
diff
changeset
|
2106 |
f7eeb54c6467
[svn] - changed playlist_shuffle_list to pick a playlist as parameter instead of calling playlist_get_active
giacomo
parents:
2142
diff
changeset
|
2107 if (!playlist) |
f7eeb54c6467
[svn] - changed playlist_shuffle_list to pick a playlist as parameter instead of calling playlist_get_active
giacomo
parents:
2142
diff
changeset
|
2108 return NULL; |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2109 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2110 REQUIRE_LOCK(playlist->mutex); |
0 | 2111 |
2112 if (!len) | |
2113 return NULL; | |
2114 | |
2115 ptrs = g_new(GList *, len); | |
2116 | |
2117 for (node = list, i = 0; i < len; node = g_list_next(node), i++) | |
2118 ptrs[i] = node; | |
2119 | |
2120 j = g_random_int_range(0, len); | |
2121 list = ptrs[j]; | |
2122 ptrs[j]->next = NULL; | |
2123 ptrs[j] = ptrs[0]; | |
2124 | |
2125 for (i = 1; i < len; i++) { | |
2126 j = g_random_int_range(0, len - i); | |
2127 list->prev = ptrs[i + j]; | |
2128 ptrs[i + j]->next = list; | |
2129 list = ptrs[i + j]; | |
2130 ptrs[i + j] = ptrs[i]; | |
2131 } | |
2132 list->prev = NULL; | |
2133 | |
2134 g_free(ptrs); | |
2135 | |
2136 return list; | |
2137 } | |
2138 | |
2139 void | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2140 playlist_random(Playlist *playlist) |
0 | 2141 { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2142 PLAYLIST_LOCK(playlist->mutex); |
2143
f7eeb54c6467
[svn] - changed playlist_shuffle_list to pick a playlist as parameter instead of calling playlist_get_active
giacomo
parents:
2142
diff
changeset
|
2143 playlist->entries = playlist_shuffle_list(playlist, playlist->entries); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2144 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 2145 } |
2146 | |
2147 GList * | |
2085 | 2148 playlist_get_selected(Playlist *playlist) |
0 | 2149 { |
2150 GList *node, *list = NULL; | |
2151 gint i = 0; | |
2152 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2153 PLAYLIST_LOCK(playlist->mutex); |
2085 | 2154 for (node = playlist->entries; node; node = g_list_next(node), i++) { |
0 | 2155 PlaylistEntry *entry = node->data; |
2156 if (entry->selected) | |
2157 list = g_list_prepend(list, GINT_TO_POINTER(i)); | |
2158 } | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2159 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 2160 return g_list_reverse(list); |
2161 } | |
2162 | |
2163 void | |
2085 | 2164 playlist_clear_selected(Playlist *playlist) |
0 | 2165 { |
2166 GList *node = NULL; | |
2167 gint i = 0; | |
2168 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2169 PLAYLIST_LOCK(playlist->mutex); |
2085 | 2170 for (node = playlist->entries; node; node = g_list_next(node), i++) { |
0 | 2171 PLAYLIST_ENTRY(node->data)->selected = FALSE; |
2172 } | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2173 PLAYLIST_UNLOCK(playlist->mutex); |
2085 | 2174 playlist_recalc_total_time(playlist); |
0 | 2175 } |
2176 | |
2177 gint | |
2085 | 2178 playlist_get_num_selected(Playlist *playlist) |
0 | 2179 { |
2180 GList *node; | |
2181 gint num = 0; | |
2182 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2183 PLAYLIST_LOCK(playlist->mutex); |
2085 | 2184 for (node = playlist->entries; node; node = g_list_next(node)) { |
0 | 2185 PlaylistEntry *entry = node->data; |
2186 if (entry->selected) | |
2187 num++; | |
2188 } | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2189 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 2190 return num; |
2191 } | |
2192 | |
2193 | |
2194 static void | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2195 playlist_generate_shuffle_list(Playlist *playlist) |
0 | 2196 { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2197 PLAYLIST_LOCK(playlist->mutex); |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2198 playlist_generate_shuffle_list_nolock(playlist); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2199 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 2200 } |
2201 | |
2202 static void | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2203 playlist_generate_shuffle_list_nolock(Playlist *playlist) |
0 | 2204 { |
2205 GList *node; | |
2206 gint numsongs; | |
2207 | |
2208 if (!cfg.shuffle || !playlist) | |
2209 return; | |
2210 | |
2143
f7eeb54c6467
[svn] - changed playlist_shuffle_list to pick a playlist as parameter instead of calling playlist_get_active
giacomo
parents:
2142
diff
changeset
|
2211 REQUIRE_LOCK(playlist->mutex); |
f7eeb54c6467
[svn] - changed playlist_shuffle_list to pick a playlist as parameter instead of calling playlist_get_active
giacomo
parents:
2142
diff
changeset
|
2212 |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2213 if (playlist->shuffle) { |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2214 g_list_free(playlist->shuffle); |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2215 playlist->shuffle = NULL; |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2216 } |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2217 |
2143
f7eeb54c6467
[svn] - changed playlist_shuffle_list to pick a playlist as parameter instead of calling playlist_get_active
giacomo
parents:
2142
diff
changeset
|
2218 playlist->shuffle = playlist_shuffle_list(playlist, g_list_copy(playlist->entries)); |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2219 numsongs = g_list_length(playlist->shuffle); |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2220 |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2221 if (playlist->position) { |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2222 gint i = g_list_index(playlist->shuffle, playlist->position); |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2223 node = g_list_nth(playlist->shuffle, i); |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2224 playlist->shuffle = g_list_remove_link(playlist->shuffle, node); |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2225 playlist->shuffle = g_list_prepend(playlist->shuffle, node->data); |
0 | 2226 } |
2227 } | |
2228 | |
2229 void | |
2085 | 2230 playlist_fileinfo(Playlist *playlist, guint pos) |
0 | 2231 { |
2232 gchar *path = NULL; | |
2233 GList *node; | |
1269 | 2234 PlaylistEntry *entry = NULL; |
2235 TitleInput *tuple = NULL; | |
1818
e3e31a084b09
[svn] - try not to reject tuples that have an mtime of 0. (special tuples referring to URIs)
nenolod
parents:
1817
diff
changeset
|
2236 gint mtime; |
0 | 2237 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2238 PLAYLIST_LOCK(playlist->mutex); |
1269 | 2239 |
2085 | 2240 if ((node = g_list_nth(playlist->entries, pos))) |
1269 | 2241 { |
2242 entry = node->data; | |
2243 tuple = entry->tuple; | |
1516
3483fb26b9fb
[svn] - when audacious is started and track detail on current song are requested, try to check if a decoder exists before falling back to the tuple display dialog
giacomo
parents:
1459
diff
changeset
|
2244 path = g_strdup(entry->filename); |
0 | 2245 } |
1269 | 2246 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2247 PLAYLIST_UNLOCK(playlist->mutex); |
1277
8c8d4841efae
[svn] - if entry->tuple == NULL, then probe the file for a decoder and build the appropriate tuple for that entry
nenolod
parents:
1270
diff
changeset
|
2248 |
8c8d4841efae
[svn] - if entry->tuple == NULL, then probe the file for a decoder and build the appropriate tuple for that entry
nenolod
parents:
1270
diff
changeset
|
2249 /* No tuple? Try to set this entry up properly. --nenolod */ |
1841
7d0cd3fab6a2
[svn] - mtime=-1 has been introduced to represent "uninitialized".
yaz
parents:
1834
diff
changeset
|
2250 if (entry->tuple == NULL || entry->tuple->mtime == -1 || |
7d0cd3fab6a2
[svn] - mtime=-1 has been introduced to represent "uninitialized".
yaz
parents:
1834
diff
changeset
|
2251 entry->tuple->mtime == 0 || entry->tuple->mtime != playlist_get_mtime(entry->filename)) |
1277
8c8d4841efae
[svn] - if entry->tuple == NULL, then probe the file for a decoder and build the appropriate tuple for that entry
nenolod
parents:
1270
diff
changeset
|
2252 { |
8c8d4841efae
[svn] - if entry->tuple == NULL, then probe the file for a decoder and build the appropriate tuple for that entry
nenolod
parents:
1270
diff
changeset
|
2253 playlist_entry_get_info(entry); |
8c8d4841efae
[svn] - if entry->tuple == NULL, then probe the file for a decoder and build the appropriate tuple for that entry
nenolod
parents:
1270
diff
changeset
|
2254 tuple = entry->tuple; |
8c8d4841efae
[svn] - if entry->tuple == NULL, then probe the file for a decoder and build the appropriate tuple for that entry
nenolod
parents:
1270
diff
changeset
|
2255 } |
8c8d4841efae
[svn] - if entry->tuple == NULL, then probe the file for a decoder and build the appropriate tuple for that entry
nenolod
parents:
1270
diff
changeset
|
2256 |
1269 | 2257 if (tuple != NULL) |
2258 { | |
2259 if (entry->decoder != NULL && entry->decoder->file_info_box == NULL) | |
2260 fileinfo_show_for_tuple(tuple); | |
1270 | 2261 else if (entry->decoder != NULL && entry->decoder->file_info_box != NULL) |
2262 entry->decoder->file_info_box(path); | |
1269 | 2263 else |
2264 fileinfo_show_for_path(path); | |
2265 g_free(path); | |
2266 } | |
2267 else if (path != NULL) | |
2268 { | |
1270 | 2269 if (entry != NULL && entry->decoder != NULL && entry->decoder->file_info_box != NULL) |
2270 entry->decoder->file_info_box(path); | |
2271 else | |
2272 fileinfo_show_for_path(path); | |
0 | 2273 g_free(path); |
2274 } | |
2275 } | |
2276 | |
2277 void | |
2085 | 2278 playlist_fileinfo_current(Playlist *playlist) |
0 | 2279 { |
2280 gchar *path = NULL; | |
1269 | 2281 TitleInput *tuple = NULL; |
0 | 2282 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2283 PLAYLIST_LOCK(playlist->mutex); |
1269 | 2284 |
2085 | 2285 if (playlist->entries && playlist->position) |
1269 | 2286 { |
2085 | 2287 path = g_strdup(playlist->position->filename); |
2288 if (( playlist->position->tuple == NULL ) || ( playlist->position->decoder == NULL )) | |
2289 playlist_entry_get_info(playlist->position); | |
2290 tuple = playlist->position->tuple; | |
1269 | 2291 } |
2292 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2293 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 2294 |
1269 | 2295 if (tuple != NULL) |
2296 { | |
2085 | 2297 if (playlist->position->decoder != NULL && playlist->position->decoder->file_info_box == NULL) |
1269 | 2298 fileinfo_show_for_tuple(tuple); |
2085 | 2299 else if (playlist->position->decoder != NULL && playlist->position->decoder->file_info_box != NULL) |
2300 playlist->position->decoder->file_info_box(path); | |
1269 | 2301 else |
2302 fileinfo_show_for_path(path); | |
2303 g_free(path); | |
2304 } | |
2305 else if (path != NULL) | |
2306 { | |
2085 | 2307 if (playlist->position != NULL && playlist->position->decoder != NULL && playlist->position->decoder->file_info_box != NULL) |
2308 playlist->position->decoder->file_info_box(path); | |
1270 | 2309 else |
2310 fileinfo_show_for_path(path); | |
0 | 2311 g_free(path); |
2312 } | |
2313 } | |
2314 | |
2315 | |
2316 static gboolean | |
2317 playlist_get_info_is_going(void) | |
2318 { | |
2319 gboolean result; | |
2320 | |
2321 G_LOCK(playlist_get_info_going); | |
2322 result = playlist_get_info_going; | |
2323 G_UNLOCK(playlist_get_info_going); | |
2324 | |
2325 return result; | |
2326 } | |
2327 | |
2328 static gpointer | |
2329 playlist_get_info_func(gpointer arg) | |
2330 { | |
2331 GList *node; | |
2332 gboolean update_playlistwin = FALSE; | |
2333 gboolean update_mainwin = FALSE; | |
2334 | |
2335 while (playlist_get_info_is_going()) { | |
2336 PlaylistEntry *entry; | |
2126
dba25b0e98c8
[svn] - use playlist_get_active() at the top of each thread.
nenolod
parents:
2125
diff
changeset
|
2337 Playlist *playlist = playlist_get_active(); |
0 | 2338 |
2026 | 2339 // on_load |
0 | 2340 if (cfg.use_pl_metadata && |
2341 cfg.get_info_on_load && | |
2342 playlist_get_info_scan_active) { | |
2343 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2344 PLAYLIST_LOCK(playlist->mutex); |
2121
185db04b815f
[svn] - remove all improper uses of playlist_get()
nenolod
parents:
2120
diff
changeset
|
2345 for (node = playlist->entries; node; node = g_list_next(node)) { |
0 | 2346 entry = node->data; |
2347 | |
1826
d66712838e9f
[svn] - and finally special tuples are treated as they should be
nenolod
parents:
1825
diff
changeset
|
2348 if(entry->tuple && (entry->tuple->length > -1)) { |
2026 | 2349 update_playlistwin = TRUE; |
2350 continue; | |
1588
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
2351 } |
0 | 2352 |
2353 if (!playlist_entry_get_info(entry)) { | |
2121
185db04b815f
[svn] - remove all improper uses of playlist_get()
nenolod
parents:
2120
diff
changeset
|
2354 if (g_list_index(playlist->entries, entry) == -1) |
0 | 2355 /* Entry disappeared while we looked it up. |
2356 Restart. */ | |
2121
185db04b815f
[svn] - remove all improper uses of playlist_get()
nenolod
parents:
2120
diff
changeset
|
2357 node = playlist->entries; |
0 | 2358 } |
2026 | 2359 else if ((entry->tuple != NULL || entry->title != NULL) && entry->length != -1) { |
0 | 2360 update_playlistwin = TRUE; |
2096 | 2361 if (entry == playlist->position) |
0 | 2362 update_mainwin = TRUE; |
2363 break; | |
2364 } | |
2365 } | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2366 PLAYLIST_UNLOCK(playlist->mutex); |
2026 | 2367 |
2368 if (!node) { | |
2369 g_mutex_lock(mutex_scan); | |
0 | 2370 playlist_get_info_scan_active = FALSE; |
2026 | 2371 g_mutex_unlock(mutex_scan); |
2372 } | |
2373 } // on_load | |
2374 | |
2375 // on_demand | |
0 | 2376 else if (!cfg.get_info_on_load && |
2377 cfg.get_info_on_demand && | |
2378 cfg.playlist_visible && | |
2379 !cfg.playlist_shaded && | |
2380 cfg.use_pl_metadata) { | |
2381 | |
2026 | 2382 g_mutex_lock(mutex_scan); |
2383 playlist_get_info_scan_active = FALSE; | |
2384 g_mutex_unlock(mutex_scan); | |
0 | 2385 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2386 PLAYLIST_LOCK(playlist->mutex); |
0 | 2387 |
2121
185db04b815f
[svn] - remove all improper uses of playlist_get()
nenolod
parents:
2120
diff
changeset
|
2388 if (!playlist->entries) { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2389 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 2390 } |
2026 | 2391 else { |
2121
185db04b815f
[svn] - remove all improper uses of playlist_get()
nenolod
parents:
2120
diff
changeset
|
2392 for (node = g_list_nth(playlist->entries, playlistwin_get_toprow()); |
185db04b815f
[svn] - remove all improper uses of playlist_get()
nenolod
parents:
2120
diff
changeset
|
2393 node && playlistwin_item_visible(g_list_position(playlist->entries, node)); |
2026 | 2394 node = g_list_next(node)) { |
2395 | |
2396 entry = node->data; | |
2397 | |
2398 if(entry->tuple && (entry->tuple->length > -1)) { | |
2399 update_playlistwin = TRUE; | |
2400 continue; | |
2401 } | |
2402 | |
2403 if (!playlist_entry_get_info(entry)) { | |
2121
185db04b815f
[svn] - remove all improper uses of playlist_get()
nenolod
parents:
2120
diff
changeset
|
2404 if (g_list_index(playlist->entries, entry) == -1) |
2026 | 2405 /* Entry disapeared while we |
2406 looked it up. Restart. */ | |
2407 node = | |
2121
185db04b815f
[svn] - remove all improper uses of playlist_get()
nenolod
parents:
2120
diff
changeset
|
2408 g_list_nth(playlist->entries, |
2026 | 2409 playlistwin_get_toprow()); |
2410 } | |
2411 else if ((entry->tuple != NULL || entry->title != NULL) && entry->length != -1) { | |
2412 update_playlistwin = TRUE; | |
2096 | 2413 if (entry == playlist->position) |
2026 | 2414 update_mainwin = TRUE; |
2027 | 2415 // no need for break here since this iteration is very short. |
2026 | 2416 } |
1706 | 2417 } |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2418 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 2419 } |
2026 | 2420 } // on_demand |
2063
a3ad15fb0f34
[svn] - playlist_scan_thread_is_going should not be TRUE if the playlist is
nenolod
parents:
2040
diff
changeset
|
2421 else if (cfg.get_info_on_demand && |
a3ad15fb0f34
[svn] - playlist_scan_thread_is_going should not be TRUE if the playlist is
nenolod
parents:
2040
diff
changeset
|
2422 (!cfg.playlist_visible || cfg.playlist_shaded |
a3ad15fb0f34
[svn] - playlist_scan_thread_is_going should not be TRUE if the playlist is
nenolod
parents:
2040
diff
changeset
|
2423 || !cfg.use_pl_metadata)) |
a3ad15fb0f34
[svn] - playlist_scan_thread_is_going should not be TRUE if the playlist is
nenolod
parents:
2040
diff
changeset
|
2424 { |
a3ad15fb0f34
[svn] - playlist_scan_thread_is_going should not be TRUE if the playlist is
nenolod
parents:
2040
diff
changeset
|
2425 g_mutex_lock(mutex_scan); |
a3ad15fb0f34
[svn] - playlist_scan_thread_is_going should not be TRUE if the playlist is
nenolod
parents:
2040
diff
changeset
|
2426 playlist_get_info_scan_active = FALSE; |
a3ad15fb0f34
[svn] - playlist_scan_thread_is_going should not be TRUE if the playlist is
nenolod
parents:
2040
diff
changeset
|
2427 g_mutex_unlock(mutex_scan); |
a3ad15fb0f34
[svn] - playlist_scan_thread_is_going should not be TRUE if the playlist is
nenolod
parents:
2040
diff
changeset
|
2428 } |
0 | 2429 |
2430 if (update_playlistwin) { | |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2431 playlistwin_update_list(playlist); |
0 | 2432 update_playlistwin = FALSE; |
2433 } | |
2434 | |
2435 if (update_mainwin) { | |
2436 mainwin_set_info_text(); | |
2437 update_mainwin = FALSE; | |
2438 } | |
2026 | 2439 |
2440 if (playlist_get_info_scan_active) { | |
2441 continue; | |
2442 } | |
2443 | |
2444 g_mutex_lock(mutex_scan); | |
2445 g_cond_wait(cond_scan, mutex_scan); | |
2446 g_mutex_unlock(mutex_scan); | |
2447 | |
2027 | 2448 } // while |
0 | 2449 |
2450 g_thread_exit(NULL); | |
2451 return NULL; | |
2452 } | |
2453 | |
2454 void | |
2455 playlist_start_get_info_thread(void) | |
2456 { | |
2027 | 2457 G_LOCK(playlist_get_info_going); |
0 | 2458 playlist_get_info_going = TRUE; |
2027 | 2459 G_UNLOCK(playlist_get_info_going); |
2460 | |
0 | 2461 playlist_get_info_thread = g_thread_create(playlist_get_info_func, |
2462 NULL, TRUE, NULL); | |
2463 } | |
2464 | |
2465 void | |
2466 playlist_stop_get_info_thread(void) | |
2467 { | |
2468 G_LOCK(playlist_get_info_going); | |
2469 playlist_get_info_going = FALSE; | |
2470 G_UNLOCK(playlist_get_info_going); | |
2026 | 2471 |
2472 g_cond_broadcast(cond_scan); | |
0 | 2473 g_thread_join(playlist_get_info_thread); |
2474 } | |
2475 | |
2476 void | |
2477 playlist_start_get_info_scan(void) | |
2478 { | |
2026 | 2479 g_mutex_lock(mutex_scan); |
0 | 2480 playlist_get_info_scan_active = TRUE; |
2026 | 2481 g_mutex_unlock(mutex_scan); |
2482 g_cond_signal(cond_scan); | |
0 | 2483 } |
2484 | |
2485 void | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2486 playlist_remove_dead_files(Playlist *playlist) |
0 | 2487 { |
2488 GList *node, *next_node; | |
2489 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2490 PLAYLIST_LOCK(playlist->mutex); |
0 | 2491 |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2492 for (node = playlist->entries; node; node = next_node) { |
0 | 2493 PlaylistEntry *entry = PLAYLIST_ENTRY(node->data); |
2494 next_node = g_list_next(node); | |
2495 | |
2496 if (!entry || !entry->filename) { | |
2497 g_message(G_STRLOC ": Playlist entry is invalid!"); | |
2498 continue; | |
2499 } | |
2500 | |
2501 /* FIXME: What about 'file:///'? */ | |
2502 /* Don't kill URLs */ | |
2503 if (strstr(entry->filename, "://")) | |
2504 continue; | |
2505 | |
2506 /* FIXME: Should test for readability */ | |
2507 if (vfs_file_test(entry->filename, G_FILE_TEST_EXISTS)) | |
2508 continue; | |
2509 | |
2096 | 2510 if (entry == playlist->position) { |
0 | 2511 /* Don't remove the currently playing song */ |
2512 if (bmp_playback_get_playing()) | |
2513 continue; | |
2514 | |
2515 if (next_node) | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2516 playlist->position = PLAYLIST_ENTRY(next_node->data); |
0 | 2517 else |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2518 playlist->position = NULL; |
0 | 2519 } |
2520 | |
2521 playlist_entry_free(entry); | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2522 playlist->entries = g_list_delete_link(playlist->entries, node); |
0 | 2523 } |
2524 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2525 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 2526 |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2527 playlist_generate_shuffle_list(playlist); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2528 playlistwin_update_list(playlist); |
2085 | 2529 playlist_recalc_total_time(playlist); |
0 | 2530 } |
2531 | |
852
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2532 |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2533 static gint |
1251 | 2534 playlist_dupscmp_title(PlaylistEntry * a, |
2535 PlaylistEntry * b) | |
852
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2536 { |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2537 const gchar *a_title, *b_title; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2538 |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2539 g_return_val_if_fail(a != NULL, 0); |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2540 g_return_val_if_fail(b != NULL, 0); |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2541 |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2542 if (a->title) |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2543 a_title = a->title; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2544 else { |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2545 if (strrchr(a->filename, '/')) |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2546 a_title = strrchr(a->filename, '/') + 1; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2547 else |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2548 a_title = a->filename; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2549 } |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2550 |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2551 if (b->title) |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2552 b_title = b->title; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2553 else { |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2554 if (strrchr(a->filename, '/')) |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2555 b_title = strrchr(b->filename, '/') + 1; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2556 else |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2557 b_title = b->filename; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2558 } |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2559 |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2560 return strcmp(a_title, b_title); |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2561 } |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2562 |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2563 static gint |
1251 | 2564 playlist_dupscmp_filename(PlaylistEntry * a, |
2565 PlaylistEntry * b ) | |
852
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2566 { |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2567 gchar *a_filename, *b_filename; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2568 |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2569 g_return_val_if_fail(a != NULL, 0); |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2570 g_return_val_if_fail(b != NULL, 0); |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2571 |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2572 if (strrchr(a->filename, '/')) |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2573 a_filename = strrchr(a->filename, '/') + 1; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2574 else |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2575 a_filename = a->filename; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2576 |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2577 if (strrchr(b->filename, '/')) |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2578 b_filename = strrchr(b->filename, '/') + 1; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2579 else |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2580 b_filename = b->filename; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2581 |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2582 return strcmp(a_filename, b_filename); |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2583 } |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2584 |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2585 static gint |
1251 | 2586 playlist_dupscmp_path(PlaylistEntry * a, |
2587 PlaylistEntry * b) | |
852
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2588 { |
853 | 2589 /* simply compare the entire filename string */ |
2590 return strcmp(a->filename, b->filename); | |
852
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2591 } |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2592 |
840
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2593 void |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2594 playlist_remove_duplicates(Playlist *playlist, PlaylistDupsType type) |
840
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2595 { |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2596 GList *node, *next_node; |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2597 GList *node_cmp, *next_node_cmp; |
1251 | 2598 gint (*dups_compare_func)(PlaylistEntry * , PlaylistEntry *); |
852
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2599 |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2600 switch ( type ) |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2601 { |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2602 case PLAYLIST_DUPS_TITLE: |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2603 dups_compare_func = playlist_dupscmp_title; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2604 break; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2605 case PLAYLIST_DUPS_PATH: |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2606 dups_compare_func = playlist_dupscmp_path; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2607 break; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2608 case PLAYLIST_DUPS_FILENAME: |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2609 default: |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2610 dups_compare_func = playlist_dupscmp_filename; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2611 break; |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2612 } |
840
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2613 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2614 PLAYLIST_LOCK(playlist->mutex); |
840
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2615 |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2616 for (node = playlist->entries; node; node = next_node) { |
840
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2617 PlaylistEntry *entry = PLAYLIST_ENTRY(node->data); |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2618 next_node = g_list_next(node); |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2619 |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2620 if (!entry || !entry->filename) { |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2621 g_message(G_STRLOC ": Playlist entry is invalid!"); |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2622 continue; |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2623 } |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2624 |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2625 for (node_cmp = next_node; node_cmp; node_cmp = next_node_cmp) { |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2626 PlaylistEntry *entry_cmp = PLAYLIST_ENTRY(node_cmp->data); |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2627 next_node_cmp = g_list_next(node_cmp); |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2628 |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2629 if (!entry_cmp || !entry_cmp->filename) { |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2630 g_message(G_STRLOC ": Playlist entry is invalid!"); |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2631 continue; |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2632 } |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2633 |
852
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2634 /* compare using the chosen dups_compare_func */ |
bcff46a2558d
[svn] added multiple 'remove duplicates' (by title, by filename, by path+filename)
giacomo
parents:
840
diff
changeset
|
2635 if ( !dups_compare_func( entry , entry_cmp ) ) { |
840
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2636 |
2096 | 2637 if (entry_cmp == playlist->position) { |
840
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2638 /* Don't remove the currently playing song */ |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2639 if (bmp_playback_get_playing()) |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2640 continue; |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2641 |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2642 if (next_node_cmp) |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2643 playlist->position = PLAYLIST_ENTRY(next_node_cmp->data); |
840
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2644 else |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2645 playlist->position = NULL; |
840
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2646 } |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2647 |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2648 /* check if this was the next item of the external |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2649 loop; if true, replace it with the next of the next*/ |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2650 if ( node_cmp == next_node ) |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2651 next_node = g_list_next(next_node); |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2652 |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2653 playlist_entry_free(entry_cmp); |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
2654 playlist->entries = g_list_delete_link(playlist->entries, node_cmp); |
840
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2655 } |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2656 } |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2657 } |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2658 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2659 PLAYLIST_UNLOCK(playlist->mutex); |
840
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2660 |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2661 playlistwin_update_list(playlist); |
2085 | 2662 playlist_recalc_total_time(playlist); |
840
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2663 } |
ffc5ab7b4b2c
[svn] added a 'remove duplicates' option to the playlist removal menu
giacomo
parents:
633
diff
changeset
|
2664 |
0 | 2665 void |
2085 | 2666 playlist_get_total_time(Playlist * playlist, |
2667 gulong * total_time, | |
0 | 2668 gulong * selection_time, |
2669 gboolean * total_more, | |
2670 gboolean * selection_more) | |
2671 { | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2672 PLAYLIST_LOCK(playlist->mutex); |
2085 | 2673 *total_time = playlist->pl_total_time; |
2674 *selection_time = playlist->pl_selection_time; | |
2675 *total_more = playlist->pl_total_more; | |
2676 *selection_more = playlist->pl_selection_more; | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2677 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 2678 } |
2679 | |
2680 | |
2681 static void | |
2085 | 2682 playlist_recalc_total_time_nolock(Playlist *playlist) |
0 | 2683 { |
2684 GList *list; | |
2685 PlaylistEntry *entry; | |
2686 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2687 REQUIRE_LOCK(playlist->mutex); |
0 | 2688 |
2085 | 2689 playlist->pl_total_time = 0; |
2690 playlist->pl_selection_time = 0; | |
2691 playlist->pl_total_more = FALSE; | |
2692 playlist->pl_selection_more = FALSE; | |
0 | 2693 |
2120
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
2694 for (list = playlist->entries; list; list = g_list_next(list)) { |
0 | 2695 entry = list->data; |
2696 | |
2697 if (entry->length != -1) | |
2085 | 2698 playlist->pl_total_time += entry->length / 1000; |
0 | 2699 else |
2085 | 2700 playlist->pl_total_more = TRUE; |
0 | 2701 |
2702 if (entry->selected) { | |
2703 if (entry->length != -1) | |
2085 | 2704 playlist->pl_selection_time += entry->length / 1000; |
0 | 2705 else |
2085 | 2706 playlist->pl_selection_more = TRUE; |
0 | 2707 } |
2708 } | |
2709 } | |
2710 | |
2711 static void | |
2085 | 2712 playlist_recalc_total_time(Playlist *playlist) |
0 | 2713 { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2714 PLAYLIST_LOCK(playlist->mutex); |
2085 | 2715 playlist_recalc_total_time_nolock(playlist); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2716 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 2717 } |
2718 | |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2719 gint |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2720 playlist_select_search( Playlist *playlist , TitleInput *tuple , gint action ) |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2721 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2722 GList *entry_list = NULL, *found_list = NULL, *sel_list = NULL; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2723 gboolean is_first_search = TRUE; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2724 gint num_of_entries_found = 0; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2725 |
2168
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2726 #if defined(USE_REGEX_ONIGURUMA) |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2727 /* set encoding for Oniguruma regex to UTF-8 */ |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2728 reg_set_encoding( REG_POSIX_ENCODING_UTF8 ); |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2729 onig_set_default_syntax( ONIG_SYNTAX_POSIX_BASIC ); |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2730 #endif |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2731 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2732 PLAYLIST_LOCK(playlist->mutex); |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2733 |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2734 if ( tuple->track_name != NULL ) |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2735 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2736 /* match by track_name */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2737 const gchar *regex_pattern = tuple->track_name; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2738 regex_t regex; |
2168
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2739 #if defined(USE_REGEX_PCRE) |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2740 if ( regcomp( ®ex , regex_pattern , REG_NOSUB | REG_ICASE | REG_UTF8 ) == 0 ) |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2741 #else |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2742 if ( regcomp( ®ex , regex_pattern , REG_NOSUB | REG_ICASE ) == 0 ) |
2168
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2743 #endif |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2744 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2745 GList *tfound_list = NULL; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2746 if ( is_first_search == TRUE ) entry_list = playlist->entries; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2747 else entry_list = found_list; /* use found_list */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2748 for ( ; entry_list ; entry_list = g_list_next(entry_list) ) |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2749 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2750 PlaylistEntry *entry = entry_list->data; |
2130
fb57249c8702
[svn] do not assume that a tuple field exists just cause the tuple does, regexec hates null strings
giacomo
parents:
2129
diff
changeset
|
2751 if ( ( entry->tuple != NULL ) && ( entry->tuple->track_name != NULL ) && |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2752 ( regexec( ®ex , entry->tuple->track_name , 0 , NULL , 0 ) == 0 ) ) |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2753 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2754 tfound_list = g_list_append( tfound_list , entry ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2755 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2756 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2757 g_list_free( found_list ); /* wipe old found_list */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2758 found_list = tfound_list; /* move tfound_list in found_list */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2759 regfree( ®ex ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2760 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2761 is_first_search = FALSE; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2762 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2763 |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2764 if ( tuple->album_name != NULL ) |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2765 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2766 /* match by album_name */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2767 const gchar *regex_pattern = tuple->album_name; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2768 regex_t regex; |
2168
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2769 #if defined(USE_REGEX_PCRE) |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2770 if ( regcomp( ®ex , regex_pattern , REG_NOSUB | REG_ICASE | REG_UTF8 ) == 0 ) |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2771 #else |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2772 if ( regcomp( ®ex , regex_pattern , REG_NOSUB | REG_ICASE ) == 0 ) |
2168
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2773 #endif |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2774 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2775 GList *tfound_list = NULL; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2776 if ( is_first_search == TRUE ) entry_list = playlist->entries; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2777 else entry_list = found_list; /* use found_list */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2778 for ( ; entry_list ; entry_list = g_list_next(entry_list) ) |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2779 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2780 PlaylistEntry *entry = entry_list->data; |
2130
fb57249c8702
[svn] do not assume that a tuple field exists just cause the tuple does, regexec hates null strings
giacomo
parents:
2129
diff
changeset
|
2781 if ( ( entry->tuple != NULL ) && ( entry->tuple->album_name != NULL ) && |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2782 ( regexec( ®ex , entry->tuple->album_name , 0 , NULL , 0 ) == 0 ) ) |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2783 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2784 tfound_list = g_list_append( tfound_list , entry ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2785 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2786 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2787 g_list_free( found_list ); /* wipe old found_list */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2788 found_list = tfound_list; /* move tfound_list in found_list */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2789 regfree( ®ex ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2790 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2791 is_first_search = FALSE; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2792 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2793 |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2794 if ( tuple->performer != NULL ) |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2795 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2796 /* match by performer */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2797 const gchar *regex_pattern = tuple->performer; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2798 regex_t regex; |
2168
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2799 #if defined(USE_REGEX_PCRE) |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2800 if ( regcomp( ®ex , regex_pattern , REG_NOSUB | REG_ICASE | REG_UTF8 ) == 0 ) |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2801 #else |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2802 if ( regcomp( ®ex , regex_pattern , REG_NOSUB | REG_ICASE ) == 0 ) |
2168
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2803 #endif |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2804 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2805 GList *tfound_list = NULL; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2806 if ( is_first_search == TRUE ) entry_list = playlist->entries; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2807 else entry_list = found_list; /* use found_list */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2808 for ( ; entry_list ; entry_list = g_list_next(entry_list) ) |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2809 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2810 PlaylistEntry *entry = entry_list->data; |
2130
fb57249c8702
[svn] do not assume that a tuple field exists just cause the tuple does, regexec hates null strings
giacomo
parents:
2129
diff
changeset
|
2811 if ( ( entry->tuple != NULL ) && ( entry->tuple->performer != NULL ) && |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2812 ( regexec( ®ex , entry->tuple->performer , 0 , NULL , 0 ) == 0 ) ) |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2813 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2814 tfound_list = g_list_append( tfound_list , entry ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2815 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2816 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2817 g_list_free( found_list ); /* wipe old found_list */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2818 found_list = tfound_list; /* move tfound_list in found_list */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2819 regfree( ®ex ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2820 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2821 is_first_search = FALSE; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2822 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2823 |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2824 if ( tuple->file_name != NULL ) |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2825 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2826 /* match by file_name */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2827 const gchar *regex_pattern = tuple->file_name; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2828 regex_t regex; |
2168
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2829 #if defined(USE_REGEX_PCRE) |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2830 if ( regcomp( ®ex , regex_pattern , REG_NOSUB | REG_ICASE | REG_UTF8 ) == 0 ) |
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2831 #else |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2832 if ( regcomp( ®ex , regex_pattern , REG_NOSUB | REG_ICASE ) == 0 ) |
2168
caaf4b1a8487
[svn] - allow user to choose a regex library between gnu (default), oniguruma, pcre (experimental); oniguruma and pcre support utf-8 encoding
giacomo
parents:
2146
diff
changeset
|
2833 #endif |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2834 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2835 GList *tfound_list = NULL; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2836 if ( is_first_search == TRUE ) entry_list = playlist->entries; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2837 else entry_list = found_list; /* use found_list */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2838 for ( ; entry_list ; entry_list = g_list_next(entry_list) ) |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2839 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2840 PlaylistEntry *entry = entry_list->data; |
2130
fb57249c8702
[svn] do not assume that a tuple field exists just cause the tuple does, regexec hates null strings
giacomo
parents:
2129
diff
changeset
|
2841 if ( ( entry->tuple != NULL ) && ( entry->tuple->file_name != NULL ) && |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2842 ( regexec( ®ex , entry->tuple->file_name , 0 , NULL , 0 ) == 0 ) ) |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2843 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2844 tfound_list = g_list_append( tfound_list , entry ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2845 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2846 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2847 g_list_free( found_list ); /* wipe old found_list */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2848 found_list = tfound_list; /* move tfound_list in found_list */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2849 regfree( ®ex ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2850 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2851 is_first_search = FALSE; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2852 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2853 |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2854 /* NOTE: action = 0 -> default behaviour, select all matching entries */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2855 /* if some entries are still in found_list, those |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2856 are what the user is searching for; select them */ |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2857 for ( sel_list = found_list ; sel_list ; sel_list = g_list_next(sel_list) ) |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2858 { |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2859 PlaylistEntry *entry = sel_list->data; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2860 entry->selected = TRUE; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2861 num_of_entries_found++; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2862 } |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2863 |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2864 g_list_free( found_list ); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2865 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2866 PLAYLIST_UNLOCK(playlist->mutex); |
2129
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2867 playlist_recalc_total_time(playlist); |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2868 |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2869 return num_of_entries_found; |
0d845907c0b9
[svn] added a regex-based search option in playlist that allows to select playlist entries using multiple match criteria
giacomo
parents:
2127
diff
changeset
|
2870 } |
0 | 2871 |
2872 void | |
2085 | 2873 playlist_select_all(Playlist *playlist, gboolean set) |
0 | 2874 { |
2875 GList *list; | |
2876 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2877 PLAYLIST_LOCK(playlist->mutex); |
0 | 2878 |
2085 | 2879 for (list = playlist->entries; list; list = g_list_next(list)) { |
0 | 2880 PlaylistEntry *entry = list->data; |
2881 entry->selected = set; | |
2882 } | |
2883 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2884 PLAYLIST_UNLOCK(playlist->mutex); |
2085 | 2885 playlist_recalc_total_time(playlist); |
0 | 2886 } |
2887 | |
2888 void | |
2085 | 2889 playlist_select_invert_all(Playlist *playlist) |
0 | 2890 { |
2891 GList *list; | |
2892 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2893 PLAYLIST_LOCK(playlist->mutex); |
0 | 2894 |
2085 | 2895 for (list = playlist->entries; list; list = g_list_next(list)) { |
0 | 2896 PlaylistEntry *entry = list->data; |
2897 entry->selected = !entry->selected; | |
2898 } | |
2899 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2900 PLAYLIST_UNLOCK(playlist->mutex); |
2085 | 2901 playlist_recalc_total_time(playlist); |
0 | 2902 } |
2903 | |
2904 gboolean | |
2085 | 2905 playlist_select_invert(Playlist *playlist, guint pos) |
0 | 2906 { |
2907 GList *list; | |
2908 gboolean invert_ok = FALSE; | |
2909 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2910 PLAYLIST_LOCK(playlist->mutex); |
0 | 2911 |
2085 | 2912 if ((list = g_list_nth(playlist->entries, pos))) { |
0 | 2913 PlaylistEntry *entry = list->data; |
2914 entry->selected = !entry->selected; | |
2915 invert_ok = TRUE; | |
2916 } | |
2917 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2918 PLAYLIST_UNLOCK(playlist->mutex); |
2085 | 2919 playlist_recalc_total_time(playlist); |
0 | 2920 |
2921 return invert_ok; | |
2922 } | |
2923 | |
2924 | |
2925 void | |
2085 | 2926 playlist_select_range(Playlist *playlist, gint min_pos, gint max_pos, gboolean select) |
0 | 2927 { |
2928 GList *list; | |
2929 gint i; | |
2930 | |
2931 if (min_pos > max_pos) | |
2932 SWAP(min_pos, max_pos); | |
2933 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2934 PLAYLIST_LOCK(playlist->mutex); |
0 | 2935 |
2085 | 2936 list = g_list_nth(playlist->entries, min_pos); |
0 | 2937 for (i = min_pos; i <= max_pos && list; i++) { |
2938 PlaylistEntry *entry = list->data; | |
2939 entry->selected = select; | |
2940 list = g_list_next(list); | |
2941 } | |
2942 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2943 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 2944 |
2085 | 2945 playlist_recalc_total_time(playlist); |
0 | 2946 } |
2947 | |
2948 gboolean | |
2085 | 2949 playlist_read_info_selection(Playlist *playlist) |
0 | 2950 { |
2951 GList *node; | |
2952 gboolean retval = FALSE; | |
2953 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2954 PLAYLIST_LOCK(playlist->mutex); |
0 | 2955 |
2121
185db04b815f
[svn] - remove all improper uses of playlist_get()
nenolod
parents:
2120
diff
changeset
|
2956 for (node = playlist->entries; node; node = g_list_next(node)) { |
0 | 2957 PlaylistEntry *entry = node->data; |
2958 if (!entry->selected) | |
2959 continue; | |
2960 | |
2961 retval = TRUE; | |
2962 | |
2963 str_replace_in(&entry->title, NULL); | |
2964 entry->length = -1; | |
2965 | |
1588
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
2966 /* invalidate mtime to reread */ |
1817 | 2967 if (entry->tuple != NULL) |
1841
7d0cd3fab6a2
[svn] - mtime=-1 has been introduced to represent "uninitialized".
yaz
parents:
1834
diff
changeset
|
2968 entry->tuple->mtime = -1; /* -1 denotes "non-initialized". now 0 is for stream etc. yaz */ |
1588
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1587
diff
changeset
|
2969 |
0 | 2970 if (!playlist_entry_get_info(entry)) { |
2121
185db04b815f
[svn] - remove all improper uses of playlist_get()
nenolod
parents:
2120
diff
changeset
|
2971 if (g_list_index(playlist->entries, entry) == -1) |
0 | 2972 /* Entry disappeared while we looked it up. Restart. */ |
2121
185db04b815f
[svn] - remove all improper uses of playlist_get()
nenolod
parents:
2120
diff
changeset
|
2973 node = playlist->entries; |
0 | 2974 } |
2975 } | |
2976 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2977 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 2978 |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
2979 playlistwin_update_list(playlist); |
2085 | 2980 playlist_recalc_total_time(playlist); |
0 | 2981 |
2982 return retval; | |
2983 } | |
2984 | |
2985 void | |
2085 | 2986 playlist_read_info(Playlist *playlist, guint pos) |
0 | 2987 { |
2988 GList *node; | |
2989 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2990 PLAYLIST_LOCK(playlist->mutex); |
0 | 2991 |
2121
185db04b815f
[svn] - remove all improper uses of playlist_get()
nenolod
parents:
2120
diff
changeset
|
2992 if ((node = g_list_nth(playlist->entries, pos))) { |
0 | 2993 PlaylistEntry *entry = node->data; |
2994 str_replace_in(&entry->title, NULL); | |
2995 entry->length = -1; | |
2996 playlist_entry_get_info(entry); | |
2997 } | |
2998 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
2999 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 3000 |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
3001 playlistwin_update_list(playlist); |
2085 | 3002 playlist_recalc_total_time(playlist); |
0 | 3003 } |
3004 | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
3005 Playlist * |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
3006 playlist_get_active(void) |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
3007 { |
2120
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
3008 if (playlists_iter != NULL) |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
3009 return (Playlist *) playlists_iter->data; |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
3010 |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
3011 return (Playlist *) playlists->data; |
1d67cf383e32
[svn] - dynamically allocate the playlist at startup and fix some lingering improper uses of playlist_get()
nenolod
parents:
2105
diff
changeset
|
3012 } |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
3013 |
0 | 3014 void |
3015 playlist_set_shuffle(gboolean shuffle) | |
3016 { | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3017 Playlist *playlist = playlist_get_active(); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3018 if (!playlist) |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3019 return; |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3020 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3021 PLAYLIST_LOCK(playlist->mutex); |
0 | 3022 |
2040
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
3023 playlist_position_before_jump = NULL; |
dbe615def81f
[svn] Playlist shuffle behaviour should now be a little more consistant.
nazca
parents:
2027
diff
changeset
|
3024 |
0 | 3025 cfg.shuffle = shuffle; |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3026 playlist_generate_shuffle_list_nolock(playlist); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3027 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3028 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 3029 } |
3030 | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
3031 Playlist * |
2141
06a86fdd4fb7
[svn] added playlist_free and ensure that each created playlist is freed in mainwin_quit_cb; the list of playlists is freed there as well
giacomo
parents:
2140
diff
changeset
|
3032 playlist_new(void) |
0 | 3033 { |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
3034 Playlist *playlist = g_new0(Playlist, 1); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3035 playlist->mutex = g_mutex_new(); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
3036 playlist->loading_playlist = FALSE; |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
3037 |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
3038 playlist_set_current_name(playlist, NULL); |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
3039 playlist_clear(playlist); |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
3040 |
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
3041 return playlist; |
0 | 3042 } |
3043 | |
2141
06a86fdd4fb7
[svn] added playlist_free and ensure that each created playlist is freed in mainwin_quit_cb; the list of playlists is freed there as well
giacomo
parents:
2140
diff
changeset
|
3044 void |
06a86fdd4fb7
[svn] added playlist_free and ensure that each created playlist is freed in mainwin_quit_cb; the list of playlists is freed there as well
giacomo
parents:
2140
diff
changeset
|
3045 playlist_free(Playlist *playlist) |
06a86fdd4fb7
[svn] added playlist_free and ensure that each created playlist is freed in mainwin_quit_cb; the list of playlists is freed there as well
giacomo
parents:
2140
diff
changeset
|
3046 { |
06a86fdd4fb7
[svn] added playlist_free and ensure that each created playlist is freed in mainwin_quit_cb; the list of playlists is freed there as well
giacomo
parents:
2140
diff
changeset
|
3047 g_mutex_free( playlist->mutex ); |
06a86fdd4fb7
[svn] added playlist_free and ensure that each created playlist is freed in mainwin_quit_cb; the list of playlists is freed there as well
giacomo
parents:
2140
diff
changeset
|
3048 g_free( playlist ); |
06a86fdd4fb7
[svn] added playlist_free and ensure that each created playlist is freed in mainwin_quit_cb; the list of playlists is freed there as well
giacomo
parents:
2140
diff
changeset
|
3049 return; |
06a86fdd4fb7
[svn] added playlist_free and ensure that each created playlist is freed in mainwin_quit_cb; the list of playlists is freed there as well
giacomo
parents:
2140
diff
changeset
|
3050 } |
06a86fdd4fb7
[svn] added playlist_free and ensure that each created playlist is freed in mainwin_quit_cb; the list of playlists is freed there as well
giacomo
parents:
2140
diff
changeset
|
3051 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3052 Playlist * |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3053 playlist_new_from_selected(void) |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3054 { |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3055 Playlist *newpl = playlist_new(); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3056 Playlist *playlist = playlist_get_active(); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3057 GList *list = playlist_get_selected(playlist); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3058 |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
3059 playlist_add_playlist( newpl ); |
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
3060 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3061 PLAYLIST_LOCK(playlist->mutex); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3062 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3063 while ( list != NULL ) |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3064 { |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3065 PlaylistEntry *entry = g_list_nth_data(playlist->entries, GPOINTER_TO_INT(list->data)); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3066 if ( entry->filename != NULL ) /* paranoid? oh well... */ |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3067 playlist_add( newpl , entry->filename ); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3068 list = g_list_next(list); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3069 } |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3070 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3071 PLAYLIST_UNLOCK(playlist->mutex); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3072 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3073 playlist_recalc_total_time(newpl); |
2140
299651a8f107
[svn] - made playlistwin_update_list depend on passed Playlist* instead of blindly using playlist_get_active(); this solves many locking issues with multiple playlists, but SHOULD be reviewed in every place playlistwin_update_list is used; added a playlist_new_from_selected() call too
giacomo
parents:
2139
diff
changeset
|
3074 playlistwin_update_list(playlist); |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3075 } |
0 | 3076 |
3077 const gchar * | |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
3078 playlist_get_filename_to_play(Playlist *playlist) |
0 | 3079 { |
3080 const gchar *filename = NULL; | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3081 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3082 if (!playlist) |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3083 return NULL; |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3084 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3085 PLAYLIST_LOCK(playlist->mutex); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3086 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3087 if (!playlist->position) { |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3088 if (cfg.shuffle) |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3089 playlist->position = playlist->shuffle->data; |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3090 else |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3091 playlist->position = playlist->entries->data; |
0 | 3092 } |
3093 | |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3094 filename = playlist->position->filename; |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3095 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3096 PLAYLIST_UNLOCK(playlist->mutex); |
0 | 3097 |
3098 return filename; | |
3099 } | |
356
99928e1275a1
[svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents:
355
diff
changeset
|
3100 |
398
f908bcd87c3d
[svn] Generate cache content on demand if it was not previously there.
nenolod
parents:
397
diff
changeset
|
3101 PlaylistEntry * |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
3102 playlist_get_entry_to_play(Playlist *playlist) |
356
99928e1275a1
[svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents:
355
diff
changeset
|
3103 { |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3104 if (!playlist) |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3105 return NULL; |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3106 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3107 PLAYLIST_LOCK(playlist->mutex); |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3108 |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3109 if (!playlist->position) { |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3110 if (cfg.shuffle) |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3111 playlist->position = playlist->shuffle->data; |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3112 else |
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3113 playlist->position = playlist->entries->data; |
356
99928e1275a1
[svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents:
355
diff
changeset
|
3114 } |
99928e1275a1
[svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents:
355
diff
changeset
|
3115 |
2139
fcd1f54efdb9
[svn] - multiple playlist support requires separated locking; each Playlist holds its GMutex now; removed playlist_get function cause it doesn't fit with this scheme
giacomo
parents:
2135
diff
changeset
|
3116 PLAYLIST_UNLOCK(playlist->mutex); |
356
99928e1275a1
[svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents:
355
diff
changeset
|
3117 |
2080
df6cf9cb531e
[svn] - this commit breaks the API. I'm not done here, but hopefully the new API is
nenolod
parents:
2073
diff
changeset
|
3118 return playlist->position; |
356
99928e1275a1
[svn] This commit reduces the amount of times we probe a source down to ONE
nenolod
parents:
355
diff
changeset
|
3119 } |