Mercurial > audlegacy-plugins
annotate src/cue/cuesheet.c @ 2202:f76e846d53d9
updating TLEN frame returned
author | Eugene Zagidullin <e.asphyx@gmail.com> |
---|---|
date | Mon, 03 Dec 2007 01:26:57 +0300 |
parents | c4b97a9c1f6b |
children | 62391135da44 |
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>. |
2147 | 5 * Jonathan Schleifer <js-audacious@webkeks.org> (few fixes) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
6 * |
848 | 7 * Copyright (C) 2007 Yoshiki Yazawa <yaz@cc.rim.or.jp> (millisecond |
8 * seek and multithreading) | |
9 * | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
10 * This file was hacked out of of xmms-cueinfo, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
11 * Copyright (C) 2003 Oskar Liljeblad |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
12 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
13 * This software is copyrighted work licensed under the terms of the |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
14 * GNU General Public License. Please consult the file "COPYING" for |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
15 * details. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
16 */ |
1772
bbebc130f8f5
cue: Mk2, HAVE_CONFIG_H removal, etc
William Pitcock <nenolod@atheme.org>
parents:
1762
diff
changeset
|
17 |
0
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 |
848 | 20 /* #define DEBUG 1 */ |
809 | 21 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
22 #include <string.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
23 #include <stdlib.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
24 #include <stdio.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
25 #include <ctype.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
26 #include <audacious/plugin.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
27 #include <audacious/output.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
28 #include <audacious/playlist.h> |
308
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
29 #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
|
30 #include <audacious/strings.h> |
356 | 31 #include <audacious/main.h> |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
32 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
33 #define MAX_CUE_LINE_LENGTH 1000 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
34 #define MAX_CUE_TRACKS 1000 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
35 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
36 static void cache_cue_file(gchar *f); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
37 static void free_cue_info(void); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
38 static void fix_cue_argument(char *line); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
39 static gboolean is_our_file(gchar *filespec); |
559 | 40 static void play(InputPlayback *data); |
41 static void play_cue_uri(InputPlayback *data, gchar *uri); | |
42 static void seek(InputPlayback *data, gint time); | |
43 static void stop(InputPlayback *data); | |
44 static void cue_pause(InputPlayback *data, short); | |
1422
35c8b1faf27b
update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
45 static Tuple *get_tuple(gchar *uri); |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
46 static Tuple *get_aud_tuple_uri(gchar *uri); |
809 | 47 static void cue_init(void); |
48 static void cue_cleanup(void); | |
49 static gpointer watchdog_func(gpointer data); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
50 |
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
|
51 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
|
52 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
|
53 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
|
54 |
809 | 55 static GMutex *cue_mutex; |
56 static GCond *cue_cond; | |
57 static enum { | |
58 STOP, | |
59 RUN, | |
60 EXIT, | |
61 } watchdog_state; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
62 |
1363
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
63 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
|
64 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
|
65 |
848 | 66 static InputPlayback *caller_ip = NULL; |
67 | |
356 | 68 static gchar *cue_file = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
69 static gchar *cue_title = NULL; |
356 | 70 static gchar *cue_performer = NULL; |
71 static gchar *cue_genre = NULL; | |
72 static gchar *cue_year = NULL; | |
73 static gchar *cue_track = NULL; | |
74 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
75 static gint last_cue_track = 0; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
76 static gint cur_cue_track = 0; |
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
|
77 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
|
78 static GMutex *cue_target_time_mutex; |
356 | 79 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
80 static struct { |
356 | 81 gchar *title; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
82 gchar *performer; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
83 gint index; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
84 } cue_tracks[MAX_CUE_TRACKS]; |
356 | 85 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
86 static gint finetune_seek = 0; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
87 |
559 | 88 static InputPlayback *real_ip = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
89 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
90 InputPlugin cue_ip = |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
91 { |
1615
41286bab50dc
cuesheet: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1597
diff
changeset
|
92 .description = "Cuesheet Plugin", /* description */ |
41286bab50dc
cuesheet: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1597
diff
changeset
|
93 .init = cue_init, /* init */ |
41286bab50dc
cuesheet: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1597
diff
changeset
|
94 .is_our_file = is_our_file, |
41286bab50dc
cuesheet: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1597
diff
changeset
|
95 .play_file = play, |
41286bab50dc
cuesheet: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1597
diff
changeset
|
96 .stop = stop, |
41286bab50dc
cuesheet: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1597
diff
changeset
|
97 .pause = cue_pause, |
41286bab50dc
cuesheet: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1597
diff
changeset
|
98 .seek = seek, |
41286bab50dc
cuesheet: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1597
diff
changeset
|
99 .cleanup = cue_cleanup, /* cleanup */ |
1623
1aee1ff54c8b
get_tuple should be get_song_tuple
William Pitcock <nenolod@atheme.org>
parents:
1615
diff
changeset
|
100 .get_song_tuple = get_tuple, |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
101 }; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
102 |
1088 | 103 InputPlugin *cue_iplist[] = { &cue_ip, NULL }; |
104 | |
1395
761e17b23e0c
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
1376
diff
changeset
|
105 DECLARE_PLUGIN(cue, NULL, NULL, cue_iplist, NULL, NULL, NULL, NULL, NULL); |
1088 | 106 |
809 | 107 static void cue_init(void) |
108 { | |
109 cue_mutex = g_mutex_new(); | |
110 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
|
111 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
|
112 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
|
113 cue_target_time_mutex = g_mutex_new(); |
809 | 114 |
115 /* create watchdog thread */ | |
116 g_mutex_lock(cue_mutex); | |
117 watchdog_state = STOP; | |
118 g_mutex_unlock(cue_mutex); | |
119 watchdog_thread = g_thread_create(watchdog_func, NULL, TRUE, NULL); | |
120 #ifdef DEBUG | |
121 g_print("watchdog_thread = %p\n", watchdog_thread); | |
122 #endif | |
1997 | 123 aud_uri_set_plugin("cue://", &cue_ip); |
809 | 124 } |
125 | |
126 static void cue_cleanup(void) | |
127 { | |
128 g_mutex_lock(cue_mutex); | |
129 watchdog_state = EXIT; | |
130 g_mutex_unlock(cue_mutex); | |
848 | 131 g_cond_broadcast(cue_cond); |
809 | 132 |
133 g_thread_join(watchdog_thread); | |
134 | |
135 g_cond_free(cue_cond); | |
136 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
|
137 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
|
138 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
|
139 g_mutex_free(cue_target_time_mutex); |
809 | 140 } |
141 | |
76
0b53b7f1959d
[svn] - too much was reverted here, only the if (!ext) return TRUE; was wrong.
nenolod
parents:
73
diff
changeset
|
142 static int is_our_file(gchar *filename) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
143 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
144 gchar *ext; |
86
60cf31332daa
[svn] - some improvements to the cuesheet plugin, not totally there yet ;)
nenolod
parents:
81
diff
changeset
|
145 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
146 /* is it a cue:// URI? */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
147 if (!strncasecmp(filename, "cue://", 6)) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
148 return TRUE; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
149 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
150 ext = strrchr(filename, '.'); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
151 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
152 if(!ext) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
153 return FALSE; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
154 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
155 if (!strncasecmp(ext, ".cue", 4)) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
156 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
157 gint i; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
158 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
159 /* add the files, build cue urls, etc. */ |
1557
c8c725957643
make cuesheet plugin work again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1510
diff
changeset
|
160 cache_cue_file(filename); //filename should be uri. |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
161 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
162 for (i = 0; i < last_cue_track; i++) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
163 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
164 gchar _buf[65535]; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
165 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
166 g_snprintf(_buf, 65535, "cue://%s?%d", filename, i); |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2050
diff
changeset
|
167 aud_playlist_add_url(aud_playlist_get_active(), _buf); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
168 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
169 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
170 free_cue_info(); |
81
254cc9620517
[svn] - fix issue where cuesheet plugin owns all codecs
nenolod
parents:
76
diff
changeset
|
171 |
254cc9620517
[svn] - fix issue where cuesheet plugin owns all codecs
nenolod
parents:
76
diff
changeset
|
172 return -1; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
173 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
174 |
81
254cc9620517
[svn] - fix issue where cuesheet plugin owns all codecs
nenolod
parents:
76
diff
changeset
|
175 return FALSE; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
176 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
177 |
559 | 178 static void play(InputPlayback *data) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
179 { |
1557
c8c725957643
make cuesheet plugin work again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1510
diff
changeset
|
180 gchar *uri = g_strdup(data->filename); |
848 | 181 |
182 #ifdef DEBUG | |
183 g_print("play: playback = %p\n", data); | |
1557
c8c725957643
make cuesheet plugin work again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1510
diff
changeset
|
184 g_print("play: uri = %s\n", uri); |
848 | 185 #endif |
186 | |
187 caller_ip = data; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
188 /* this isn't a cue:// uri? */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
189 if (strncasecmp("cue://", uri, 6)) |
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 gchar *tmp = g_strdup_printf("cue://%s?0", uri); |
1557
c8c725957643
make cuesheet plugin work again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1510
diff
changeset
|
192 g_free(uri); |
c8c725957643
make cuesheet plugin work again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1510
diff
changeset
|
193 uri = tmp; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
194 } |
1363
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
195 play_thread = g_thread_self(); |
1557
c8c725957643
make cuesheet plugin work again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1510
diff
changeset
|
196 data->set_pb_ready(data); // it should be done in real input plugin? --yaz |
559 | 197 play_cue_uri(data, uri); |
1557
c8c725957643
make cuesheet plugin work again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1510
diff
changeset
|
198 g_free(uri); uri = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
199 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
200 |
1422
35c8b1faf27b
update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
201 static Tuple *get_tuple(gchar *uri) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
202 { |
1422
35c8b1faf27b
update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
203 Tuple *ret; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
204 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
205 /* this isn't a cue:// uri? */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
206 if (strncasecmp("cue://", uri, 6)) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
207 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
208 gchar *tmp = g_strdup_printf("cue://%s?0", uri); |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
209 ret = get_aud_tuple_uri(tmp); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
210 g_free(tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
211 return ret; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
212 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
213 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
214 return get_aud_tuple_uri(uri); |
0
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 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
217 static void _aud_tuple_copy_field(Tuple *tuple, Tuple *tuple2, const gint nfield, const gchar *field) |
1422
35c8b1faf27b
update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
218 { |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
219 const gchar *str = aud_tuple_get_string(tuple, nfield, field); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
220 aud_tuple_disassociate(tuple2, nfield, field); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
221 aud_tuple_associate_string(tuple2, nfield, field, str); |
1422
35c8b1faf27b
update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
222 } |
35c8b1faf27b
update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
223 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
224 static Tuple *get_aud_tuple_uri(gchar *uri) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
225 { |
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
|
226 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
|
227 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
|
228 gint track = 0; |
308
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
229 |
1363
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
230 ProbeResult *pr; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
231 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
|
232 |
1422
35c8b1faf27b
update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
233 Tuple *phys_tuple, *out; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
234 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
235 if (_path != NULL && *_path == '?') |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
236 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
237 *_path = '\0'; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
238 _path++; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
239 track = atoi(_path); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
240 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
241 |
1557
c8c725957643
make cuesheet plugin work again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1510
diff
changeset
|
242 cache_cue_file(path2); //path2 should be uri. |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
243 |
241
a1e15310703e
[svn] Crash avoidance for zeroed cue sheets. By TiCPU, submitted in #audacious.
chainsaw
parents:
239
diff
changeset
|
244 if (cue_file == NULL) |
a1e15310703e
[svn] Crash avoidance for zeroed cue sheets. By TiCPU, submitted in #audacious.
chainsaw
parents:
239
diff
changeset
|
245 return NULL; |
1557
c8c725957643
make cuesheet plugin work again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1510
diff
changeset
|
246 #ifdef DEBUG |
c8c725957643
make cuesheet plugin work again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1510
diff
changeset
|
247 g_print("cue_file = %s\n", cue_file); |
c8c725957643
make cuesheet plugin work again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1510
diff
changeset
|
248 #endif |
2073 | 249 pr = aud_input_check_file(cue_file, FALSE); |
1363
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
250 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
|
251 return NULL; |
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
252 dec = pr->ip; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
253 if (dec == NULL) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
254 return NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
255 |
308
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
256 if (dec->get_song_tuple) |
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
257 phys_tuple = dec->get_song_tuple(cue_file); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
258 |
1422
35c8b1faf27b
update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
259 if(!phys_tuple) |
35c8b1faf27b
update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
260 return NULL; |
35c8b1faf27b
update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
261 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
262 out = aud_tuple_new(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
263 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
264 _aud_tuple_copy_field(phys_tuple, out, FIELD_FILE_PATH, NULL); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
265 _aud_tuple_copy_field(phys_tuple, out, FIELD_FILE_NAME, NULL); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
266 _aud_tuple_copy_field(phys_tuple, out, FIELD_FILE_EXT, NULL); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
267 _aud_tuple_copy_field(phys_tuple, out, FIELD_CODEC, NULL); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
268 _aud_tuple_copy_field(phys_tuple, out, FIELD_QUALITY, NULL); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
269 _aud_tuple_copy_field(phys_tuple, out, FIELD_COPYRIGHT, NULL); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
270 _aud_tuple_copy_field(phys_tuple, out, FIELD_COMMENT, NULL); |
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
|
271 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
272 aud_tuple_associate_int(out, FIELD_LENGTH, NULL, aud_tuple_get_int(phys_tuple, FIELD_LENGTH, NULL)); |
1422
35c8b1faf27b
update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
273 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
274 aud_tuple_free(phys_tuple); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
275 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
276 aud_tuple_associate_string(out, FIELD_TITLE, NULL, cue_tracks[track].title); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
277 aud_tuple_associate_string(out, FIELD_ARTIST, NULL, 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
|
278 cue_tracks[track].performer : cue_performer); |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
279 aud_tuple_associate_string(out, FIELD_ALBUM, NULL, cue_title); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
280 aud_tuple_associate_string(out, FIELD_GENRE, NULL, cue_genre); |
1557
c8c725957643
make cuesheet plugin work again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1510
diff
changeset
|
281 if(cue_year) |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
282 aud_tuple_associate_int(out, FIELD_YEAR, NULL, atoi(cue_year)); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
283 aud_tuple_associate_int(out, FIELD_TRACK_NUMBER, NULL, track + 1); |
1422
35c8b1faf27b
update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
284 |
35c8b1faf27b
update to new API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
285 return out; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
286 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
287 |
559 | 288 static void seek(InputPlayback * data, gint time) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
289 { |
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
|
290 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
|
291 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
|
292 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
|
293 |
848 | 294 #ifdef DEBUG |
295 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
|
296 g_print("cue: seek: target_time = %d\n", target_time); |
848 | 297 #endif |
298 | |
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
|
299 if (real_ip != NULL) { |
559 | 300 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
|
301 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
302 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
303 |
559 | 304 static void stop(InputPlayback * data) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
305 { |
848 | 306 #ifdef DEBUG |
307 g_print("f: stop: playback = %p\n", data); | |
308 #endif | |
1363
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
309 |
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
310 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
|
311 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
|
312 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
|
313 |
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
314 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
|
315 real_ip->plugin->stop(real_ip); |
853
def1af87ae1f
[svn] - add 1sec guard time after issue of playlist_prev/next.
yaz
parents:
848
diff
changeset
|
316 #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
|
317 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
|
318 #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
|
319 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
|
320 |
1363
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
321 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
|
322 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
|
323 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
|
324 caller_ip->playing = 0; |
804 | 325 |
1363
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
326 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
|
327 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
|
328 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
|
329 g_cond_signal(cue_cond); |
809 | 330 |
1363
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
331 free_cue_info(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
332 |
1363
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
333 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
|
334 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
|
335 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
|
336 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
|
337 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
|
338 } |
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
339 } /* 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
|
340 |
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
341 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
|
342 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
|
343 |
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
344 } /*play_thread*/ |
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
345 |
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
346 |
848 | 347 #ifdef DEBUG |
348 g_print("e: stop\n"); | |
349 #endif | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
350 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
351 |
1274
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
352 static gboolean do_stop(gpointer data) |
848 | 353 { |
354 #ifdef DEBUG | |
355 g_print("f: do_stop\n"); | |
356 #endif | |
1274
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
357 |
2068
c8ba6764985d
use audacious DRCT API here.
William Pitcock <nenolod@atheme.org>
parents:
2061
diff
changeset
|
358 audacious_drct_stop(); |
848 | 359 |
360 #ifdef DEBUG | |
361 g_print("e: do_stop\n"); | |
362 #endif | |
1274
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
363 return FALSE; //one-shot |
848 | 364 } |
365 | |
1274
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
366 static gboolean do_setpos(gpointer data) |
848 | 367 { |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2050
diff
changeset
|
368 Playlist *playlist = aud_playlist_get_active(); |
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2050
diff
changeset
|
369 gint pos = aud_playlist_get_position_nolock(playlist); |
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
|
370 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
|
371 |
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
|
372 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
|
373 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
|
374 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
|
375 |
848 | 376 #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
|
377 g_print("do_setpos: pos = %d\n\n", pos); |
848 | 378 #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
|
379 |
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
|
380 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
|
381 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
|
382 |
1274
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
383 /* being done from the main loop thread, does not require locks */ |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2050
diff
changeset
|
384 aud_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
|
385 |
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
386 return FALSE; //one-shot |
848 | 387 } |
388 | |
559 | 389 static void cue_pause(InputPlayback * data, short p) |
251 | 390 { |
391 if (real_ip != NULL) | |
559 | 392 real_ip->plugin->pause(real_ip, p); |
251 | 393 } |
394 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
395 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
|
396 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
397 gchar *title; |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2050
diff
changeset
|
398 Playlist *playlist = aud_playlist_get_active(); |
363
958855dae693
[svn] - fix other plugins dependant on the playlist framework
nenolod
parents:
357
diff
changeset
|
399 |
958855dae693
[svn] - fix other plugins dependant on the playlist framework
nenolod
parents:
357
diff
changeset
|
400 g_return_if_fail(playlist != NULL); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
401 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
402 /* annoying. */ |
363
958855dae693
[svn] - fix other plugins dependant on the playlist framework
nenolod
parents:
357
diff
changeset
|
403 if (playlist->position->tuple == NULL) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
404 { |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2050
diff
changeset
|
405 gint pos = aud_playlist_get_position(playlist); |
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2050
diff
changeset
|
406 aud_playlist_get_tuple(playlist, pos); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
407 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
408 |
363
958855dae693
[svn] - fix other plugins dependant on the playlist framework
nenolod
parents:
357
diff
changeset
|
409 title = g_strdup(playlist->position->title); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
410 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
411 cue_ip.set_info(title, length, rate, freq, nch); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
412 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
413 |
559 | 414 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
|
415 { |
1557
c8c725957643
make cuesheet plugin work again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1510
diff
changeset
|
416 gchar *path2 = g_strdup(uri + 6); // "cue://" is stripped. |
809 | 417 gchar *_path = strchr(path2, '?'); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
418 gint track = 0; |
1363
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
419 ProbeResult *pr; |
559 | 420 InputPlugin *real_ip_plugin; |
1737
b729c7a72c20
- remove get_song_info interface.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1692
diff
changeset
|
421 Tuple *tuple = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
422 |
809 | 423 #ifdef DEBUG |
424 g_print("f: play_cue_uri\n"); | |
848 | 425 g_print("play_cue_uri: playback = %p\n", data); |
1557
c8c725957643
make cuesheet plugin work again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1510
diff
changeset
|
426 g_print("play_cue_uri: path2 = %s\n", path2); |
809 | 427 #endif |
848 | 428 |
809 | 429 /* stop watchdog thread */ |
430 g_mutex_lock(cue_mutex); | |
431 watchdog_state = STOP; | |
848 | 432 g_mutex_unlock(cue_mutex); |
809 | 433 g_cond_signal(cue_cond); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
434 |
809 | 435 if (_path != NULL && *_path == '?') |
436 { | |
437 *_path = '\0'; | |
438 _path++; | |
439 track = atoi(_path); | |
440 } | |
441 cur_cue_track = track; | |
1557
c8c725957643
make cuesheet plugin work again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1510
diff
changeset
|
442 cache_cue_file(path2); //path2 should be uri. |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
443 |
1978 | 444 if (cue_file == NULL || !aud_vfs_file_test(cue_file, G_FILE_TEST_EXISTS)) |
809 | 445 return; |
241
a1e15310703e
[svn] Crash avoidance for zeroed cue sheets. By TiCPU, submitted in #audacious.
chainsaw
parents:
239
diff
changeset
|
446 |
2073 | 447 pr = aud_input_check_file(cue_file, FALSE); |
1363
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
448 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
|
449 return; |
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
450 |
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
451 real_ip_plugin = pr->ip; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
452 |
559 | 453 if (real_ip_plugin != NULL) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
454 { |
809 | 455 if (real_ip) |
456 g_free(real_ip); | |
1999
3afd18361a10
change the way of duplicating original playback.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1997
diff
changeset
|
457 |
3afd18361a10
change the way of duplicating original playback.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1997
diff
changeset
|
458 /* duplicate original playback and modify */ |
3afd18361a10
change the way of duplicating original playback.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1997
diff
changeset
|
459 real_ip = (InputPlayback *)g_memdup(data, sizeof(InputPlayback)); |
559 | 460 real_ip->plugin = real_ip_plugin; |
461 real_ip->plugin->set_info = set_info_override; | |
462 real_ip->plugin->output = cue_ip.output; | |
463 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
|
464 |
2162 | 465 data->playing = 1; |
466 | |
1363
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
467 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
|
468 g_usleep(50000); // wait for 50msec while real input plugin is initializing. |
809 | 469 |
1363
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
470 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
|
471 #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
|
472 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
|
473 #endif |
809 | 474 real_ip->plugin->mseek(real_ip, finetune_seek ? finetune_seek : cue_tracks[track].index); |
475 } | |
476 else | |
477 real_ip->plugin->seek(real_ip, finetune_seek ? finetune_seek / 1000 : cue_tracks[track].index / 1000 + 1); | |
478 | |
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
|
479 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
|
480 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
|
481 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
|
482 #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
|
483 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
|
484 #endif |
1737
b729c7a72c20
- remove get_song_info interface.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1692
diff
changeset
|
485 |
b729c7a72c20
- remove get_song_info interface.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1692
diff
changeset
|
486 tuple = real_ip->plugin->get_song_tuple(cue_file); |
b729c7a72c20
- remove get_song_info interface.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1692
diff
changeset
|
487 if(tuple) { |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
488 cue_tracks[last_cue_track].index = aud_tuple_get_int(tuple, FIELD_LENGTH, NULL); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1961
diff
changeset
|
489 aud_tuple_free(tuple); tuple = NULL; |
1737
b729c7a72c20
- remove get_song_info interface.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1692
diff
changeset
|
490 } |
860 | 491 |
809 | 492 /* kick watchdog thread */ |
493 g_mutex_lock(cue_mutex); | |
494 watchdog_state = RUN; | |
848 | 495 g_mutex_unlock(cue_mutex); |
809 | 496 g_cond_signal(cue_cond); |
853
def1af87ae1f
[svn] - add 1sec guard time after issue of playlist_prev/next.
yaz
parents:
848
diff
changeset
|
497 #ifdef DEBUG |
848 | 498 g_print("watchdog activated\n"); |
853
def1af87ae1f
[svn] - add 1sec guard time after issue of playlist_prev/next.
yaz
parents:
848
diff
changeset
|
499 #endif |
1363
da987606127e
first attempt to adapt cuesheet to the new threading model.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1274
diff
changeset
|
500 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
|
501 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
|
502 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
|
503 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
|
504 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
|
505 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
506 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
507 |
809 | 508 #ifdef DEBUG |
509 g_print("e: play_cue_uri\n"); | |
510 #endif | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
511 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
512 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
513 /******************************************************* watchdog */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
514 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
515 /* |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
516 * This is fairly hard to explain. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
517 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
518 * 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
|
519 * 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
|
520 * right place. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
521 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
522 * 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
|
523 * as well as I was hoping. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
524 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
525 * 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
|
526 * cool with it. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
527 * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
528 * - nenolod |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
529 */ |
809 | 530 static gpointer watchdog_func(gpointer data) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
531 { |
809 | 532 gint time = 0; |
533 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
|
534 GTimeVal sleep_time; |
809 | 535 |
536 #ifdef DEBUG | |
537 g_print("f: watchdog\n"); | |
538 #endif | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
539 |
809 | 540 while(1) { |
853
def1af87ae1f
[svn] - add 1sec guard time after issue of playlist_prev/next.
yaz
parents:
848
diff
changeset
|
541 #if 0 |
809 | 542 #if DEBUG |
848 | 543 g_print("time = %d cur = %d cidx = %d nidx = %d last = %d\n", |
544 time, cur_cue_track, | |
809 | 545 cue_tracks[cur_cue_track].index, |
848 | 546 cue_tracks[cur_cue_track+1].index, last_cue_track); |
809 | 547 #endif |
548 #endif | |
549 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
|
550 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
|
551 |
809 | 552 g_mutex_lock(cue_mutex); |
553 switch(watchdog_state) { | |
554 case EXIT: | |
555 #ifdef DEBUG | |
556 g_print("e: watchdog exit\n"); | |
557 #endif | |
1274
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
558 g_mutex_unlock(cue_mutex); // stop() will lock cue_mutex. |
809 | 559 stop(real_ip); // need not to care about real_ip != NULL here. |
560 g_thread_exit(NULL); | |
561 break; | |
562 case RUN: | |
563 if(!playlist) | |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2050
diff
changeset
|
564 playlist = aud_playlist_get_active(); |
809 | 565 g_cond_timed_wait(cue_cond, cue_mutex, &sleep_time); |
566 break; | |
567 case STOP: | |
568 #ifdef DEBUG | |
569 g_print("watchdog deactivated\n"); | |
570 #endif | |
571 g_cond_wait(cue_cond, cue_mutex); | |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2050
diff
changeset
|
572 playlist = aud_playlist_get_active(); |
809 | 573 break; |
574 } | |
575 g_mutex_unlock(cue_mutex); | |
576 | |
859
301d03667d2f
[svn] - make use of playlist_set_position() instead of playlist_prev/next(). now cuesheet directly jumps to the objective track.
yaz
parents:
853
diff
changeset
|
577 if(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
|
578 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
|
579 |
2075 | 580 time = audacious_drct_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
|
581 #if 0 |
8702f72b3382
- reduce guard time in initiating play to avoid stuttering start.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1364
diff
changeset
|
582 #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
|
583 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
|
584 #endif |
8702f72b3382
- reduce guard time in initiating play to avoid stuttering start.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1364
diff
changeset
|
585 #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
|
586 if(time == 0 || time <= target_time) |
848 | 587 continue; |
809 | 588 |
589 // prev track | |
590 if (time < cue_tracks[cur_cue_track].index) | |
591 { | |
1274
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
592 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
|
593 gint oldpos = cur_cue_track; |
809 | 594 #ifdef DEBUG |
595 g_print("i: watchdog prev\n"); | |
596 g_print("time = %d cur = %d cidx = %d nidx = %d\n", time, cur_cue_track, | |
597 cue_tracks[cur_cue_track].index, | |
598 cue_tracks[cur_cue_track+1].index); | |
599 #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
|
600 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
|
601 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
|
602 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
|
603 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
|
604 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
|
605 #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
|
606 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
|
607 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
|
608 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
|
609 #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
|
610 } |
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
|
611 |
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
|
612 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
|
613 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
|
614 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
|
615 #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
|
616 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
|
617 #endif |
1274
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
618 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
|
619 continue; |
809 | 620 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
621 |
809 | 622 // next track |
861 | 623 if (cur_cue_track + 1 < last_cue_track && time > cue_tracks[cur_cue_track + 1].index) |
809 | 624 { |
1274
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
625 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
|
626 gint oldpos = cur_cue_track; |
809 | 627 #ifdef DEBUG |
628 g_print("i: watchdog next\n"); | |
860 | 629 g_print("time = %d cur = %d cidx = %d nidx = %d last = %d lidx = %d\n", time, cur_cue_track, |
809 | 630 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
|
631 cue_tracks[cur_cue_track+1].index, |
860 | 632 last_cue_track, cue_tracks[last_cue_track].index); |
809 | 633 #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
|
634 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
|
635 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
|
636 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
|
637 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
|
638 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
|
639 #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
|
640 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
|
641 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
|
642 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
|
643 #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
|
644 } |
809 | 645 |
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
|
646 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
|
647 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
|
648 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
|
649 #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
|
650 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
|
651 #endif |
2061 | 652 if(aud_cfg->stopaftersong) { |
1274
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
653 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
|
654 continue; |
848 | 655 } |
853
def1af87ae1f
[svn] - add 1sec guard time after issue of playlist_prev/next.
yaz
parents:
848
diff
changeset
|
656 else { |
1274
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
657 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
|
658 continue; |
853
def1af87ae1f
[svn] - add 1sec guard time after issue of playlist_prev/next.
yaz
parents:
848
diff
changeset
|
659 } |
809 | 660 } |
848 | 661 |
861 | 662 // last track |
848 | 663 if (cur_cue_track + 1 == last_cue_track && |
861 | 664 (cue_tracks[last_cue_track].index - time < 500 || |
665 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
|
666 if(!real_ip->output->buffer_playing()) { |
2057
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2050
diff
changeset
|
667 gint pos = aud_playlist_get_position(playlist); |
cf4fa45ffd80
playlist API vtabling
William Pitcock <nenolod@atheme.org>
parents:
2050
diff
changeset
|
668 if (pos + 1 == aud_playlist_get_length(playlist)) { |
848 | 669 #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
|
670 g_print("i: watchdog eof reached\n\n"); |
848 | 671 #endif |
2061 | 672 if(aud_cfg->repeat) { |
1274
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
673 static gint incr = 0; |
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
674 incr = -pos; |
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
675 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
|
676 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
|
677 } |
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 else { |
1274
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
679 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
|
680 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
|
681 } |
860 | 682 } |
683 else { | |
2061 | 684 if(aud_cfg->stopaftersong) { |
1274
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
685 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
|
686 continue; |
987
8f432e790cfb
[svn] - add check for cfg.stopaftersong at the end of cue.
yaz
parents:
932
diff
changeset
|
687 } |
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 #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
|
689 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
|
690 #endif |
1274
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
691 static gint incr = 1; |
bcf6dc9564f4
- eliminate gdk_threads_*() based on giacomo's suggestion.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1267
diff
changeset
|
692 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
|
693 continue; |
860 | 694 } |
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
|
695 } |
848 | 696 } |
809 | 697 } |
698 #ifdef DEBUG | |
860 | 699 g_print("e: watchdog\n"); |
809 | 700 #endif |
701 return NULL; // dummy. | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
702 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
703 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
704 /******************************************************** cuefile */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
705 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
706 static void free_cue_info(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
707 { |
356 | 708 g_free(cue_file); cue_file = NULL; |
709 g_free(cue_title); cue_title = NULL; | |
710 g_free(cue_performer); cue_performer = NULL; | |
711 g_free(cue_genre); cue_genre = NULL; | |
712 g_free(cue_year); cue_year = NULL; | |
713 g_free(cue_track); cue_track = NULL; | |
714 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
715 for (; last_cue_track > 0; last_cue_track--) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
716 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
|
717 cue_tracks[last_cue_track-1].performer = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
718 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
|
719 cue_tracks[last_cue_track-1].title = NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
720 } |
809 | 721 #ifdef DEBUG |
860 | 722 g_print("free_cue_info: last_cue_track = %d\n", last_cue_track); |
809 | 723 #endif |
724 last_cue_track = 0; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
725 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
726 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
727 static void cache_cue_file(char *f) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
728 { |
1978 | 729 VFSFile *file = aud_vfs_fopen(f, "rb"); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
730 gchar line[MAX_CUE_LINE_LENGTH+1]; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
731 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
732 if(!file) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
733 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
734 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
735 while (TRUE) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
736 gint p; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
737 gint q; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
738 |
1978 | 739 if (aud_vfs_fgets(line, MAX_CUE_LINE_LENGTH+1, file) == NULL) { |
740 aud_vfs_fclose(file); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
741 return; |
860 | 742 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
743 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
744 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
|
745 if (!line[p]) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
746 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
747 for (q = p; line[q] && !isspace((int) line[q]); q++); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
748 if (!line[q]) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
749 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
750 line[q] = '\0'; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
751 for (q++; line[q] && isspace((int) line[q]); q++); |
356 | 752 if (strcasecmp(line+p, "REM") == 0) { |
1762
cf97a7767faa
now cuesheet can handle INDEX more than 99 minutes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1737
diff
changeset
|
753 for (p = q; line[p] && !isspace((int) line[p]); p++); |
cf97a7767faa
now cuesheet can handle INDEX more than 99 minutes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1737
diff
changeset
|
754 if (!line[p]) |
356 | 755 continue; |
1762
cf97a7767faa
now cuesheet can handle INDEX more than 99 minutes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1737
diff
changeset
|
756 line[p] = '\0'; |
cf97a7767faa
now cuesheet can handle INDEX more than 99 minutes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1737
diff
changeset
|
757 for (p++; line[p] && isspace((int) line[p]); p++); |
356 | 758 if(strcasecmp(line+q, "GENRE") == 0) { |
1762
cf97a7767faa
now cuesheet can handle INDEX more than 99 minutes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1737
diff
changeset
|
759 fix_cue_argument(line+p); |
356 | 760 if (last_cue_track == 0) |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1999
diff
changeset
|
761 cue_genre = aud_str_to_utf8(line + p); |
356 | 762 } |
763 if(strcasecmp(line+q, "DATE") == 0) { | |
764 gchar *tmp; | |
1762
cf97a7767faa
now cuesheet can handle INDEX more than 99 minutes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1737
diff
changeset
|
765 fix_cue_argument(line+p); |
356 | 766 if (last_cue_track == 0) { |
1762
cf97a7767faa
now cuesheet can handle INDEX more than 99 minutes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1737
diff
changeset
|
767 tmp = g_strdup(line + p); |
356 | 768 if (tmp) { |
769 cue_year = strtok(tmp, "/"); // XXX: always in the same format? | |
770 } | |
771 } | |
772 } | |
773 } | |
774 else if (strcasecmp(line+p, "PERFORMER") == 0) { | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
775 fix_cue_argument(line+q); |
308
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
776 |
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
777 if (last_cue_track == 0) |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1999
diff
changeset
|
778 cue_performer = aud_str_to_utf8(line + q); |
308
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
779 else |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1999
diff
changeset
|
780 cue_tracks[last_cue_track - 1].performer = aud_str_to_utf8(line + q); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
781 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
782 else if (strcasecmp(line+p, "FILE") == 0) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
783 gchar *tmp = g_path_get_dirname(f); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
784 fix_cue_argument(line+q); |
1762
cf97a7767faa
now cuesheet can handle INDEX more than 99 minutes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1737
diff
changeset
|
785 cue_file = g_strdup_printf("%s/%s", tmp, line+q); //XXX need to check encoding? |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
786 g_free(tmp); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
787 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
788 else if (strcasecmp(line+p, "TITLE") == 0) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
789 fix_cue_argument(line+q); |
308
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
790 if (last_cue_track == 0) |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1999
diff
changeset
|
791 cue_title = aud_str_to_utf8(line + q); |
308
1bf162c7b4b9
[svn] - cuesheet plugin improvements via hiro @ audacious boards
nenolod
parents:
251
diff
changeset
|
792 else |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1999
diff
changeset
|
793 cue_tracks[last_cue_track-1].title = aud_str_to_utf8(line + q); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
794 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
795 else if (strcasecmp(line+p, "TRACK") == 0) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
796 gint track; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
797 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
798 fix_cue_argument(line+q); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
799 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
|
800 line[p] = '\0'; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
801 for (; line[q] && line[q] == '0'; q++); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
802 if (!line[q]) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
803 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
804 track = atoi(line+q); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
805 if (track >= MAX_CUE_TRACKS) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
806 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
807 last_cue_track = track; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
808 cue_tracks[last_cue_track-1].index = 0; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
809 cue_tracks[last_cue_track-1].performer = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
810 cue_tracks[last_cue_track-1].title = NULL; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
811 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
812 else if (strcasecmp(line+p, "INDEX") == 0) { |
1762
cf97a7767faa
now cuesheet can handle INDEX more than 99 minutes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1737
diff
changeset
|
813 gint min, sec, frac; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
814 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
|
815 if (!line[p]) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
816 continue; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
817 for (p++; line[p] && isspace((int) line[p]); p++); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
818 for (q = p; line[q] && !isspace((int) line[q]); q++); |
1762
cf97a7767faa
now cuesheet can handle INDEX more than 99 minutes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1737
diff
changeset
|
819 |
cf97a7767faa
now cuesheet can handle INDEX more than 99 minutes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1737
diff
changeset
|
820 if(sscanf(line+p, "%d:%d:%d", &min, &sec, &frac) == 3) { |
cf97a7767faa
now cuesheet can handle INDEX more than 99 minutes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1737
diff
changeset
|
821 // printf("%3d:%02d:%02d\n", min, sec, frac); |
cf97a7767faa
now cuesheet can handle INDEX more than 99 minutes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1737
diff
changeset
|
822 cue_tracks[last_cue_track-1].index = min * 60000 + sec * 1000 + frac * 10; |
cf97a7767faa
now cuesheet can handle INDEX more than 99 minutes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1737
diff
changeset
|
823 } |
cf97a7767faa
now cuesheet can handle INDEX more than 99 minutes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1737
diff
changeset
|
824 } |
cf97a7767faa
now cuesheet can handle INDEX more than 99 minutes.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1737
diff
changeset
|
825 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
826 |
1978 | 827 aud_vfs_fclose(file); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
828 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
829 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
830 static void fix_cue_argument(char *line) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
831 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
832 if (line[0] == '"') { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
833 gchar *l2; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
834 for (l2 = line+1; *l2 && *l2 != '"'; l2++) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
835 *(l2-1) = *l2; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
836 *(l2-1) = *l2; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
837 for (; *line && *line != '"'; line++) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
838 if (*line == '\\' && *(line+1)) { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
839 for (l2 = line+1; *l2 && *l2 != '"'; l2++) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
840 *(l2-1) = *l2; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
841 *(l2-1) = *l2; |
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 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
844 *line = '\0'; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
845 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
846 else { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
847 for (; *line && *line != '\r' && *line != '\n'; line++); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
848 *line = '\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 } |