annotate src/cue/cuesheet.c @ 860:cafc7d5769f9 trunk

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