annotate src/cue/cuesheet.c @ 1510:3a252050736c

replace tuple_formatter_process_string() with tuple_formatter_make_title_string() except that for streamings.
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Tue, 21 Aug 2007 17:11:59 +0900
parents e8330e6bd0ba
children c8c725957643
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>
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
34
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
35 #define MAX_CUE_LINE_LENGTH 1000
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
36 #define MAX_CUE_TRACKS 1000
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
37
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
38 static void cache_cue_file(gchar *f);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
39 static void free_cue_info(void);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
40 static void fix_cue_argument(char *line);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
41 static gboolean is_our_file(gchar *filespec);
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
42 static void play(InputPlayback *data);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
43 static void play_cue_uri(InputPlayback *data, gchar *uri);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
44 static gint get_time(InputPlayback *data);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
45 static void seek(InputPlayback *data, gint time);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
46 static void stop(InputPlayback *data);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
47 static void cue_pause(InputPlayback *data, short);
1422
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
48 static Tuple *get_tuple(gchar *uri);
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
49 static Tuple *get_tuple_uri(gchar *uri);
86
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
50 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
51 static void cue_init(void);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
52 static void cue_cleanup(void);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
53 static gpointer watchdog_func(gpointer data);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
54
1364
8916502b398c make sure thread pointer to be NULL if corresponding thread doesn't exist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1363
diff changeset
55 static GThread *watchdog_thread = NULL;
8916502b398c make sure thread pointer to be NULL if corresponding thread doesn't exist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1363
diff changeset
56 static GThread *play_thread = NULL;
8916502b398c make sure thread pointer to be NULL if corresponding thread doesn't exist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1363
diff changeset
57 static GThread *real_play_thread = NULL;
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
58
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
59 static GMutex *cue_mutex;
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
60 static GCond *cue_cond;
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
61 static enum {
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
62 STOP,
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
63 RUN,
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
64 EXIT,
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
65 } watchdog_state;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
66
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
67 static GMutex *cue_block_mutex;
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
68 static GCond *cue_block_cond;
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
69
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
70 static InputPlayback *caller_ip = NULL;
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
71
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
72 static gchar *cue_file = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
73 static gchar *cue_title = NULL;
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
74 static gchar *cue_performer = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
75 static gchar *cue_genre = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
76 static gchar *cue_year = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
77 static gchar *cue_track = NULL;
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 gint last_cue_track = 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
80 static gint cur_cue_track = 0;
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
81 static gint target_time = 0;
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
82 static GMutex *cue_target_time_mutex;
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
83
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
84 static struct {
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
85 gchar *title;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
86 gchar *performer;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
87 gint index;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
88 } cue_tracks[MAX_CUE_TRACKS];
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
89
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
90 static gint finetune_seek = 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
91
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
92 static InputPlayback *real_ip = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
93
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
94 InputPlugin cue_ip =
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
95 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
96 NULL, /* handle */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
97 NULL, /* filename */
1088
07914886d6aa [svn] - cue: convert to plugin API v2
nenolod
parents: 987
diff changeset
98 "Cuesheet Plugin", /* description */
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
99 cue_init, /* init */
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
100 NULL, /* about */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
101 NULL, /* configure */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
102 is_our_file,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
103 NULL, /* audio cd */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
104 play,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
105 stop,
251
0469aa4ae1ec [svn] - make pause do something. closes #636
nenolod
parents: 242
diff changeset
106 cue_pause,
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
107 seek,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
108 NULL, /* set eq */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
109 get_time,
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,
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
112 cue_cleanup, /* cleanup */
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 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
116 NULL,
86
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
117 get_song_info, /* XXX get_song_info iface */
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
118 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
119 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
120 get_tuple,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
121 NULL
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
122 };
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
123
1088
07914886d6aa [svn] - cue: convert to plugin API v2
nenolod
parents: 987
diff changeset
124 InputPlugin *cue_iplist[] = { &cue_ip, NULL };
07914886d6aa [svn] - cue: convert to plugin API v2
nenolod
parents: 987
diff changeset
125
1395
761e17b23e0c added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents: 1376
diff changeset
126 DECLARE_PLUGIN(cue, NULL, NULL, cue_iplist, NULL, NULL, NULL, NULL, NULL);
1088
07914886d6aa [svn] - cue: convert to plugin API v2
nenolod
parents: 987
diff changeset
127
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
128 static void cue_init(void)
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
129 {
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
130 cue_mutex = g_mutex_new();
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
131 cue_cond = g_cond_new();
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
132 cue_block_mutex = g_mutex_new();
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
133 cue_block_cond = g_cond_new();
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
134 cue_target_time_mutex = g_mutex_new();
809
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 /* create watchdog thread */
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
137 g_mutex_lock(cue_mutex);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
138 watchdog_state = STOP;
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
139 g_mutex_unlock(cue_mutex);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
140 watchdog_thread = g_thread_create(watchdog_func, NULL, TRUE, NULL);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
141 #ifdef DEBUG
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
142 g_print("watchdog_thread = %p\n", watchdog_thread);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
143 #endif
1483
e8330e6bd0ba Register cue:// with uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents: 1473
diff changeset
144 uri_set_plugin("cue://", &cue_ip);
809
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
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
147 static void cue_cleanup(void)
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
148 {
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
149 g_mutex_lock(cue_mutex);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
150 watchdog_state = EXIT;
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
151 g_mutex_unlock(cue_mutex);
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
152 g_cond_broadcast(cue_cond);
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
153
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
154 g_thread_join(watchdog_thread);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
155
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
156 g_cond_free(cue_cond);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
157 g_mutex_free(cue_mutex);
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
158 g_cond_free(cue_block_cond);
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
159 g_mutex_free(cue_block_mutex);
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
160 g_mutex_free(cue_target_time_mutex);
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
161 }
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
162
76
0b53b7f1959d [svn] - too much was reverted here, only the if (!ext) return TRUE; was wrong.
nenolod
parents: 73
diff changeset
163 static int is_our_file(gchar *filename)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
164 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
165 gchar *ext;
86
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
166
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
167 /* is it a cue:// URI? */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
168 if (!strncasecmp(filename, "cue://", 6))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
169 return TRUE;
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 ext = strrchr(filename, '.');
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
172
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
173 if(!ext)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
174 return FALSE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
175
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
176 if (!strncasecmp(ext, ".cue", 4))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
177 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
178 gint i;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
179
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
180 /* add the files, build cue urls, etc. */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
181 cache_cue_file(filename);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
182
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
183 for (i = 0; i < last_cue_track; i++)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
184 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
185 gchar _buf[65535];
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 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
188 playlist_add_url(playlist_get_active(), _buf);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
189 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
190
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
191 free_cue_info();
81
254cc9620517 [svn] - fix issue where cuesheet plugin owns all codecs
nenolod
parents: 76
diff changeset
192
254cc9620517 [svn] - fix issue where cuesheet plugin owns all codecs
nenolod
parents: 76
diff changeset
193 return -1;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
194 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
195
81
254cc9620517 [svn] - fix issue where cuesheet plugin owns all codecs
nenolod
parents: 76
diff changeset
196 return FALSE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
197 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
198
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
199 static gint get_time(InputPlayback *playback)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
200 {
602
20b8e735f69e [svn] - adaptation for playback API. make cuesheet plugin pass playback->output to real_ip.
yaz
parents: 559
diff changeset
201 return playback->output->output_time();
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
202 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
203
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
204 static void play(InputPlayback *data)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
205 {
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
206 gchar *uri = data->filename;
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
207
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
208 #ifdef DEBUG
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
209 g_print("play: playback = %p\n", data);
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
210 #endif
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
211
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
212 caller_ip = data;
0
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);
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
217 play_cue_uri(data, tmp);
0
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;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
220 }
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
221 play_thread = g_thread_self();
1447
195b5657303e updated input plugins to use set_pb_ready to signal to the core that they're ready for playback
Giacomo Lozito <james@develia.org>
parents: 1422
diff changeset
222 data->set_pb_ready(data);
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
223 play_cue_uri(data, uri);
0
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
1422
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
226 static Tuple *get_tuple(gchar *uri)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
227 {
1422
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
228 Tuple *ret;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
229
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
230 /* this isn't a cue:// uri? */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
231 if (strncasecmp("cue://", uri, 6))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
232 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
233 gchar *tmp = g_strdup_printf("cue://%s?0", uri);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
234 ret = get_tuple_uri(tmp);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
235 g_free(tmp);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
236 return ret;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
237 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
238
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
239 return get_tuple_uri(uri);
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
1422
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
242 static void _tuple_copy_field(Tuple *tuple, Tuple *tuple2, const gchar *field)
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
243 {
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
244 const gchar *str = tuple_get_string(tuple, field);
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
245 tuple_disassociate(tuple2, field);
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
246 tuple_associate_string(tuple2, field, str);
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
247 }
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
248
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
249 static Tuple *get_tuple_uri(gchar *uri)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
250 {
901
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
251 gchar *path2 = g_strdup(uri + 6);
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
252 gchar *_path = strchr(path2, '?');
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
253 gint track = 0;
308
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
254
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
255 ProbeResult *pr;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
256 InputPlugin *dec;
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
257
1422
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
258 Tuple *phys_tuple, *out;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
259
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
260 if (_path != NULL && *_path == '?')
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
261 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
262 *_path = '\0';
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
263 _path++;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
264 track = atoi(_path);
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
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
267 cache_cue_file(path2);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
268
241
a1e15310703e [svn] Crash avoidance for zeroed cue sheets. By TiCPU, submitted in #audacious.
chainsaw
parents: 239
diff changeset
269 if (cue_file == NULL)
a1e15310703e [svn] Crash avoidance for zeroed cue sheets. By TiCPU, submitted in #audacious.
chainsaw
parents: 239
diff changeset
270 return NULL;
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
271
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
272 pr = input_check_file(cue_file, FALSE);
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
273 if (pr == NULL)
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
274 return NULL;
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
275 dec = pr->ip;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
276 if (dec == NULL)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
277 return NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
278
308
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
279 if (dec->get_song_tuple)
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
280 phys_tuple = dec->get_song_tuple(cue_file);
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
281 else
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
282 phys_tuple = input_get_song_tuple(cue_file);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
283
1422
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
284 if(!phys_tuple)
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
285 return NULL;
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
286
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
287 out = tuple_new();
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
288
1422
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
289 _tuple_copy_field(phys_tuple, out, "file-path");
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
290 _tuple_copy_field(phys_tuple, out, "file-name");
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
291 _tuple_copy_field(phys_tuple, out, "file-exit");
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
292 _tuple_copy_field(phys_tuple, out, "codec");
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
293 _tuple_copy_field(phys_tuple, out, "quality");
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
294 _tuple_copy_field(phys_tuple, out, "copyright");
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
295 _tuple_copy_field(phys_tuple, out, "comment");
1192
16413a86172c fix for crash when the file pointed in a cuesheet does not exist. closes #978.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1088
diff changeset
296
1422
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
297 tuple_associate_int(out, "length", tuple_get_int(phys_tuple, "length"));
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
298
1465
db616ccdd40c use tuple_free(x) in place of mowgli_object_unref(x)
Giacomo Lozito <james@develia.org>
parents: 1447
diff changeset
299 tuple_free(phys_tuple);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
300
1422
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
301 tuple_associate_string(out, "title", cue_tracks[track].title);
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
302 tuple_associate_string(out, "artist", cue_tracks[track].performer ?
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
303 cue_tracks[track].performer : cue_performer);
1422
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
304 tuple_associate_string(out, "album", cue_title);
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
305 tuple_associate_string(out, "genre", cue_genre);
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
306 tuple_associate_int(out, "year", atoi(cue_year));
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
307 tuple_associate_int(out, "track-number", track + 1);
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
308
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
309 return out;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
310 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
311
86
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
312 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
313 {
1422
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
314 Tuple *tuple;
86
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
315
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
316 /* this isn't a cue:// uri? */
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
317 if (strncasecmp("cue://", uri, 6))
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
318 {
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
319 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
320 tuple = get_tuple_uri(tmp);
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
321 g_free(tmp);
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
322 }
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
323 else
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
324 tuple = get_tuple_uri(uri);
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
325
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
326 g_return_if_fail(tuple != NULL);
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
327
1510
3a252050736c replace tuple_formatter_process_string() with tuple_formatter_make_title_string() except that for streamings.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1483
diff changeset
328 *title = tuple_formatter_make_title_string(tuple, get_gentitle_format());
1422
35c8b1faf27b update to new API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
329 *length = tuple_get_int(tuple, "length");
86
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
330
1465
db616ccdd40c use tuple_free(x) in place of mowgli_object_unref(x)
Giacomo Lozito <james@develia.org>
parents: 1447
diff changeset
331 tuple_free(tuple);
86
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
332 }
60cf31332daa [svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents: 81
diff changeset
333
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
334 static void seek(InputPlayback * data, gint time)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
335 {
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
336 g_mutex_lock(cue_target_time_mutex);
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
337 target_time = time * 1000;
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
338 g_mutex_unlock(cue_target_time_mutex);
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
339
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
340 #ifdef DEBUG
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
341 g_print("seek: playback = %p\n", data);
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
342 g_print("cue: seek: target_time = %d\n", target_time);
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
343 #endif
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
344
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
345 if (real_ip != NULL) {
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
346 real_ip->plugin->seek(real_ip, time);
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
347 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
348 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
349
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
350 static void stop(InputPlayback * data)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
351 {
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
352 #ifdef DEBUG
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
353 g_print("f: stop: playback = %p\n", data);
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
354 #endif
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
355
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
356 if(play_thread) {
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
357 if(real_play_thread) {
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
358 g_cond_signal(cue_block_cond); /* kick play_cue_uri */
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
359
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
360 if (real_ip != NULL)
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
361 real_ip->plugin->stop(real_ip);
853
def1af87ae1f [svn] - add 1sec guard time after issue of playlist_prev/next.
yaz
parents: 848
diff changeset
362 #ifdef DEBUG
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
363 g_print("i: stop(real_ip) finished\n");
853
def1af87ae1f [svn] - add 1sec guard time after issue of playlist_prev/next.
yaz
parents: 848
diff changeset
364 #endif
1364
8916502b398c make sure thread pointer to be NULL if corresponding thread doesn't exist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1363
diff changeset
365 real_play_thread = NULL;
8916502b398c make sure thread pointer to be NULL if corresponding thread doesn't exist.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1363
diff changeset
366
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
367 if (data != NULL)
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
368 data->playing = 0;
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
369 if (caller_ip != NULL)
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
370 caller_ip->playing = 0;
804
1cc14b1239a1 [svn] - need to clear data->playing when stopped.
yaz
parents: 803
diff changeset
371
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
372 g_mutex_lock(cue_mutex);
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
373 watchdog_state = STOP;
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
374 g_mutex_unlock(cue_mutex);
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
375 g_cond_signal(cue_cond);
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
376
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
377 free_cue_info();
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
378
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
379 if (real_ip != NULL) {
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
380 real_ip->plugin->set_info = cue_ip.set_info;
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
381 real_ip->plugin->output = NULL;
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
382 g_free(real_ip);
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
383 real_ip = NULL;
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
384 }
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
385 } /* real_play_thread */
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
386
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
387 g_thread_join(play_thread);
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
388 play_thread = NULL;
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
389
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
390 } /*play_thread*/
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
391
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
392
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
393 #ifdef DEBUG
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
394 g_print("e: stop\n");
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
395 #endif
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
396 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
397
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
398 /* not publicly available functions. */
901
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
399 extern void playback_stop(void);
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
400 extern void mainwin_clear_song_info(void);
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
401
1274
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
402 static gboolean do_stop(gpointer data)
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
403 {
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
404 #ifdef DEBUG
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
405 g_print("f: do_stop\n");
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
406 #endif
1274
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
407
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
408 ip_data.stop = TRUE;
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
409 playback_stop();
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
410 ip_data.stop = FALSE;
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
411
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
412 mainwin_clear_song_info();
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
413
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
414 #ifdef DEBUG
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
415 g_print("e: do_stop\n");
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
416 #endif
1274
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
417 return FALSE; //one-shot
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
418 }
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
419
1274
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
420 static gboolean do_setpos(gpointer data)
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
421 {
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
422 Playlist *playlist = playlist_get_active();
901
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
423 gint pos = playlist_get_position_nolock(playlist);
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
424 gint incr = *(gint *)data;
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
425
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
426 pos = pos + incr;
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
427 if(pos < 0)
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
428 pos = 0;
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
429
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
430 #ifdef DEBUG
901
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
431 g_print("do_setpos: pos = %d\n\n", pos);
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
432 #endif
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
433
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
434 if (!playlist)
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
435 return FALSE;
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
436
1274
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
437 /* being done from the main loop thread, does not require locks */
901
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
438 playlist_set_position(playlist, (guint)pos);
1274
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
439
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
440 return FALSE; //one-shot
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
441 }
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
442
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
443 static void cue_pause(InputPlayback * data, short p)
251
0469aa4ae1ec [svn] - make pause do something. closes #636
nenolod
parents: 242
diff changeset
444 {
0469aa4ae1ec [svn] - make pause do something. closes #636
nenolod
parents: 242
diff changeset
445 if (real_ip != NULL)
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
446 real_ip->plugin->pause(real_ip, p);
251
0469aa4ae1ec [svn] - make pause do something. closes #636
nenolod
parents: 242
diff changeset
447 }
0469aa4ae1ec [svn] - make pause do something. closes #636
nenolod
parents: 242
diff changeset
448
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
449 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
450 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
451 gchar *title;
363
958855dae693 [svn] - fix other plugins dependant on the playlist framework
nenolod
parents: 357
diff changeset
452 Playlist *playlist = playlist_get_active();
958855dae693 [svn] - fix other plugins dependant on the playlist framework
nenolod
parents: 357
diff changeset
453
958855dae693 [svn] - fix other plugins dependant on the playlist framework
nenolod
parents: 357
diff changeset
454 g_return_if_fail(playlist != NULL);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
455
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
456 /* annoying. */
363
958855dae693 [svn] - fix other plugins dependant on the playlist framework
nenolod
parents: 357
diff changeset
457 if (playlist->position->tuple == NULL)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
458 {
363
958855dae693 [svn] - fix other plugins dependant on the playlist framework
nenolod
parents: 357
diff changeset
459 gint pos = playlist_get_position(playlist);
958855dae693 [svn] - fix other plugins dependant on the playlist framework
nenolod
parents: 357
diff changeset
460 playlist_get_tuple(playlist, pos);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
461 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
462
363
958855dae693 [svn] - fix other plugins dependant on the playlist framework
nenolod
parents: 357
diff changeset
463 title = g_strdup(playlist->position->title);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
464
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
465 cue_ip.set_info(title, length, rate, freq, nch);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
466 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
467
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
468 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
469 {
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
470 gchar *path2 = g_strdup(uri + 6);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
471 gchar *_path = strchr(path2, '?');
309
b7aab7965968 [svn] - fix
nenolod
parents: 308
diff changeset
472 gint file_length = 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
473 gint track = 0;
310
86b52a87ba33 [svn] - get_song_info() in some plugins, typically wav, would crash with NULL argument.
yaz
parents: 309
diff changeset
474 gchar *dummy = NULL;
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
475 ProbeResult *pr;
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
476 InputPlugin *real_ip_plugin;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
477
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
478 #ifdef DEBUG
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
479 g_print("f: play_cue_uri\n");
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
480 g_print("play_cue_uri: playback = %p\n", data);
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
481 #endif
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
482
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
483 /* stop watchdog thread */
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
484 g_mutex_lock(cue_mutex);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
485 watchdog_state = STOP;
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
486 g_mutex_unlock(cue_mutex);
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
487 g_cond_signal(cue_cond);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
488
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
489 if (_path != NULL && *_path == '?')
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
490 {
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
491 *_path = '\0';
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
492 _path++;
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
493 track = atoi(_path);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
494 }
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
495 cur_cue_track = track;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
496 cache_cue_file(path2);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
497
1237
0d5b0f861bf0 - quick fix for link breakage to libaudid3tag.so when --prefix is specified.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1192
diff changeset
498 if (cue_file == NULL || !vfs_file_test(cue_file, G_FILE_TEST_EXISTS))
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
499 return;
241
a1e15310703e [svn] Crash avoidance for zeroed cue sheets. By TiCPU, submitted in #audacious.
chainsaw
parents: 239
diff changeset
500
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
501 pr = input_check_file(cue_file, FALSE);
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
502 if (pr == NULL)
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
503 return;
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
504
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
505 real_ip_plugin = pr->ip;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
506
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
507 if (real_ip_plugin != NULL)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
508 {
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
509 if (real_ip)
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
510 g_free(real_ip);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
511 real_ip = g_new0(InputPlayback, 1);
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
512 real_ip->plugin = real_ip_plugin;
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
513 real_ip->plugin->set_info = set_info_override;
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
514 real_ip->plugin->output = cue_ip.output;
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 532
diff changeset
515 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
516
20b8e735f69e [svn] - adaptation for playback API. make cuesheet plugin pass playback->output to real_ip.
yaz
parents: 559
diff changeset
517 /* 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
518 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
519 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
520
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
521 real_play_thread = g_thread_create((GThreadFunc)(real_ip->plugin->play_file), (gpointer)real_ip, TRUE, NULL);
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
522 g_usleep(50000); // wait for 50msec while real input plugin is initializing.
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
523
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
524 if(real_ip->plugin->mseek) {
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
525 #ifdef DEBUG
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
526 g_print("mseek\n");
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
527 #endif
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
528 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
529 }
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
530 else
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
531 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
532
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
533 g_mutex_lock(cue_target_time_mutex);
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
534 target_time = finetune_seek ? finetune_seek : cue_tracks[track].index;
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
535 g_mutex_unlock(cue_target_time_mutex);
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
536 #ifdef DEBUG
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
537 g_print("cue: play_cue_uri: target_time = %d\n", target_time);
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
538 #endif
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
539 /* in some plugins, NULL as 2nd arg causes crash. */
860
cafc7d5769f9 [svn] - support "Repeat".
yaz
parents: 859
diff changeset
540 real_ip->plugin->get_song_info(cue_file, &dummy, &file_length);
cafc7d5769f9 [svn] - support "Repeat".
yaz
parents: 859
diff changeset
541 g_free(dummy);
cafc7d5769f9 [svn] - support "Repeat".
yaz
parents: 859
diff changeset
542 cue_tracks[last_cue_track].index = file_length;
cafc7d5769f9 [svn] - support "Repeat".
yaz
parents: 859
diff changeset
543
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
544 /* kick watchdog thread */
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
545 g_mutex_lock(cue_mutex);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
546 watchdog_state = RUN;
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
547 g_mutex_unlock(cue_mutex);
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
548 g_cond_signal(cue_cond);
853
def1af87ae1f [svn] - add 1sec guard time after issue of playlist_prev/next.
yaz
parents: 848
diff changeset
549 #ifdef DEBUG
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
550 g_print("watchdog activated\n");
853
def1af87ae1f [svn] - add 1sec guard time after issue of playlist_prev/next.
yaz
parents: 848
diff changeset
551 #endif
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
552 finetune_seek = 0;
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
553 if(real_play_thread) {
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
554 g_mutex_lock(cue_block_mutex);
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
555 g_cond_wait(cue_block_cond, cue_block_mutex); // block until stop() is called.
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
556 g_mutex_unlock(cue_block_mutex);
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
557 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
558 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
559
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
560 #ifdef DEBUG
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
561 g_print("e: play_cue_uri\n");
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
562 #endif
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
563 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
564
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
565 /******************************************************* watchdog */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
566
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
567 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
568 * This is fairly hard to explain.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
569 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
570 * 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
571 * 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
572 * right place.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
573 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
574 * 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
575 * as well as I was hoping.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
576 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
577 * 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
578 * cool with it.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
579 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
580 * - nenolod
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
581 */
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
582 static gpointer watchdog_func(gpointer data)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
583 {
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
584 gint time = 0;
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
585 Playlist *playlist = NULL;
901
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
586 GTimeVal sleep_time;
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
587
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
588 #ifdef DEBUG
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
589 g_print("f: watchdog\n");
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
590 #endif
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
591
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
592 while(1) {
853
def1af87ae1f [svn] - add 1sec guard time after issue of playlist_prev/next.
yaz
parents: 848
diff changeset
593 #if 0
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
594 #if DEBUG
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
595 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
596 time, cur_cue_track,
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
597 cue_tracks[cur_cue_track].index,
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
598 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
599 #endif
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
600 #endif
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
601 g_get_current_time(&sleep_time);
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
602 g_time_val_add(&sleep_time, 10000); // interval is 10msec.
308
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
603
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
604 g_mutex_lock(cue_mutex);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
605 switch(watchdog_state) {
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
606 case EXIT:
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
607 #ifdef DEBUG
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
608 g_print("e: watchdog exit\n");
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
609 #endif
1274
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
610 g_mutex_unlock(cue_mutex); // stop() will lock cue_mutex.
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
611 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
612 g_thread_exit(NULL);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
613 break;
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
614 case RUN:
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
615 if(!playlist)
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
616 playlist = playlist_get_active();
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
617 g_cond_timed_wait(cue_cond, cue_mutex, &sleep_time);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
618 break;
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
619 case STOP:
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
620 #ifdef DEBUG
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
621 g_print("watchdog deactivated\n");
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
622 #endif
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
623 g_cond_wait(cue_cond, cue_mutex);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
624 playlist = playlist_get_active();
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
625 break;
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 g_mutex_unlock(cue_mutex);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
628
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
629 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
630 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
631
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
632 time = get_output_time();
1365
8702f72b3382 - reduce guard time in initiating play to avoid stuttering start.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1364
diff changeset
633 #if 0
8702f72b3382 - reduce guard time in initiating play to avoid stuttering start.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1364
diff changeset
634 #ifdef DEBUG
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
635 g_print("time = %d target_time = %d\n", time, target_time);
1365
8702f72b3382 - reduce guard time in initiating play to avoid stuttering start.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1364
diff changeset
636 #endif
8702f72b3382 - reduce guard time in initiating play to avoid stuttering start.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1364
diff changeset
637 #endif
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
638 if(time == 0 || time <= target_time)
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
639 continue;
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
640
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
641 // prev track
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
642 if (time < cue_tracks[cur_cue_track].index)
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
643 {
1274
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
644 static gint incr = 0;
901
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
645 gint oldpos = cur_cue_track;
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
646 #ifdef DEBUG
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
647 g_print("i: watchdog prev\n");
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
648 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
649 cue_tracks[cur_cue_track].index,
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
650 cue_tracks[cur_cue_track+1].index);
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
651 #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
652 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
653 cur_cue_track--;
901
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
654 incr = cur_cue_track - oldpos; // relative position
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
655 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
656 finetune_seek = time;
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
657 #ifdef DEBUG
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
658 g_print("cue: prev_track: time = %d cue_tracks[cur_cue_track].index = %d\n",
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
659 time, cue_tracks[cur_cue_track].index);
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
660 g_print("cue: prev_track: finetune_seek = %d\n", finetune_seek);
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
661 #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
662 }
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
663
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
664 g_mutex_lock(cue_target_time_mutex);
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
665 target_time = finetune_seek ? finetune_seek : cue_tracks[cur_cue_track].index;
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
666 g_mutex_unlock(cue_target_time_mutex);
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
667 #ifdef DEBUG
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
668 g_print("cue: prev_track: target_time = %d\n", target_time);
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
669 #endif
1274
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
670 g_idle_add_full(G_PRIORITY_HIGH , do_setpos, &incr, NULL);
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
671 continue;
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
672 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
673
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
674 // next track
861
59a876be8550 [svn] - refine watchdog thread.
yaz
parents: 860
diff changeset
675 if (cur_cue_track + 1 < last_cue_track && time > cue_tracks[cur_cue_track + 1].index)
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
676 {
1274
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
677 static gint incr = 0;
901
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
678 gint oldpos = cur_cue_track;
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
679 #ifdef DEBUG
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
680 g_print("i: watchdog next\n");
860
cafc7d5769f9 [svn] - support "Repeat".
yaz
parents: 859
diff changeset
681 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
682 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
683 cue_tracks[cur_cue_track+1].index,
860
cafc7d5769f9 [svn] - support "Repeat".
yaz
parents: 859
diff changeset
684 last_cue_track, cue_tracks[last_cue_track].index);
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
685 #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
686 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
687 cur_cue_track++;
901
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
688 incr = cur_cue_track - oldpos; // relative position
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
689 if (time >= 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
690 finetune_seek = time;
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
691 #ifdef DEBUG
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
692 g_print("cue: next_track: time = %d cue_tracks[cur_cue_track].index = %d\n",
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
693 time, cue_tracks[cur_cue_track].index);
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
694 g_print("cue: next_track: finetune_seek = %d\n", finetune_seek);
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
695 #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
696 }
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
697
1376
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
698 g_mutex_lock(cue_target_time_mutex);
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
699 target_time = finetune_seek ? finetune_seek : cue_tracks[cur_cue_track].index;
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
700 g_mutex_unlock(cue_target_time_mutex);
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
701 #ifdef DEBUG
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
702 g_print("cue: next_track: target_time = %d\n", target_time);
3a2a91d80818 - introduce target_time and simplify the flow of the watchdog thread. TRANSITION_GUARD_TIME is no longer needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1365
diff changeset
703 #endif
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
704 if(cfg.stopaftersong) {
1274
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
705 g_idle_add_full(G_PRIORITY_HIGH, do_stop, (void *)real_ip, NULL);
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
706 continue;
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
707 }
853
def1af87ae1f [svn] - add 1sec guard time after issue of playlist_prev/next.
yaz
parents: 848
diff changeset
708 else {
1274
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
709 g_idle_add_full(G_PRIORITY_HIGH , do_setpos, &incr, NULL);
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
710 continue;
853
def1af87ae1f [svn] - add 1sec guard time after issue of playlist_prev/next.
yaz
parents: 848
diff changeset
711 }
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
712 }
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
713
861
59a876be8550 [svn] - refine watchdog thread.
yaz
parents: 860
diff changeset
714 // last track
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
715 if (cur_cue_track + 1 == last_cue_track &&
861
59a876be8550 [svn] - refine watchdog thread.
yaz
parents: 860
diff changeset
716 (cue_tracks[last_cue_track].index - time < 500 ||
59a876be8550 [svn] - refine watchdog thread.
yaz
parents: 860
diff changeset
717 time > cue_tracks[last_cue_track].index) ){ // may not happen. for safety.
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
718 if(!real_ip->output->buffer_playing()) {
901
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
719 gint pos = playlist_get_position(playlist);
932
a5752784d87b [svn] - chase audacious r4268 (patch by Joker).
nenolod
parents: 901
diff changeset
720 if (pos + 1 == playlist_get_length(playlist)) {
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
721 #ifdef DEBUG
901
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
722 g_print("i: watchdog eof reached\n\n");
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
723 #endif
901
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
724 if(cfg.repeat) {
1274
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
725 static gint incr = 0;
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
726 incr = -pos;
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
727 g_idle_add_full(G_PRIORITY_HIGH , do_setpos, &incr, NULL);
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
728 continue;
901
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
729 }
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
730 else {
1274
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
731 g_idle_add_full(G_PRIORITY_HIGH, do_stop, (void *)real_ip, NULL);
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
732 continue;
901
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
733 }
860
cafc7d5769f9 [svn] - support "Repeat".
yaz
parents: 859
diff changeset
734 }
cafc7d5769f9 [svn] - support "Repeat".
yaz
parents: 859
diff changeset
735 else {
987
8f432e790cfb [svn] - add check for cfg.stopaftersong at the end of cue.
yaz
parents: 932
diff changeset
736 if(cfg.stopaftersong) {
1274
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
737 g_idle_add_full(G_PRIORITY_HIGH, do_stop, (void *)real_ip, NULL);
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
738 continue;
987
8f432e790cfb [svn] - add check for cfg.stopaftersong at the end of cue.
yaz
parents: 932
diff changeset
739 }
901
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
740 #ifdef DEBUG
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
741 g_print("i: watchdog end of cue, advance in playlist\n\n");
08643d5994fe [svn] - now do_setpos() takes relative position as the argument and works even if cuesheets are included in large playlist. may close #869.
yaz
parents: 861
diff changeset
742 #endif
1274
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
743 static gint incr = 1;
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
744 g_idle_add_full(G_PRIORITY_HIGH , do_setpos, &incr, NULL);
bcf6dc9564f4 - eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1267
diff changeset
745 continue;
860
cafc7d5769f9 [svn] - support "Repeat".
yaz
parents: 859
diff changeset
746 }
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
747 }
848
2452835bbfcf [svn] - make "stop after current song" work.
yaz
parents: 809
diff changeset
748 }
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
749 }
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
750 #ifdef DEBUG
860
cafc7d5769f9 [svn] - support "Repeat".
yaz
parents: 859
diff changeset
751 g_print("e: watchdog\n");
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
752 #endif
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
753 return NULL; // dummy.
0
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 /******************************************************** cuefile */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
757
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
758 static void free_cue_info(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
759 {
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
760 g_free(cue_file); cue_file = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
761 g_free(cue_title); cue_title = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
762 g_free(cue_performer); cue_performer = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
763 g_free(cue_genre); cue_genre = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
764 g_free(cue_year); cue_year = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
765 g_free(cue_track); cue_track = NULL;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
766
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
767 for (; last_cue_track > 0; last_cue_track--) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
768 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
769 cue_tracks[last_cue_track-1].performer = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
770 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
771 cue_tracks[last_cue_track-1].title = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
772 }
809
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
773 #ifdef DEBUG
860
cafc7d5769f9 [svn] - support "Repeat".
yaz
parents: 859
diff changeset
774 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
775 #endif
29ae10725c4c [svn] - make use of new millisecond seek API.
yaz
parents: 805
diff changeset
776 last_cue_track = 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
777 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
778
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
779 static void cache_cue_file(char *f)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
780 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
781 VFSFile *file = vfs_fopen(f, "rb");
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
782 gchar line[MAX_CUE_LINE_LENGTH+1];
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
783
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
784 if(!file)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
785 return;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
786
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
787 while (TRUE) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
788 gint p;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
789 gint q;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
790
239
e45005422574 [svn] FD leak fix by TiCPU, submitted in #audacious.
chainsaw
parents: 86
diff changeset
791 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
792 vfs_fclose(file);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
793 return;
860
cafc7d5769f9 [svn] - support "Repeat".
yaz
parents: 859
diff changeset
794 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
795
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
796 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
797 if (!line[p])
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
798 continue;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
799 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
800 if (!line[q])
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
801 continue;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
802 line[q] = '\0';
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
803 for (q++; line[q] && isspace((int) line[q]); q++);
356
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
804 if (strcasecmp(line+p, "REM") == 0) {
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
805 gint r;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
806 for (r = q; line[r] && !isspace((int) line[r]); r++);
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
807 if (!line[r])
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
808 continue;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
809 line[r] = '\0';
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
810 for (r++; line[r] && isspace((int) line[r]); r++);
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
811 if(strcasecmp(line+q, "GENRE") == 0) {
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
812 fix_cue_argument(line+r);
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
813 if (last_cue_track == 0)
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
814 cue_genre = str_to_utf8(line + r);
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
815 }
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
816 if(strcasecmp(line+q, "DATE") == 0) {
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
817 gchar *tmp;
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
818 fix_cue_argument(line+r);
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
819 if (last_cue_track == 0) {
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
820 tmp = g_strdup(line + r);
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
821 if (tmp) {
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
822 cue_year = strtok(tmp, "/"); // XXX: always in the same format?
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
823 }
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
824 }
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
825 }
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
826 }
35b5161ba78d [svn] cuesheet improvement:
yaz
parents: 310
diff changeset
827 else if (strcasecmp(line+p, "PERFORMER") == 0) {
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
828 fix_cue_argument(line+q);
308
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
829
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
830 if (last_cue_track == 0)
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
831 cue_performer = str_to_utf8(line + q);
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
832 else
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
833 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
834 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
835 else if (strcasecmp(line+p, "FILE") == 0) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
836 gchar *tmp = g_path_get_dirname(f);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
837 fix_cue_argument(line+q);
1363
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
838 cue_file = g_strdup_printf("%s/%s", tmp, line+q);
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
839 /* XXX: yaz might need to UTF validate this?? -nenolod */
da987606127e first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1274
diff changeset
840 /* 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
841 g_free(tmp);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
842 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
843 else if (strcasecmp(line+p, "TITLE") == 0) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
844 fix_cue_argument(line+q);
308
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
845 if (last_cue_track == 0)
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
846 cue_title = str_to_utf8(line + q);
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
847 else
1bf162c7b4b9 [svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents: 251
diff changeset
848 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
849 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
850 else if (strcasecmp(line+p, "TRACK") == 0) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
851 gint track;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
852
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
853 fix_cue_argument(line+q);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
854 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
855 line[p] = '\0';
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
856 for (; line[q] && line[q] == '0'; q++);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
857 if (!line[q])
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
858 continue;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
859 track = atoi(line+q);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
860 if (track >= MAX_CUE_TRACKS)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
861 continue;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
862 last_cue_track = track;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
863 cue_tracks[last_cue_track-1].index = 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
864 cue_tracks[last_cue_track-1].performer = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
865 cue_tracks[last_cue_track-1].title = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
866 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
867 else if (strcasecmp(line+p, "INDEX") == 0) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
868 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
869 if (!line[p])
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
870 continue;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
871 for (p++; line[p] && isspace((int) line[p]); p++);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
872 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
873 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
874 cue_tracks[last_cue_track-1].index =
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
875 ((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
876 ((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
877 ((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
878 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
879 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
880 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
881
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
882 vfs_fclose(file);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
883 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
884
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
885 static void fix_cue_argument(char *line)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
886 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
887 if (line[0] == '"') {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
888 gchar *l2;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
889 for (l2 = line+1; *l2 && *l2 != '"'; l2++)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
890 *(l2-1) = *l2;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
891 *(l2-1) = *l2;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
892 for (; *line && *line != '"'; line++) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
893 if (*line == '\\' && *(line+1)) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
894 for (l2 = line+1; *l2 && *l2 != '"'; l2++)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
895 *(l2-1) = *l2;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
896 *(l2-1) = *l2;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
897 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
898 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
899 *line = '\0';
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
900 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
901 else {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
902 for (; *line && *line != '\r' && *line != '\n'; line++);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
903 *line = '\0';
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
904 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
905 }