Mercurial > audlegacy-plugins
annotate src/cue/cuesheet.c @ 848:2452835bbfcf trunk
[svn] - make "stop after current song" work.
- now cuesheet plugin handles the end of file nicely.
- improve reliability.
author | yaz |
---|---|
date | Tue, 13 Mar 2007 09:37:27 -0700 |
parents | 29ae10725c4c |
children | def1af87ae1f |
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 * |
848 | 7 * Copyright (C) 2007 Yoshiki Yazawa <yaz@cc.rim.or.jp> (millisecond |
8 * seek and multithreading) | |
9 * | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
10 * This file was hacked out of of xmms-cueinfo, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
11 * Copyright (C) 2003 Oskar Liljeblad |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
12 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
13 * 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
|
14 * 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
|
15 * details. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
16 */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
17 #ifdef HAVE_CONFIG_H |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
18 #include "config.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
19 #endif |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
20 |
848 | 21 /* #define DEBUG 1 */ |
809 | 22 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
23 #include <string.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
24 #include <stdlib.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
25 #include <stdio.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
26 #include <ctype.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
27 #include <audacious/plugin.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
28 #include <audacious/output.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
29 #include <audacious/playlist.h> |
5 | 30 #include <audacious/vfs.h> |
308
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
31 #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
|
32 #include <audacious/strings.h> |
356 | 33 #include <audacious/main.h> |
520
8f1785471613
[svn] - add missing inclusion of audacious/strings.h where necessary
giacomo
parents:
363
diff
changeset
|
34 #include <audacious/strings.h> |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
35 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
36 #define MAX_CUE_LINE_LENGTH 1000 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
37 #define MAX_CUE_TRACKS 1000 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
38 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
39 static void cache_cue_file(gchar *f); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
40 static void free_cue_info(void); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
41 static void fix_cue_argument(char *line); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
42 static gboolean is_our_file(gchar *filespec); |
559 | 43 static void play(InputPlayback *data); |
44 static void play_cue_uri(InputPlayback *data, gchar *uri); | |
45 static gint get_time(InputPlayback *data); | |
46 static void seek(InputPlayback *data, gint time); | |
47 static void stop(InputPlayback *data); | |
48 static void cue_pause(InputPlayback *data, short); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
49 static TitleInput *get_tuple(gchar *uri); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
50 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
|
51 static void get_song_info(gchar *uri, gchar **title, gint *length); |
809 | 52 static void cue_init(void); |
53 static void cue_cleanup(void); | |
54 static gpointer watchdog_func(gpointer data); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
55 |
809 | 56 GThread *watchdog_thread; |
57 static GMutex *cue_mutex; | |
58 static GCond *cue_cond; | |
59 static enum { | |
60 STOP, | |
61 RUN, | |
62 EXIT, | |
63 } watchdog_state; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
64 |
848 | 65 static InputPlayback *caller_ip = NULL; |
66 GThread *exec_thread; | |
67 | |
356 | 68 static gchar *cue_file = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
69 static gchar *cue_title = NULL; |
356 | 70 static gchar *cue_performer = NULL; |
71 static gchar *cue_genre = NULL; | |
72 static gchar *cue_year = NULL; | |
73 static gchar *cue_track = NULL; | |
74 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
75 static gint last_cue_track = 0; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
76 static gint cur_cue_track = 0; |
356 | 77 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
78 static struct { |
356 | 79 gchar *title; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
80 gchar *performer; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
81 gint index; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
82 } cue_tracks[MAX_CUE_TRACKS]; |
356 | 83 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
84 static gint finetune_seek = 0; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
85 |
559 | 86 static InputPlayback *real_ip = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
87 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
88 InputPlugin cue_ip = |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
89 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
90 NULL, /* handle */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
91 NULL, /* filename */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
92 NULL, /* description */ |
809 | 93 cue_init, /* init */ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
94 NULL, /* about */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
95 NULL, /* configure */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
96 is_our_file, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
97 NULL, /* audio cd */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
98 play, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
99 stop, |
251 | 100 cue_pause, |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
101 seek, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
102 NULL, /* set eq */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
103 get_time, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
104 NULL, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
105 NULL, |
809 | 106 cue_cleanup, /* cleanup */ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
107 NULL, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
108 NULL, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
109 NULL, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
110 NULL, |
86
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
111 get_song_info, /* XXX get_song_info iface */ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
112 NULL, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
113 NULL, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
114 get_tuple, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
115 NULL |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
116 }; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
117 |
809 | 118 static void cue_init(void) |
119 { | |
120 cue_mutex = g_mutex_new(); | |
121 cue_cond = g_cond_new(); | |
122 | |
123 /* create watchdog thread */ | |
124 g_mutex_lock(cue_mutex); | |
125 watchdog_state = STOP; | |
126 g_mutex_unlock(cue_mutex); | |
127 watchdog_thread = g_thread_create(watchdog_func, NULL, TRUE, NULL); | |
128 #ifdef DEBUG | |
129 g_print("watchdog_thread = %p\n", watchdog_thread); | |
130 #endif | |
131 } | |
132 | |
133 static void cue_cleanup(void) | |
134 { | |
135 g_mutex_lock(cue_mutex); | |
136 watchdog_state = EXIT; | |
137 g_mutex_unlock(cue_mutex); | |
848 | 138 g_cond_broadcast(cue_cond); |
809 | 139 |
140 g_thread_join(watchdog_thread); | |
141 | |
142 g_cond_free(cue_cond); | |
143 g_mutex_free(cue_mutex); | |
144 } | |
145 | |
76
0b53b7f1959d
[svn] - too much was reverted here, only the if (!ext) return TRUE; was wrong.
nenolod
parents:
73
diff
changeset
|
146 static int is_our_file(gchar *filename) |
0
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 *ext; |
86
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
149 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
150 /* is it a cue:// URI? */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
151 if (!strncasecmp(filename, "cue://", 6)) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
152 return TRUE; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
153 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
154 ext = strrchr(filename, '.'); |
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 if(!ext) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
157 return FALSE; |
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 if (!strncasecmp(ext, ".cue", 4)) |
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 gint i; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
162 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
163 /* add the files, build cue urls, etc. */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
164 cache_cue_file(filename); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
165 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
166 for (i = 0; i < last_cue_track; i++) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
167 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
168 gchar _buf[65535]; |
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 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
|
171 playlist_add_url(playlist_get_active(), _buf); |
0
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 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
174 free_cue_info(); |
81
254cc9620517
[svn] - fix issue where cuesheet plugin owns all codecs
nenolod
parents:
76
diff
changeset
|
175 |
254cc9620517
[svn] - fix issue where cuesheet plugin owns all codecs
nenolod
parents:
76
diff
changeset
|
176 return -1; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
177 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
178 |
81
254cc9620517
[svn] - fix issue where cuesheet plugin owns all codecs
nenolod
parents:
76
diff
changeset
|
179 return FALSE; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
180 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
181 |
559 | 182 static gint get_time(InputPlayback *playback) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
183 { |
602
20b8e735f69e
[svn] - adaptation for playback API. make cuesheet plugin pass playback->output to real_ip.
yaz
parents:
559
diff
changeset
|
184 return playback->output->output_time(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
185 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
186 |
559 | 187 static void play(InputPlayback *data) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
188 { |
809 | 189 gchar *uri = data->filename; |
848 | 190 |
191 #ifdef DEBUG | |
192 g_print("play: playback = %p\n", data); | |
193 #endif | |
194 | |
195 caller_ip = data; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
196 /* this isn't a cue:// uri? */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
197 if (strncasecmp("cue://", uri, 6)) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
198 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
199 gchar *tmp = g_strdup_printf("cue://%s?0", uri); |
559 | 200 play_cue_uri(data, tmp); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
201 g_free(tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
202 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
203 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
204 |
559 | 205 play_cue_uri(data, uri); |
0
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 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
208 static TitleInput *get_tuple(gchar *uri) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
209 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
210 TitleInput *ret; |
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 /* this isn't a cue:// uri? */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
213 if (strncasecmp("cue://", uri, 6)) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
214 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
215 gchar *tmp = g_strdup_printf("cue://%s?0", uri); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
216 ret = get_tuple_uri(tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
217 g_free(tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
218 return ret; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
219 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
220 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
221 return get_tuple_uri(uri); |
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 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
224 static TitleInput *get_tuple_uri(gchar *uri) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
225 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
226 gchar *path2 = g_strdup(uri + 6); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
227 gchar *_path = strchr(path2, '?'); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
228 gint track = 0; |
308
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
229 gint file_length = 0; |
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
230 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
231 InputPlugin *dec; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
232 TitleInput *phys_tuple, *out; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
233 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
234 if (_path != NULL && *_path == '?') |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
235 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
236 *_path = '\0'; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
237 _path++; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
238 track = atoi(_path); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
239 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
240 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
241 cache_cue_file(path2); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
242 |
241
a1e15310703e
[svn] Crash avoidance for zeroed cue sheets. By TiCPU, submitted in #audacious.
chainsaw
parents:
239
diff
changeset
|
243 if (cue_file == NULL) |
a1e15310703e
[svn] Crash avoidance for zeroed cue sheets. By TiCPU, submitted in #audacious.
chainsaw
parents:
239
diff
changeset
|
244 return NULL; |
a1e15310703e
[svn] Crash avoidance for zeroed cue sheets. By TiCPU, submitted in #audacious.
chainsaw
parents:
239
diff
changeset
|
245 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
246 dec = input_check_file(cue_file, FALSE); |
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 (dec == NULL) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
249 return NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
250 |
308
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
251 if (dec->get_song_tuple) |
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
252 phys_tuple = dec->get_song_tuple(cue_file); |
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
253 else |
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
254 phys_tuple = input_get_song_tuple(cue_file); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
255 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
256 out = bmp_title_input_new(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
257 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
258 out->file_path = g_strdup(phys_tuple->file_path); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
259 out->file_name = g_strdup(phys_tuple->file_name); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
260 out->file_ext = g_strdup(phys_tuple->file_ext); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
261 out->length = phys_tuple->length; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
262 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
263 bmp_title_input_free(phys_tuple); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
264 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
265 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
|
266 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
|
267 cue_tracks[track].performer : cue_performer); |
356 | 268 out->album_name = g_strdup(cue_title); |
269 out->genre = g_strdup(cue_genre); | |
357 | 270 out->year = cue_year ? atoi(cue_year) : 0; |
356 | 271 out->track_number = track + 1; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
272 return out; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
273 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
274 |
86
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
275 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
|
276 { |
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
277 TitleInput *tuple; |
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
278 |
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
279 /* this isn't a cue:// uri? */ |
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
280 if (strncasecmp("cue://", uri, 6)) |
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
281 { |
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
282 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
|
283 tuple = get_tuple_uri(tmp); |
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
284 g_free(tmp); |
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
285 } |
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
286 else |
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
287 tuple = get_tuple_uri(uri); |
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
288 |
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
289 g_return_if_fail(tuple != NULL); |
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
290 |
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
291 *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
|
292 *length = tuple->length; |
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
293 |
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
294 bmp_title_input_free(tuple); |
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
295 } |
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
296 |
559 | 297 static void seek(InputPlayback * data, gint time) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
298 { |
848 | 299 #ifdef DEBUG |
300 g_print("seek: playback = %p\n", data); | |
301 #endif | |
302 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
303 if (real_ip != NULL) |
559 | 304 real_ip->plugin->seek(real_ip, time); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
305 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
306 |
559 | 307 static void stop(InputPlayback * data) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
308 { |
848 | 309 #ifdef DEBUG |
310 g_print("f: stop: playback = %p\n", data); | |
311 #endif | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
312 if (real_ip != NULL) |
559 | 313 real_ip->plugin->stop(real_ip); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
314 |
809 | 315 if (data != NULL) |
316 data->playing = 0; | |
848 | 317 if (caller_ip != NULL) |
318 caller_ip->playing = 0; | |
804 | 319 |
809 | 320 g_mutex_lock(cue_mutex); |
321 watchdog_state = STOP; | |
848 | 322 g_mutex_unlock(cue_mutex); |
809 | 323 g_cond_signal(cue_cond); |
324 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
325 free_cue_info(); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
326 |
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
|
327 if (real_ip != NULL) { |
559 | 328 real_ip->plugin->set_info = cue_ip.set_info; |
329 real_ip->plugin->output = NULL; | |
330 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
|
331 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
|
332 } |
848 | 333 #ifdef DEBUG |
334 g_print("e: stop\n"); | |
335 #endif | |
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 |
848 | 338 static gpointer do_stop(gpointer data) |
339 { | |
340 InputPlayback *playback = (InputPlayback *)data; | |
341 #ifdef DEBUG | |
342 g_print("f: do_stop\n"); | |
343 #endif | |
344 ip_data.stop = TRUE; | |
345 playback_stop(); | |
346 ip_data.stop = FALSE; | |
347 | |
348 gdk_threads_enter(); | |
349 mainwin_clear_song_info(); | |
350 gdk_threads_leave(); | |
351 | |
352 #ifdef DEBUG | |
353 g_print("e: do_stop\n"); | |
354 #endif | |
355 g_thread_exit(NULL); | |
356 } | |
357 | |
358 static gpointer do_prev(gpointer data) | |
359 { | |
360 Playlist *playlist = playlist_get_active(); | |
361 | |
362 #ifdef DEBUG | |
363 g_print("do_prev\n"); | |
364 #endif | |
365 playlist_prev(playlist); | |
366 g_thread_exit(NULL); | |
367 } | |
368 | |
369 static gpointer do_next(gpointer data) | |
370 { | |
371 Playlist *playlist = playlist_get_active(); | |
372 | |
373 #ifdef DEBUG | |
374 g_print("do_next\n"); | |
375 #endif | |
376 playlist_next(playlist); | |
377 g_thread_exit(NULL); | |
378 } | |
379 | |
380 | |
559 | 381 static void cue_pause(InputPlayback * data, short p) |
251 | 382 { |
383 if (real_ip != NULL) | |
559 | 384 real_ip->plugin->pause(real_ip, p); |
251 | 385 } |
386 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
387 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
|
388 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
389 gchar *title; |
363
958855dae693
[svn] - fix other plugins dependant on the playlist framework
nenolod
parents:
357
diff
changeset
|
390 Playlist *playlist = playlist_get_active(); |
958855dae693
[svn] - fix other plugins dependant on the playlist framework
nenolod
parents:
357
diff
changeset
|
391 |
958855dae693
[svn] - fix other plugins dependant on the playlist framework
nenolod
parents:
357
diff
changeset
|
392 g_return_if_fail(playlist != NULL); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
393 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
394 /* annoying. */ |
363
958855dae693
[svn] - fix other plugins dependant on the playlist framework
nenolod
parents:
357
diff
changeset
|
395 if (playlist->position->tuple == NULL) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
396 { |
363
958855dae693
[svn] - fix other plugins dependant on the playlist framework
nenolod
parents:
357
diff
changeset
|
397 gint pos = playlist_get_position(playlist); |
958855dae693
[svn] - fix other plugins dependant on the playlist framework
nenolod
parents:
357
diff
changeset
|
398 playlist_get_tuple(playlist, pos); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
399 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
400 |
363
958855dae693
[svn] - fix other plugins dependant on the playlist framework
nenolod
parents:
357
diff
changeset
|
401 title = g_strdup(playlist->position->title); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
402 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
403 cue_ip.set_info(title, length, rate, freq, nch); |
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 |
559 | 406 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
|
407 { |
809 | 408 gchar *path2 = g_strdup(uri + 6); |
409 gchar *_path = strchr(path2, '?'); | |
309 | 410 gint file_length = 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
411 gint track = 0; |
310
86b52a87ba33
[svn] - get_song_info() in some plugins, typically wav, would crash with NULL argument.
yaz
parents:
309
diff
changeset
|
412 gchar *dummy = NULL; |
559 | 413 InputPlugin *real_ip_plugin; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
414 |
809 | 415 #ifdef DEBUG |
416 g_print("f: play_cue_uri\n"); | |
848 | 417 g_print("play_cue_uri: playback = %p\n", data); |
809 | 418 #endif |
848 | 419 |
809 | 420 /* stop watchdog thread */ |
421 g_mutex_lock(cue_mutex); | |
422 watchdog_state = STOP; | |
848 | 423 g_mutex_unlock(cue_mutex); |
809 | 424 g_cond_signal(cue_cond); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
425 |
809 | 426 if (_path != NULL && *_path == '?') |
427 { | |
428 *_path = '\0'; | |
429 _path++; | |
430 track = atoi(_path); | |
431 } | |
432 cur_cue_track = track; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
433 cache_cue_file(path2); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
434 |
809 | 435 if (cue_file == NULL) |
436 return; | |
241
a1e15310703e
[svn] Crash avoidance for zeroed cue sheets. By TiCPU, submitted in #audacious.
chainsaw
parents:
239
diff
changeset
|
437 |
559 | 438 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
|
439 |
559 | 440 if (real_ip_plugin != NULL) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
441 { |
809 | 442 if (real_ip) |
443 g_free(real_ip); | |
444 real_ip = g_new0(InputPlayback, 1); | |
559 | 445 real_ip->plugin = real_ip_plugin; |
446 real_ip->plugin->set_info = set_info_override; | |
447 real_ip->plugin->output = cue_ip.output; | |
448 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
|
449 |
20b8e735f69e
[svn] - adaptation for playback API. make cuesheet plugin pass playback->output to real_ip.
yaz
parents:
559
diff
changeset
|
450 /* 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
|
451 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
|
452 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
|
453 |
559 | 454 real_ip->plugin->play_file(real_ip); |
809 | 455 |
456 if(real_ip->plugin->mseek) { // seek by millisecond | |
457 #ifdef DEBUG | |
458 g_print("mseek\n"); | |
459 #endif | |
460 real_ip->plugin->mseek(real_ip, finetune_seek ? finetune_seek : cue_tracks[track].index); | |
461 } | |
462 else | |
463 real_ip->plugin->seek(real_ip, finetune_seek ? finetune_seek / 1000 : cue_tracks[track].index / 1000 + 1); | |
464 | |
465 /* kick watchdog thread */ | |
466 g_mutex_lock(cue_mutex); | |
467 watchdog_state = RUN; | |
848 | 468 g_mutex_unlock(cue_mutex); |
809 | 469 g_cond_signal(cue_cond); |
848 | 470 g_print("watchdog activated\n"); |
809 | 471 |
356 | 472 // in some plugins, NULL as 2nd arg causes crash. |
559 | 473 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
|
474 g_free(dummy); |
308
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
475 cue_tracks[last_cue_track].index = file_length; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
476 } |
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 finetune_seek = 0; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
479 |
809 | 480 #ifdef DEBUG |
481 g_print("e: play_cue_uri\n"); | |
482 #endif | |
0
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 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
485 InputPlugin *get_iplugin_info(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
486 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
487 cue_ip.description = g_strdup_printf("Cuesheet Container Plugin"); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
488 return &cue_ip; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
489 } |
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 /******************************************************* watchdog */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
492 |
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 * This is fairly hard to explain. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
495 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
496 * 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
|
497 * 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
|
498 * right place. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
499 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
500 * 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
|
501 * as well as I was hoping. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
502 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
503 * 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
|
504 * cool with it. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
505 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
506 * - nenolod |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
507 */ |
809 | 508 static gpointer watchdog_func(gpointer data) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
509 { |
809 | 510 gint time = 0; |
511 Playlist *playlist = NULL; | |
512 GTimeVal sleep_time, startup_time; | |
513 | |
514 #ifdef DEBUG | |
515 g_print("f: watchdog\n"); | |
516 #endif | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
517 |
809 | 518 while(1) { |
848 | 519 #if 1 |
809 | 520 #if DEBUG |
848 | 521 g_print("time = %d cur = %d cidx = %d nidx = %d last = %d\n", |
522 time, cur_cue_track, | |
809 | 523 cue_tracks[cur_cue_track].index, |
848 | 524 cue_tracks[cur_cue_track+1].index, last_cue_track); |
809 | 525 #endif |
526 #endif | |
527 g_get_current_time(&sleep_time); | |
528 g_time_val_add(&sleep_time, 10000); // 10msec | |
308
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
529 |
809 | 530 g_mutex_lock(cue_mutex); |
531 switch(watchdog_state) { | |
532 case EXIT: | |
533 #ifdef DEBUG | |
534 g_print("e: watchdog exit\n"); | |
535 #endif | |
536 g_mutex_unlock(cue_mutex); // stop() locks cue_mutex. | |
537 stop(real_ip); // need not to care about real_ip != NULL here. | |
538 g_thread_exit(NULL); | |
539 break; | |
540 case RUN: | |
541 if(!playlist) | |
542 playlist = playlist_get_active(); | |
543 g_cond_timed_wait(cue_cond, cue_mutex, &sleep_time); | |
544 break; | |
545 case STOP: | |
546 #ifdef DEBUG | |
547 g_print("watchdog deactivated\n"); | |
548 #endif | |
549 g_cond_wait(cue_cond, cue_mutex); | |
550 playlist = playlist_get_active(); | |
551 break; | |
552 } | |
553 g_mutex_unlock(cue_mutex); | |
554 | |
555 time = get_output_time(); | |
848 | 556 if(time == 0) |
557 continue; | |
809 | 558 |
848 | 559 #ifdef DEBUG |
560 if(real_ip) { | |
561 g_print("real_ip->playing = %d\n", real_ip->playing); | |
562 if(real_ip->playing == 0) | |
563 g_print("not playing\n"); | |
564 if(!real_ip->output->buffer_playing()) | |
565 g_print("not buffer_playing\n"); | |
566 } | |
567 #endif | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
568 |
809 | 569 // prev track |
570 if (time < cue_tracks[cur_cue_track].index) | |
571 { | |
572 #ifdef DEBUG | |
573 g_print("i: watchdog prev\n"); | |
574 g_print("time = %d cur = %d cidx = %d nidx = %d\n", time, cur_cue_track, | |
575 cue_tracks[cur_cue_track].index, | |
576 cue_tracks[cur_cue_track+1].index); | |
577 #endif | |
578 cur_cue_track--; | |
579 if (time >= cue_tracks[cur_cue_track].index) | |
580 finetune_seek = time; | |
848 | 581 exec_thread = g_thread_create(do_prev, NULL, FALSE, NULL); |
809 | 582 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
583 |
809 | 584 // next track |
585 if (cur_cue_track != last_cue_track && (time > cue_tracks[cur_cue_track + 1].index)) | |
586 { | |
587 #ifdef DEBUG | |
588 g_print("i: watchdog next\n"); | |
589 g_print("time = %d cur = %d cidx = %d nidx = %d\n", time, cur_cue_track, | |
590 cue_tracks[cur_cue_track].index, | |
591 cue_tracks[cur_cue_track+1].index); | |
592 #endif | |
593 cur_cue_track++; | |
594 if (time <= cue_tracks[cur_cue_track].index) | |
595 finetune_seek = time; | |
596 | |
848 | 597 if(cfg.stopaftersong) { |
598 exec_thread = g_thread_create(do_stop, (void *)real_ip, FALSE, NULL); | |
599 } | |
809 | 600 else |
848 | 601 exec_thread = g_thread_create(do_next, NULL, FALSE, NULL); |
809 | 602 } |
848 | 603 |
604 // end of file | |
605 if (cur_cue_track + 1 == last_cue_track && | |
606 cue_tracks[cur_cue_track + 1].index - time < 500) { // difference < 500ms | |
607 #ifdef DEBUG | |
608 g_print("eof reached\n"); | |
609 #endif | |
610 exec_thread = g_thread_create(do_stop, (void *)real_ip, FALSE, NULL); | |
611 } | |
612 | |
809 | 613 } |
614 | |
615 #ifdef DEBUG | |
616 g_print("e: watchdog\n"); | |
617 #endif | |
618 return NULL; // dummy. | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
619 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
620 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
621 /******************************************************** cuefile */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
622 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
623 static void free_cue_info(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
624 { |
356 | 625 g_free(cue_file); cue_file = NULL; |
626 g_free(cue_title); cue_title = NULL; | |
627 g_free(cue_performer); cue_performer = NULL; | |
628 g_free(cue_genre); cue_genre = NULL; | |
629 g_free(cue_year); cue_year = NULL; | |
630 g_free(cue_track); cue_track = NULL; | |
631 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
632 for (; last_cue_track > 0; last_cue_track--) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
633 g_free(cue_tracks[last_cue_track-1].performer); |
803
4a2b2677dd9b
[svn] - performer and title of each track should be NULL after freed.
yaz
parents:
602
diff
changeset
|
634 cue_tracks[last_cue_track-1].performer = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
635 g_free(cue_tracks[last_cue_track-1].title); |
803
4a2b2677dd9b
[svn] - performer and title of each track should be NULL after freed.
yaz
parents:
602
diff
changeset
|
636 cue_tracks[last_cue_track-1].title = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
637 } |
809 | 638 #ifdef DEBUG |
639 g_print("last_cue_track = %d\n", last_cue_track); | |
640 #endif | |
641 last_cue_track = 0; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
642 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
643 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
644 static void cache_cue_file(char *f) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
645 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
646 VFSFile *file = vfs_fopen(f, "rb"); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
647 gchar line[MAX_CUE_LINE_LENGTH+1]; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
648 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
649 if(!file) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
650 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
651 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
652 while (TRUE) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
653 gint p; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
654 gint q; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
655 |
239
e45005422574
[svn] FD leak fix by TiCPU, submitted in #audacious.
chainsaw
parents:
86
diff
changeset
|
656 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
|
657 vfs_fclose(file); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
658 return; |
239
e45005422574
[svn] FD leak fix by TiCPU, submitted in #audacious.
chainsaw
parents:
86
diff
changeset
|
659 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
660 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
661 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
|
662 if (!line[p]) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
663 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
664 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
|
665 if (!line[q]) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
666 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
667 line[q] = '\0'; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
668 for (q++; line[q] && isspace((int) line[q]); q++); |
356 | 669 if (strcasecmp(line+p, "REM") == 0) { |
670 gint r; | |
671 for (r = q; line[r] && !isspace((int) line[r]); r++); | |
672 if (!line[r]) | |
673 continue; | |
674 line[r] = '\0'; | |
675 for (r++; line[r] && isspace((int) line[r]); r++); | |
676 if(strcasecmp(line+q, "GENRE") == 0) { | |
677 fix_cue_argument(line+r); | |
678 if (last_cue_track == 0) | |
679 cue_genre = str_to_utf8(line + r); | |
680 } | |
681 if(strcasecmp(line+q, "DATE") == 0) { | |
682 gchar *tmp; | |
683 fix_cue_argument(line+r); | |
684 if (last_cue_track == 0) { | |
685 tmp = g_strdup(line + r); | |
686 if (tmp) { | |
687 cue_year = strtok(tmp, "/"); // XXX: always in the same format? | |
688 } | |
689 } | |
690 } | |
691 } | |
692 else if (strcasecmp(line+p, "PERFORMER") == 0) { | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
693 fix_cue_argument(line+q); |
308
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
694 |
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
695 if (last_cue_track == 0) |
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
696 cue_performer = str_to_utf8(line + q); |
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
697 else |
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
698 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
|
699 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
700 else if (strcasecmp(line+p, "FILE") == 0) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
701 gchar *tmp = g_path_get_dirname(f); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
702 fix_cue_argument(line+q); |
356 | 703 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
|
704 g_free(tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
705 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
706 else if (strcasecmp(line+p, "TITLE") == 0) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
707 fix_cue_argument(line+q); |
308
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
708 if (last_cue_track == 0) |
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
709 cue_title = str_to_utf8(line + q); |
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
710 else |
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
711 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
|
712 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
713 else if (strcasecmp(line+p, "TRACK") == 0) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
714 gint track; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
715 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
716 fix_cue_argument(line+q); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
717 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
|
718 line[p] = '\0'; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
719 for (; line[q] && line[q] == '0'; q++); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
720 if (!line[q]) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
721 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
722 track = atoi(line+q); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
723 if (track >= MAX_CUE_TRACKS) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
724 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
725 last_cue_track = track; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
726 cue_tracks[last_cue_track-1].index = 0; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
727 cue_tracks[last_cue_track-1].performer = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
728 cue_tracks[last_cue_track-1].title = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
729 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
730 else if (strcasecmp(line+p, "INDEX") == 0) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
731 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
|
732 if (!line[p]) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
733 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
734 for (p++; line[p] && isspace((int) line[p]); p++); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
735 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
|
736 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
|
737 cue_tracks[last_cue_track-1].index = |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
738 ((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
|
739 ((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
|
740 ((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
|
741 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
742 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
743 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
744 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
745 vfs_fclose(file); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
746 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
747 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
748 static void fix_cue_argument(char *line) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
749 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
750 if (line[0] == '"') { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
751 gchar *l2; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
752 for (l2 = line+1; *l2 && *l2 != '"'; l2++) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
753 *(l2-1) = *l2; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
754 *(l2-1) = *l2; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
755 for (; *line && *line != '"'; line++) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
756 if (*line == '\\' && *(line+1)) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
757 for (l2 = line+1; *l2 && *l2 != '"'; l2++) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
758 *(l2-1) = *l2; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
759 *(l2-1) = *l2; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
760 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
761 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
762 *line = '\0'; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
763 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
764 else { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
765 for (; *line && *line != '\r' && *line != '\n'; line++); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
766 *line = '\0'; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
767 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
768 } |