Mercurial > audlegacy
comparison Plugins/Input/cue/cuesheet.c @ 1468:5e2482d471ec trunk
[svn] - tuple builder
author | nenolod |
---|---|
date | Wed, 02 Aug 2006 19:24:40 -0700 |
parents | 6fd38612425b |
children | 27b62d78f35e |
comparison
equal
deleted
inserted
replaced
1467:6fd38612425b | 1468:5e2482d471ec |
---|---|
36 static void play(gchar *uri); | 36 static void play(gchar *uri); |
37 static void play_cue_uri(gchar *uri); | 37 static void play_cue_uri(gchar *uri); |
38 static gint get_time(void); | 38 static gint get_time(void); |
39 static void seek(gint time); | 39 static void seek(gint time); |
40 static void stop(void); | 40 static void stop(void); |
41 static TitleInput *get_tuple(gchar *uri); | |
42 static TitleInput *get_tuple_uri(gchar *uri); | |
41 | 43 |
42 static gchar *cue_performer = NULL; | 44 static gchar *cue_performer = NULL; |
43 static gchar *cue_title = NULL; | 45 static gchar *cue_title = NULL; |
44 static gchar *cue_file = NULL; | 46 static gchar *cue_file = NULL; |
45 static gint last_cue_track = 0; | 47 static gint last_cue_track = 0; |
80 NULL, | 82 NULL, |
81 NULL, | 83 NULL, |
82 NULL, /* XXX get_song_info iface */ | 84 NULL, /* XXX get_song_info iface */ |
83 NULL, | 85 NULL, |
84 NULL, | 86 NULL, |
85 #if 0 | |
86 get_tuple, | 87 get_tuple, |
87 #endif | |
88 NULL | 88 NULL |
89 }; | 89 }; |
90 | 90 |
91 static gboolean is_our_file(gchar *filename) | 91 static gboolean is_our_file(gchar *filename) |
92 { | 92 { |
97 if (!strncasecmp(filename, "cue://", 6)) | 97 if (!strncasecmp(filename, "cue://", 6)) |
98 return TRUE; | 98 return TRUE; |
99 | 99 |
100 ext = strrchr(filename, '.'); | 100 ext = strrchr(filename, '.'); |
101 | 101 |
102 if (!strncasecmp(ext, ".cue", 4)) | 102 if (!strncasecmp(ext, ".cue", 4) && ext + 5 == '\0') |
103 { | 103 { |
104 gint i; | 104 gint i; |
105 FILE *f = fopen(filename, "rb"); | 105 FILE *f = fopen(filename, "rb"); |
106 ret = FALSE; | 106 ret = TRUE; |
107 | 107 |
108 /* add the files, build cue urls, etc. */ | 108 /* add the files, build cue urls, etc. */ |
109 cache_cue_file(f); | 109 cache_cue_file(f); |
110 | 110 |
111 for (i = 0; i < last_cue_track; i++) | 111 for (i = 1; i < last_cue_track; i++) |
112 { | 112 { |
113 gchar _buf[65535]; | 113 gchar _buf[65535]; |
114 | 114 |
115 g_snprintf(_buf, 65535, "cue://%s?%d", filename, i); | 115 g_snprintf(_buf, 65535, "cue://%s?%d", filename, i); |
116 playlist_add_url(_buf); | 116 playlist_add_url(_buf); |
128 return get_output_time(); | 128 return get_output_time(); |
129 } | 129 } |
130 | 130 |
131 static void play(gchar *uri) | 131 static void play(gchar *uri) |
132 { | 132 { |
133 /* this isn't a cue:// uri? */ | |
134 if (strncasecmp("cue://", uri, 6)) | |
135 { | |
136 gchar *tmp = g_strdup_printf("cue://%s?0", uri); | |
137 play_cue_uri(tmp); | |
138 g_free(tmp); | |
139 return; | |
140 } | |
141 | |
133 play_cue_uri(uri); | 142 play_cue_uri(uri); |
134 } | 143 } |
135 | 144 |
136 static void seek(gint time) | 145 static TitleInput *get_tuple(gchar *uri) |
137 { | 146 { |
138 if (real_ip != NULL) | 147 TitleInput *ret; |
139 real_ip->seek(time); | 148 |
140 } | 149 /* this isn't a cue:// uri? */ |
141 | 150 if (strncasecmp("cue://", uri, 6)) |
142 static void stop(void) | 151 { |
143 { | 152 gchar *tmp = g_strdup_printf("cue://%s?0", uri); |
144 if (real_ip != NULL) | 153 ret = get_tuple_uri(tmp); |
145 real_ip->stop(); | 154 g_free(tmp); |
146 } | 155 return ret; |
147 | 156 } |
148 static void play_cue_uri(gchar *uri) | 157 |
158 return get_tuple_uri(uri); | |
159 } | |
160 | |
161 static TitleInput *get_tuple_uri(gchar *uri) | |
149 { | 162 { |
150 gchar *path2 = g_strdup(uri + 6); | 163 gchar *path2 = g_strdup(uri + 6); |
151 gchar *_path = strchr(path2, '?'); | 164 gchar *_path = strchr(path2, '?'); |
152 gint track = 0; | 165 gint track = 0; |
153 FILE *f; | 166 FILE *f; |
167 InputPlugin *dec; | |
168 TitleInput *phys_tuple, *out; | |
154 | 169 |
155 if (_path != NULL && *_path == '?') | 170 if (_path != NULL && *_path == '?') |
156 { | 171 { |
157 *_path = '\0'; | 172 *_path = '\0'; |
158 _path++; | 173 _path++; |
161 | 176 |
162 f = fopen(path2, "rb"); | 177 f = fopen(path2, "rb"); |
163 cache_cue_file(f); | 178 cache_cue_file(f); |
164 fclose(f); | 179 fclose(f); |
165 | 180 |
181 dec = input_check_file(cue_file, FALSE); | |
182 | |
183 if (dec == NULL) | |
184 return NULL; | |
185 | |
186 phys_tuple = dec->get_song_tuple(path2); | |
187 | |
188 out = bmp_title_input_new(); | |
189 | |
190 out->genre = g_strdup(phys_tuple->genre); | |
191 out->album_name = g_strdup(phys_tuple->album_name); | |
192 out->length = phys_tuple->length; | |
193 | |
194 bmp_title_input_free(phys_tuple); | |
195 | |
196 out->track_name = cue_tracks[track].title; | |
197 out->performer = cue_tracks[track].performer; | |
198 | |
199 return out; | |
200 } | |
201 | |
202 static void seek(gint time) | |
203 { | |
204 if (real_ip != NULL) | |
205 real_ip->seek(time); | |
206 } | |
207 | |
208 static void stop(void) | |
209 { | |
210 if (real_ip != NULL) | |
211 real_ip->stop(); | |
212 | |
213 free_cue_info(); | |
214 } | |
215 | |
216 static void play_cue_uri(gchar *uri) | |
217 { | |
218 gchar *path2 = g_strdup(uri + 6); | |
219 gchar *_path = strchr(path2, '?'); | |
220 gint track = 0; | |
221 FILE *f; | |
222 | |
223 if (_path != NULL && *_path == '?') | |
224 { | |
225 *_path = '\0'; | |
226 _path++; | |
227 track = atoi(_path); | |
228 } | |
229 | |
230 f = fopen(path2, "rb"); | |
231 cache_cue_file(f); | |
232 fclose(f); | |
233 | |
166 real_ip = input_check_file(cue_file, FALSE); | 234 real_ip = input_check_file(cue_file, FALSE); |
167 | 235 |
168 if (real_ip != NULL) | 236 if (real_ip != NULL) |
169 { | 237 { |
170 /* set_current_input_plugin(real_ip); */ | |
171 real_ip->output = cue_ip.output; | 238 real_ip->output = cue_ip.output; |
172 real_ip->play_file(cue_file); | 239 real_ip->play_file(cue_file); |
173 real_ip->seek(cue_tracks[track].index / 1000); | 240 real_ip->seek(cue_tracks[track].index / 1000); /* XXX: seek doesn't use frames? strange... -nenolod */ |
174 } | 241 } |
175 | 242 |
176 free_cue_info(); | 243 cur_cue_track = track; |
177 } | 244 } |
178 | 245 |
179 InputPlugin *get_iplugin_info(void) | 246 InputPlugin *get_iplugin_info(void) |
180 { | 247 { |
181 cue_ip.description = g_strdup_printf("Cuesheet Container Plugin"); | 248 cue_ip.description = g_strdup_printf("Cuesheet Container Plugin"); |