annotate src/audacious/playlist.c @ 4780:6284337e04fd

g_basename is deprecated, replace with g_path_get_basename.
author Tony Vroon <chainsaw@gentoo.org>
date Fri, 26 Sep 2008 21:38:00 +0100
parents 34e0d0de2018
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1 /* Audacious
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2 * Copyright (C) 2005-2007 Audacious team.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
4 * BMP (C) GPL 2003 $top_src_dir/AUTHORS
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
5 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
6 * based on:
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
7 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
8 * XMMS - Cross-platform multimedia player
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
9 * Copyright (C) 1998-2003 Peter Alm, Mikael Alm, Olle Hallnas,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
10 * Thomas Nilsson and 4Front Technologies
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
11 * Copyright (C) 1999-2003 Haavard Kvaalen
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
12 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
13 * This program is free software; you can redistribute it and/or modify
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
14 * it under the terms of the GNU General Public License as published by
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 3097
diff changeset
15 * the Free Software Foundation; under version 3 of the License.
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
16 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
20 * GNU General Public License for more details.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
21 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 3097
diff changeset
23 * along with this program. If not, see <http://www.gnu.org/licenses>.
3123
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
24 *
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
25 * The Audacious team does not consider modular code linking to
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
26 * Audacious or using our public API to be a derived work.
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
27 */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
28
4228
9f3cc7f3aaf6 update titles after 3 sec. delay when custom template changed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4227
diff changeset
29 /* #define AUD_DEBUG 1 */
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
30
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
31 #ifdef HAVE_CONFIG_H
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
32 # include "config.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
33 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
34
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
35 #include "playlist.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
36
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
37 #include <glib.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
38 #include <glib/gprintf.h>
4505
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4504
diff changeset
39 #include <mowgli.h>
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
40 #include <stdlib.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
41 #include <string.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
42 #include <sys/types.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
43 #include <sys/stat.h>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
44 #include <sys/errno.h>
4505
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4504
diff changeset
45 #include <time.h>
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4504
diff changeset
46 #include <unistd.h>
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
47
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
48 #if defined(USE_REGEX_ONIGURUMA)
3460
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
49 # include <onigposix.h>
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
50 #elif defined(USE_REGEX_PCRE)
3460
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
51 # include <pcreposix.h>
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
52 #else
3460
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
53 # include <regex.h>
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
54 #endif
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
55
4505
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4504
diff changeset
56 #include "configdb.h"
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4504
diff changeset
57 #include "hook.h"
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
58 #include "input.h"
4505
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4504
diff changeset
59 #include "playback.h"
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4504
diff changeset
60 #include "playlist_container.h"
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4504
diff changeset
61 #include "playlist_evmessages.h"
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4504
diff changeset
62 #include "pluginenum.h"
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4504
diff changeset
63 #include "strings.h"
4700
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents: 4646
diff changeset
64 #include "legacy/ui_playlist.h"
4505
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4504
diff changeset
65 #include "util.h"
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4504
diff changeset
66 #include "vfs.h"
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
67
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
68 #include "debug.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
69
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
70 typedef gint (*PlaylistCompareFunc) (PlaylistEntry * a, PlaylistEntry * b);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
71 typedef void (*PlaylistSaveFunc) (FILE * file);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
72
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
73 /* If we manually change the song, p_p_b_j will show us where to go back to */
4505
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4504
diff changeset
74 static PlaylistEntry *playlist_position_before_jump = NULL;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
75
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
76 static GList *playlists = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
77 static GList *playlists_iter;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
78
4505
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4504
diff changeset
79
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
80 /* If this is set to TRUE, we do not probe upon playlist add.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
81 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
82 * Under Audacious 0.1.x, this was not a big deal because we used
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
83 * file extension introspection instead of looking for file format magic
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
84 * strings.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
85 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
86 * Because we use file magic strings, we have to fstat a file being added
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
87 * to a playlist up to 1 * <number of input plugins installed> times.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
88 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
89 * This can get really slow now that we're looking for files to add to a
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
90 * playlist. (Up to 5 minutes for 5000 songs, etcetera.)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
91 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
92 * So, we obviously don't want to probe while opening a large playlist
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
93 * up. Hince the boolean below.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
94 *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
95 * January 7, 2006, William Pitcock <nenolod@nenolod.net>
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
96 */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
97
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
98 static gboolean playlist_get_info_scan_active = FALSE;
4505
a849b8af8db6 - make a lot of stuff static
mf0102 <0102@gmx.at>
parents: 4504
diff changeset
99 static GStaticRWLock playlist_get_info_rwlock = G_STATIC_RW_LOCK_INIT;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
100 static gboolean playlist_get_info_going = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
101 static GThread *playlist_get_info_thread;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
102
3934
e924c9ee3958 when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3923
diff changeset
103 extern GHashTable *ext_hash;
e924c9ee3958 when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3923
diff changeset
104
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
105 static gint path_compare(const gchar * a, const gchar * b);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
106 static gint playlist_compare_path(PlaylistEntry * a, PlaylistEntry * b);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
107 static gint playlist_compare_filename(PlaylistEntry * a, PlaylistEntry * b);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
108 static gint playlist_compare_title(PlaylistEntry * a, PlaylistEntry * b);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
109 static gint playlist_compare_artist(PlaylistEntry * a, PlaylistEntry * b);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
110 static time_t playlist_get_mtime(const gchar *filename);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
111 static gint playlist_compare_date(PlaylistEntry * a, PlaylistEntry * b);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
112 static gint playlist_compare_track(PlaylistEntry * a, PlaylistEntry * b);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
113 static gint playlist_compare_playlist(PlaylistEntry * a, PlaylistEntry * b);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
114
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
115 static gint playlist_dupscmp_path(PlaylistEntry * a, PlaylistEntry * b);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
116 static gint playlist_dupscmp_filename(PlaylistEntry * a, PlaylistEntry * b);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
117 static gint playlist_dupscmp_title(PlaylistEntry * a, PlaylistEntry * b);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
118
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
119 static PlaylistCompareFunc playlist_compare_func_table[] = {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
120 playlist_compare_path,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
121 playlist_compare_filename,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
122 playlist_compare_title,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
123 playlist_compare_artist,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
124 playlist_compare_date,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
125 playlist_compare_track,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
126 playlist_compare_playlist
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
127 };
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
128
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
129 static guint playlist_load_ins(Playlist * playlist, const gchar * filename, gint pos);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
130
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
131 static void playlist_generate_shuffle_list(Playlist *);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
132 static void playlist_generate_shuffle_list_nolock(Playlist *);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
133
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
134 static void playlist_recalc_total_time_nolock(Playlist *);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
135 static void playlist_recalc_total_time(Playlist *);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
136 static gboolean playlist_entry_get_info(PlaylistEntry * entry);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
137
3971
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
138
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
139 #define EXT_TRUE 1
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
140 #define EXT_FALSE 0
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
141 #define EXT_HAVE_SUBTUNE 2
3979
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
142 #define EXT_CUSTOM 3
3971
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
143
4532
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
144 const gchar *aud_titlestring_presets[] = {
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
145 "${title}",
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
146 "${?artist:${artist} - }${title}",
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
147 "${?artist:${artist} - }${?album:${album} - }${title}",
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
148 "${?artist:${artist} - }${?album:${album} - }${?track-number:${track-number}. }${title}",
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
149 "${?artist:${artist} }${?album:[ ${album} ] }${?artist:- }${?track-number:${track-number}. }${title}",
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
150 "${?album:${album} - }${title}"
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
151 };
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
152 const guint n_titlestring_presets = G_N_ELEMENTS(aud_titlestring_presets);
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
153
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
154
3971
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
155 static gint filter_by_extension(const gchar *filename);
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
156 static gboolean is_http(const gchar *filename);
4076
8f9966f00c98 deep copy is needed!
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4075
diff changeset
157 static gboolean do_precheck(Playlist *playlist, const gchar *uri, ProbeResult **pr);
3934
e924c9ee3958 when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3923
diff changeset
158
2633
c079e507869a [svn] - use a managed heap for playlist entry node allocation.
nenolod
parents: 2614
diff changeset
159 static mowgli_heap_t *playlist_entry_heap = NULL;
c079e507869a [svn] - use a managed heap for playlist entry node allocation.
nenolod
parents: 2614
diff changeset
160
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
161 /* *********************** playlist entry code ********************** */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
162
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
163 PlaylistEntry *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
164 playlist_entry_new(const gchar * filename,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
165 const gchar * title,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
166 const gint length,
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
167 InputPlugin * dec)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
168 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
169 PlaylistEntry *entry;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
170
2633
c079e507869a [svn] - use a managed heap for playlist entry node allocation.
nenolod
parents: 2614
diff changeset
171 entry = mowgli_heap_alloc(playlist_entry_heap);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
172 entry->filename = g_strdup(filename);
4608
23a9ded30c70 Use str_assert_utf8() where it makes sense in the core.
Matti Hamalainen <ccr@tnsp.org>
parents: 4597
diff changeset
173 entry->title = str_assert_utf8(title);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
174 entry->length = length;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
175 entry->selected = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
176 entry->decoder = dec;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
177
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
178 /* only do this if we have a decoder, otherwise it just takes too long */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
179 if (entry->decoder)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
180 playlist_entry_get_info(entry);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
181
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
182 return entry;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
183 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
184
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
185 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
186 playlist_entry_free(PlaylistEntry * entry)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
187 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
188 if (!entry)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
189 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
190
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
191 if (entry->tuple != NULL) {
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
192 mowgli_object_unref(entry->tuple);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
193 entry->tuple = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
194 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
195
3510
b2a82a73a788 Few bits of pre-integration shit.
Matti Hamalainen <ccr@tnsp.org>
parents: 3507
diff changeset
196 g_free(entry->filename);
b2a82a73a788 Few bits of pre-integration shit.
Matti Hamalainen <ccr@tnsp.org>
parents: 3507
diff changeset
197 g_free(entry->title);
2633
c079e507869a [svn] - use a managed heap for playlist entry node allocation.
nenolod
parents: 2614
diff changeset
198 mowgli_heap_free(playlist_entry_heap, entry);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
199 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
200
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
201 static gboolean
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
202 playlist_entry_get_info(PlaylistEntry * entry)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
203 {
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
204 Tuple *tuple = NULL;
3127
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
205 ProbeResult *pr = NULL;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
206 time_t modtime;
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
207 const gchar *formatter;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
208
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
209 g_return_val_if_fail(entry != NULL, FALSE);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
210
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
211 if (entry->tuple == NULL || tuple_get_int(entry->tuple, FIELD_MTIME, NULL) > 0 ||
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
212 tuple_get_int(entry->tuple, FIELD_MTIME, NULL) == -1)
2636
517d13842fe7 [svn] improve support for static playlist.
yaz
parents: 2633
diff changeset
213 modtime = playlist_get_mtime(entry->filename);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
214 else
2636
517d13842fe7 [svn] improve support for static playlist.
yaz
parents: 2633
diff changeset
215 modtime = 0; /* URI -nenolod */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
216
2668
d5da5d37ec8b [svn] - unlock many playlist operations that do not really need locking
nenolod
parents: 2667
diff changeset
217 if (str_has_prefix_nocase(entry->filename, "http:") &&
d5da5d37ec8b [svn] - unlock many playlist operations that do not really need locking
nenolod
parents: 2667
diff changeset
218 g_thread_self() != playlist_get_info_thread)
d5da5d37ec8b [svn] - unlock many playlist operations that do not really need locking
nenolod
parents: 2667
diff changeset
219 return FALSE;
d5da5d37ec8b [svn] - unlock many playlist operations that do not really need locking
nenolod
parents: 2667
diff changeset
220
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
221 if (entry->decoder == NULL) {
3127
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
222 pr = input_check_file(entry->filename, FALSE);
4184
4b4810391b05 Make sure "if (pr)" doesn't get optimized out. (Bugzilla #30)
William Pitcock <nenolod@atheme.org>
parents: 4114
diff changeset
223 if (pr != NULL)
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
224 entry->decoder = pr->ip;
3127
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
225 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
226
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
227 /* renew tuple if file mtime is newer than tuple mtime. */
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
228 if (entry->tuple){
4105
0d300e0b0001 Fixes memory leak in playlist_entry_get_info() due not freeing probe result (Bugzilla #38)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 4100
diff changeset
229 if (tuple_get_int(entry->tuple, FIELD_MTIME, NULL) == modtime) {
4227
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
230 if (pr != NULL) g_free(pr);
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
231
4227
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
232 if (entry->title_is_valid == FALSE) { /* update title even tuple is present and up to date --asphyx */
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
233 AUDDBG("updating title from actual tuple\n");
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
234 formatter = tuple_get_string(entry->tuple, FIELD_FORMATTER, NULL);
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
235 if (entry->title != NULL) g_free(entry->title);
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
236 entry->title = tuple_formatter_make_title_string(entry->tuple, formatter ?
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
237 formatter : get_gentitle_format());
4227
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
238 entry->title_is_valid = TRUE;
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
239 AUDDBG("new title: \"%s\"\n", entry->title);
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
240 }
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
241
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
242 return TRUE;
4105
0d300e0b0001 Fixes memory leak in playlist_entry_get_info() due not freeing probe result (Bugzilla #38)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 4100
diff changeset
243 } else {
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
244 mowgli_object_unref(entry->tuple);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
245 entry->tuple = NULL;
4597
aec8fc12e075 prevent endless loop
Tomasz Mon <desowin@gmail.com>
parents: 4581
diff changeset
246 return TRUE;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
247 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
248 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
249
3127
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
250 if (pr != NULL && pr->tuple != NULL)
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
251 tuple = pr->tuple;
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
252 else if (entry->decoder != NULL && entry->decoder->get_song_tuple != NULL)
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4228
diff changeset
253 {
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4228
diff changeset
254 plugin_set_current((Plugin *)(entry->decoder));
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
255 tuple = entry->decoder->get_song_tuple(entry->filename);
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4228
diff changeset
256 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
257
4105
0d300e0b0001 Fixes memory leak in playlist_entry_get_info() due not freeing probe result (Bugzilla #38)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 4100
diff changeset
258 if (tuple == NULL) {
4227
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
259 if (pr != NULL) g_free(pr);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
260 return FALSE;
4105
0d300e0b0001 Fixes memory leak in playlist_entry_get_info() due not freeing probe result (Bugzilla #38)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 4100
diff changeset
261 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
262
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
263 /* attach mtime */
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
264 tuple_associate_int(tuple, FIELD_MTIME, NULL, modtime);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
265
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
266 /* entry is still around */
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
267 formatter = tuple_get_string(tuple, FIELD_FORMATTER, NULL);
3349
01a241d35146 add tuple_formatter_make_title_string(). it is a wrapper function to tuple_formatter_process_construct() to make title string. it falls back to the file name if the formatted string is blank or unavailable.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3348
diff changeset
268 entry->title = tuple_formatter_make_title_string(tuple, formatter ?
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
269 formatter : get_gentitle_format());
4227
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
270 entry->title_is_valid = TRUE;
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
271 entry->length = tuple_get_int(tuple, FIELD_LENGTH, NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
272 entry->tuple = tuple;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
273
4227
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
274 if (pr != NULL) g_free(pr);
3127
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
275
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
276 return TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
277 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
278
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
279 /* *********************** playlist selector code ************************* */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
280
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
281 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
282 playlist_init(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
283 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
284 Playlist *initial_pl;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
285
2633
c079e507869a [svn] - use a managed heap for playlist entry node allocation.
nenolod
parents: 2614
diff changeset
286 /* create a heap with 1024 playlist entry nodes preallocated. --nenolod */
c079e507869a [svn] - use a managed heap for playlist entry node allocation.
nenolod
parents: 2614
diff changeset
287 playlist_entry_heap = mowgli_heap_create(sizeof(PlaylistEntry), 1024,
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
288 BH_NOW);
2633
c079e507869a [svn] - use a managed heap for playlist entry node allocation.
nenolod
parents: 2614
diff changeset
289
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
290 /* FIXME: is this really necessary? REQUIRE_STATIC_LOCK(playlists); */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
291
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
292 initial_pl = playlist_new();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
293
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
294 playlist_add_playlist(initial_pl);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
295 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
296
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
297 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
298 playlist_add_playlist(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
299 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
300 playlists = g_list_append(playlists, playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
301
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
302 if (playlists_iter == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
303 playlists_iter = playlists;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
304
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
305 hook_call("playlist update", NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
306 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
307
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
308 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
309 playlist_remove_playlist(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
310 {
3473
3b26640f9fd6 Don't stop playback when deleting a non-active playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3401
diff changeset
311 gboolean active;
3b26640f9fd6 Don't stop playback when deleting a non-active playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3401
diff changeset
312 active = (playlist && playlist == playlist_get_active());
2820
81604260bc08 [svn] - make playback stop on removing playlist.
yaz
parents: 2792
diff changeset
313 /* users suppose playback will be stopped on removing playlist */
3473
3b26640f9fd6 Don't stop playback when deleting a non-active playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3401
diff changeset
314 if (active && playback_get_playing()) {
2820
81604260bc08 [svn] - make playback stop on removing playlist.
yaz
parents: 2792
diff changeset
315 ip_data.stop = TRUE;
81604260bc08 [svn] - make playback stop on removing playlist.
yaz
parents: 2792
diff changeset
316 playback_stop();
81604260bc08 [svn] - make playback stop on removing playlist.
yaz
parents: 2792
diff changeset
317 ip_data.stop = FALSE;
4504
a47288ced5d5 - renamed some files to reflect their UI contents
mf0102 <0102@gmx.at>
parents: 4412
diff changeset
318 hook_call("playlist end reached", NULL);
2820
81604260bc08 [svn] - make playback stop on removing playlist.
yaz
parents: 2792
diff changeset
319 }
81604260bc08 [svn] - make playback stop on removing playlist.
yaz
parents: 2792
diff changeset
320
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
321 /* trying to free the last playlist simply clears and resets it */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
322 if (g_list_length(playlists) < 2) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
323 playlist_clear(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
324 playlist_set_current_name(playlist, NULL);
3477
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
325 playlist_filename_set(playlist, NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
326 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
327 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
328
3473
3b26640f9fd6 Don't stop playback when deleting a non-active playlist
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3401
diff changeset
329 if (active) playlist_select_next();
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
330
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
331 /* upon removal, a playlist should be cleared and freed */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
332 playlists = g_list_remove(playlists, playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
333 playlist_clear(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
334 playlist_free(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
335
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
336 if (playlists_iter == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
337 playlists_iter = playlists;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
338
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
339 hook_call("playlist update", NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
340 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
341
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
342 GList *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
343 playlist_get_playlists(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
344 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
345 return playlists;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
346 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
347
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
348 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
349 playlist_select_next(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
350 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
351 if (playlists_iter == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
352 playlists_iter = playlists;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
353
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
354 playlists_iter = g_list_next(playlists_iter);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
355
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
356 if (playlists_iter == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
357 playlists_iter = playlists;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
358
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
359 hook_call("playlist update", playlist_get_active());
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
360 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
361
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
362 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
363 playlist_select_prev(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
364 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
365 if (playlists_iter == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
366 playlists_iter = playlists;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
367
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
368 playlists_iter = g_list_previous(playlists_iter);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
369
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
370 if (playlists_iter == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
371 playlists_iter = playlists;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
372
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
373 hook_call("playlist update", playlist_get_active());
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
374 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
375
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
376 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
377 playlist_select_playlist(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
378 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
379 playlists_iter = g_list_find(playlists, playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
380
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
381 if (playlists_iter == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
382 playlists_iter = playlists;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
383
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
384 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
385 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
386
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
387 /* *********************** playlist code ********************** */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
388
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
389 const gchar *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
390 playlist_get_current_name(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
391 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
392 return playlist->title;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
393 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
394
3477
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
395 /* This function now sets the playlist title, not the playlist filename.
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
396 * See playlist_filename_set */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
397 gboolean
3477
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
398 playlist_set_current_name(Playlist *playlist, const gchar * title)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
399 {
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
400 gchar *oldtitle = playlist->title;
3477
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
401
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
402 if (!title) {
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
403 playlist->title = NULL;
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
404 g_free(oldtitle);
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
405 hook_call("playlist update", NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
406 return FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
407 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
408
4608
23a9ded30c70 Use str_assert_utf8() where it makes sense in the core.
Matti Hamalainen <ccr@tnsp.org>
parents: 4597
diff changeset
409 playlist->title = str_assert_utf8(title);
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
410 g_free(oldtitle);
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
411 hook_call("playlist update", NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
412 return TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
413 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
414
3477
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
415 /* Setting the filename allows the original playlist to be modified later */
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
416 gboolean
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
417 playlist_filename_set(Playlist *playlist, const gchar * filename)
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
418 {
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
419 gchar *old;
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
420 old = playlist->filename;
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
421
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
422 if (!filename) {
3477
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
423 playlist->filename = NULL;
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
424 g_free(old);
3477
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
425 return FALSE;
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
426 }
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
427
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
428 playlist->filename = filename_to_utf8(filename);
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
429 g_free(old);
3477
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
430 return TRUE;
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
431 }
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
432
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
433 gchar *
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
434 playlist_filename_get(Playlist *playlist)
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
435 {
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
436 if (!playlist->filename) return NULL;
3477
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
437 return g_filename_from_utf8(playlist->filename, -1, NULL, NULL, NULL);
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
438 }
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
439
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
440 static GList *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
441 find_playlist_position_list(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
442 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
443 REQUIRE_LOCK(playlist->mutex);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
444
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
445 if (!playlist->position) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
446 if (cfg.shuffle)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
447 return playlist->shuffle;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
448 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
449 return playlist->entries;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
450 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
451
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
452 if (cfg.shuffle)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
453 return g_list_find(playlist->shuffle, playlist->position);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
454 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
455 return g_list_find(playlist->entries, playlist->position);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
456 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
457
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
458 static void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
459 play_queued(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
460 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
461 GList *tmp = playlist->queue;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
462
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
463 REQUIRE_LOCK(playlist->mutex);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
464
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
465 playlist->position = playlist->queue->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
466 playlist->queue = g_list_remove_link(playlist->queue, playlist->queue);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
467 g_list_free_1(tmp);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
468 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
469
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
470 void
3460
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
471 playlist_clear_only(Playlist *playlist)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
472 {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
473 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
474
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
475 g_list_foreach(playlist->entries, (GFunc) playlist_entry_free, NULL);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
476 g_list_free(playlist->entries);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
477 playlist->position = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
478 playlist->entries = NULL;
2549
ef59b072a5d2 [svn] - update playlist->tail when an entry has been removed.
yaz
parents: 2548
diff changeset
479 playlist->tail = NULL;
2637
420ce282920d [svn] - clear playlist attribute when playlist_clear() is called.
yaz
parents: 2636
diff changeset
480 playlist->attribute = PLAYLIST_PLAIN;
3920
c2b2828186ba - serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3867
diff changeset
481 playlist->serial = 0;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
482
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
483 PLAYLIST_UNLOCK(playlist);
3460
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
484 }
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
485
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
486 void
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
487 playlist_clear(Playlist *playlist)
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
488 {
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
489 if (!playlist)
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
490 return;
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
491
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
492 playlist_clear_only(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
493 playlist_generate_shuffle_list(playlist);
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
494 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
495 playlist_recalc_total_time(playlist);
3923
e9fd46b0893b - redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3922
diff changeset
496 PLAYLIST_INCR_SERIAL(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
497 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
498
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
499 static void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
500 playlist_delete_node(Playlist * playlist, GList * node, gboolean * set_info_text,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
501 gboolean * restart_playing)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
502 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
503 PlaylistEntry *entry;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
504 GList *playing_song = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
505
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
506 REQUIRE_LOCK(playlist->mutex);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
507
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
508 /* We call g_list_find manually here because we don't want an item
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
509 * in the shuffle_list */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
510
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
511 if (playlist->position)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
512 playing_song = g_list_find(playlist->entries, playlist->position);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
513
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
514 entry = PLAYLIST_ENTRY(node->data);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
515
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
516 if (playing_song == node) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
517 *set_info_text = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
518
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
519 if (playback_get_playing()) {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
520 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
521 ip_data.stop = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
522 playback_stop();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
523 ip_data.stop = FALSE;
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
524 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
525 *restart_playing = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
526 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
527
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
528 playing_song = find_playlist_position_list(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
529
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
530 if (g_list_next(playing_song))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
531 playlist->position = g_list_next(playing_song)->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
532 else if (g_list_previous(playing_song))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
533 playlist->position = g_list_previous(playing_song)->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
534 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
535 playlist->position = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
536
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
537 /* Make sure the entry did not disappear under us */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
538 if (g_list_index(playlist->entries, entry) == -1)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
539 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
540
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
541 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
542 else if (g_list_position(playlist->entries, playing_song) >
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
543 g_list_position(playlist->entries, node)) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
544 *set_info_text = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
545 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
546
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
547 playlist->shuffle = g_list_remove(playlist->shuffle, entry);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
548 playlist->queue = g_list_remove(playlist->queue, entry);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
549 playlist->entries = g_list_remove_link(playlist->entries, node);
2549
ef59b072a5d2 [svn] - update playlist->tail when an entry has been removed.
yaz
parents: 2548
diff changeset
550 playlist->tail = g_list_last(playlist->entries);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
551 playlist_entry_free(entry);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
552 g_list_free_1(node);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
553
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
554 playlist_recalc_total_time_nolock(playlist);
3923
e9fd46b0893b - redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3922
diff changeset
555 PLAYLIST_INCR_SERIAL(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
556 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
557
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
558 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
559 playlist_delete_index(Playlist *playlist, guint pos)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
560 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
561 gboolean restart_playing = FALSE, set_info_text = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
562 GList *node;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
563
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
564 if (!playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
565 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
566
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
567 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
568
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
569 node = g_list_nth(playlist->entries, pos);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
570
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
571 if (!node) {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
572 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
573 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
574 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
575
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
576 playlist_delete_node(playlist, node, &set_info_text, &restart_playing);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
577
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
578 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
579
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
580 playlist_recalc_total_time(playlist);
3923
e9fd46b0893b - redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3922
diff changeset
581 PLAYLIST_INCR_SERIAL(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
582
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
583 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
584 if (restart_playing) {
3348
2a081105513c -Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents: 3346
diff changeset
585 if (playlist->position)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
586 playback_initiate();
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
587 else
4504
a47288ced5d5 - renamed some files to reflect their UI contents
mf0102 <0102@gmx.at>
parents: 4412
diff changeset
588 hook_call("playlist end reached", NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
589 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
590 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
591
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
592 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
593 playlist_delete(Playlist * playlist, gboolean crop)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
594 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
595 gboolean restart_playing = FALSE, set_info_text = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
596 GList *node, *next_node;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
597 PlaylistEntry *entry;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
598
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
599 g_return_if_fail(playlist != NULL);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
600
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
601 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
602
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
603 node = playlist->entries;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
604
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
605 while (node) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
606 entry = PLAYLIST_ENTRY(node->data);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
607
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
608 next_node = g_list_next(node);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
609
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
610 if ((entry->selected && !crop) || (!entry->selected && crop)) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
611 playlist_delete_node(playlist, node, &set_info_text, &restart_playing);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
612 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
613
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
614 node = next_node;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
615 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
616
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
617 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
618
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
619 playlist_recalc_total_time(playlist);
3923
e9fd46b0893b - redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3922
diff changeset
620 PLAYLIST_INCR_SERIAL(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
621
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
622 if (restart_playing) {
3348
2a081105513c -Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents: 3346
diff changeset
623 if (playlist->position)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
624 playback_initiate();
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
625 else
4504
a47288ced5d5 - renamed some files to reflect their UI contents
mf0102 <0102@gmx.at>
parents: 4412
diff changeset
626 hook_call("playlist end reached", NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
627 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
628
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
629 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
630 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
631
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
632 static void
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
633 __playlist_ins_file(Playlist * playlist,
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
634 const gchar * filename,
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
635 gint pos,
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
636 Tuple *tuple,
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
637 const gchar *title, // may NULL
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
638 gint len,
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
639 InputPlugin * dec)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
640 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
641 PlaylistEntry *entry;
3778
b4fe7d2a0d0d Use a more describing variable name.
Matti Hamalainen <ccr@tnsp.org>
parents: 3733
diff changeset
642 Tuple *parent_tuple = NULL;
3784
2c92b8947057 Maybe it works now.
Matti Hamalainen <ccr@tnsp.org>
parents: 3782
diff changeset
643 gint nsubtunes = 0, subtune = 0;
3636
65b750891387 Possibly fix a lockup problem.
Matti Hamalainen <ccr@tnsp.org>
parents: 3635
diff changeset
644 gboolean add_flag = TRUE;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
645
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
646 g_return_if_fail(playlist != NULL);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
647 g_return_if_fail(filename != NULL);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
648
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
649 if (tuple != NULL) {
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
650 nsubtunes = tuple->nsubtunes;
3784
2c92b8947057 Maybe it works now.
Matti Hamalainen <ccr@tnsp.org>
parents: 3782
diff changeset
651 if (nsubtunes > 0) {
3778
b4fe7d2a0d0d Use a more describing variable name.
Matti Hamalainen <ccr@tnsp.org>
parents: 3733
diff changeset
652 parent_tuple = tuple;
3784
2c92b8947057 Maybe it works now.
Matti Hamalainen <ccr@tnsp.org>
parents: 3782
diff changeset
653 subtune = 1;
2c92b8947057 Maybe it works now.
Matti Hamalainen <ccr@tnsp.org>
parents: 3782
diff changeset
654 }
3782
a3fc112b10f1 Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry
Matti Hamalainen <ccr@tnsp.org>
parents: 3780
diff changeset
655 }
a3fc112b10f1 Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry
Matti Hamalainen <ccr@tnsp.org>
parents: 3780
diff changeset
656
a3fc112b10f1 Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry
Matti Hamalainen <ccr@tnsp.org>
parents: 3780
diff changeset
657 for (; add_flag && subtune <= nsubtunes; subtune++) {
3550
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
658 gchar *filename_entry;
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
659
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
660 if (nsubtunes > 0) {
3640
d5309028af21 Simplify adding of all sub-tunes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3638
diff changeset
661 filename_entry = g_strdup_printf("%s?%d", filename,
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
662 parent_tuple->subtunes ? parent_tuple->subtunes[subtune - 1] : subtune);
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
663
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
664 /* We're dealing with subtune, let's ask again tuple information
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
665 * to plugin, by passing the ?subtune suffix; this way we get
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
666 * specific subtune information in the tuple, if available.
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
667 */
4266
2b7a74fce100 Implemented support for multiple subplugins inside a plugin (see bug #148) and PluginHeader finalization
stefano@zanga
parents: 4228
diff changeset
668 plugin_set_current((Plugin *)dec);
3550
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
669 tuple = dec->get_song_tuple(filename_entry);
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
670 } else
3550
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
671 filename_entry = g_strdup(filename);
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
672
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
673 if (tuple) {
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
674 entry = playlist_entry_new(filename_entry,
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
675 tuple_get_string(tuple, FIELD_TITLE, NULL),
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
676 tuple_get_int(tuple, FIELD_LENGTH, NULL), dec);
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
677 }
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
678 else {
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
679 entry = playlist_entry_new(filename_entry, title, len, dec);
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
680 }
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
681
3550
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
682 g_free(filename_entry);
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
683
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
684
3784
2c92b8947057 Maybe it works now.
Matti Hamalainen <ccr@tnsp.org>
parents: 3782
diff changeset
685 PLAYLIST_LOCK(playlist);
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
686
3636
65b750891387 Possibly fix a lockup problem.
Matti Hamalainen <ccr@tnsp.org>
parents: 3635
diff changeset
687 if (!playlist->tail)
3550
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
688 playlist->tail = g_list_last(playlist->entries);
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
689
3782
a3fc112b10f1 Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry
Matti Hamalainen <ccr@tnsp.org>
parents: 3780
diff changeset
690 if (pos == -1) { // the common case
3550
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
691 GList *element;
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
692 element = g_list_alloc();
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
693 element->data = entry;
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
694 element->prev = playlist->tail; // NULL is allowed here.
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
695 element->next = NULL;
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
696
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
697 if(!playlist->entries) { // this is the first element
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
698 playlist->entries = element;
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
699 playlist->tail = element;
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
700 } else { // the rests
3636
65b750891387 Possibly fix a lockup problem.
Matti Hamalainen <ccr@tnsp.org>
parents: 3635
diff changeset
701 if (playlist->tail != NULL) {
65b750891387 Possibly fix a lockup problem.
Matti Hamalainen <ccr@tnsp.org>
parents: 3635
diff changeset
702 playlist->tail->next = element;
65b750891387 Possibly fix a lockup problem.
Matti Hamalainen <ccr@tnsp.org>
parents: 3635
diff changeset
703 playlist->tail = element;
65b750891387 Possibly fix a lockup problem.
Matti Hamalainen <ccr@tnsp.org>
parents: 3635
diff changeset
704 } else
65b750891387 Possibly fix a lockup problem.
Matti Hamalainen <ccr@tnsp.org>
parents: 3635
diff changeset
705 add_flag = FALSE;
3550
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
706 }
4646
c18e18ecc36b Proper updating of playlist->tail was missing from some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 4608
diff changeset
707 } else {
3782
a3fc112b10f1 Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry
Matti Hamalainen <ccr@tnsp.org>
parents: 3780
diff changeset
708 playlist->entries = g_list_insert(playlist->entries, entry, pos++);
4646
c18e18ecc36b Proper updating of playlist->tail was missing from some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 4608
diff changeset
709 playlist->tail = g_list_last(playlist->entries);
c18e18ecc36b Proper updating of playlist->tail was missing from some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 4608
diff changeset
710 }
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
711
3550
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
712 if (tuple != NULL) {
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
713 const gchar *formatter = tuple_get_string(tuple, FIELD_FORMATTER, NULL);
4110
d5d4590cb7d2 Fixes memory leaks when adding files to playlist (Bugzilla #34)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 4105
diff changeset
714 g_free(entry->title);
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
715 entry->title = tuple_formatter_make_title_string(tuple,
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
716 formatter ? formatter : get_gentitle_format());
4227
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
717 entry->title_is_valid = TRUE;
3550
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
718 entry->length = tuple_get_int(tuple, FIELD_LENGTH, NULL);
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
719 entry->tuple = tuple;
6b0be1d088e6 - subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
Giacomo Lozito <james@develia.org>
parents: 3512
diff changeset
720 }
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
721
3782
a3fc112b10f1 Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry
Matti Hamalainen <ccr@tnsp.org>
parents: 3780
diff changeset
722 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
723 }
3782
a3fc112b10f1 Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry
Matti Hamalainen <ccr@tnsp.org>
parents: 3780
diff changeset
724
3778
b4fe7d2a0d0d Use a more describing variable name.
Matti Hamalainen <ccr@tnsp.org>
parents: 3733
diff changeset
725 if (parent_tuple)
b4fe7d2a0d0d Use a more describing variable name.
Matti Hamalainen <ccr@tnsp.org>
parents: 3733
diff changeset
726 tuple_free(parent_tuple);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
727
3934
e924c9ee3958 when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3923
diff changeset
728 if (!tuple || (tuple && tuple_get_int(tuple, FIELD_MTIME, NULL) == -1)) {
e924c9ee3958 when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3923
diff changeset
729 // kick the scanner thread when tuple == NULL or mtime = -1 (uninitialized)
2545
610d85b8a22b [svn] - on loading a playlist with tuple, invoke the scanner thread only if mtime is -1.
yaz
parents: 2504
diff changeset
730 g_mutex_lock(mutex_scan);
610d85b8a22b [svn] - on loading a playlist with tuple, invoke the scanner thread only if mtime is -1.
yaz
parents: 2504
diff changeset
731 playlist_get_info_scan_active = TRUE;
610d85b8a22b [svn] - on loading a playlist with tuple, invoke the scanner thread only if mtime is -1.
yaz
parents: 2504
diff changeset
732 g_mutex_unlock(mutex_scan);
610d85b8a22b [svn] - on loading a playlist with tuple, invoke the scanner thread only if mtime is -1.
yaz
parents: 2504
diff changeset
733 g_cond_signal(cond_scan);
610d85b8a22b [svn] - on loading a playlist with tuple, invoke the scanner thread only if mtime is -1.
yaz
parents: 2504
diff changeset
734 }
3923
e9fd46b0893b - redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3922
diff changeset
735 PLAYLIST_INCR_SERIAL(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
736 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
737
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
738 gboolean
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
739 playlist_ins(Playlist * playlist, const gchar * filename, gint pos)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
740 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
741 gchar buf[64], *p;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
742 gint r;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
743 VFSFile *file;
3127
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
744 ProbeResult *pr = NULL;
2667
8c56926de2ad [svn] - probe remote sources (hardcoded to http://, https://) in the background.
nenolod
parents: 2637
diff changeset
745 InputPlugin *dec = NULL;
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
746 Tuple *tuple = NULL;
4075
6f4ee8c0d0d7 quick fix for the bug which had prevented to add remote url when "Detect file formats on demand" was disabled.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4070
diff changeset
747 gboolean http_flag = is_http(filename);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
748
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
749 g_return_val_if_fail(playlist != NULL, FALSE);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
750 g_return_val_if_fail(filename != NULL, FALSE);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
751
4378
342a1a1de225 Mark the playlist as modified when moving/adding/removing/sorting/randomizing the playlist, so that the jump to file cache picks up the change.
Ivan N. Zlatev <contact@i-nz.net>
parents: 4371
diff changeset
752 PLAYLIST_INCR_SERIAL(playlist);
342a1a1de225 Mark the playlist as modified when moving/adding/removing/sorting/randomizing the playlist, so that the jump to file cache picks up the change.
Ivan N. Zlatev <contact@i-nz.net>
parents: 4371
diff changeset
753
3959
a575c29cee05 - revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3947
diff changeset
754 /* load playlist */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
755 if (is_playlist_name(filename)) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
756 playlist->loading_playlist = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
757 playlist_load_ins(playlist, filename, pos);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
758 playlist->loading_playlist = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
759 return TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
760 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
761
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
762 if (do_precheck(playlist, filename, &pr)) {
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
763 if (pr) {
3127
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
764 dec = pr->ip;
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
765 tuple = pr->tuple;
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
766 }
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
767 /* add filename to playlist */
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
768 if (cfg.playlist_detect == TRUE ||
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
769 playlist->loading_playlist == TRUE ||
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
770 (playlist->loading_playlist == FALSE && dec != NULL) ||
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
771 (playlist->loading_playlist == FALSE && !is_playlist_name(filename)
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
772 && http_flag))
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
773 {
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
774 __playlist_ins_file(playlist, filename, pos, tuple, NULL, -1, dec);
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
775
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
776 g_free(pr);
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
777 playlist_generate_shuffle_list(playlist);
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
778 hook_call("playlist update", playlist);
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
779 return TRUE;
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
780 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
781 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
782
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
783 /* Some files (typically produced by some cgi-scripts) don't have
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
784 * the correct extension. Try to recognize these files by looking
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
785 * at their content. We only check for http entries since it does
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
786 * not make sense to have file entries in a playlist fetched from
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
787 * the net. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
788
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
789 /* Some strange people put fifo's with the .mp3 extension, so we
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
790 * need to make sure it's a real file (otherwise fread() may block
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
791 * and stall the entire program) */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
792
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
793 /* FIXME: bah, FIFOs actually pass this regular file test */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
794 if (!vfs_file_test(filename, G_FILE_TEST_IS_REGULAR))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
795 return FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
796
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
797 if ((file = vfs_fopen(filename, "rb")) == NULL)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
798 return FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
799
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
800 r = vfs_fread(buf, 1, sizeof(buf), file);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
801 vfs_fclose(file);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
802
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
803 for (p = buf; r-- > 0 && (*p == '\r' || *p == '\n'); p++);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
804
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
805 if (r > 5 && str_has_prefix_nocase(p, "http:")) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
806 playlist_load_ins(playlist, filename, pos);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
807 return TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
808 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
809
2493
b7f48f00a342 [svn] - patch from Mark Glines to ad https:// URI support to playlists.
nenolod
parents: 2489
diff changeset
810 if (r > 6 && str_has_prefix_nocase(p, "https:")) {
b7f48f00a342 [svn] - patch from Mark Glines to ad https:// URI support to playlists.
nenolod
parents: 2489
diff changeset
811 playlist_load_ins(playlist, filename, pos);
b7f48f00a342 [svn] - patch from Mark Glines to ad https:// URI support to playlists.
nenolod
parents: 2489
diff changeset
812 return TRUE;
b7f48f00a342 [svn] - patch from Mark Glines to ad https:// URI support to playlists.
nenolod
parents: 2489
diff changeset
813 }
b7f48f00a342 [svn] - patch from Mark Glines to ad https:// URI support to playlists.
nenolod
parents: 2489
diff changeset
814
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
815 return FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
816 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
817
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
818 /* FIXME: The next few functions are specific to Unix
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
819 * filesystems. Either abstract it away, or don't even bother checking
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
820 * at such low level */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
821
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
822 typedef struct {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
823 dev_t dev;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
824 ino_t ino;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
825 } DeviceInode;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
826
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
827 static DeviceInode *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
828 devino_new(dev_t device,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
829 ino_t inode)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
830 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
831 DeviceInode *devino = g_new0(DeviceInode, 1);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
832
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
833 if (devino) {
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
834 devino->dev = device;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
835 devino->ino = inode;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
836 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
837
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
838 return devino;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
839 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
840
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
841 static guint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
842 devino_hash(gconstpointer key)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
843 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
844 const DeviceInode *d = key;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
845 return d->ino;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
846 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
847
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
848 static gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
849 devino_compare(gconstpointer a,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
850 gconstpointer b)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
851 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
852 const DeviceInode *da = a, *db = b;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
853 return (da->dev == db->dev && da->ino == db->ino);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
854 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
855
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
856 static gboolean
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
857 devino_destroy(gpointer key,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
858 gpointer value,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
859 gpointer data)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
860 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
861 g_free(key);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
862 return TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
863 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
864
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
865 static gboolean
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
866 file_is_hidden(const gchar * filename)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
867 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
868 g_return_val_if_fail(filename != NULL, FALSE);
4780
6284337e04fd g_basename is deprecated, replace with g_path_get_basename.
Tony Vroon <chainsaw@gentoo.org>
parents: 4745
diff changeset
869 return (g_path_get_basename(filename)[0] == '.');
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
870 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
871
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
872 static GList *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
873 playlist_dir_find_files(const gchar * path,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
874 gboolean background,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
875 GHashTable * htab)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
876 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
877 GDir *dir;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
878 GList *list = NULL, *ilist;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
879 const gchar *dir_entry;
3127
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
880 ProbeResult *pr = NULL;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
881
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
882 struct stat statbuf;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
883 DeviceInode *devino;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
884
3079
72766f2e8713 recursive directory scan for add file dialog works again
Giacomo Lozito <james@develia.org>
parents: 2994
diff changeset
885 if (!path)
72766f2e8713 recursive directory scan for add file dialog works again
Giacomo Lozito <james@develia.org>
parents: 2994
diff changeset
886 return NULL;
72766f2e8713 recursive directory scan for add file dialog works again
Giacomo Lozito <james@develia.org>
parents: 2994
diff changeset
887
2993
83727fbfec54 Use vfs_file_test() where appropriate.
William Pitcock <nenolod@atheme-project.org>
parents: 2978
diff changeset
888 if (!vfs_file_test(path, G_FILE_TEST_IS_DIR))
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
889 return NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
890
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
891 stat(path, &statbuf);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
892 devino = devino_new(statbuf.st_dev, statbuf.st_ino);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
893
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
894 if (g_hash_table_lookup(htab, devino)) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
895 g_free(devino);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
896 return NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
897 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
898
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
899 g_hash_table_insert(htab, devino, GINT_TO_POINTER(1));
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
900
2994
750c530b1bf5 playlist_dir_find_files(): Return list of URIs.
William Pitcock <nenolod@atheme-project.org>
parents: 2993
diff changeset
901 /* XXX: what the hell is this for? --nenolod */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
902 if ((ilist = input_scan_dir(path))) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
903 GList *node;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
904 for (node = ilist; node; node = g_list_next(node)) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
905 gchar *name = g_build_filename(path, node->data, NULL);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
906 list = g_list_prepend(list, name);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
907 g_free(node->data);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
908 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
909 g_list_free(ilist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
910 return list;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
911 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
912
3079
72766f2e8713 recursive directory scan for add file dialog works again
Giacomo Lozito <james@develia.org>
parents: 2994
diff changeset
913 /* g_dir_open does not handle URI, so path should come here not-urified. --giacomo */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
914 if (!(dir = g_dir_open(path, 0, NULL)))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
915 return NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
916
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
917 while ((dir_entry = g_dir_read_name(dir))) {
2994
750c530b1bf5 playlist_dir_find_files(): Return list of URIs.
William Pitcock <nenolod@atheme-project.org>
parents: 2993
diff changeset
918 gchar *filename, *tmp;
3971
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
919 gint ext_flag;
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
920 gboolean http_flag;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
921
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
922 if (file_is_hidden(dir_entry))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
923 continue;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
924
2994
750c530b1bf5 playlist_dir_find_files(): Return list of URIs.
William Pitcock <nenolod@atheme-project.org>
parents: 2993
diff changeset
925 tmp = g_build_filename(path, dir_entry, NULL);
750c530b1bf5 playlist_dir_find_files(): Return list of URIs.
William Pitcock <nenolod@atheme-project.org>
parents: 2993
diff changeset
926 filename = g_filename_to_uri(tmp, NULL, NULL);
750c530b1bf5 playlist_dir_find_files(): Return list of URIs.
William Pitcock <nenolod@atheme-project.org>
parents: 2993
diff changeset
927 g_free(tmp);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
928
3971
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
929 ext_flag = filter_by_extension(filename);
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
930 http_flag = is_http(filename);
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
931
3959
a575c29cee05 - revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3947
diff changeset
932 if (vfs_file_test(filename, G_FILE_TEST_IS_DIR)) { /* directory */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
933 GList *sub;
3079
72766f2e8713 recursive directory scan for add file dialog works again
Giacomo Lozito <james@develia.org>
parents: 2994
diff changeset
934 gchar *dirfilename = g_filename_from_uri(filename, NULL, NULL);
72766f2e8713 recursive directory scan for add file dialog works again
Giacomo Lozito <james@develia.org>
parents: 2994
diff changeset
935 sub = playlist_dir_find_files(dirfilename, background, htab);
72766f2e8713 recursive directory scan for add file dialog works again
Giacomo Lozito <james@develia.org>
parents: 2994
diff changeset
936 g_free(dirfilename);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
937 g_free(filename);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
938 list = g_list_concat(list, sub);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
939 }
3979
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
940 else if (cfg.playlist_detect && ext_flag != EXT_HAVE_SUBTUNE && ext_flag != EXT_CUSTOM) { /* local file, no probing, no subtune */
3959
a575c29cee05 - revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3947
diff changeset
941 if(cfg.use_extension_probing) {
3971
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
942 if(ext_flag == EXT_TRUE)
3959
a575c29cee05 - revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3947
diff changeset
943 list = g_list_prepend(list, filename);
4114
3218e86beed7 Fixes memory leak in playlist_add_files() function when using extension probing and trying to add file with unknown extension. (Bugzilla #44)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 4111
diff changeset
944 else // ext_flag == EXT_FALSE => extension isn't known
3218e86beed7 Fixes memory leak in playlist_add_files() function when using extension probing and trying to add file with unknown extension. (Bugzilla #44)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 4111
diff changeset
945 g_free(filename);
3959
a575c29cee05 - revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3947
diff changeset
946 }
a575c29cee05 - revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3947
diff changeset
947 else
3934
e924c9ee3958 when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3923
diff changeset
948 list = g_list_prepend(list, filename);
e924c9ee3958 when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3923
diff changeset
949 }
3971
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
950 else if ((pr = input_check_file(filename, TRUE)) != NULL) /* local file, probing or have subtune */
3127
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
951 {
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
952 list = g_list_prepend(list, filename);
3127
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
953
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
954 g_free(pr);
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
955 pr = NULL;
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
956 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
957 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
958 g_free(filename);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
959
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
960 while (background && gtk_events_pending())
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
961 gtk_main_iteration();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
962 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
963 g_dir_close(dir);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
964
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
965 return list;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
966 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
967
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
968 gboolean
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
969 playlist_add(Playlist * playlist, const gchar * filename)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
970 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
971 return playlist_ins(playlist, filename, -1);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
972 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
973
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
974 guint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
975 playlist_add_dir(Playlist * playlist, const gchar * directory)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
976 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
977 return playlist_ins_dir(playlist, directory, -1, TRUE);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
978 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
979
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
980 guint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
981 playlist_add_url(Playlist * playlist, const gchar * url)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
982 {
3337
99f34db2c3fc - fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3334
diff changeset
983 guint entries;
99f34db2c3fc - fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3334
diff changeset
984 entries = playlist_ins_url(playlist, url, -1);
99f34db2c3fc - fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3334
diff changeset
985 return entries;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
986 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
987
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
988 guint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
989 playlist_ins_dir(Playlist * playlist, const gchar * path,
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
990 gint pos,
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
991 gboolean background)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
992 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
993 guint entries = 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
994 GList *list, *node;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
995 GHashTable *htab;
2978
f4971c7d6384 Remove inlined urldecoding functions and use g_filename_from_uri() instead where appropriate.
William Pitcock <nenolod@atheme-project.org>
parents: 2976
diff changeset
996 gchar *path2 = g_filename_from_uri(path, NULL, NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
997
2580
48288757d7c7 [svn] - fix a regression introduced by the DnD fix.
nenolod
parents: 2579
diff changeset
998 if (path2 == NULL)
48288757d7c7 [svn] - fix a regression introduced by the DnD fix.
nenolod
parents: 2579
diff changeset
999 path2 = g_strdup(path);
48288757d7c7 [svn] - fix a regression introduced by the DnD fix.
nenolod
parents: 2579
diff changeset
1000
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1001 htab = g_hash_table_new(devino_hash, devino_compare);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1002
2579
364714f2d555 [svn] - urldecode playlist paths
nenolod
parents: 2575
diff changeset
1003 list = playlist_dir_find_files(path2, background, htab);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1004 list = g_list_sort(list, (GCompareFunc) path_compare);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1005
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1006 g_hash_table_foreach_remove(htab, devino_destroy, NULL);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1007
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1008 for (node = list; node; node = g_list_next(node)) {
3129
f416657ee9b7 Call playlist_ins() instead of __playlist_ins().
William Pitcock <nenolod@atheme-project.org>
parents: 3128
diff changeset
1009 playlist_ins(playlist, node->data, pos);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1010 g_free(node->data);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1011 entries++;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1012 if (pos >= 0)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1013 pos++;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1014 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1015
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1016 g_list_free(list);
2579
364714f2d555 [svn] - urldecode playlist paths
nenolod
parents: 2575
diff changeset
1017 g_free(path2);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1018
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1019 playlist_recalc_total_time(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1020 playlist_generate_shuffle_list(playlist);
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
1021 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1022 return entries;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1023 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1024
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1025 guint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1026 playlist_ins_url(Playlist * playlist, const gchar * string,
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1027 gint pos)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1028 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1029 gchar *tmp;
3337
99f34db2c3fc - fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3334
diff changeset
1030 gint entries = 0;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1031 gchar *decoded = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1032
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1033 g_return_val_if_fail(playlist != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1034 g_return_val_if_fail(string != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1035
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1036 while (*string) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1037 GList *node;
3337
99f34db2c3fc - fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3334
diff changeset
1038 guint i = 0;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1039 tmp = strchr(string, '\n');
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1040 if (tmp) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1041 if (*(tmp - 1) == '\r')
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1042 *(tmp - 1) = '\0';
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1043 *tmp = '\0';
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1044 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1045
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1046 decoded = g_strdup(string);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1047
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1048 if (vfs_file_test(decoded, G_FILE_TEST_IS_DIR))
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1049 i = playlist_ins_dir(playlist, decoded, pos, FALSE);
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1050 else if (is_playlist_name(decoded))
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1051 i = playlist_load_ins(playlist, decoded, pos);
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1052 else if (playlist_ins(playlist, decoded, pos))
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1053 i = 1;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1054
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1055 g_free(decoded);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1056
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1057 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1058 node = g_list_nth(playlist->entries, pos);
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1059 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1060
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1061 entries += i;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1062
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1063 if (pos >= 0)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1064 pos += i;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1065 if (!tmp)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1066 break;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1067
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1068 string = tmp + 1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1069 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1070
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1071 playlist_recalc_total_time(playlist);
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1072 PLAYLIST_INCR_SERIAL(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1073 playlist_generate_shuffle_list(playlist);
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
1074 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1075
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1076 return entries;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1077 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1078
3980
bf0471c64f6a remove duplicated code between playlist_set_info() and playlist_set_info_old_abi(). now playlist_set_info_old_abi() become wrapper function for playlist_set_info().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3979
diff changeset
1079 /* set info for current song. */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1080 void
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1081 playlist_set_info(Playlist * playlist, const gchar * title,
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1082 gint length, gint rate, gint freq, gint nch)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1083 {
3159
a2d552ea48f0 Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents: 3132
diff changeset
1084 PlaylistEventInfoChange *msg;
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents: 3159
diff changeset
1085 gchar *text;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1086
3980
bf0471c64f6a remove duplicated code between playlist_set_info() and playlist_set_info_old_abi(). now playlist_set_info_old_abi() become wrapper function for playlist_set_info().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3979
diff changeset
1087 g_return_if_fail(playlist != NULL);
bf0471c64f6a remove duplicated code between playlist_set_info() and playlist_set_info_old_abi(). now playlist_set_info_old_abi() become wrapper function for playlist_set_info().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3979
diff changeset
1088
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1089 if (length == -1) {
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1090 // event_queue hates NULL --yaz
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1091 event_queue("hide seekbar", (gpointer)0xdeadbeef);
3197
5dd8bc77a590 now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3165
diff changeset
1092 }
5dd8bc77a590 now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3165
diff changeset
1093
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1094 if (playlist->position) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1095 g_free(playlist->position->title);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1096 playlist->position->title = g_strdup(title);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1097 playlist->position->length = length;
2488
c5075a79f1aa [svn] make input->set_info overwrite tuple->track_name. it allows input
yaz
parents: 2480
diff changeset
1098
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1099 // overwrite tuple::title, mainly for streaming. it may incur side effects. --yaz
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
1100 if (playlist->position->tuple && tuple_get_int(playlist->position->tuple, FIELD_LENGTH, NULL) == -1){
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
1101 tuple_disassociate(playlist->position->tuple, FIELD_TITLE, NULL);
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
1102 tuple_associate_string(playlist->position->tuple, FIELD_TITLE, NULL, title);
2488
c5075a79f1aa [svn] make input->set_info overwrite tuple->track_name. it allows input
yaz
parents: 2480
diff changeset
1103 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1104 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1105
3922
23e5b148ae7c to get rid of annoying side effects, an independent function for playlist serial increment has been provided.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3921
diff changeset
1106 playlist_recalc_total_time(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1107
3159
a2d552ea48f0 Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents: 3132
diff changeset
1108 /* broadcast a PlaylistEventInfoChange message. */
a2d552ea48f0 Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents: 3132
diff changeset
1109 msg = g_new0(PlaylistEventInfoChange, 1);
a2d552ea48f0 Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents: 3132
diff changeset
1110 msg->bitrate = rate;
a2d552ea48f0 Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents: 3132
diff changeset
1111 msg->samplerate = freq;
a2d552ea48f0 Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents: 3132
diff changeset
1112 msg->channels = nch;
a2d552ea48f0 Use message passing to make sure the UI is updated in the main thread.
William Pitcock <nenolod@atheme-project.org>
parents: 3132
diff changeset
1113
4579
7f8a87023730 move playback_set_sample_params function call to playlist.c
Tomasz Mon <desowin@gmail.com>
parents: 4546
diff changeset
1114 playback_set_sample_params(rate, freq, nch);
4581
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 4579
diff changeset
1115 event_queue_with_data_free("playlist info change", msg);
2460
5e8526a4f554 [svn] - added a new hook: playlist set info
giacomo
parents: 2433
diff changeset
1116
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents: 3159
diff changeset
1117 text = playlist_get_info_text(playlist);
4581
cf6711eeb12f implement event_queue_with_data_free()
Tomasz Mon <desowin@gmail.com>
parents: 4579
diff changeset
1118 event_queue_with_data_free("title change", text);
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents: 3159
diff changeset
1119
2460
5e8526a4f554 [svn] - added a new hook: playlist set info
giacomo
parents: 2433
diff changeset
1120 if ( playlist->position )
5e8526a4f554 [svn] - added a new hook: playlist set info
giacomo
parents: 2433
diff changeset
1121 hook_call( "playlist set info" , playlist->position );
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1122 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1123
3980
bf0471c64f6a remove duplicated code between playlist_set_info() and playlist_set_info_old_abi(). now playlist_set_info_old_abi() become wrapper function for playlist_set_info().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3979
diff changeset
1124 /* wrapper for playlist_set_info. this function is called by input plugins. */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1125 void
3980
bf0471c64f6a remove duplicated code between playlist_set_info() and playlist_set_info_old_abi(). now playlist_set_info_old_abi() become wrapper function for playlist_set_info().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3979
diff changeset
1126 playlist_set_info_old_abi(const gchar * title, gint length, gint rate,
bf0471c64f6a remove duplicated code between playlist_set_info() and playlist_set_info_old_abi(). now playlist_set_info_old_abi() become wrapper function for playlist_set_info().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3979
diff changeset
1127 gint freq, gint nch)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1128 {
3980
bf0471c64f6a remove duplicated code between playlist_set_info() and playlist_set_info_old_abi(). now playlist_set_info_old_abi() become wrapper function for playlist_set_info().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3979
diff changeset
1129 Playlist *playlist = playlist_get_active();
bf0471c64f6a remove duplicated code between playlist_set_info() and playlist_set_info_old_abi(). now playlist_set_info_old_abi() become wrapper function for playlist_set_info().
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3979
diff changeset
1130 playlist_set_info(playlist, title, length, rate, freq, nch);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1131 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1132
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1133 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1134 playlist_check_pos_current(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1135 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1136 gint pos, row, bottom;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1137
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1138 if (!playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1139 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1140
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1141 PLAYLIST_LOCK(playlist);
4297
40a991213507 check if playlistwin_list is UiSkinnedPlaylist before accessing it contents
Tomasz Mon <desowin@gmail.com>
parents: 4284
diff changeset
1142 if (!playlist->position) {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1143 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1144 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1145 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1146
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1147 pos = g_list_index(playlist->entries, playlist->position);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1148
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1149 if (playlistwin_item_visible(pos)) {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1150 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1151 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1152 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1153
4297
40a991213507 check if playlistwin_list is UiSkinnedPlaylist before accessing it contents
Tomasz Mon <desowin@gmail.com>
parents: 4284
diff changeset
1154 bottom = MAX(0, playlist_get_length(playlist) - playlistwin_list_get_visible_count());
40a991213507 check if playlistwin_list is UiSkinnedPlaylist before accessing it contents
Tomasz Mon <desowin@gmail.com>
parents: 4284
diff changeset
1155 row = CLAMP(pos - playlistwin_list_get_visible_count() / 2, 0, bottom);
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1156 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1157 playlistwin_set_toprow(row);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1158 g_cond_signal(cond_scan);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1159 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1160
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1161 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1162 playlist_next(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1163 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1164 GList *plist_pos_list;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1165 gboolean restart_playing = FALSE;
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1166
2480
bb2f191895ce [svn] - fixed crash when skipping to next song with an empty playlist
marvin
parents: 2460
diff changeset
1167 if (!playlist_get_length(playlist))
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1168 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1169
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1170 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1171
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
1172 if ((playlist_position_before_jump != NULL) && playlist->queue == NULL) {
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1173 playlist->position = playlist_position_before_jump;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1174 playlist_position_before_jump = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1175 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1176
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1177 plist_pos_list = find_playlist_position_list(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1178
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1179 if (!cfg.repeat && !g_list_next(plist_pos_list) && playlist->queue == NULL)
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1180 {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1181 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1182 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1183 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1184
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1185 if (playback_get_playing()) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1186 /* We need to stop before changing playlist_position */
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1187 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1188 ip_data.stop = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1189 playback_stop();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1190 ip_data.stop = FALSE;
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1191 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1192 restart_playing = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1193 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1194
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1195 plist_pos_list = find_playlist_position_list(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1196 if (playlist->queue != NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1197 play_queued(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1198 else if (g_list_next(plist_pos_list))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1199 playlist->position = g_list_next(plist_pos_list)->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1200 else if (cfg.repeat) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1201 playlist->position = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1202 playlist_generate_shuffle_list_nolock(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1203 if (cfg.shuffle)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1204 playlist->position = playlist->shuffle->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1205 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1206 playlist->position = playlist->entries->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1207 }
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1208
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1209 PLAYLIST_UNLOCK(playlist);
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1210
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1211 playlist_check_pos_current(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1212
3348
2a081105513c -Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents: 3346
diff changeset
1213 if (restart_playing)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1214 playback_initiate();
4728
ab79ddbdcf42 introduce new playlist widget
Tomasz Mon <desowin@gmail.com>
parents: 4700
diff changeset
1215 else
ab79ddbdcf42 introduce new playlist widget
Tomasz Mon <desowin@gmail.com>
parents: 4700
diff changeset
1216 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1217 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1218
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1219 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1220 playlist_prev(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1221 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1222 GList *plist_pos_list;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1223 gboolean restart_playing = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1224
2480
bb2f191895ce [svn] - fixed crash when skipping to next song with an empty playlist
marvin
parents: 2460
diff changeset
1225 if (!playlist_get_length(playlist))
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1226 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1227
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1228 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1229
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
1230 if ((playlist_position_before_jump != NULL) && playlist->queue == NULL) {
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1231 playlist->position = playlist_position_before_jump;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1232 playlist_position_before_jump = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1233 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1234
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1235 plist_pos_list = find_playlist_position_list(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1236
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1237 if (!cfg.repeat && !g_list_previous(plist_pos_list)) {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1238 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1239 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1240 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1241
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1242 if (playback_get_playing()) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1243 /* We need to stop before changing playlist_position */
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1244 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1245 ip_data.stop = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1246 playback_stop();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1247 ip_data.stop = FALSE;
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1248 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1249 restart_playing = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1250 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1251
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1252 plist_pos_list = find_playlist_position_list(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1253 if (g_list_previous(plist_pos_list)) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1254 playlist->position = g_list_previous(plist_pos_list)->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1255 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1256 else if (cfg.repeat) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1257 GList *node;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1258 playlist->position = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1259 playlist_generate_shuffle_list_nolock(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1260 if (cfg.shuffle)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1261 node = g_list_last(playlist->shuffle);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1262 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1263 node = g_list_last(playlist->entries);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1264 if (node)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1265 playlist->position = node->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1266 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1267
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1268 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1269
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1270 playlist_check_pos_current(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1271
3348
2a081105513c -Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents: 3346
diff changeset
1272 if (restart_playing)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1273 playback_initiate();
3348
2a081105513c -Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents: 3346
diff changeset
1274 else
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
1275 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1276 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1277
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1278 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1279 playlist_queue(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1280 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1281 GList *list = playlist_get_selected(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1282 GList *it = list;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1283
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1284 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1285
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
1286 if ((cfg.shuffle) && (playlist_position_before_jump == NULL)) {
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1287 /* Shuffling and this is our first manual jump. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1288 playlist_position_before_jump = playlist->position;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1289 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1290
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1291 while (it) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1292 GList *next = g_list_next(it);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1293 GList *tmp;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1294
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1295 /* XXX: WTF? --nenolod */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1296 it->data = g_list_nth_data(playlist->entries, GPOINTER_TO_INT(it->data));
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1297 if ((tmp = g_list_find(playlist->queue, it->data))) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1298 playlist->queue = g_list_remove_link(playlist->queue, tmp);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1299 g_list_free_1(tmp);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1300 list = g_list_remove_link(list, it);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1301 g_list_free_1(it);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1302 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1303
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1304 it = next;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1305 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1306
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1307 playlist->queue = g_list_concat(playlist->queue, list);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1308
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1309 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1310
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1311 playlist_recalc_total_time(playlist);
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
1312 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1313 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1314
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1315 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1316 playlist_queue_position(Playlist *playlist, guint pos)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1317 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1318 GList *tmp;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1319 PlaylistEntry *entry;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1320
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1321 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1322
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1323 if ((cfg.shuffle) && (playlist_position_before_jump == NULL))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1324 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1325 /* Shuffling and this is our first manual jump. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1326 playlist_position_before_jump = playlist->position;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1327 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1328
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1329 entry = g_list_nth_data(playlist->entries, pos);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1330 if ((tmp = g_list_find(playlist->queue, entry))) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1331 playlist->queue = g_list_remove_link(playlist->queue, tmp);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1332 g_list_free_1(tmp);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1333 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1334 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1335 playlist->queue = g_list_append(playlist->queue, entry);
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1336 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1337
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1338 playlist_recalc_total_time(playlist);
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
1339 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1340 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1341
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1342 gboolean
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1343 playlist_is_position_queued(Playlist *playlist, guint pos)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1344 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1345 PlaylistEntry *entry;
3867
e48f2f4c116d - many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3863
diff changeset
1346 GList *tmp = NULL;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1347
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1348 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1349 entry = g_list_nth_data(playlist->entries, pos);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1350 tmp = g_list_find(playlist->queue, entry);
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1351 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1352
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1353 return tmp != NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1354 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1355
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1356 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1357 playlist_get_queue_position_number(Playlist *playlist, guint pos)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1358 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1359 PlaylistEntry *entry;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1360 gint tmp;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1361
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1362 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1363 entry = g_list_nth_data(playlist->entries, pos);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1364 tmp = g_list_index(playlist->queue, entry);
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1365 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1366
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1367 return tmp;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1368 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1369
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1370 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1371 playlist_get_queue_qposition_number(Playlist *playlist, guint pos)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1372 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1373 PlaylistEntry *entry;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1374 gint tmp;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1375
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1376 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1377 entry = g_list_nth_data(playlist->queue, pos);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1378 tmp = g_list_index(playlist->entries, entry);
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1379 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1380
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1381 return tmp;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1382 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1383
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1384 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1385 playlist_clear_queue(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1386 {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1387 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1388 g_list_free(playlist->queue);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1389 playlist->queue = NULL;
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1390 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1391
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1392 playlist_recalc_total_time(playlist);
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
1393 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1394 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1395
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1396 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1397 playlist_queue_remove(Playlist *playlist, guint pos)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1398 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1399 void *entry;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1400
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1401 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1402 entry = g_list_nth_data(playlist->entries, pos);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1403 playlist->queue = g_list_remove(playlist->queue, entry);
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1404 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1405
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
1406 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1407 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1408
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1409 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1410 playlist_get_queue_position(Playlist *playlist, PlaylistEntry * entry)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1411 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1412 return g_list_index(playlist->queue, entry);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1413 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1414
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1415 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1416 playlist_set_position(Playlist *playlist, guint pos)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1417 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1418 GList *node;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1419 gboolean restart_playing = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1420
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1421 if (!playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1422 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1423
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1424 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1425
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1426 node = g_list_nth(playlist->entries, pos);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1427 if (!node) {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1428 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1429 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1430 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1431
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1432 if (playback_get_playing()) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1433 /* We need to stop before changing playlist_position */
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1434 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1435 ip_data.stop = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1436 playback_stop();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1437 ip_data.stop = FALSE;
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1438 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1439 restart_playing = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1440 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1441
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1442 if ((cfg.shuffle) && (playlist_position_before_jump == NULL))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1443 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1444 /* Shuffling and this is our first manual jump. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1445 playlist_position_before_jump = playlist->position;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1446 }
3246
2127f7108033 - fixed some cases where the playlist wasn't redrawn
mf0102 <0102@gmx.at>
parents: 3217
diff changeset
1447
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1448 playlist->position = node->data;
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1449 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1450 playlist_check_pos_current(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1451
3348
2a081105513c -Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents: 3346
diff changeset
1452 if (restart_playing)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1453 playback_initiate();
3348
2a081105513c -Set the track "title" in metadata instead of "name"
Ben Tucker <ben.tucker@gmail.com>
parents: 3346
diff changeset
1454 else
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
1455 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1456 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1457
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1458 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1459 playlist_eof_reached(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1460 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1461 GList *plist_pos_list;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1462
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1463 if ((cfg.no_playlist_advance && !cfg.repeat) || cfg.stopaftersong)
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1464 ip_data.stop = TRUE;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1465 playback_stop();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1466 if ((cfg.no_playlist_advance && !cfg.repeat) || cfg.stopaftersong)
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1467 ip_data.stop = FALSE;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1468
2408
b380e84148bb [svn] - rename some hooks so that they are more logical
nenolod
parents: 2407
diff changeset
1469 hook_call("playback end", playlist->position);
2407
1dc1d36d0347 [svn] - add hooks: playback begin, playback end, playlist reached end
nenolod
parents: 2380
diff changeset
1470
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1471 PLAYLIST_LOCK(playlist);
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1472
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1473 if ((playlist_position_before_jump != NULL) && playlist->queue == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1474 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1475 playlist->position = playlist_position_before_jump;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1476 playlist_position_before_jump = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1477 }
3246
2127f7108033 - fixed some cases where the playlist wasn't redrawn
mf0102 <0102@gmx.at>
parents: 3217
diff changeset
1478
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1479 plist_pos_list = find_playlist_position_list(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1480
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1481 if (cfg.no_playlist_advance) {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1482 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1483 if (cfg.repeat)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1484 playback_initiate();
4504
a47288ced5d5 - renamed some files to reflect their UI contents
mf0102 <0102@gmx.at>
parents: 4412
diff changeset
1485 else
a47288ced5d5 - renamed some files to reflect their UI contents
mf0102 <0102@gmx.at>
parents: 4412
diff changeset
1486 hook_call("playlist end reached", NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1487 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1488 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1489
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1490 if (cfg.stopaftersong) {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1491 PLAYLIST_UNLOCK(playlist);
4504
a47288ced5d5 - renamed some files to reflect their UI contents
mf0102 <0102@gmx.at>
parents: 4412
diff changeset
1492 hook_call("playlist end reached", NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1493 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1494 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1495
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1496 if (playlist->queue != NULL) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1497 play_queued(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1498 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1499 else if (!g_list_next(plist_pos_list)) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1500 if (cfg.shuffle) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1501 playlist->position = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1502 playlist_generate_shuffle_list_nolock(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1503 }
2380
825c3715b90f [svn] - handle empty playlists gracefully
nenolod
parents: 2373
diff changeset
1504 else if (playlist->entries != NULL)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1505 playlist->position = playlist->entries->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1506
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1507 if (!cfg.repeat) {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1508 PLAYLIST_UNLOCK(playlist);
4504
a47288ced5d5 - renamed some files to reflect their UI contents
mf0102 <0102@gmx.at>
parents: 4412
diff changeset
1509 hook_call("playlist end reached", NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1510 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1511 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1512 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1513 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1514 playlist->position = g_list_next(plist_pos_list)->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1515
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1516 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1517
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1518 playlist_check_pos_current(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1519 playback_initiate();
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
1520 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1521 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1522
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1523 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1524 playlist_queue_get_length(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1525 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1526 gint length;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1527
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1528 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1529 length = g_list_length(playlist->queue);
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1530 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1531
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1532 return length;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1533 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1534
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1535 gint
2671
e9b379528fbc [svn] - playlist_get_length_nolock() -> playlist_get_length(), no need for
nenolod
parents: 2670
diff changeset
1536 playlist_get_length(Playlist *playlist)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1537 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1538 return g_list_length(playlist->entries);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1539 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1540
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1541 gchar *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1542 playlist_get_info_text(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1543 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1544 gchar *text, *title, *numbers, *length;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1545
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1546 g_return_val_if_fail(playlist != NULL, NULL);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1547
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1548 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1549 if (!playlist->position) {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1550 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1551 return NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1552 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1553
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1554 /* FIXME: there should not be a need to do additional conversion,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1555 * if playlist is properly maintained */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1556 if (playlist->position->title) {
4608
23a9ded30c70 Use str_assert_utf8() where it makes sense in the core.
Matti Hamalainen <ccr@tnsp.org>
parents: 4597
diff changeset
1557 title = str_assert_utf8(playlist->position->title);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1558 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1559 else {
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
1560 gchar *realfn = g_filename_from_uri(playlist->position->filename, NULL, NULL);
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
1561 gchar *basename = g_path_get_basename(realfn ? realfn : playlist->position->filename);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1562 title = filename_to_utf8(basename);
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
1563 g_free(realfn);
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
1564 g_free(basename);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1565 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1566
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1567 /*
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1568 * If the user don't want numbers in the playlist, don't
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1569 * display them in other parts of XMMS
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1570 */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1571
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1572 if (cfg.show_numbers_in_pl)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1573 numbers = g_strdup_printf("%d. ", playlist_get_position_nolock(playlist) + 1);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1574 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1575 numbers = g_strdup("");
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1576
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1577 if (playlist->position->length != -1)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1578 length = g_strdup_printf(" (%d:%-2.2d)",
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1579 playlist->position->length / 60000,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1580 (playlist->position->length / 1000) % 60);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1581 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1582 length = g_strdup("");
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1583
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1584 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1585
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1586 text = convert_title_text(g_strconcat(numbers, title, length, NULL));
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1587
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1588 g_free(numbers);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1589 g_free(title);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1590 g_free(length);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1591
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1592 return text;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1593 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1594
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1595 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1596 playlist_get_current_length(Playlist * playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1597 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1598 gint len = 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1599
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1600 if (!playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1601 return 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1602
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1603 if (playlist->position)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1604 len = playlist->position->length;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1605
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1606 return len;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1607 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1608
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1609 gboolean
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1610 playlist_save(Playlist * playlist, const gchar * filename)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1611 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1612 PlaylistContainer *plc = NULL;
3476
9152829f3c19 Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3474
diff changeset
1613 GList *old_iter;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1614 gchar *ext;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1615
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1616 g_return_val_if_fail(playlist != NULL, FALSE);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1617 g_return_val_if_fail(filename != NULL, FALSE);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1618
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1619 ext = strrchr(filename, '.') + 1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1620
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1621 if ((plc = playlist_container_find(ext)) == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1622 return FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1623
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1624 if (plc->plc_write == NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1625 return FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1626
3476
9152829f3c19 Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3474
diff changeset
1627 /* Save the right playlist to disk */
9152829f3c19 Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3474
diff changeset
1628 if (playlist != playlist_get_active()) {
9152829f3c19 Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3474
diff changeset
1629 old_iter = playlists_iter;
9152829f3c19 Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3474
diff changeset
1630 playlists_iter = g_list_find(playlists, playlist);
9152829f3c19 Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3474
diff changeset
1631 if(!playlists_iter) playlists_iter = old_iter;
9152829f3c19 Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3474
diff changeset
1632 plc->plc_write(filename, 0);
9152829f3c19 Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3474
diff changeset
1633 playlists_iter = old_iter;
9152829f3c19 Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3474
diff changeset
1634 } else {
9152829f3c19 Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3474
diff changeset
1635 plc->plc_write(filename, 0);
9152829f3c19 Allow non-active playlist to be saved to file
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3474
diff changeset
1636 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1637
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1638 return TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1639 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1640
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1641 gboolean
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1642 playlist_load(Playlist * playlist, const gchar * filename)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1643 {
3337
99f34db2c3fc - fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3334
diff changeset
1644 guint ret = 0;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1645 g_return_val_if_fail(playlist != NULL, FALSE);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1646
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1647 playlist->loading_playlist = TRUE;
3477
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
1648 if(!playlist_get_length(playlist)) {
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
1649 /* Loading new playlist */
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
1650 playlist_filename_set(playlist, filename);
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
1651 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1652 ret = playlist_load_ins(playlist, filename, -1);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1653 playlist->loading_playlist = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1654
3337
99f34db2c3fc - fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3334
diff changeset
1655 return ret ? TRUE : FALSE;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1656 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1657
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1658 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1659 playlist_load_ins_file(Playlist *playlist,
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1660 const gchar * uri,
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1661 const gchar * playlist_name, gint pos,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1662 const gchar * title, gint len)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1663 {
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1664 ProbeResult *pr = NULL;
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1665
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1666 g_return_if_fail(uri != NULL);
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1667 g_return_if_fail(playlist_name != NULL);
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1668 g_return_if_fail(playlist != NULL);
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1669
4076
8f9966f00c98 deep copy is needed!
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4075
diff changeset
1670 if(do_precheck(playlist, uri, &pr)) {
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1671 __playlist_ins_file(playlist, uri, pos, NULL, title, len, pr ? pr->ip : NULL);
4052
b0429a649a84 Handle streams inside m3u files better. If thres a better way than is_http() to detect streams, let me know.
Christian Birchinger <joker@netswarm.net>
parents: 4020
diff changeset
1672 }
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1673 g_free(pr);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1674 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1675
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1676 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1677 playlist_load_ins_file_tuple(Playlist * playlist,
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1678 const gchar * uri,
3979
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
1679 const gchar * playlist_name, //path of playlist file itself
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
1680 gint pos,
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
1681 Tuple *tuple)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1682 {
3127
c92070f10148 Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents: 3123
diff changeset
1683 ProbeResult *pr = NULL; /* for decoder cache */
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1684
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1685 g_return_if_fail(uri != NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1686 g_return_if_fail(playlist_name != NULL);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1687 g_return_if_fail(playlist != NULL);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1688
4076
8f9966f00c98 deep copy is needed!
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4075
diff changeset
1689 if(do_precheck(playlist, uri, &pr)) {
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1690 __playlist_ins_file(playlist, uri, pos, tuple, NULL, -1, pr ? pr->ip : NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1691 }
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1692 g_free(pr);
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1693
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1694 }
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1695
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1696 static gboolean
4076
8f9966f00c98 deep copy is needed!
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4075
diff changeset
1697 do_precheck(Playlist *playlist, const gchar *uri, ProbeResult **pr)
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1698 {
3979
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
1699 gint ext_flag = filter_by_extension(uri);
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
1700 gboolean http_flag = is_http(uri);
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1701 gboolean rv = FALSE;
3979
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
1702
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
1703 /* playlist file or remote uri */
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
1704 if ((playlist->loading_playlist == TRUE && ext_flag != EXT_HAVE_SUBTUNE ) || http_flag == TRUE) {
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
1705 pr = NULL;
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1706 rv = TRUE;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1707 }
3979
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
1708 /* local file and on-demand probing is on */
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
1709 else if (cfg.playlist_detect == TRUE && ext_flag != EXT_HAVE_SUBTUNE && ext_flag != EXT_CUSTOM) {
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1710 if(cfg.use_extension_probing && ext_flag == EXT_FALSE) {
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1711 AUDDBG("reject %s\n", uri);
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1712 rv = FALSE;
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1713 }
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1714 else {
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1715 pr = NULL;
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1716 rv = TRUE;
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1717 }
3979
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
1718 }
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
1719 /* find decorder for local file */
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
1720 else {
4076
8f9966f00c98 deep copy is needed!
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4075
diff changeset
1721 *pr = input_check_file(uri, TRUE);
8f9966f00c98 deep copy is needed!
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4075
diff changeset
1722 if(*pr) {
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1723 AUDDBG("got pr\n");
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1724 rv = TRUE;
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1725 }
3979
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
1726 }
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
1727
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
1728 return rv;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1729 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1730
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1731 static guint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1732 playlist_load_ins(Playlist * playlist, const gchar * filename, gint pos)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1733 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1734 PlaylistContainer *plc;
3383
e2e875f3d02b Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3382
diff changeset
1735 GList *old_iter;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1736 gchar *ext;
3337
99f34db2c3fc - fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3334
diff changeset
1737 gint old_len, new_len;
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1738
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1739 g_return_val_if_fail(playlist != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1740 g_return_val_if_fail(filename != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1741
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1742 ext = strrchr(filename, '.') + 1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1743 plc = playlist_container_find(ext);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1744
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1745 g_return_val_if_fail(plc != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1746 g_return_val_if_fail(plc->plc_read != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1747
3337
99f34db2c3fc - fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3334
diff changeset
1748 old_len = playlist_get_length(playlist);
3383
e2e875f3d02b Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3382
diff changeset
1749 /* make sure it adds files to the right playlist */
e2e875f3d02b Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3382
diff changeset
1750 if (playlist != playlist_get_active()) {
e2e875f3d02b Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3382
diff changeset
1751 old_iter = playlists_iter;
e2e875f3d02b Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3382
diff changeset
1752 playlists_iter = g_list_find(playlists, playlist);
3478
481a4a88d3ec Use old iterator when new one isn't found
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3477
diff changeset
1753 if (!playlists_iter) playlists_iter = old_iter;
3383
e2e875f3d02b Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3382
diff changeset
1754 plc->plc_read(filename, pos);
e2e875f3d02b Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3382
diff changeset
1755 playlists_iter = old_iter;
e2e875f3d02b Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3382
diff changeset
1756 } else {
e2e875f3d02b Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3382
diff changeset
1757 plc->plc_read(filename, pos);
e2e875f3d02b Make playlist_load_ins handle the case when playlist is not the currently active one
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3382
diff changeset
1758 }
3337
99f34db2c3fc - fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3334
diff changeset
1759 new_len = playlist_get_length(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1760
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1761 playlist_generate_shuffle_list(playlist);
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
1762 hook_call("playlist update", playlist);
3923
e9fd46b0893b - redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3922
diff changeset
1763
e9fd46b0893b - redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3922
diff changeset
1764 playlist_recalc_total_time(playlist); //tentative --yaz
e9fd46b0893b - redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3922
diff changeset
1765 PLAYLIST_INCR_SERIAL(playlist);
e9fd46b0893b - redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3922
diff changeset
1766
3337
99f34db2c3fc - fix a bug that playlist_ins_url() always returns 1 even if no url has been added. now playlist_ins_url() returns number of new entries which actually added to the playlist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3334
diff changeset
1767 return new_len - old_len;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1768 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1769
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1770 GList *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1771 get_playlist_nth(Playlist *playlist, guint nth)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1772 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1773 g_warning("deprecated function get_playlist_nth() was called");
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1774 REQUIRE_LOCK(playlist->mutex);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1775 return g_list_nth(playlist->entries, nth);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1776 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1777
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1778 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1779 playlist_get_position_nolock(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1780 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1781 if (playlist && playlist->position)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1782 return g_list_index(playlist->entries, playlist->position);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1783 return 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1784 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1785
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1786 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1787 playlist_get_position(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1788 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1789 gint pos;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1790
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1791 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1792 pos = playlist_get_position_nolock(playlist);
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1793 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1794
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1795 return pos;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1796 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1797
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1798 gchar *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1799 playlist_get_filename(Playlist *playlist, guint pos)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1800 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1801 gchar *filename;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1802 PlaylistEntry *entry;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1803 GList *node;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1804
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1805 if (!playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1806 return NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1807
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1808 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1809 node = g_list_nth(playlist->entries, pos);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1810 if (!node) {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1811 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1812 return NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1813 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1814 entry = node->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1815
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1816 filename = g_strdup(entry->filename);
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1817 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1818
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1819 return filename;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1820 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1821
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1822 gchar *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1823 playlist_get_songtitle(Playlist *playlist, guint pos)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1824 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1825 gchar *title = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1826 PlaylistEntry *entry;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1827 GList *node;
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1828 time_t mtime;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1829
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1830 if (!playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1831 return NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1832
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1833 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1834
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1835 if (!(node = g_list_nth(playlist->entries, pos))) {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1836 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1837 return NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1838 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1839
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1840 entry = node->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1841
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1842 if (entry->tuple)
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
1843 mtime = tuple_get_int(entry->tuple, FIELD_MTIME, NULL);
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1844 else
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1845 mtime = 0;
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1846
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1847 /* FIXME: simplify this logic */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1848 if ((entry->title == NULL && entry->length == -1) ||
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1849 (entry->tuple && mtime != 0 &&
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1850 (mtime == -1 || mtime != playlist_get_mtime(entry->filename))))
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1851 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1852 if (playlist_entry_get_info(entry))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1853 title = entry->title;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1854 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1855 else {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1856 title = entry->title;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1857 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1858
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
1859 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1860
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1861 if (!title) {
3081
ba2143c1c6f5 unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3079
diff changeset
1862 gchar *realfn = NULL;
ba2143c1c6f5 unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3079
diff changeset
1863 realfn = g_filename_from_uri(entry->filename, NULL, NULL);
ba2143c1c6f5 unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3079
diff changeset
1864 title = g_path_get_basename(realfn ? realfn : entry->filename);
ba2143c1c6f5 unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3079
diff changeset
1865 g_free(realfn); realfn = NULL;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1866 return str_replace(title, filename_to_utf8(title));
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1867 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1868
4608
23a9ded30c70 Use str_assert_utf8() where it makes sense in the core.
Matti Hamalainen <ccr@tnsp.org>
parents: 4597
diff changeset
1869 return str_assert_utf8(title);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1870 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1871
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1872 Tuple *
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1873 playlist_get_tuple(Playlist *playlist, guint pos)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1874 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1875 PlaylistEntry *entry;
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1876 Tuple *tuple = NULL;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1877 GList *node;
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1878 time_t mtime;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1879
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1880 if (!playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1881 return NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1882
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1883 if (!(node = g_list_nth(playlist->entries, pos))) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1884 return NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1885 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1886
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1887 entry = (PlaylistEntry *) node->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1888
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1889 tuple = entry->tuple;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1890
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1891 if (tuple)
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
1892 mtime = tuple_get_int(tuple, FIELD_MTIME, NULL);
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1893 else
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1894 mtime = 0;
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1895
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1896 // if no tuple or tuple with old mtime, get new one.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1897 if (tuple == NULL ||
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1898 (entry->tuple && mtime != 0 && (mtime == -1 || mtime != playlist_get_mtime(entry->filename))))
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1899 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1900 playlist_entry_get_info(entry);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1901 tuple = entry->tuple;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1902 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1903
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1904 return tuple;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1905 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1906
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1907 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1908 playlist_get_songtime(Playlist *playlist, guint pos)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1909 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1910 gint song_time = -1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1911 PlaylistEntry *entry;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1912 GList *node;
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1913 time_t mtime;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1914
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1915 if (!playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1916 return -1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1917
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
1918 if (!(node = g_list_nth(playlist->entries, pos)))
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1919 return -1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1920
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1921 entry = node->data;
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1922
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1923 if (entry->tuple)
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
1924 mtime = tuple_get_int(entry->tuple, FIELD_MTIME, NULL);
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1925 else
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1926 mtime = 0;
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1927
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1928 if (entry->tuple == NULL ||
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1929 (mtime != 0 && (mtime == -1 || mtime != playlist_get_mtime(entry->filename)))) {
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1930
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1931 if (playlist_entry_get_info(entry))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1932 song_time = entry->length;
3635
b20e98407a30 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 3633
diff changeset
1933 } else
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1934 song_time = entry->length;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1935
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1936 return song_time;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1937 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1938
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1939 static gint
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1940 playlist_compare_track(PlaylistEntry * a, PlaylistEntry * b)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1941 {
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1942 gint tracknumber_a;
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1943 gint tracknumber_b;
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1944
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1945 g_return_val_if_fail(a != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1946 g_return_val_if_fail(b != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1947
2614
deb09bfd716b [svn] - now sort by track number and sort by title work even if on display metadata loading is specified.
yaz
parents: 2580
diff changeset
1948 if(!a->tuple)
deb09bfd716b [svn] - now sort by track number and sort by title work even if on display metadata loading is specified.
yaz
parents: 2580
diff changeset
1949 playlist_entry_get_info(a);
deb09bfd716b [svn] - now sort by track number and sort by title work even if on display metadata loading is specified.
yaz
parents: 2580
diff changeset
1950 if(!b->tuple)
deb09bfd716b [svn] - now sort by track number and sort by title work even if on display metadata loading is specified.
yaz
parents: 2580
diff changeset
1951 playlist_entry_get_info(b);
deb09bfd716b [svn] - now sort by track number and sort by title work even if on display metadata loading is specified.
yaz
parents: 2580
diff changeset
1952
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1953 if (a->tuple == NULL)
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1954 return 0;
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1955 if (b->tuple == NULL)
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1956 return 0;
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1957
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
1958 tracknumber_a = tuple_get_int(a->tuple, FIELD_TRACK_NUMBER, NULL);
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
1959 tracknumber_b = tuple_get_int(b->tuple, FIELD_TRACK_NUMBER, NULL);
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1960
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
1961 return (tracknumber_a && tracknumber_b ?
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1962 tracknumber_a - tracknumber_b : 0);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1963 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1964
3638
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
1965 static void
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
1966 playlist_get_entry_title(PlaylistEntry * e, const gchar ** title)
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
1967 {
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
1968 if (e->title)
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
1969 *title = e->title;
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
1970 else {
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
1971 if (strrchr(e->filename, '/'))
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
1972 *title = strrchr(e->filename, '/') + 1;
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
1973 else
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
1974 *title = e->filename;
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
1975 }
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
1976 }
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
1977
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1978 static gint
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1979 playlist_compare_playlist(PlaylistEntry * a, PlaylistEntry * b)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1980 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1981 const gchar *a_title = NULL, *b_title = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1982
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1983 g_return_val_if_fail(a != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1984 g_return_val_if_fail(b != NULL, 0);
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
1985
3638
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
1986 playlist_get_entry_title(a, &a_title);
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
1987 playlist_get_entry_title(b, &b_title);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1988
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1989 return strcasecmp(a_title, b_title);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1990 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1991
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1992 static gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1993 playlist_compare_title(PlaylistEntry * a,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1994 PlaylistEntry * b)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1995 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1996 const gchar *a_title = NULL, *b_title = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1997
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1998 g_return_val_if_fail(a != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
1999 g_return_val_if_fail(b != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2000
3638
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
2001 if (a->tuple == NULL)
2614
deb09bfd716b [svn] - now sort by track number and sort by title work even if on display metadata loading is specified.
yaz
parents: 2580
diff changeset
2002 playlist_entry_get_info(a);
3638
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
2003 if (b->tuple == NULL)
2614
deb09bfd716b [svn] - now sort by track number and sort by title work even if on display metadata loading is specified.
yaz
parents: 2580
diff changeset
2004 playlist_entry_get_info(b);
deb09bfd716b [svn] - now sort by track number and sort by title work even if on display metadata loading is specified.
yaz
parents: 2580
diff changeset
2005
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
2006 if (a->tuple != NULL)
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2007 a_title = tuple_get_string(a->tuple, FIELD_TITLE, NULL);
4284
3ff4aef1e401 playlist_compare_artist(): Avoid NULL dereferences.
William Pitcock <nenolod@atheme.org>
parents: 4266
diff changeset
2008
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
2009 if (b->tuple != NULL)
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2010 b_title = tuple_get_string(b->tuple, FIELD_TITLE, NULL);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2011
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2012 if (a_title != NULL && b_title != NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2013 return strcasecmp(a_title, b_title);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2014
3638
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
2015 playlist_get_entry_title(a, &a_title);
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
2016 playlist_get_entry_title(b, &b_title);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2017
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2018 return strcasecmp(a_title, b_title);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2019 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2020
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2021 static gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2022 playlist_compare_artist(PlaylistEntry * a,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2023 PlaylistEntry * b)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2024 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2025 const gchar *a_artist = NULL, *b_artist = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2026
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2027 g_return_val_if_fail(a != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2028 g_return_val_if_fail(b != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2029
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2030 if (a->tuple != NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2031 playlist_entry_get_info(a);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2032
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2033 if (b->tuple != NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2034 playlist_entry_get_info(b);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2035
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
2036 if (a->tuple != NULL) {
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2037 a_artist = tuple_get_string(a->tuple, FIELD_ARTIST, NULL);
4284
3ff4aef1e401 playlist_compare_artist(): Avoid NULL dereferences.
William Pitcock <nenolod@atheme.org>
parents: 4266
diff changeset
2038
3ff4aef1e401 playlist_compare_artist(): Avoid NULL dereferences.
William Pitcock <nenolod@atheme.org>
parents: 4266
diff changeset
2039 if (a_artist == NULL)
3ff4aef1e401 playlist_compare_artist(): Avoid NULL dereferences.
William Pitcock <nenolod@atheme.org>
parents: 4266
diff changeset
2040 return 0;
3ff4aef1e401 playlist_compare_artist(): Avoid NULL dereferences.
William Pitcock <nenolod@atheme.org>
parents: 4266
diff changeset
2041
2683
d2ffabee3ced [svn] Modified playlist_compare_artist so that a leading "the" in an artist's
magma
parents: 2671
diff changeset
2042 if (str_has_prefix_nocase(a_artist, "the "))
d2ffabee3ced [svn] Modified playlist_compare_artist so that a leading "the" in an artist's
magma
parents: 2671
diff changeset
2043 a_artist += 4;
d2ffabee3ced [svn] Modified playlist_compare_artist so that a leading "the" in an artist's
magma
parents: 2671
diff changeset
2044 }
d2ffabee3ced [svn] Modified playlist_compare_artist so that a leading "the" in an artist's
magma
parents: 2671
diff changeset
2045
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
2046 if (b->tuple != NULL) {
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2047 b_artist = tuple_get_string(b->tuple, FIELD_ARTIST, NULL);
4284
3ff4aef1e401 playlist_compare_artist(): Avoid NULL dereferences.
William Pitcock <nenolod@atheme.org>
parents: 4266
diff changeset
2048
3ff4aef1e401 playlist_compare_artist(): Avoid NULL dereferences.
William Pitcock <nenolod@atheme.org>
parents: 4266
diff changeset
2049 if (b_artist == NULL)
3ff4aef1e401 playlist_compare_artist(): Avoid NULL dereferences.
William Pitcock <nenolod@atheme.org>
parents: 4266
diff changeset
2050 return 0;
3ff4aef1e401 playlist_compare_artist(): Avoid NULL dereferences.
William Pitcock <nenolod@atheme.org>
parents: 4266
diff changeset
2051
2683
d2ffabee3ced [svn] Modified playlist_compare_artist so that a leading "the" in an artist's
magma
parents: 2671
diff changeset
2052 if (str_has_prefix_nocase(b_artist, "the "))
d2ffabee3ced [svn] Modified playlist_compare_artist so that a leading "the" in an artist's
magma
parents: 2671
diff changeset
2053 b_artist += 4;
d2ffabee3ced [svn] Modified playlist_compare_artist so that a leading "the" in an artist's
magma
parents: 2671
diff changeset
2054 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2055
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2056 if (a_artist != NULL && b_artist != NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2057 return strcasecmp(a_artist, b_artist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2058
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2059 return 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2060 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2061
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2062 static gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2063 playlist_compare_filename(PlaylistEntry * a,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2064 PlaylistEntry * b)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2065 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2066 gchar *a_filename, *b_filename;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2067
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2068 g_return_val_if_fail(a != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2069 g_return_val_if_fail(b != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2070
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2071 if (strrchr(a->filename, '/'))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2072 a_filename = strrchr(a->filename, '/') + 1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2073 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2074 a_filename = a->filename;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2075
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2076 if (strrchr(b->filename, '/'))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2077 b_filename = strrchr(b->filename, '/') + 1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2078 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2079 b_filename = b->filename;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2080
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2081
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2082 return strcasecmp(a_filename, b_filename);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2083 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2084
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2085 static gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2086 path_compare(const gchar * a, const gchar * b)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2087 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2088 gchar *posa, *posb;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2089 gint len, ret;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2090
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2091 posa = strrchr(a, '/');
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2092 posb = strrchr(b, '/');
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2093
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2094 /*
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2095 * Sort directories before files
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2096 */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2097 if (posa && posb && (posa - a != posb - b)) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2098 if (posa - a > posb - b) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2099 len = posb - b;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2100 ret = -1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2101 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2102 else {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2103 len = posa - a;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2104 ret = 1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2105 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2106 if (!strncasecmp(a, b, len))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2107 return ret;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2108 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2109 return strcasecmp(a, b);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2110 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2111
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2112 static gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2113 playlist_compare_path(PlaylistEntry * a,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2114 PlaylistEntry * b)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2115 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2116 return path_compare(a->filename, b->filename);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2117 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2118
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2119
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2120 static time_t
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2121 playlist_get_mtime(const gchar *filename)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2122 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2123 struct stat buf;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2124 gint rv;
3081
ba2143c1c6f5 unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3079
diff changeset
2125 gchar *realfn = NULL;
ba2143c1c6f5 unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3079
diff changeset
2126
ba2143c1c6f5 unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3079
diff changeset
2127 /* stat() does not accept file:// --yaz */
ba2143c1c6f5 unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3079
diff changeset
2128 realfn = g_filename_from_uri(filename, NULL, NULL);
ba2143c1c6f5 unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3079
diff changeset
2129 rv = stat(realfn ? realfn : filename, &buf);
ba2143c1c6f5 unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3079
diff changeset
2130 g_free(realfn); realfn = NULL;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2131
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2132 if (rv == 0) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2133 return buf.st_mtime;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2134 } else {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2135 return 0; //error
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2136 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2137 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2138
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2139
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2140 static gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2141 playlist_compare_date(PlaylistEntry * a,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2142 PlaylistEntry * b)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2143 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2144 struct stat buf;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2145 time_t modtime;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2146
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2147 gint rv;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2148
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2149
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2150 rv = stat(a->filename, &buf);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2151
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2152 if (rv == 0) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2153 modtime = buf.st_mtime;
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2154 rv = stat(b->filename, &buf);
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2155
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2156 if (stat(b->filename, &buf) == 0) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2157 if (buf.st_mtime == modtime)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2158 return 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2159 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2160 return (buf.st_mtime - modtime) > 0 ? -1 : 1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2161 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2162 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2163 return -1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2164 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2165 else if (!lstat(b->filename, &buf))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2166 return 1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2167 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2168 return playlist_compare_filename(a, b);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2169 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2170
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2171
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2172 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2173 playlist_sort(Playlist *playlist, PlaylistSortType type)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2174 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2175 playlist_remove_dead_files(playlist);
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2176 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2177 playlist->entries =
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2178 g_list_sort(playlist->entries,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2179 (GCompareFunc) playlist_compare_func_table[type]);
4646
c18e18ecc36b Proper updating of playlist->tail was missing from some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 4608
diff changeset
2180 playlist->tail = g_list_last(playlist->entries);
4378
342a1a1de225 Mark the playlist as modified when moving/adding/removing/sorting/randomizing the playlist, so that the jump to file cache picks up the change.
Ivan N. Zlatev <contact@i-nz.net>
parents: 4371
diff changeset
2181 PLAYLIST_INCR_SERIAL(playlist);
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2182 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2183 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2184
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2185 static GList *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2186 playlist_sort_selected_generic(GList * list, GCompareFunc cmpfunc)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2187 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2188 GList *list1, *list2;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2189 GList *tmp_list = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2190 GList *index_list = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2191
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2192 /*
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2193 * We take all the selected entries out of the playlist,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2194 * sorts them, and then put them back in again.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2195 */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2196
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2197 list1 = g_list_last(list);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2198
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2199 while (list1) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2200 list2 = g_list_previous(list1);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2201 if (PLAYLIST_ENTRY(list1->data)->selected) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2202 gpointer idx;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2203 idx = GINT_TO_POINTER(g_list_position(list, list1));
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2204 index_list = g_list_prepend(index_list, idx);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2205 list = g_list_remove_link(list, list1);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2206 tmp_list = g_list_concat(list1, tmp_list);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2207 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2208 list1 = list2;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2209 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2210
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2211 tmp_list = g_list_sort(tmp_list, cmpfunc);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2212 list1 = tmp_list;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2213 list2 = index_list;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2214
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2215 while (list2) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2216 if (!list1) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2217 g_critical(G_STRLOC ": Error during list sorting. "
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2218 "Possibly dropped some playlist-entries.");
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2219 break;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2220 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2221
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2222 list = g_list_insert(list, list1->data, GPOINTER_TO_INT(list2->data));
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2223
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2224 list2 = g_list_next(list2);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2225 list1 = g_list_next(list1);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2226 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2227
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2228 g_list_free(index_list);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2229 g_list_free(tmp_list);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2230
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2231 return list;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2232 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2233
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2234 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2235 playlist_sort_selected(Playlist *playlist, PlaylistSortType type)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2236 {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2237 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2238 playlist->entries = playlist_sort_selected_generic(playlist->entries, (GCompareFunc)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2239 playlist_compare_func_table
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2240 [type]);
4646
c18e18ecc36b Proper updating of playlist->tail was missing from some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 4608
diff changeset
2241 playlist->tail = g_list_last(playlist->entries);
4378
342a1a1de225 Mark the playlist as modified when moving/adding/removing/sorting/randomizing the playlist, so that the jump to file cache picks up the change.
Ivan N. Zlatev <contact@i-nz.net>
parents: 4371
diff changeset
2242 PLAYLIST_INCR_SERIAL(playlist);
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2243 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2244 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2245
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2246 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2247 playlist_reverse(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2248 {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2249 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2250 playlist->entries = g_list_reverse(playlist->entries);
4646
c18e18ecc36b Proper updating of playlist->tail was missing from some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 4608
diff changeset
2251 playlist->tail = g_list_last(playlist->entries);
4378
342a1a1de225 Mark the playlist as modified when moving/adding/removing/sorting/randomizing the playlist, so that the jump to file cache picks up the change.
Ivan N. Zlatev <contact@i-nz.net>
parents: 4371
diff changeset
2252 PLAYLIST_INCR_SERIAL(playlist);
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2253 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2254 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2255
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2256 static GList *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2257 playlist_shuffle_list(Playlist *playlist, GList * list)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2258 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2259 /*
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2260 * Note that this doesn't make a copy of the original list.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2261 * The pointer to the original list is not valid after this
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2262 * fuction is run.
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2263 */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2264 gint len = g_list_length(list);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2265 gint i, j;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2266 GList *node, **ptrs;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2267
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2268 if (!playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2269 return NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2270
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2271 REQUIRE_LOCK(playlist->mutex);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2272
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2273 if (!len)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2274 return NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2275
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2276 ptrs = g_new(GList *, len);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2277
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2278 for (node = list, i = 0; i < len; node = g_list_next(node), i++)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2279 ptrs[i] = node;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2280
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2281 j = g_random_int_range(0, len);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2282 list = ptrs[j];
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2283 ptrs[j]->next = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2284 ptrs[j] = ptrs[0];
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2285
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2286 for (i = 1; i < len; i++) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2287 j = g_random_int_range(0, len - i);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2288 list->prev = ptrs[i + j];
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2289 ptrs[i + j]->next = list;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2290 list = ptrs[i + j];
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2291 ptrs[i + j] = ptrs[i];
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2292 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2293 list->prev = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2294
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2295 g_free(ptrs);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2296
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2297 return list;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2298 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2299
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2300 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2301 playlist_random(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2302 {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2303 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2304 playlist->entries = playlist_shuffle_list(playlist, playlist->entries);
4646
c18e18ecc36b Proper updating of playlist->tail was missing from some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 4608
diff changeset
2305 playlist->tail = g_list_last(playlist->entries);
4378
342a1a1de225 Mark the playlist as modified when moving/adding/removing/sorting/randomizing the playlist, so that the jump to file cache picks up the change.
Ivan N. Zlatev <contact@i-nz.net>
parents: 4371
diff changeset
2306 PLAYLIST_INCR_SERIAL(playlist);
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2307 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2308 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2309
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2310 GList *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2311 playlist_get_selected(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2312 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2313 GList *node, *list = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2314 gint i = 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2315
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2316 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2317 for (node = playlist->entries; node; node = g_list_next(node), i++) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2318 PlaylistEntry *entry = node->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2319 if (entry->selected)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2320 list = g_list_prepend(list, GINT_TO_POINTER(i));
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2321 }
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2322 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2323 return g_list_reverse(list);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2324 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2325
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2326 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2327 playlist_clear_selected(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2328 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2329 GList *node = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2330 gint i = 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2331
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2332 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2333 for (node = playlist->entries; node; node = g_list_next(node), i++) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2334 PLAYLIST_ENTRY(node->data)->selected = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2335 }
4378
342a1a1de225 Mark the playlist as modified when moving/adding/removing/sorting/randomizing the playlist, so that the jump to file cache picks up the change.
Ivan N. Zlatev <contact@i-nz.net>
parents: 4371
diff changeset
2336 PLAYLIST_INCR_SERIAL(playlist);
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2337 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2338 playlist_recalc_total_time(playlist);
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
2339 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2340 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2341
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2342 gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2343 playlist_get_num_selected(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2344 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2345 GList *node;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2346 gint num = 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2347
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2348 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2349 for (node = playlist->entries; node; node = g_list_next(node)) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2350 PlaylistEntry *entry = node->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2351 if (entry->selected)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2352 num++;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2353 }
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2354 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2355 return num;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2356 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2357
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2358
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2359 static void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2360 playlist_generate_shuffle_list(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2361 {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2362 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2363 playlist_generate_shuffle_list_nolock(playlist);
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2364 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2365 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2366
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2367 static void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2368 playlist_generate_shuffle_list_nolock(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2369 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2370 GList *node;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2371 gint numsongs;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2372
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2373 if (!cfg.shuffle || !playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2374 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2375
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2376 REQUIRE_LOCK(playlist->mutex);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2377
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2378 if (playlist->shuffle) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2379 g_list_free(playlist->shuffle);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2380 playlist->shuffle = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2381 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2382
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2383 playlist->shuffle = playlist_shuffle_list(playlist, g_list_copy(playlist->entries));
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2384 numsongs = g_list_length(playlist->shuffle);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2385
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2386 if (playlist->position) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2387 gint i = g_list_index(playlist->shuffle, playlist->position);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2388 node = g_list_nth(playlist->shuffle, i);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2389 playlist->shuffle = g_list_remove_link(playlist->shuffle, node);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2390 playlist->shuffle = g_list_prepend(playlist->shuffle, node->data);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2391 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2392 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2393
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2394
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2395 static gboolean
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2396 playlist_get_info_is_going(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2397 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2398 gboolean result;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2399
3460
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2400 g_static_rw_lock_reader_lock(&playlist_get_info_rwlock);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2401 result = playlist_get_info_going;
3460
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2402 g_static_rw_lock_reader_unlock(&playlist_get_info_rwlock);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2403
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2404 return result;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2405 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2406
3460
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2407
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2408 static gpointer
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2409 playlist_get_info_func(gpointer arg)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2410 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2411 GList *node;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2412 gboolean update_playlistwin = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2413
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2414 while (playlist_get_info_is_going()) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2415 PlaylistEntry *entry;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2416 Playlist *playlist = playlist_get_active();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2417
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2418 // on_load
3460
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2419 if (cfg.use_pl_metadata && cfg.get_info_on_load &&
3959
a575c29cee05 - revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3947
diff changeset
2420 playlist_get_info_scan_active) {
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2421
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2422 for (node = playlist->entries; node; node = g_list_next(node)) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2423 entry = node->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2424
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2425 if (playlist->attribute & PLAYLIST_STATIC || // live lock fix
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2426 (entry->tuple &&
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2427 tuple_get_int(entry->tuple, FIELD_LENGTH, NULL) > -1 &&
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2428 tuple_get_int(entry->tuple, FIELD_MTIME, NULL) != -1 &&
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2429 entry->title_is_valid))
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2430 {
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2431 update_playlistwin = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2432 continue;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2433 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2434
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2435 if (!playlist_entry_get_info(entry) &&
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2436 g_list_index(playlist->entries, entry) == -1)
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2437 /* Entry disappeared while we looked it up.
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2438 Restart. */
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2439 node = playlist->entries;
4744
89891f400f98 Patch from Steve Cotton <steve0001@s.cotton.clara.co.uk> to resolve a
William Pitcock <nenolod@atheme.org>
parents: 4646
diff changeset
2440 else if ((entry->tuple != NULL) ||
89891f400f98 Patch from Steve Cotton <steve0001@s.cotton.clara.co.uk> to resolve a
William Pitcock <nenolod@atheme.org>
parents: 4646
diff changeset
2441 (entry->title != NULL &&
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2442 tuple_get_int(entry->tuple, FIELD_LENGTH, NULL) > -1 &&
4744
89891f400f98 Patch from Steve Cotton <steve0001@s.cotton.clara.co.uk> to resolve a
William Pitcock <nenolod@atheme.org>
parents: 4646
diff changeset
2443 tuple_get_int(entry->tuple, FIELD_MTIME, NULL) != -1))
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2444 {
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2445 update_playlistwin = TRUE;
4227
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
2446 break; /* hmmm... --asphyx */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2447 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2448 }
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2449
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2450 if (!node) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2451 g_mutex_lock(mutex_scan);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2452 playlist_get_info_scan_active = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2453 g_mutex_unlock(mutex_scan);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2454 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2455 } // on_load
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2456
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2457 // on_demand
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2458 else if (!cfg.get_info_on_load &&
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2459 cfg.get_info_on_demand &&
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2460 cfg.playlist_visible &&
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2461 !cfg.playlist_shaded &&
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2462 cfg.use_pl_metadata) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2463
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2464 g_mutex_lock(mutex_scan);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2465 playlist_get_info_scan_active = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2466 g_mutex_unlock(mutex_scan);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2467
2668
d5da5d37ec8b [svn] - unlock many playlist operations that do not really need locking
nenolod
parents: 2667
diff changeset
2468 for (node = g_list_nth(playlist->entries, playlistwin_get_toprow());
d5da5d37ec8b [svn] - unlock many playlist operations that do not really need locking
nenolod
parents: 2667
diff changeset
2469 node && playlistwin_item_visible(g_list_position(playlist->entries, node));
d5da5d37ec8b [svn] - unlock many playlist operations that do not really need locking
nenolod
parents: 2667
diff changeset
2470 node = g_list_next(node)) {
d5da5d37ec8b [svn] - unlock many playlist operations that do not really need locking
nenolod
parents: 2667
diff changeset
2471
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2472 entry = node->data;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2473
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2474 if (playlist->attribute & PLAYLIST_STATIC ||
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
2475 (entry->tuple &&
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
2476 tuple_get_int(entry->tuple, FIELD_LENGTH, NULL) > -1 &&
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
2477 tuple_get_int(entry->tuple, FIELD_MTIME, NULL) != -1 &&
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
2478 entry->title_is_valid))
2668
d5da5d37ec8b [svn] - unlock many playlist operations that do not really need locking
nenolod
parents: 2667
diff changeset
2479 continue;
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2480
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2481 AUDDBG("len=%d mtime=%d\n",
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2482 tuple_get_int(entry->tuple, FIELD_LENGTH, NULL),
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2483 tuple_get_int(entry->tuple, FIELD_MTIME, NULL));
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2484
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2485 if (!playlist_entry_get_info(entry)) {
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2486 if (g_list_index(playlist->entries, entry) == -1)
2668
d5da5d37ec8b [svn] - unlock many playlist operations that do not really need locking
nenolod
parents: 2667
diff changeset
2487 /* Entry disapeared while we
d5da5d37ec8b [svn] - unlock many playlist operations that do not really need locking
nenolod
parents: 2667
diff changeset
2488 looked it up. Restart. */
d5da5d37ec8b [svn] - unlock many playlist operations that do not really need locking
nenolod
parents: 2667
diff changeset
2489 node = g_list_nth(playlist->entries,
d5da5d37ec8b [svn] - unlock many playlist operations that do not really need locking
nenolod
parents: 2667
diff changeset
2490 playlistwin_get_toprow());
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2491 }
4744
89891f400f98 Patch from Steve Cotton <steve0001@s.cotton.clara.co.uk> to resolve a
William Pitcock <nenolod@atheme.org>
parents: 4646
diff changeset
2492 else if ((entry->tuple != NULL) ||
89891f400f98 Patch from Steve Cotton <steve0001@s.cotton.clara.co.uk> to resolve a
William Pitcock <nenolod@atheme.org>
parents: 4646
diff changeset
2493 (entry->title != NULL &&
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2494 tuple_get_int(entry->tuple, FIELD_LENGTH, NULL) > -1 &&
4744
89891f400f98 Patch from Steve Cotton <steve0001@s.cotton.clara.co.uk> to resolve a
William Pitcock <nenolod@atheme.org>
parents: 4646
diff changeset
2495 tuple_get_int(entry->tuple, FIELD_MTIME, NULL) != -1)) {
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2496 update_playlistwin = TRUE;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2497 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2498 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2499 } // on_demand
4087
776c30747439 avoid unnecessary serial increment.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4086
diff changeset
2500
3460
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2501 else if (cfg.get_info_on_demand &&
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2502 (!cfg.playlist_visible || cfg.playlist_shaded || !cfg.use_pl_metadata))
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2503 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2504 g_mutex_lock(mutex_scan);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2505 playlist_get_info_scan_active = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2506 g_mutex_unlock(mutex_scan);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2507 }
4087
776c30747439 avoid unnecessary serial increment.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4086
diff changeset
2508
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2509 else /* not on_demand and not on_load...
4412
180996fcf12a bmp_config_* -> aud_config_*
Matti Hamalainen <ccr@tnsp.org>
parents: 4378
diff changeset
2510 NOTE: this shouldn't happen anymore, sanity check in aud_config_load now */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2511 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2512 g_mutex_lock(mutex_scan);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2513 playlist_get_info_scan_active = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2514 g_mutex_unlock(mutex_scan);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2515 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2516
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2517 if (update_playlistwin) {
4086
96d8114f0b89 now jtf follows on-demand metadata loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4076
diff changeset
2518 Playlist *playlist = playlist_get_active();
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
2519 event_queue("playlist update", playlist);
4086
96d8114f0b89 now jtf follows on-demand metadata loading.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4076
diff changeset
2520 PLAYLIST_INCR_SERIAL(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2521 update_playlistwin = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2522 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2523
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2524 if (playlist_get_info_scan_active)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2525 continue;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2526
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2527 g_mutex_lock(mutex_scan);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2528 g_cond_wait(cond_scan, mutex_scan);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2529 g_mutex_unlock(mutex_scan);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2530
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2531 // AUDDBG("scanner invoked\n");
3934
e924c9ee3958 when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3923
diff changeset
2532
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2533 } // while
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2534
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2535 g_thread_exit(NULL);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2536 return NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2537 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2538
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2539 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2540 playlist_start_get_info_thread(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2541 {
3460
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2542 g_static_rw_lock_writer_lock(&playlist_get_info_rwlock);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2543 playlist_get_info_going = TRUE;
3460
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2544 g_static_rw_lock_writer_unlock(&playlist_get_info_rwlock);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2545
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2546 playlist_get_info_thread = g_thread_create(playlist_get_info_func,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2547 NULL, TRUE, NULL);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2548 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2549
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2550 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2551 playlist_stop_get_info_thread(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2552 {
3460
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2553 g_static_rw_lock_writer_lock(&playlist_get_info_rwlock);
4525
16466c2624b2 Check if the playlist scanning thread has already been stopped, so that we don't crash in thread joining.
Matti Hamalainen <ccr@tnsp.org>
parents: 4516
diff changeset
2554 if (!playlist_get_info_going) {
16466c2624b2 Check if the playlist scanning thread has already been stopped, so that we don't crash in thread joining.
Matti Hamalainen <ccr@tnsp.org>
parents: 4516
diff changeset
2555 g_static_rw_lock_writer_unlock(&playlist_get_info_rwlock);
16466c2624b2 Check if the playlist scanning thread has already been stopped, so that we don't crash in thread joining.
Matti Hamalainen <ccr@tnsp.org>
parents: 4516
diff changeset
2556 return;
16466c2624b2 Check if the playlist scanning thread has already been stopped, so that we don't crash in thread joining.
Matti Hamalainen <ccr@tnsp.org>
parents: 4516
diff changeset
2557 }
16466c2624b2 Check if the playlist scanning thread has already been stopped, so that we don't crash in thread joining.
Matti Hamalainen <ccr@tnsp.org>
parents: 4516
diff changeset
2558
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2559 playlist_get_info_going = FALSE;
3460
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2560 g_static_rw_lock_writer_unlock(&playlist_get_info_rwlock);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2561
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2562 g_cond_broadcast(cond_scan);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2563 g_thread_join(playlist_get_info_thread);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2564 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2565
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2566 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2567 playlist_start_get_info_scan(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2568 {
4227
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
2569 AUDDBG("waking up scan thread\n");
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2570 g_mutex_lock(mutex_scan);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2571 playlist_get_info_scan_active = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2572 g_mutex_unlock(mutex_scan);
3460
0fcff78c0c2c Make the shutdown procedure more sane and improve playlist clearing
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2573
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2574 g_cond_signal(cond_scan);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2575 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2576
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2577 void
4227
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
2578 playlist_update_all_titles(void) /* update titles after format changing --asphyx */
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
2579 {
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
2580 PlaylistEntry *entry;
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
2581 GList *node;
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
2582 Playlist *playlist = playlist_get_active();
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2583
4227
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
2584 AUDDBG("invalidating titles\n");
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
2585 PLAYLIST_LOCK(playlist);
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
2586 for (node = playlist->entries; node; node = g_list_next(node)) {
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
2587 entry = node->data;
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
2588 entry->title_is_valid = FALSE;
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
2589 }
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
2590 PLAYLIST_UNLOCK(playlist);
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
2591 playlist_start_get_info_scan();
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
2592 }
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
2593
206378f34610 update titles when formatter template changes even if tuples is up to date
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 4184
diff changeset
2594 void
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2595 playlist_remove_dead_files(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2596 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2597 GList *node, *next_node;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2598
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2599 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2600
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2601 for (node = playlist->entries; node; node = next_node) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2602 PlaylistEntry *entry = PLAYLIST_ENTRY(node->data);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2603 next_node = g_list_next(node);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2604
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2605 if (!entry || !entry->filename) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2606 g_message(G_STRLOC ": Playlist entry is invalid!");
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2607 continue;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2608 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2609
4060
21833104ed4c fixed(URI-fied) "remove unavailable files"
Cristi Magherusan <majeru@atheme-project.org>
parents: 4059
diff changeset
2610 if (!g_str_has_prefix(entry->filename, "file://"))
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2611 continue;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2612
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2613 /* FIXME: Should test for readability */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2614 if (vfs_file_test(entry->filename, G_FILE_TEST_EXISTS))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2615 continue;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2616
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2617 if (entry == playlist->position) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2618 /* Don't remove the currently playing song */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2619 if (playback_get_playing())
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2620 continue;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2621
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2622 if (next_node)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2623 playlist->position = PLAYLIST_ENTRY(next_node->data);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2624 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2625 playlist->position = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2626 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2627
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2628 playlist_entry_free(entry);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2629 playlist->entries = g_list_delete_link(playlist->entries, node);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2630 }
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2631
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2632 PLAYLIST_UNLOCK(playlist);
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2633
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2634 playlist_generate_shuffle_list(playlist);
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
2635 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2636 playlist_recalc_total_time(playlist);
3923
e9fd46b0893b - redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3922
diff changeset
2637 PLAYLIST_INCR_SERIAL(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2638 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2639
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2640
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2641 static gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2642 playlist_dupscmp_title(PlaylistEntry * a,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2643 PlaylistEntry * b)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2644 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2645 const gchar *a_title, *b_title;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2646
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2647 g_return_val_if_fail(a != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2648 g_return_val_if_fail(b != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2649
3638
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
2650 playlist_get_entry_title(a, &a_title);
8d2f06fc841c Slight cleanup of few functions and fix a potential segfault.
Matti Hamalainen <ccr@tnsp.org>
parents: 3636
diff changeset
2651 playlist_get_entry_title(b, &b_title);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2652
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2653 return strcmp(a_title, b_title);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2654 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2655
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2656 static gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2657 playlist_dupscmp_filename(PlaylistEntry * a,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2658 PlaylistEntry * b )
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2659 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2660 gchar *a_filename, *b_filename;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2661
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2662 g_return_val_if_fail(a != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2663 g_return_val_if_fail(b != NULL, 0);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2664
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2665 if (strrchr(a->filename, '/'))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2666 a_filename = strrchr(a->filename, '/') + 1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2667 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2668 a_filename = a->filename;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2669
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2670 if (strrchr(b->filename, '/'))
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2671 b_filename = strrchr(b->filename, '/') + 1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2672 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2673 b_filename = b->filename;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2674
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2675 return strcmp(a_filename, b_filename);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2676 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2677
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2678 static gint
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2679 playlist_dupscmp_path(PlaylistEntry * a,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2680 PlaylistEntry * b)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2681 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2682 /* simply compare the entire filename string */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2683 return strcmp(a->filename, b->filename);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2684 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2685
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2686 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2687 playlist_remove_duplicates(Playlist *playlist, PlaylistDupsType type)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2688 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2689 GList *node, *next_node;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2690 GList *node_cmp, *next_node_cmp;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2691 gint (*dups_compare_func)(PlaylistEntry * , PlaylistEntry *);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2692
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2693 switch ( type )
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2694 {
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2695 case PLAYLIST_DUPS_TITLE:
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2696 dups_compare_func = playlist_dupscmp_title;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2697 break;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2698 case PLAYLIST_DUPS_PATH:
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2699 dups_compare_func = playlist_dupscmp_path;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2700 break;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2701 case PLAYLIST_DUPS_FILENAME:
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2702 default:
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2703 dups_compare_func = playlist_dupscmp_filename;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2704 break;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2705 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2706
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2707 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2708
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2709 for (node = playlist->entries; node; node = next_node) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2710 PlaylistEntry *entry = PLAYLIST_ENTRY(node->data);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2711 next_node = g_list_next(node);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2712
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2713 if (!entry || !entry->filename) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2714 g_message(G_STRLOC ": Playlist entry is invalid!");
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2715 continue;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2716 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2717
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2718 for (node_cmp = next_node; node_cmp; node_cmp = next_node_cmp) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2719 PlaylistEntry *entry_cmp = PLAYLIST_ENTRY(node_cmp->data);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2720 next_node_cmp = g_list_next(node_cmp);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2721
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2722 if (!entry_cmp || !entry_cmp->filename) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2723 g_message(G_STRLOC ": Playlist entry is invalid!");
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2724 continue;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2725 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2726
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2727 /* compare using the chosen dups_compare_func */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2728 if ( !dups_compare_func( entry , entry_cmp ) ) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2729
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2730 if (entry_cmp == playlist->position) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2731 /* Don't remove the currently playing song */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2732 if (playback_get_playing())
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2733 continue;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2734
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2735 if (next_node_cmp)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2736 playlist->position = PLAYLIST_ENTRY(next_node_cmp->data);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2737 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2738 playlist->position = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2739 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2740
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2741 /* check if this was the next item of the external
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2742 loop; if true, replace it with the next of the next*/
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2743 if ( node_cmp == next_node )
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2744 next_node = g_list_next(next_node);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2745
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2746 playlist_entry_free(entry_cmp);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2747 playlist->entries = g_list_delete_link(playlist->entries, node_cmp);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2748 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2749 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2750 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2751
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2752 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2753
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
2754 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2755 playlist_recalc_total_time(playlist);
3923
e9fd46b0893b - redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3922
diff changeset
2756 PLAYLIST_INCR_SERIAL(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2757 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2758
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2759 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2760 playlist_get_total_time(Playlist * playlist,
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2761 gulong * total_time,
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2762 gulong * selection_time,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2763 gboolean * total_more,
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2764 gboolean * selection_more)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2765 {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2766 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2767 *total_time = playlist->pl_total_time;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2768 *selection_time = playlist->pl_selection_time;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2769 *total_more = playlist->pl_total_more;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2770 *selection_more = playlist->pl_selection_more;
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2771 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2772 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2773
3922
23e5b148ae7c to get rid of annoying side effects, an independent function for playlist serial increment has been provided.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3921
diff changeset
2774 static void
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2775 playlist_recalc_total_time_nolock(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2776 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2777 GList *list;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2778 PlaylistEntry *entry;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2779
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2780 REQUIRE_LOCK(playlist->mutex);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2781
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2782 playlist->pl_total_time = 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2783 playlist->pl_selection_time = 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2784 playlist->pl_total_more = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2785 playlist->pl_selection_more = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2786
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2787 for (list = playlist->entries; list; list = g_list_next(list)) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2788 entry = list->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2789
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2790 if (entry->length != -1)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2791 playlist->pl_total_time += entry->length / 1000;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2792 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2793 playlist->pl_total_more = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2794
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2795 if (entry->selected) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2796 if (entry->length != -1)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2797 playlist->pl_selection_time += entry->length / 1000;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2798 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2799 playlist->pl_selection_more = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2800 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2801 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2802 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2803
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2804 static void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2805 playlist_recalc_total_time(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2806 {
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2807 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2808 playlist_recalc_total_time_nolock(playlist);
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2809 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2810 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2811
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2812 gint
3298
f985357757e0 audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents: 3246
diff changeset
2813 playlist_select_search( Playlist *playlist , Tuple *tuple , gint action )
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2814 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2815 GList *entry_list = NULL, *found_list = NULL, *sel_list = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2816 gboolean is_first_search = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2817 gint num_of_entries_found = 0;
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2818 const gchar *regex_pattern;
3863
dd5c459c5f2d fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents: 3784
diff changeset
2819 const gchar *track_name;
dd5c459c5f2d fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents: 3784
diff changeset
2820 const gchar *album_name;
dd5c459c5f2d fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents: 3784
diff changeset
2821 const gchar *performer;
dd5c459c5f2d fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents: 3784
diff changeset
2822 const gchar *file_name;
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2823
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2824 #if defined(USE_REGEX_ONIGURUMA)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2825 /* set encoding for Oniguruma regex to UTF-8 */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2826 reg_set_encoding( REG_POSIX_ENCODING_UTF8 );
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2827 onig_set_default_syntax( ONIG_SYNTAX_POSIX_BASIC );
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2828 #endif
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2829
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2830 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2831
3863
dd5c459c5f2d fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents: 3784
diff changeset
2832 if ( (regex_pattern = tuple_get_string(tuple, FIELD_TITLE, NULL)) != NULL &&
dd5c459c5f2d fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents: 3784
diff changeset
2833 (*regex_pattern != '\0') )
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2834 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2835 /* match by track_name */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2836 regex_t regex;
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2837 #if defined(USE_REGEX_PCRE)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2838 if ( regcomp( &regex , regex_pattern , REG_NOSUB | REG_ICASE | REG_UTF8 ) == 0 )
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2839 #else
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2840 if ( regcomp( &regex , regex_pattern , REG_NOSUB | REG_ICASE ) == 0 )
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2841 #endif
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2842 {
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2843 GList *tfound_list = NULL;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2844 if ( is_first_search == TRUE ) entry_list = playlist->entries;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2845 else entry_list = found_list; /* use found_list */
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2846 for ( ; entry_list ; entry_list = g_list_next(entry_list) )
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2847 {
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2848 PlaylistEntry *entry = entry_list->data;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2849 if ( entry->tuple != NULL )
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2850 {
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2851 track_name = tuple_get_string( entry->tuple, FIELD_TITLE, NULL );
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2852 if (( track_name != NULL ) &&
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2853 ( regexec( &regex , track_name , 0 , NULL , 0 ) == 0 ) )
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2854 {
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2855 tfound_list = g_list_append( tfound_list , entry );
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2856 }
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2857 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2858 }
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2859 g_list_free( found_list ); /* wipe old found_list */
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2860 found_list = tfound_list; /* move tfound_list in found_list */
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2861 regfree( &regex );
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2862 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2863 is_first_search = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2864 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2865
3863
dd5c459c5f2d fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents: 3784
diff changeset
2866 if ( (regex_pattern = tuple_get_string(tuple, FIELD_ALBUM, NULL)) != NULL &&
dd5c459c5f2d fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents: 3784
diff changeset
2867 (*regex_pattern != '\0') )
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2868 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2869 /* match by album_name */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2870 regex_t regex;
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2871 #if defined(USE_REGEX_PCRE)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2872 if ( regcomp( &regex , regex_pattern , REG_NOSUB | REG_ICASE | REG_UTF8 ) == 0 )
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2873 #else
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2874 if ( regcomp( &regex , regex_pattern , REG_NOSUB | REG_ICASE ) == 0 )
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2875 #endif
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2876 {
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2877 GList *tfound_list = NULL;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2878 if ( is_first_search == TRUE ) entry_list = playlist->entries;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2879 else entry_list = found_list; /* use found_list */
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2880 for ( ; entry_list ; entry_list = g_list_next(entry_list) )
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2881 {
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2882 PlaylistEntry *entry = entry_list->data;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2883 if ( entry->tuple != NULL )
3863
dd5c459c5f2d fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents: 3784
diff changeset
2884 {
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2885 album_name = tuple_get_string( entry->tuple, FIELD_ALBUM, NULL );
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2886 if ( ( album_name != NULL ) &&
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2887 ( regexec( &regex , album_name , 0 , NULL , 0 ) == 0 ) )
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2888 {
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2889 tfound_list = g_list_append( tfound_list , entry );
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2890 }
3863
dd5c459c5f2d fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents: 3784
diff changeset
2891 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2892 }
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2893 g_list_free( found_list ); /* wipe old found_list */
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2894 found_list = tfound_list; /* move tfound_list in found_list */
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2895 regfree( &regex );
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2896 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2897 is_first_search = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2898 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2899
3863
dd5c459c5f2d fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents: 3784
diff changeset
2900 if ( (regex_pattern = tuple_get_string(tuple, FIELD_ARTIST, NULL)) != NULL &&
dd5c459c5f2d fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents: 3784
diff changeset
2901 (*regex_pattern != '\0') )
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2902 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2903 /* match by performer */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2904 regex_t regex;
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2905 #if defined(USE_REGEX_PCRE)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2906 if ( regcomp( &regex , regex_pattern , REG_NOSUB | REG_ICASE | REG_UTF8 ) == 0 )
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2907 #else
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2908 if ( regcomp( &regex , regex_pattern , REG_NOSUB | REG_ICASE ) == 0 )
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2909 #endif
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2910 {
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2911 GList *tfound_list = NULL;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2912 if ( is_first_search == TRUE ) entry_list = playlist->entries;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2913 else entry_list = found_list; /* use found_list */
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2914 for ( ; entry_list ; entry_list = g_list_next(entry_list) )
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2915 {
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2916 PlaylistEntry *entry = entry_list->data;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2917 if ( entry->tuple != NULL )
3863
dd5c459c5f2d fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents: 3784
diff changeset
2918 {
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2919 performer = tuple_get_string( entry->tuple, FIELD_ARTIST, NULL );
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2920 if ( ( entry->tuple != NULL ) && ( performer != NULL ) &&
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2921 ( regexec( &regex , performer , 0 , NULL , 0 ) == 0 ) )
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2922 {
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2923 tfound_list = g_list_append( tfound_list , entry );
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2924 }
3863
dd5c459c5f2d fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents: 3784
diff changeset
2925 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2926 }
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2927 g_list_free( found_list ); /* wipe old found_list */
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2928 found_list = tfound_list; /* move tfound_list in found_list */
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2929 regfree( &regex );
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2930 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2931 is_first_search = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2932 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2933
3863
dd5c459c5f2d fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents: 3784
diff changeset
2934 if ( (regex_pattern = tuple_get_string(tuple, FIELD_FILE_NAME, NULL)) != NULL &&
dd5c459c5f2d fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents: 3784
diff changeset
2935 (*regex_pattern != '\0') )
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2936 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2937 /* match by file_name */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2938 regex_t regex;
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2939 #if defined(USE_REGEX_PCRE)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2940 if ( regcomp( &regex , regex_pattern , REG_NOSUB | REG_ICASE | REG_UTF8 ) == 0 )
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2941 #else
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2942 if ( regcomp( &regex , regex_pattern , REG_NOSUB | REG_ICASE ) == 0 )
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
2943 #endif
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2944 {
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2945 GList *tfound_list = NULL;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2946 if ( is_first_search == TRUE ) entry_list = playlist->entries;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2947 else entry_list = found_list; /* use found_list */
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2948 for ( ; entry_list ; entry_list = g_list_next(entry_list) )
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2949 {
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2950 PlaylistEntry *entry = entry_list->data;
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2951 if ( entry->tuple != NULL )
3863
dd5c459c5f2d fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents: 3784
diff changeset
2952 {
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2953 file_name = tuple_get_string( entry->tuple, FIELD_FILE_NAME, NULL );
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2954 if ( ( file_name != NULL ) &&
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2955 ( regexec( &regex , file_name , 0 , NULL , 0 ) == 0 ) )
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2956 {
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2957 tfound_list = g_list_append( tfound_list , entry );
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2958 }
3863
dd5c459c5f2d fix search and select. (bugzilla #29)
William Pitcock <nenolod@atheme.org>
parents: 3784
diff changeset
2959 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2960 }
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2961 g_list_free( found_list ); /* wipe old found_list */
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2962 found_list = tfound_list; /* move tfound_list in found_list */
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2963 regfree( &regex );
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2964 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2965 is_first_search = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2966 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2967
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2968 /* NOTE: action = 0 -> default behaviour, select all matching entries */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2969 /* if some entries are still in found_list, those
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2970 are what the user is searching for; select them */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2971 for ( sel_list = found_list ; sel_list ; sel_list = g_list_next(sel_list) )
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2972 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2973 PlaylistEntry *entry = sel_list->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2974 entry->selected = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2975 num_of_entries_found++;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2976 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2977
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2978 g_list_free( found_list );
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2979
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2980 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2981 playlist_recalc_total_time(playlist);
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
2982 // PLAYLIST_INCR_SERIAL(playlist); //unnecessary? --yaz
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2983
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2984 return num_of_entries_found;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2985 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2986
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2987 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2988 playlist_select_all(Playlist *playlist, gboolean set)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2989 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2990 GList *list;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2991
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2992 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2993
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2994 for (list = playlist->entries; list; list = g_list_next(list)) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2995 PlaylistEntry *entry = list->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2996 entry->selected = set;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2997 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
2998
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
2999 PLAYLIST_UNLOCK(playlist);
3922
23e5b148ae7c to get rid of annoying side effects, an independent function for playlist serial increment has been provided.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3921
diff changeset
3000 playlist_recalc_total_time(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3001 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3002
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3003 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3004 playlist_select_invert_all(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3005 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3006 GList *list;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3007
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
3008 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3009
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3010 for (list = playlist->entries; list; list = g_list_next(list)) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3011 PlaylistEntry *entry = list->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3012 entry->selected = !entry->selected;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3013 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3014
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
3015 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3016 playlist_recalc_total_time(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3017 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3018
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3019 gboolean
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3020 playlist_select_invert(Playlist *playlist, guint pos)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3021 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3022 GList *list;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3023 gboolean invert_ok = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3024
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
3025 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3026
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3027 if ((list = g_list_nth(playlist->entries, pos))) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3028 PlaylistEntry *entry = list->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3029 entry->selected = !entry->selected;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3030 invert_ok = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3031 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3032
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
3033 PLAYLIST_UNLOCK(playlist);
3922
23e5b148ae7c to get rid of annoying side effects, an independent function for playlist serial increment has been provided.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3921
diff changeset
3034 playlist_recalc_total_time(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3035
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3036 return invert_ok;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3037 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3038
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3039
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3040 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3041 playlist_select_range(Playlist *playlist, gint min_pos, gint max_pos, gboolean select)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3042 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3043 GList *list;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3044 gint i;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3045
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3046 if (min_pos > max_pos)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3047 SWAP(min_pos, max_pos);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3048
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
3049 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3050
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3051 list = g_list_nth(playlist->entries, min_pos);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3052 for (i = min_pos; i <= max_pos && list; i++) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3053 PlaylistEntry *entry = list->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3054 entry->selected = select;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3055 list = g_list_next(list);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3056 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3057
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
3058 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3059
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3060 playlist_recalc_total_time(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3061 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3062
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3063 gboolean
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3064 playlist_read_info_selection(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3065 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3066 GList *node;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3067 gboolean retval = FALSE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3068
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
3069 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3070
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3071 for (node = playlist->entries; node; node = g_list_next(node)) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3072 PlaylistEntry *entry = node->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3073 if (!entry->selected)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3074 continue;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3075
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3076 retval = TRUE;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3077
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3078 str_replace_in(&entry->title, NULL);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3079 entry->length = -1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3080
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
3081 /* invalidate mtime to reread */
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
3082 if (entry->tuple != NULL)
3490
602ec8c40d0d Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 3401
diff changeset
3083 tuple_associate_int(entry->tuple, FIELD_MTIME, NULL, -1); /* -1 denotes "non-initialized". now 0 is for stream etc. yaz */
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3084
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3085 if (!playlist_entry_get_info(entry)) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3086 if (g_list_index(playlist->entries, entry) == -1)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3087 /* Entry disappeared while we looked it up. Restart. */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3088 node = playlist->entries;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3089 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3090 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3091
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
3092 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3093
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
3094 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3095 playlist_recalc_total_time(playlist);
3923
e9fd46b0893b - redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3922
diff changeset
3096 PLAYLIST_INCR_SERIAL(playlist); //tentative --yaz
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3097
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3098 return retval;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3099 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3100
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3101 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3102 playlist_read_info(Playlist *playlist, guint pos)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3103 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3104 GList *node;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3105
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
3106 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3107
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3108 if ((node = g_list_nth(playlist->entries, pos))) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3109 PlaylistEntry *entry = node->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3110 str_replace_in(&entry->title, NULL);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3111 entry->length = -1;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3112 playlist_entry_get_info(entry);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3113 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3114
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
3115 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3116
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
3117 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3118 playlist_recalc_total_time(playlist);
3923
e9fd46b0893b - redefine playlist_incr_serial as a macro.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3922
diff changeset
3119 PLAYLIST_INCR_SERIAL(playlist); //tentative --yaz
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3120 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3121
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3122 Playlist *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3123 playlist_get_active(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3124 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3125 if (playlists_iter != NULL)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3126 return (Playlist *) playlists_iter->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3127
2736
8249a1248a09 [svn] - avoid null dereferences
nenolod
parents: 2717
diff changeset
3128 if (playlists)
8249a1248a09 [svn] - avoid null dereferences
nenolod
parents: 2717
diff changeset
3129 return (Playlist *) playlists->data;
8249a1248a09 [svn] - avoid null dereferences
nenolod
parents: 2717
diff changeset
3130
8249a1248a09 [svn] - avoid null dereferences
nenolod
parents: 2717
diff changeset
3131 return NULL;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3132 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3133
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3134 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3135 playlist_set_shuffle(gboolean shuffle)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3136 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3137 Playlist *playlist = playlist_get_active();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3138 if (!playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3139 return;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3140
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
3141 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3142
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3143 playlist_position_before_jump = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3144
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3145 cfg.shuffle = shuffle;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3146 playlist_generate_shuffle_list_nolock(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3147
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
3148 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3149 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3150
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3151 Playlist *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3152 playlist_new(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3153 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3154 Playlist *playlist = g_new0(Playlist, 1);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3155 playlist->mutex = g_mutex_new();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3156 playlist->loading_playlist = FALSE;
3477
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
3157 playlist->title = NULL;
57f4971b7086 New functions for associating a filename with a playlist. Made title/filename setting more consistent.
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3476
diff changeset
3158 playlist->filename = NULL;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3159 playlist_clear(playlist);
3920
c2b2828186ba - serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3867
diff changeset
3160 playlist->tail = NULL;
c2b2828186ba - serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3867
diff changeset
3161 playlist->attribute = PLAYLIST_PLAIN;
c2b2828186ba - serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3867
diff changeset
3162 playlist->serial = 0;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3163
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3164 return playlist;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3165 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3166
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3167 void
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3168 playlist_free(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3169 {
3467
5a6896b6000f Implement playlist_get_info_scanning() with mutex locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 3460
diff changeset
3170 if (!playlist)
5a6896b6000f Implement playlist_get_info_scanning() with mutex locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 3460
diff changeset
3171 return;
4111
3e63b1bee1e7 Fixes memory leak in usage of playlist_free() function. (Bugzilla #36)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 4110
diff changeset
3172
3e63b1bee1e7 Fixes memory leak in usage of playlist_free() function. (Bugzilla #36)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 4110
diff changeset
3173 if (playlist->filename)
3e63b1bee1e7 Fixes memory leak in usage of playlist_free() function. (Bugzilla #36)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 4110
diff changeset
3174 g_free( playlist->filename );
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3175 g_mutex_free( playlist->mutex );
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3176 g_free( playlist );
3920
c2b2828186ba - serial number has been added to playlist structure so that changes of the current playlist can be notified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3867
diff changeset
3177 playlist = NULL; //XXX lead to crash? --yaz
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3178 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3179
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3180 Playlist *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3181 playlist_new_from_selected(void)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3182 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3183 Playlist *newpl = playlist_new();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3184 Playlist *playlist = playlist_get_active();
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3185 GList *list = playlist_get_selected(playlist);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3186
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3187 playlist_add_playlist( newpl );
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3188
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
3189 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3190
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3191 while ( list != NULL )
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3192 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3193 PlaylistEntry *entry = g_list_nth_data(playlist->entries, GPOINTER_TO_INT(list->data));
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3194 if ( entry->filename != NULL ) /* paranoid? oh well... */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3195 playlist_add( newpl , entry->filename );
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3196 list = g_list_next(list);
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3197 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3198
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
3199 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3200
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3201 playlist_recalc_total_time(newpl);
4516
9fbb55542e73 hookified many function calls
mf0102 <0102@gmx.at>
parents: 4515
diff changeset
3202 hook_call("playlist update", playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3203
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3204 return newpl;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3205 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3206
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3207 const gchar *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3208 playlist_get_filename_to_play(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3209 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3210 const gchar *filename = NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3211
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3212 if (!playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3213 return NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3214
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
3215 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3216
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3217 if (!playlist->position) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3218 if (cfg.shuffle)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3219 playlist->position = playlist->shuffle->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3220 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3221 playlist->position = playlist->entries->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3222 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3223
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3224 filename = playlist->position->filename;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3225
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
3226 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3227
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3228 return filename;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3229 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3230
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3231 PlaylistEntry *
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3232 playlist_get_entry_to_play(Playlist *playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3233 {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3234 if (!playlist)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3235 return NULL;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3236
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
3237 PLAYLIST_LOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3238
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3239 if (!playlist->position) {
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3240 if (cfg.shuffle)
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3241 playlist->position = playlist->shuffle->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3242 else
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3243 playlist->position = playlist->entries->data;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3244 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3245
3468
440877c9360e Changed PLAYLIST_{UN}LOCK() macros to use playlist itself as argument, not
Matti Hamalainen <ccr@tnsp.org>
parents: 3467
diff changeset
3246 PLAYLIST_UNLOCK(playlist);
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3247
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3248 return playlist->position;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
3249 }
3474
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3250
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3251 gboolean
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3252 playlist_playlists_equal(Playlist *p1, Playlist *p2)
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3253 {
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3254 GList *l1, *l2;
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3255 PlaylistEntry *e1, *e2;
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3256 if (!p1 || !p2) return FALSE;
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3257 l1 = p1->entries;
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3258 l2 = p2->entries;
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3259 do {
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3260 if (!l1 && !l2) break;
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3261 if (!l1 || !l2) return FALSE; /* different length */
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3262 e1 = (PlaylistEntry *) l1->data;
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3263 e2 = (PlaylistEntry *) l2->data;
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3264 if (strcmp(e1->filename, e2->filename) != 0) return FALSE;
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3265 l1 = l1->next;
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3266 l2 = l2->next;
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3267 } while(1);
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3268 return TRUE;
adc785ee517b Add playlist_playlists_equal for comparing entire playlists
Kieran Clancy <clancy.kieran+audacious@gmail.com>
parents: 3473
diff changeset
3269 }
3934
e924c9ee3958 when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3923
diff changeset
3270
3971
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3271 static gint
3934
e924c9ee3958 when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3923
diff changeset
3272 filter_by_extension(const gchar *uri)
e924c9ee3958 when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3923
diff changeset
3273 {
3979
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3274 gchar *base, *ext, *lext, *filename, *tmp_uri;
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3275 gchar *tmp;
3971
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3276 gint rv;
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3277 GList **lhandle, *node;
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3278 InputPlugin *ip;
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
3279
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
3280 g_return_val_if_fail(uri != NULL, EXT_FALSE);
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
3281
3979
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3282 /* Some URIs will end in ?<subsong> to determine the subsong requested. */
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3283 tmp_uri = g_strdup(uri);
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3284 tmp = strrchr(tmp_uri, '?');
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3285
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3286 if (tmp != NULL && g_ascii_isdigit(*(tmp + 1)))
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3287 *tmp = '\0';
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3288
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3289 /* Check for plugins with custom URI:// strings */
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3290 /* cue:// cdda:// tone:// tact:// */
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3291 if ((ip = uri_get_plugin(tmp_uri)) != NULL && ip->enabled) {
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3292 g_free(tmp_uri);
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3293 return EXT_CUSTOM;
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3294 }
4515
212790dd92ba reindent the code before messing with it
mf0102 <0102@gmx.at>
parents: 4514
diff changeset
3295
3979
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3296 tmp = g_filename_from_uri(tmp_uri, NULL, NULL);
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3297 filename = g_strdup(tmp ? tmp : tmp_uri);
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3298 g_free(tmp); tmp = NULL;
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3299 g_free(tmp_uri); tmp_uri = NULL;
67f01143e613 improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3971
diff changeset
3300
3947
eb20411bb9e1 fixed bug in extension filtering function
mf0102 <0102@gmx.at>
parents: 3945
diff changeset
3301
3934
e924c9ee3958 when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3923
diff changeset
3302 base = g_path_get_basename(filename);
4100
e1ecacef3789 Fix memory leak in filter_by_extension() (Bugzilla #29)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 4087
diff changeset
3303 g_free(filename);
3959
a575c29cee05 - revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3947
diff changeset
3304 ext = strrchr(base, '.');
3934
e924c9ee3958 when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3923
diff changeset
3305
e924c9ee3958 when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3923
diff changeset
3306 if(!ext) {
3947
eb20411bb9e1 fixed bug in extension filtering function
mf0102 <0102@gmx.at>
parents: 3945
diff changeset
3307 g_free(base);
4070
040243a50bd3 - modified playlist_load_ins_file() and playlist_load_ins_file_tuple(). path builder and ext_hash checker
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 4063
diff changeset
3308 return EXT_FALSE;
3934
e924c9ee3958 when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3923
diff changeset
3309 }
e924c9ee3958 when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3923
diff changeset
3310
3959
a575c29cee05 - revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3947
diff changeset
3311 lext = g_ascii_strdown(ext+1, -1);
a575c29cee05 - revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3947
diff changeset
3312 g_free(base);
3945
0b93c2b0cd59 make filter_by_extension() case insensitive.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3934
diff changeset
3313
3971
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3314 lhandle = g_hash_table_lookup(ext_hash, lext);
3945
0b93c2b0cd59 make filter_by_extension() case insensitive.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3934
diff changeset
3315 g_free(lext);
3971
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3316
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3317 if(!lhandle) {
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3318 return EXT_FALSE;
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3319 }
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3320
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3321 for(node = *lhandle; node; node = g_list_next(node)) {
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3322 ip = (InputPlugin *)node->data;
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3323
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3324 if(ip->have_subtune == TRUE) {
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3325 return EXT_HAVE_SUBTUNE;
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3326 }
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3327 else
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3328 rv = EXT_TRUE;
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3329 }
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3330
3945
0b93c2b0cd59 make filter_by_extension() case insensitive.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3934
diff changeset
3331 return rv;
3934
e924c9ee3958 when "Detect file formats on demand" is specified, filter unplayable files on loading by the hash table of all available extensions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3923
diff changeset
3332 }
3971
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3333
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3334 static gboolean
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3335 is_http(const gchar *uri)
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3336 {
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3337 gboolean rv = FALSE;
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3338
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3339 if(str_has_prefix_nocase(uri, "http://") ||
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3340 str_has_prefix_nocase(uri, "https://")) {
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3341 rv = TRUE;
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3342 }
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3343
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3344 return rv;
b0ae5dbd2f53 - add subtune support to on demand probing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3967
diff changeset
3345 }
4532
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
3346
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
3347 const gchar *
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
3348 get_gentitle_format(void)
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
3349 {
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
3350 guint titlestring_preset = cfg.titlestring_preset;
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
3351
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
3352 if (titlestring_preset < n_titlestring_presets)
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
3353 return aud_titlestring_presets[titlestring_preset];
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
3354
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
3355 return cfg.gentitle_format;
97b29dec6c6b moved away some stuff from main.c
mf0102 <0102@gmx.at>
parents: 4525
diff changeset
3356 }