annotate audacious/playlist.c @ 2120:1d67cf383e32 trunk

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