comparison src/cue/cuesheet.c @ 308:1bf162c7b4b9 trunk

[svn] - cuesheet plugin improvements via hiro @ audacious boards
author nenolod
date Sat, 25 Nov 2006 19:48:27 -0800
parents 0469aa4ae1ec
children b7aab7965968
comparison
equal deleted inserted replaced
307:5648731be0fd 308:1bf162c7b4b9
21 #include <ctype.h> 21 #include <ctype.h>
22 #include <audacious/plugin.h> 22 #include <audacious/plugin.h>
23 #include <audacious/output.h> 23 #include <audacious/output.h>
24 #include <audacious/playlist.h> 24 #include <audacious/playlist.h>
25 #include <audacious/vfs.h> 25 #include <audacious/vfs.h>
26 #include <audacious/util.h>
26 27
27 #define MAX_CUE_LINE_LENGTH 1000 28 #define MAX_CUE_LINE_LENGTH 1000
28 #define MAX_CUE_TRACKS 1000 29 #define MAX_CUE_TRACKS 1000
29 30
30 static void cache_cue_file(gchar *f); 31 static void cache_cue_file(gchar *f);
124 return FALSE; 125 return FALSE;
125 } 126 }
126 127
127 static gint get_time(void) 128 static gint get_time(void)
128 { 129 {
129 return cue_ip.output->output_time(); 130 if (real_ip)
131 return real_ip->get_time();
132
133 return -1;
130 } 134 }
131 135
132 static void play(gchar *uri) 136 static void play(gchar *uri)
133 { 137 {
134 /* this isn't a cue:// uri? */ 138 /* this isn't a cue:// uri? */
162 static TitleInput *get_tuple_uri(gchar *uri) 166 static TitleInput *get_tuple_uri(gchar *uri)
163 { 167 {
164 gchar *path2 = g_strdup(uri + 6); 168 gchar *path2 = g_strdup(uri + 6);
165 gchar *_path = strchr(path2, '?'); 169 gchar *_path = strchr(path2, '?');
166 gint track = 0; 170 gint track = 0;
171 gint file_length = 0;
172
167 InputPlugin *dec; 173 InputPlugin *dec;
168 TitleInput *phys_tuple, *out; 174 TitleInput *phys_tuple, *out;
169 175
170 if (_path != NULL && *_path == '?') 176 if (_path != NULL && *_path == '?')
171 { 177 {
182 dec = input_check_file(cue_file, FALSE); 188 dec = input_check_file(cue_file, FALSE);
183 189
184 if (dec == NULL) 190 if (dec == NULL)
185 return NULL; 191 return NULL;
186 192
187 phys_tuple = dec->get_song_tuple(cue_file); 193 if (dec->get_song_tuple)
194 phys_tuple = dec->get_song_tuple(cue_file);
195 else
196 phys_tuple = input_get_song_tuple(cue_file);
188 197
189 out = bmp_title_input_new(); 198 out = bmp_title_input_new();
190 199
191 out->genre = g_strdup(phys_tuple->genre); 200 out->genre = g_strdup(phys_tuple->genre);
192 out->album_name = g_strdup(phys_tuple->album_name); 201 out->album_name = g_strdup(phys_tuple->album_name);
292 { 301 {
293 real_ip->set_info = set_info_override; 302 real_ip->set_info = set_info_override;
294 real_ip->output = cue_ip.output; 303 real_ip->output = cue_ip.output;
295 real_ip->play_file(cue_file); 304 real_ip->play_file(cue_file);
296 real_ip->seek(finetune_seek ? finetune_seek / 1000 : cue_tracks[track].index / 1000 + 1); 305 real_ip->seek(finetune_seek ? finetune_seek / 1000 : cue_tracks[track].index / 1000 + 1);
306 real_ip->get_song_info(cue_file, NULL, &file_length);
307 cue_tracks[last_cue_track].index = file_length;
297 } 308 }
298 309
299 finetune_seek = 0; 310 finetune_seek = 0;
300 311
301 cur_cue_track = track; 312 cur_cue_track = track;
328 */ 339 */
329 static gint watchdog_func(gpointer unused) 340 static gint watchdog_func(gpointer unused)
330 { 341 {
331 gint time = get_output_time(); 342 gint time = get_output_time();
332 gboolean dir = FALSE; 343 gboolean dir = FALSE;
344
345 if (time == -1)
346 time = G_MAXINT;
333 347
334 while (time < cue_tracks[cur_cue_track].index) 348 while (time < cue_tracks[cur_cue_track].index)
335 { 349 {
336 cur_cue_track--; 350 cur_cue_track--;
337 if (!(time < cue_tracks[cur_cue_track].index)) 351 if (!(time < cue_tracks[cur_cue_track].index))
397 line[q] = '\0'; 411 line[q] = '\0';
398 for (q++; line[q] && isspace((int) line[q]); q++); 412 for (q++; line[q] && isspace((int) line[q]); q++);
399 413
400 if (strcasecmp(line+p, "PERFORMER") == 0) { 414 if (strcasecmp(line+p, "PERFORMER") == 0) {
401 fix_cue_argument(line+q); 415 fix_cue_argument(line+q);
402 if (last_cue_track == 0) { 416
403 if (!g_utf8_validate(line + q, -1, NULL)) { 417 if (last_cue_track == 0)
404 cue_performer = g_locale_to_utf8 (line + q, -1, NULL, NULL, NULL); 418 cue_performer = str_to_utf8(line + q);
405 } else 419 else
406 cue_performer = g_strdup(line+q); 420 cue_tracks[last_cue_track - 1].performer = str_to_utf8(line + q);
407 } else {
408 if (!g_utf8_validate(line + q, -1, NULL)) {
409 cue_tracks[last_cue_track-1].performer = g_locale_to_utf8 (line + q, -1, NULL, NULL, NULL);
410 } else
411 cue_tracks[last_cue_track-1].performer = g_strdup(line+q);
412 }
413 } 421 }
414 else if (strcasecmp(line+p, "FILE") == 0) { 422 else if (strcasecmp(line+p, "FILE") == 0) {
415 gchar *tmp = g_path_get_dirname(f); 423 gchar *tmp = g_path_get_dirname(f);
416 fix_cue_argument(line+q); 424 fix_cue_argument(line+q);
417 cue_file = g_strdup_printf("%s/%s", tmp, line+q); /* XXX: yaz might need to UTF validate this?? -nenolod */ 425 cue_file = g_strdup_printf("%s/%s", tmp, line+q); /* XXX: yaz might need to UTF validate this?? -nenolod */
418 g_free(tmp); 426 g_free(tmp);
419 } 427 }
420 else if (strcasecmp(line+p, "TITLE") == 0) { 428 else if (strcasecmp(line+p, "TITLE") == 0) {
421 fix_cue_argument(line+q); 429 fix_cue_argument(line+q);
422 if (last_cue_track == 0) { 430 if (last_cue_track == 0)
423 if (!g_utf8_validate(line + q, -1, NULL)) { 431 cue_title = str_to_utf8(line + q);
424 cue_title = g_locale_to_utf8 (line + q, -1, NULL, NULL, NULL); 432 else
425 } else 433 cue_tracks[last_cue_track-1].title = str_to_utf8(line + q);
426 cue_title = g_strdup(line+q);
427 } else {
428 if (!g_utf8_validate(line + q, -1, NULL)) {
429 cue_tracks[last_cue_track-1].title = g_locale_to_utf8 (line + q, -1, NULL, NULL, NULL);
430 } else
431 cue_tracks[last_cue_track-1].title = g_strdup(line+q);
432 }
433 } 434 }
434 else if (strcasecmp(line+p, "TRACK") == 0) { 435 else if (strcasecmp(line+p, "TRACK") == 0) {
435 gint track; 436 gint track;
436 437
437 fix_cue_argument(line+q); 438 fix_cue_argument(line+q);