annotate audacious/playlist.c @ 2080:df6cf9cb531e trunk

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