Mercurial > audlegacy-plugins
comparison src/vorbis/vorbis.c @ 2134:fd0d5615f674
Fix seeking for non-streamed files.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Sat, 27 Oct 2007 10:45:20 -0500 |
parents | bba61e3fe881 |
children | 329267b09658 |
comparison
equal
deleted
inserted
replaced
2133:bba61e3fe881 | 2134:fd0d5615f674 |
---|---|
66 static int vorbis_check_fd(char *filename, VFSFile *stream); | 66 static int vorbis_check_fd(char *filename, VFSFile *stream); |
67 static void vorbis_play(InputPlayback *data); | 67 static void vorbis_play(InputPlayback *data); |
68 static void vorbis_stop(InputPlayback *data); | 68 static void vorbis_stop(InputPlayback *data); |
69 static void vorbis_pause(InputPlayback *data, short p); | 69 static void vorbis_pause(InputPlayback *data, short p); |
70 static void vorbis_seek(InputPlayback *data, int time); | 70 static void vorbis_seek(InputPlayback *data, int time); |
71 static void vorbis_get_song_info(char *filename, char **title, int *length); | |
72 static gchar *vorbis_generate_title(OggVorbis_File * vorbisfile, gchar * fn); | 71 static gchar *vorbis_generate_title(OggVorbis_File * vorbisfile, gchar * fn); |
73 static void vorbis_aboutbox(void); | 72 static void vorbis_aboutbox(void); |
74 static void vorbis_init(void); | 73 static void vorbis_init(void); |
75 static void vorbis_cleanup(void); | 74 static void vorbis_cleanup(void); |
76 static long vorbis_process_replaygain(float **pcm, int samples, int ch, | 75 static long vorbis_process_replaygain(float **pcm, int samples, int ch, |
107 .play_file = vorbis_play, | 106 .play_file = vorbis_play, |
108 .stop = vorbis_stop, | 107 .stop = vorbis_stop, |
109 .pause = vorbis_pause, | 108 .pause = vorbis_pause, |
110 .seek = vorbis_seek, | 109 .seek = vorbis_seek, |
111 .cleanup = vorbis_cleanup, | 110 .cleanup = vorbis_cleanup, |
112 .get_song_info = vorbis_get_song_info, | |
113 .file_info_box = vorbis_file_info_box, /* file info box, tag editing */ | 111 .file_info_box = vorbis_file_info_box, /* file info box, tag editing */ |
114 .get_song_tuple = get_song_tuple, | 112 .get_song_tuple = get_song_tuple, |
115 .is_our_file_from_vfs = vorbis_check_fd, | 113 .is_our_file_from_vfs = vorbis_check_fd, |
116 .vfs_extensions = vorbis_fmts, | 114 .vfs_extensions = vorbis_fmts, |
117 }; | 115 }; |
366 } | 364 } |
367 vi = ov_info(&vf, -1); | 365 vi = ov_info(&vf, -1); |
368 | 366 |
369 if (aud_vfs_is_streaming(fd->fd)) | 367 if (aud_vfs_is_streaming(fd->fd)) |
370 time = -1; | 368 time = -1; |
369 else | |
370 time = ov_time_total(&vf, -1) * 1000; | |
371 | 371 |
372 if (vi->channels > 2) { | 372 if (vi->channels > 2) { |
373 playback->eof = TRUE; | 373 playback->eof = TRUE; |
374 g_mutex_unlock(vf_mutex); | 374 g_mutex_unlock(vf_mutex); |
375 goto play_cleanup; | 375 goto play_cleanup; |
490 | 490 |
491 while (seekneeded != -1) | 491 while (seekneeded != -1) |
492 g_usleep(20000); | 492 g_usleep(20000); |
493 } | 493 } |
494 | 494 |
495 static void | |
496 vorbis_get_song_info(char *filename, char **title, int *length) | |
497 { | |
498 Tuple *tuple = get_song_tuple(filename); | |
499 | |
500 *length = aud_tuple_get_int(tuple, FIELD_LENGTH, NULL); | |
501 *title = aud_tuple_formatter_make_title_string(tuple, vorbis_cfg.tag_override ? | |
502 vorbis_cfg.tag_format : aud_get_gentitle_format()); | |
503 | |
504 aud_tuple_free(tuple); | |
505 } | |
506 | |
507 /* | |
508 static const gchar * | |
509 get_extension(const gchar * filename) | |
510 { | |
511 const gchar *ext; | |
512 if ((ext = strrchr(filename, '.'))) | |
513 ++ext; | |
514 return ext; | |
515 } | |
516 */ | |
517 | |
518 /* Make sure you've locked vf_mutex */ | 495 /* Make sure you've locked vf_mutex */ |
519 static gboolean | 496 static gboolean |
520 vorbis_update_replaygain(float *scale) | 497 vorbis_update_replaygain(float *scale) |
521 { | 498 { |
522 vorbis_comment *comment; | 499 vorbis_comment *comment; |
637 static Tuple * | 614 static Tuple * |
638 get_aud_tuple_for_vorbisfile(OggVorbis_File * vorbisfile, gchar *filename) | 615 get_aud_tuple_for_vorbisfile(OggVorbis_File * vorbisfile, gchar *filename) |
639 { | 616 { |
640 VFSVorbisFile *vfd = (VFSVorbisFile *) vorbisfile->datasource; | 617 VFSVorbisFile *vfd = (VFSVorbisFile *) vorbisfile->datasource; |
641 Tuple *tuple = NULL; | 618 Tuple *tuple = NULL; |
642 gboolean is_stream; | 619 gint length; |
643 vorbis_comment *comment; | 620 vorbis_comment *comment; |
644 | 621 |
645 tuple = aud_tuple_new_from_filename(filename); | 622 tuple = aud_tuple_new_from_filename(filename); |
646 is_stream = aud_vfs_is_streaming(vfd->fd); | 623 |
647 | 624 if (aud_vfs_is_streaming(vfd->fd)) |
648 /* Retrieve the length */ | 625 length = -1; |
649 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, | 626 else |
650 is_stream ? -1 : (ov_time_total(vorbisfile, -1) * 1000)); | 627 length = ov_time_total(vorbisfile, -1) * 1000; |
628 | |
629 /* associate with tuple */ | |
630 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, length); | |
651 | 631 |
652 if ((comment = ov_comment(vorbisfile, -1))) { | 632 if ((comment = ov_comment(vorbisfile, -1))) { |
653 gchar *tmps; | 633 gchar *tmps; |
654 _aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, vorbis_comment_query(comment, "title", 0)); | 634 _aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, vorbis_comment_query(comment, "title", 0)); |
655 _aud_tuple_associate_string(tuple, FIELD_ARTIST, NULL, vorbis_comment_query(comment, "artist", 0)); | 635 _aud_tuple_associate_string(tuple, FIELD_ARTIST, NULL, vorbis_comment_query(comment, "artist", 0)); |