annotate src/cue/cuesheet.c @ 602:20b8e735f69e trunk

[svn] - adaptation for playback API. make cuesheet plugin pass playback->output to real_ip.
author yaz
date Sat, 03 Feb 2007 08:55:23 -0800
parents d5782f3bd760
children 4a2b2677dd9b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
1 /* Audacious: An advanced media player.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
2 * cuesheet.c: Support cuesheets as a media container.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
3 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
4 * Copyright (C) 2006 William Pitcock <nenolod -at- nenolod.net>.
52
ac74515f80c1 [svn] Add +1 to the position so that the position isn't in two tracks anymore
js
parents: 51
diff changeset
5 * Jonathan Schleifer <js@h3c.de> (only small fixes)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
6 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
7 * This file was hacked out of of xmms-cueinfo,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
8 * Copyright (C) 2003 Oskar Liljeblad
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
9 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
10 * This software is copyrighted work licensed under the terms of the
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
11 * GNU General Public License. Please consult the file "COPYING" for
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
12 * details.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
13 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
14 #ifdef HAVE_CONFIG_H
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
15 #include "config.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
16 #endif
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
17
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
18 #include <string.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
19 #include <stdlib.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
20 #include <stdio.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
21 #include <ctype.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
22 #include <audacious/plugin.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
23 #include <audacious/output.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
24 #include <audacious/playlist.h>
5
54f9e753b511 [svn] - SDK pathchange fixes
nenolod
parents: 0
diff changeset
25 #include <audacious/vfs.h>
308
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
26 #include <audacious/util.h>
532
04b0c54d16bb [svn] - if the performer of a track is not specified in cue sheet, the performer of the album will be used.
yaz
parents: 520
diff changeset
27 #include <audacious/strings.h>
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
28 #include <audacious/main.h>
520
8f1785471613 [svn] - add missing inclusion of audacious/strings.h where necessary
giacomo
parents: 363
diff changeset
29 #include <audacious/strings.h>
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
30
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
31 #define MAX_CUE_LINE_LENGTH 1000
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
32 #define MAX_CUE_TRACKS 1000
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
33
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
34 static void cache_cue_file(gchar *f);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
35 static void free_cue_info(void);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
36 static void fix_cue_argument(char *line);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
37 static gboolean is_our_file(gchar *filespec);
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
38 static void play(InputPlayback *data);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
39 static void play_cue_uri(InputPlayback *data, gchar *uri);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
40 static gint get_time(InputPlayback *data);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
41 static void seek(InputPlayback *data, gint time);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
42 static void stop(InputPlayback *data);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
43 static void cue_pause(InputPlayback *data, short);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
44 static TitleInput *get_tuple(gchar *uri);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
45 static TitleInput *get_tuple_uri(gchar *uri);
86
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
46 static void get_song_info(gchar *uri, gchar **title, gint *length);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
47
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
48 static gint watchdog_func(gpointer data);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
49
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
50 static gchar *cue_file = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
51 static gchar *cue_title = NULL;
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
52 static gchar *cue_performer = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
53 static gchar *cue_genre = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
54 static gchar *cue_year = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
55 static gchar *cue_track = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
56
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
57 static gint last_cue_track = 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
58 static gint cur_cue_track = 0;
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
59
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
60 static struct {
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
61 gchar *title;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
62 gchar *performer;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
63 gint index;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
64 } cue_tracks[MAX_CUE_TRACKS];
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
65
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
66 static gint timeout_tag = 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
67 static gint finetune_seek = 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
68
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
69 static InputPlayback *real_ip = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
70
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
71 InputPlugin cue_ip =
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
72 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
73 NULL, /* handle */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
74 NULL, /* filename */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
75 NULL, /* description */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
76 NULL, /* init */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
77 NULL, /* about */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
78 NULL, /* configure */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
79 is_our_file,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
80 NULL, /* audio cd */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
81 play,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
82 stop,
251
0469aa4ae1ec [svn] - make pause do something. closes #636
nenolod
parents: 242
diff changeset
83 cue_pause,
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
84 seek,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
85 NULL, /* set eq */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
86 get_time,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
87 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
88 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
89 NULL, /* cleanup */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
90 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
91 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
92 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
93 NULL,
86
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
94 get_song_info, /* XXX get_song_info iface */
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
95 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
96 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
97 get_tuple,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
98 NULL
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
99 };
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
100
76
0b53b7f1959d [svn] - too much was reverted here, only the if (!ext) return TRUE; was wrong.
nenolod
parents: 73
diff changeset
101 static int is_our_file(gchar *filename)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
102 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
103 gchar *ext;
86
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
104
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
105 /* is it a cue:// URI? */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
106 if (!strncasecmp(filename, "cue://", 6))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
107 return TRUE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
108
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
109 ext = strrchr(filename, '.');
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
110
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
111 if(!ext)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
112 return FALSE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
113
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
114 if (!strncasecmp(ext, ".cue", 4))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
115 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
116 gint i;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
117
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
118 /* add the files, build cue urls, etc. */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
119 cache_cue_file(filename);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
120
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
121 for (i = 0; i < last_cue_track; i++)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
122 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
123 gchar _buf[65535];
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
124
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
125 g_snprintf(_buf, 65535, "cue://%s?%d", filename, i);
363
958855dae693 [svn] - fix other plugins dependant on the playlist framework
nenolod
parents: 357
diff changeset
126 playlist_add_url(playlist_get_active(), _buf);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
127 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
128
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
129 free_cue_info();
81
254cc9620517 [svn] - fix issue where cuesheet plugin owns all codecs
nenolod
parents: 76
diff changeset
130
254cc9620517 [svn] - fix issue where cuesheet plugin owns all codecs
nenolod
parents: 76
diff changeset
131 return -1;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
132 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
133
81
254cc9620517 [svn] - fix issue where cuesheet plugin owns all codecs
nenolod
parents: 76
diff changeset
134 return FALSE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
135 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
136
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
137 static gint get_time(InputPlayback *playback)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
138 {
602
20b8e735f69e [svn] - adaptation for playback API. make cuesheet plugin pass playback->output to real_ip.
yaz
parents: 559
diff changeset
139 return playback->output->output_time();
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
140 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
141
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
142 static void play(InputPlayback *data)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
143 {
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
144 gchar *uri = data->filename;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
145 /* this isn't a cue:// uri? */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
146 if (strncasecmp("cue://", uri, 6))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
147 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
148 gchar *tmp = g_strdup_printf("cue://%s?0", uri);
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
149 play_cue_uri(data, tmp);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
150 g_free(tmp);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
151 return;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
152 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
153
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
154 play_cue_uri(data, uri);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
155 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
156
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
157 static TitleInput *get_tuple(gchar *uri)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
158 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
159 TitleInput *ret;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
160
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
161 /* this isn't a cue:// uri? */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
162 if (strncasecmp("cue://", uri, 6))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
163 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
164 gchar *tmp = g_strdup_printf("cue://%s?0", uri);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
165 ret = get_tuple_uri(tmp);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
166 g_free(tmp);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
167 return ret;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
168 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
169
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
170 return get_tuple_uri(uri);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
171 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
172
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
173 static TitleInput *get_tuple_uri(gchar *uri)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
174 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
175 gchar *path2 = g_strdup(uri + 6);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
176 gchar *_path = strchr(path2, '?');
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
177 gint track = 0;
308
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
178 gint file_length = 0;
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
179
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
180 InputPlugin *dec;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
181 TitleInput *phys_tuple, *out;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
182
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
183 if (_path != NULL && *_path == '?')
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
184 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
185 *_path = '\0';
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
186 _path++;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
187 track = atoi(_path);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
188 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
189
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
190 cache_cue_file(path2);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
191
241
a1e15310703e [svn] Crash avoidance for zeroed cue sheets. By TiCPU, submitted in #audacious.
chainsaw
parents: 239
diff changeset
192 if (cue_file == NULL)
a1e15310703e [svn] Crash avoidance for zeroed cue sheets. By TiCPU, submitted in #audacious.
chainsaw
parents: 239
diff changeset
193 return NULL;
a1e15310703e [svn] Crash avoidance for zeroed cue sheets. By TiCPU, submitted in #audacious.
chainsaw
parents: 239
diff changeset
194
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
195 dec = input_check_file(cue_file, FALSE);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
196
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
197 if (dec == NULL)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
198 return NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
199
308
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
200 if (dec->get_song_tuple)
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
201 phys_tuple = dec->get_song_tuple(cue_file);
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
202 else
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
203 phys_tuple = input_get_song_tuple(cue_file);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
204
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
205 out = bmp_title_input_new();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
206
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
207 out->file_path = g_strdup(phys_tuple->file_path);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
208 out->file_name = g_strdup(phys_tuple->file_name);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
209 out->file_ext = g_strdup(phys_tuple->file_ext);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
210 out->length = phys_tuple->length;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
211
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
212 bmp_title_input_free(phys_tuple);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
213
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
214 out->track_name = g_strdup(cue_tracks[track].title);
532
04b0c54d16bb [svn] - if the performer of a track is not specified in cue sheet, the performer of the album will be used.
yaz
parents: 520
diff changeset
215 out->performer = g_strdup(cue_tracks[track].performer ?
04b0c54d16bb [svn] - if the performer of a track is not specified in cue sheet, the performer of the album will be used.
yaz
parents: 520
diff changeset
216 cue_tracks[track].performer : cue_performer);
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
217 out->album_name = g_strdup(cue_title);
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
218 out->genre = g_strdup(cue_genre);
357
c4b4c6011c66 [svn] - fix for potential bug.
yaz
parents: 356
diff changeset
219 out->year = cue_year ? atoi(cue_year) : 0;
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
220 out->track_number = track + 1;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
221 return out;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
222 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
223
86
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
224 static void get_song_info(gchar *uri, gchar **title, gint *length)
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
225 {
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
226 TitleInput *tuple;
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
227
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
228 /* this isn't a cue:// uri? */
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
229 if (strncasecmp("cue://", uri, 6))
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
230 {
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
231 gchar *tmp = g_strdup_printf("cue://%s?0", uri);
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
232 tuple = get_tuple_uri(tmp);
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
233 g_free(tmp);
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
234 }
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
235 else
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
236 tuple = get_tuple_uri(uri);
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
237
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
238 g_return_if_fail(tuple != NULL);
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
239
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
240 *title = xmms_get_titlestring(xmms_get_gentitle_format(), tuple);
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
241 *length = tuple->length;
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
242
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
243 bmp_title_input_free(tuple);
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
244 }
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
245
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
246 static void seek(InputPlayback * data, gint time)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
247 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
248 if (real_ip != NULL)
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
249 real_ip->plugin->seek(real_ip, time);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
250 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
251
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
252 static void stop(InputPlayback * data)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
253 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
254 if (real_ip != NULL)
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
255 real_ip->plugin->stop(real_ip);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
256
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
257 gtk_timeout_remove(timeout_tag);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
258 free_cue_info();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
259
51
59e759d8c176 [svn] Fixed a crash in the cue plugin when no plugin is found / the file doesn't exist
js
parents: 12
diff changeset
260 if (real_ip != NULL) {
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
261 real_ip->plugin->set_info = cue_ip.set_info;
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
262 real_ip->plugin->output = NULL;
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
263 g_free(real_ip);
51
59e759d8c176 [svn] Fixed a crash in the cue plugin when no plugin is found / the file doesn't exist
js
parents: 12
diff changeset
264 real_ip = NULL;
59e759d8c176 [svn] Fixed a crash in the cue plugin when no plugin is found / the file doesn't exist
js
parents: 12
diff changeset
265 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
266 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
267
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
268 static void cue_pause(InputPlayback * data, short p)
251
0469aa4ae1ec [svn] - make pause do something. closes #636
nenolod
parents: 242
diff changeset
269 {
0469aa4ae1ec [svn] - make pause do something. closes #636
nenolod
parents: 242
diff changeset
270 if (real_ip != NULL)
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
271 real_ip->plugin->pause(real_ip, p);
251
0469aa4ae1ec [svn] - make pause do something. closes #636
nenolod
parents: 242
diff changeset
272 }
0469aa4ae1ec [svn] - make pause do something. closes #636
nenolod
parents: 242
diff changeset
273
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
274 static void set_info_override(gchar * unused, gint length, gint rate, gint freq, gint nch)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
275 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
276 gchar *title;
363
958855dae693 [svn] - fix other plugins dependant on the playlist framework
nenolod
parents: 357
diff changeset
277 Playlist *playlist = playlist_get_active();
958855dae693 [svn] - fix other plugins dependant on the playlist framework
nenolod
parents: 357
diff changeset
278
958855dae693 [svn] - fix other plugins dependant on the playlist framework
nenolod
parents: 357
diff changeset
279 g_return_if_fail(playlist != NULL);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
280
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
281 /* annoying. */
363
958855dae693 [svn] - fix other plugins dependant on the playlist framework
nenolod
parents: 357
diff changeset
282 if (playlist->position->tuple == NULL)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
283 {
363
958855dae693 [svn] - fix other plugins dependant on the playlist framework
nenolod
parents: 357
diff changeset
284 gint pos = playlist_get_position(playlist);
958855dae693 [svn] - fix other plugins dependant on the playlist framework
nenolod
parents: 357
diff changeset
285 playlist_get_tuple(playlist, pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
286 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
287
363
958855dae693 [svn] - fix other plugins dependant on the playlist framework
nenolod
parents: 357
diff changeset
288 title = g_strdup(playlist->position->title);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
289
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
290 cue_ip.set_info(title, length, rate, freq, nch);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
291 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
292
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
293 static void play_cue_uri(InputPlayback * data, gchar *uri)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
294 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
295 gchar *path2 = g_strdup(uri + 6);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
296 gchar *_path = strchr(path2, '?');
309
b7aab7965968 [svn] - fix
nenolod
parents: 308
diff changeset
297 gint file_length = 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
298 gint track = 0;
310
86b52a87ba33 [svn] - get_song_info() in some plugins, typically wav, would crash with NULL argument.
yaz
parents: 309
diff changeset
299 gchar *dummy = NULL;
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
300 InputPlugin *real_ip_plugin;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
301
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
302 if (_path != NULL && *_path == '?')
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
303 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
304 *_path = '\0';
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
305 _path++;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
306 track = atoi(_path);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
307 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
308
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
309 cache_cue_file(path2);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
310
241
a1e15310703e [svn] Crash avoidance for zeroed cue sheets. By TiCPU, submitted in #audacious.
chainsaw
parents: 239
diff changeset
311 if (cue_file == NULL)
242
e5d78e44971f [svn] - suppress compile time waring.
yaz
parents: 241
diff changeset
312 return;
241
a1e15310703e [svn] Crash avoidance for zeroed cue sheets. By TiCPU, submitted in #audacious.
chainsaw
parents: 239
diff changeset
313
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
314 real_ip_plugin = input_check_file(cue_file, FALSE);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
315
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
316 if (real_ip_plugin != NULL)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
317 {
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
318 if (real_ip)
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
319 g_free(real_ip);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
320 real_ip = g_new0(InputPlayback, 1);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
321 real_ip->plugin = real_ip_plugin;
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
322 real_ip->plugin->set_info = set_info_override;
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
323 real_ip->plugin->output = cue_ip.output;
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
324 real_ip->filename = cue_file;
602
20b8e735f69e [svn] - adaptation for playback API. make cuesheet plugin pass playback->output to real_ip.
yaz
parents: 559
diff changeset
325
20b8e735f69e [svn] - adaptation for playback API. make cuesheet plugin pass playback->output to real_ip.
yaz
parents: 559
diff changeset
326 /* need to pass playback->output to real_ip */
20b8e735f69e [svn] - adaptation for playback API. make cuesheet plugin pass playback->output to real_ip.
yaz
parents: 559
diff changeset
327 real_ip->output = data->output;
20b8e735f69e [svn] - adaptation for playback API. make cuesheet plugin pass playback->output to real_ip.
yaz
parents: 559
diff changeset
328 real_ip->data = data->data;
20b8e735f69e [svn] - adaptation for playback API. make cuesheet plugin pass playback->output to real_ip.
yaz
parents: 559
diff changeset
329
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
330 real_ip->plugin->play_file(real_ip);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
331 real_ip->plugin->seek(real_ip, finetune_seek ? finetune_seek / 1000 : cue_tracks[track].index / 1000 + 1);
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
332 // in some plugins, NULL as 2nd arg causes crash.
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
333 real_ip->plugin->get_song_info(cue_file, &dummy, &file_length);
310
86b52a87ba33 [svn] - get_song_info() in some plugins, typically wav, would crash with NULL argument.
yaz
parents: 309
diff changeset
334 g_free(dummy);
308
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
335 cue_tracks[last_cue_track].index = file_length;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
336 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
337
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
338 finetune_seek = 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
339
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
340 cur_cue_track = track;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
341
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
342 timeout_tag = gtk_timeout_add(100, watchdog_func, data);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
343 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
344
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
345 InputPlugin *get_iplugin_info(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
346 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
347 cue_ip.description = g_strdup_printf("Cuesheet Container Plugin");
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
348 return &cue_ip;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
349 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
350
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
351 /******************************************************* watchdog */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
352
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
353 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
354 * This is fairly hard to explain.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
355 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
356 * Basically we loop until we have reached the correct track.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
357 * Then we set a finetune adjustment to make sure we stay in the
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
358 * right place.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
359 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
360 * I used to recurse here (it was prettier), but that didn't work
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
361 * as well as I was hoping.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
362 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
363 * Anyhow, yeah. The logic here isn't great, but it works, so I'm
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
364 * cool with it.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
365 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
366 * - nenolod
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
367 */
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
368 static gint watchdog_func(gpointer data)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
369 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
370 gint time = get_output_time();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
371 gboolean dir = FALSE;
363
958855dae693 [svn] - fix other plugins dependant on the playlist framework
nenolod
parents: 357
diff changeset
372 Playlist *playlist = playlist_get_active();
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
373
308
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
374 if (time == -1)
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
375 time = G_MAXINT;
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
376
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
377 while (time < cue_tracks[cur_cue_track].index)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
378 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
379 cur_cue_track--;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
380 if (!(time < cue_tracks[cur_cue_track].index))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
381 finetune_seek = time;
363
958855dae693 [svn] - fix other plugins dependant on the playlist framework
nenolod
parents: 357
diff changeset
382 playlist_prev(playlist);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
383 dir = TRUE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
384 time = get_output_time();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
385 g_usleep(10000);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
386 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
387
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
388 while (dir == FALSE && cur_cue_track != last_cue_track && (time > cue_tracks[cur_cue_track + 1].index))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
389 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
390 cur_cue_track++;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
391 if (!(time > cue_tracks[cur_cue_track].index))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
392 finetune_seek = time;
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
393 if(cfg.stopaftersong) {
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
394 stop(data);
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
395 return TRUE;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
396 }
363
958855dae693 [svn] - fix other plugins dependant on the playlist framework
nenolod
parents: 357
diff changeset
397 playlist_next(playlist);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
398 time = get_output_time();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
399 g_usleep(10000);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
400 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
401
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
402 return TRUE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
403 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
404
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
405 /******************************************************** cuefile */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
406
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
407 static void free_cue_info(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
408 {
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
409 g_free(cue_file); cue_file = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
410 g_free(cue_title); cue_title = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
411 g_free(cue_performer); cue_performer = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
412 g_free(cue_genre); cue_genre = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
413 g_free(cue_year); cue_year = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
414 g_free(cue_track); cue_track = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
415
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
416 for (; last_cue_track > 0; last_cue_track--) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
417 g_free(cue_tracks[last_cue_track-1].performer);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
418 g_free(cue_tracks[last_cue_track-1].title);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
419 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
420 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
421
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
422 static void cache_cue_file(char *f)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
423 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
424 VFSFile *file = vfs_fopen(f, "rb");
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
425 gchar line[MAX_CUE_LINE_LENGTH+1];
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
426
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
427 if(!file)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
428 return;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
429
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
430 while (TRUE) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
431 gint p;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
432 gint q;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
433
239
e45005422574 [svn] FD leak fix by TiCPU, submitted in #audacious.
chainsaw
parents: 86
diff changeset
434 if (vfs_fgets(line, MAX_CUE_LINE_LENGTH+1, file) == NULL) {
e45005422574 [svn] FD leak fix by TiCPU, submitted in #audacious.
chainsaw
parents: 86
diff changeset
435 vfs_fclose(file);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
436 return;
239
e45005422574 [svn] FD leak fix by TiCPU, submitted in #audacious.
chainsaw
parents: 86
diff changeset
437 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
438
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
439 for (p = 0; line[p] && isspace((int) line[p]); p++);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
440 if (!line[p])
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
441 continue;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
442 for (q = p; line[q] && !isspace((int) line[q]); q++);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
443 if (!line[q])
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
444 continue;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
445 line[q] = '\0';
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
446 for (q++; line[q] && isspace((int) line[q]); q++);
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
447 if (strcasecmp(line+p, "REM") == 0) {
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
448 gint r;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
449 for (r = q; line[r] && !isspace((int) line[r]); r++);
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
450 if (!line[r])
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
451 continue;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
452 line[r] = '\0';
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
453 for (r++; line[r] && isspace((int) line[r]); r++);
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
454 if(strcasecmp(line+q, "GENRE") == 0) {
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
455 fix_cue_argument(line+r);
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
456 if (last_cue_track == 0)
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
457 cue_genre = str_to_utf8(line + r);
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
458 }
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
459 if(strcasecmp(line+q, "DATE") == 0) {
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
460 gchar *tmp;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
461 fix_cue_argument(line+r);
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
462 if (last_cue_track == 0) {
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
463 tmp = g_strdup(line + r);
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
464 if (tmp) {
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
465 cue_year = strtok(tmp, "/"); // XXX: always in the same format?
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
466 }
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
467 }
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
468 }
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
469 }
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
470 else if (strcasecmp(line+p, "PERFORMER") == 0) {
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
471 fix_cue_argument(line+q);
308
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
472
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
473 if (last_cue_track == 0)
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
474 cue_performer = str_to_utf8(line + q);
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
475 else
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
476 cue_tracks[last_cue_track - 1].performer = str_to_utf8(line + q);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
477 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
478 else if (strcasecmp(line+p, "FILE") == 0) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
479 gchar *tmp = g_path_get_dirname(f);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
480 fix_cue_argument(line+q);
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
481 cue_file = g_strdup_printf("%s/%s", tmp, line+q); /* XXX: yaz might need to UTF validate this?? -nenolod */ /* as far as I know, all FILEs are in plain ASCII - yaz */
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
482 g_free(tmp);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
483 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
484 else if (strcasecmp(line+p, "TITLE") == 0) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
485 fix_cue_argument(line+q);
308
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
486 if (last_cue_track == 0)
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
487 cue_title = str_to_utf8(line + q);
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
488 else
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
489 cue_tracks[last_cue_track-1].title = str_to_utf8(line + q);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
490 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
491 else if (strcasecmp(line+p, "TRACK") == 0) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
492 gint track;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
493
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
494 fix_cue_argument(line+q);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
495 for (p = q; line[p] && isdigit((int) line[p]); p++);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
496 line[p] = '\0';
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
497 for (; line[q] && line[q] == '0'; q++);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
498 if (!line[q])
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
499 continue;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
500 track = atoi(line+q);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
501 if (track >= MAX_CUE_TRACKS)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
502 continue;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
503 last_cue_track = track;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
504 cue_tracks[last_cue_track-1].index = 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
505 cue_tracks[last_cue_track-1].performer = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
506 cue_tracks[last_cue_track-1].title = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
507 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
508 else if (strcasecmp(line+p, "INDEX") == 0) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
509 for (p = q; line[p] && !isspace((int) line[p]); p++);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
510 if (!line[p])
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
511 continue;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
512 for (p++; line[p] && isspace((int) line[p]); p++);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
513 for (q = p; line[q] && !isspace((int) line[q]); q++);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
514 if (q-p >= 8 && line[p+2] == ':' && line[p+5] == ':') {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
515 cue_tracks[last_cue_track-1].index =
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
516 ((line[p+0]-'0')*10 + (line[p+1]-'0')) * 60000 +
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
517 ((line[p+3]-'0')*10 + (line[p+4]-'0')) * 1000 +
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
518 ((line[p+6]-'0')*10 + (line[p+7]-'0')) * 10;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
519 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
520 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
521 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
522
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
523 vfs_fclose(file);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
524 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
525
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
526 static void fix_cue_argument(char *line)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
527 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
528 if (line[0] == '"') {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
529 gchar *l2;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
530 for (l2 = line+1; *l2 && *l2 != '"'; l2++)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
531 *(l2-1) = *l2;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
532 *(l2-1) = *l2;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
533 for (; *line && *line != '"'; line++) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
534 if (*line == '\\' && *(line+1)) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
535 for (l2 = line+1; *l2 && *l2 != '"'; l2++)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
536 *(l2-1) = *l2;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
537 *(l2-1) = *l2;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
538 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
539 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
540 *line = '\0';
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
541 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
542 else {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
543 for (; *line && *line != '\r' && *line != '\n'; line++);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
544 *line = '\0';
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
545 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
546 }