annotate audacious/playlist.c @ 2081:b98891c9e155 trunk

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