annotate src/cue/cuesheet.c @ 2505:590c9610f968

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