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