Mercurial > audlegacy-plugins
comparison src/flacng/plugin.c @ 1255:37598c8f4425
- Add flac_is_our_fd()
author | Ralf Ertzinger <ralf@skytale.net> |
---|---|
date | Thu, 12 Jul 2007 22:34:44 +0200 |
parents | 626f78ff2439 |
children | 574ee15195f3 |
comparison
equal
deleted
inserted
replaced
1248:0e0f73fed025 | 1255:37598c8f4425 |
---|---|
55 NULL, | 55 NULL, |
56 NULL, | 56 NULL, |
57 flac_get_song_tuple, // get a tuple | 57 flac_get_song_tuple, // get a tuple |
58 NULL, | 58 NULL, |
59 NULL, // write a tuple back to a file as a tag | 59 NULL, // write a tuple back to a file as a tag |
60 /* flac_is_our_fd */ NULL, // version of is_our_file which is handed an FD | 60 flac_is_our_fd, // version of is_our_file which is handed an FD |
61 flac_fmts // vector of fileextensions allowed by the plugin | 61 flac_fmts // vector of fileextensions allowed by the plugin |
62 }; | 62 }; |
63 | 63 |
64 InputPlugin *flac_iplist[] = { &flac_ip, NULL }; | 64 InputPlugin *flac_iplist[] = { &flac_ip, NULL }; |
65 | 65 |
173 _LEAVE; | 173 _LEAVE; |
174 } | 174 } |
175 | 175 |
176 /* --- */ | 176 /* --- */ |
177 | 177 |
178 gboolean flac_is_our_file(gchar* filename) { | 178 gboolean flac_is_our_fd(gchar* filename, VFSFile* fd) { |
179 | 179 |
180 _ENTER; | 180 _ENTER; |
181 | 181 |
182 if (!plugin_initialized) { | 182 if (!plugin_initialized) { |
183 _ERROR("Plugin not initialized!"); | 183 _ERROR("Plugin not initialized!"); |
184 _LEAVE FALSE; | 184 _LEAVE FALSE; |
185 } | 185 } |
186 | 186 |
187 _DEBUG("Testing file: %s", filename); | 187 _DEBUG("Testing file: %s", filename); |
188 | 188 |
189 if (FALSE == read_metadata(filename, test_decoder, test_info)) { | 189 if (FALSE == read_metadata(fd, test_decoder, test_info)) { |
190 _DEBUG("File not handled by this plugin!"); | 190 _DEBUG("File not handled by this plugin!"); |
191 _LEAVE FALSE; | 191 _LEAVE FALSE; |
192 } | 192 } |
193 | 193 |
194 /* | 194 /* |
201 | 201 |
202 /* | 202 /* |
203 * If we get here, the file is supported by FLAC. | 203 * If we get here, the file is supported by FLAC. |
204 * The stream characteristics have been filled in by | 204 * The stream characteristics have been filled in by |
205 * the metadata callback. | 205 * the metadata callback. |
206 * We can close the stream now. | 206 * Do not close the stream, though. |
207 */ | 207 */ |
208 | |
209 vfs_fclose(test_info->input_stream); | |
210 test_info->input_stream = NULL; | 208 test_info->input_stream = NULL; |
211 | 209 |
212 | 210 |
213 _DEBUG("Stream encoded at %d Hz, %d bps, %d channels", | 211 _DEBUG("Stream encoded at %d Hz, %d bps, %d channels", |
214 test_info->stream.samplerate, | 212 test_info->stream.samplerate, |
236 _DEBUG("Accepting file %s", filename); | 234 _DEBUG("Accepting file %s", filename); |
237 | 235 |
238 reset_info(test_info); | 236 reset_info(test_info); |
239 | 237 |
240 _LEAVE TRUE; | 238 _LEAVE TRUE; |
239 } | |
240 | |
241 /* --- */ | |
242 | |
243 gboolean flac_is_our_file(gchar* filename) { | |
244 | |
245 VFSFile* fd; | |
246 gboolean ret; | |
247 | |
248 _ENTER; | |
249 | |
250 _DEBUG("Testing file: %s", filename); | |
251 /* | |
252 * Open the file | |
253 */ | |
254 if (NULL == (fd = vfs_fopen(filename, "rb"))) { | |
255 _ERROR("Could not open file for reading! (%s)", filename); | |
256 _LEAVE FALSE; | |
257 } | |
258 | |
259 ret = flac_is_our_fd(filename, fd); | |
260 | |
261 vfs_fclose(fd); | |
262 | |
263 _LEAVE ret; | |
241 } | 264 } |
242 | 265 |
243 /* --- */ | 266 /* --- */ |
244 | 267 |
245 void squeeze_audio(gint32* src, void* dst, guint count, guint src_res, guint dst_res) { | 268 void squeeze_audio(gint32* src, void* dst, guint count, guint src_res, guint dst_res) { |
528 | 551 |
529 /* --- */ | 552 /* --- */ |
530 | 553 |
531 void flac_play_file (InputPlayback* input) { | 554 void flac_play_file (InputPlayback* input) { |
532 | 555 |
556 VFSFile* fd; | |
533 gint l; | 557 gint l; |
534 | 558 |
535 _ENTER; | 559 _ENTER; |
536 | 560 |
537 if (!plugin_initialized) { | 561 if (!plugin_initialized) { |
543 * This will end a currently running decoder thread | 567 * This will end a currently running decoder thread |
544 */ | 568 */ |
545 input->playing = FALSE; | 569 input->playing = FALSE; |
546 xmms_usleep(20000); | 570 xmms_usleep(20000); |
547 | 571 |
548 if (FALSE == read_metadata(input->filename, main_decoder, main_info)) { | 572 /* |
573 * Open the file | |
574 */ | |
575 if (NULL == (fd = vfs_fopen(filename, "rb"))) { | |
576 _ERROR("Could not open file for reading! (%s)", filename); | |
577 _LEAVE; | |
578 } | |
579 | |
580 if (FALSE == read_metadata(fd, main_decoder, main_info)) { | |
549 _ERROR("Could not prepare file for playing!"); | 581 _ERROR("Could not prepare file for playing!"); |
550 _LEAVE; | 582 _LEAVE; |
551 } | 583 } |
552 | 584 |
553 /* | 585 /* |