Mercurial > otakunoraifu
changeset 45:53a311ea8289
Patched an old patch of mine (OGG koe files handling)... It's a bit less ugly, and it works with tremor!
author | thib |
---|---|
date | Wed, 25 Mar 2009 17:32:52 +0000 |
parents | a85cdca1980a |
children | 3aa3d244ad90 |
files | music2/koedec.cc music2/koedec_ogg.cc |
diffstat | 2 files changed, 4 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/music2/koedec.cc +++ b/music2/koedec.cc @@ -86,9 +86,7 @@ static AvgKoeCache koe_cache; AvgKoeInfo FindKoe(int file_number, int index) { return koe_cache.Find(file_number, index); }; -#if HAVE_LIBVORBISFILE || HAVE_LIBVORBISIDEC -extern int ogg_get_rate(FILE*); -#endif + AvgKoeInfo AvgKoeCache::Find(int file_number, int index) { AvgKoeInfo info; info.stream = 0; info.length = 0; info.offset = 0; @@ -113,19 +111,16 @@ AvgKoeInfo AvgKoeCache::Find(int file_nu } #if HAVE_LIBVORBISFILE || HAVE_LIBVORBISIDEC if (arcinfo == 0) { + //FIXME: OMG that's ugly, improve it as soon as you can! DIRFILE* koedir = (DIRFILE*) file_searcher.MakeARCFILE((FILESEARCH::ARCTYPE)0, "koe"); sprintf(fname, "%04d", file_number); koedir = new DIRFILE(koedir->SearchFile(fname)); sprintf(fname, "z%04d%05d.ogg", file_number, index); arcinfo = koedir->Find(fname, ".ogg"); delete koedir; - + if (arcinfo == 0) return info; - FILE* stream = arcinfo->OpenFile(); - info.rate = ogg_get_rate(stream); - fseek(stream, 0L, SEEK_END); - info.length = ftell(stream); - fseek(stream, 0L, SEEK_CUR); + FILE* stream = arcinfo->OpenFile(&info.length); info.type = koe_ogg; info.stream = stream; return info;
--- a/music2/koedec_ogg.cc +++ b/music2/koedec_ogg.cc @@ -104,21 +104,6 @@ static int fseek_wrap(FILE *f,ogg_int64_ return fseek(f,off,whence); } - -int ogg_get_rate(FILE *stream) -{ - OggVorbis_File vf; - ov_callbacks callback; - callback.read_func = (size_t (*)(void*, size_t, size_t, void*))fread; - callback.seek_func = (int (*)(void*, ogg_int64_t, int))fseek_wrap; - callback.tell_func = (long int (*)(void*))ftell; - callback.close_func = NULL; - ov_test_callbacks(stream, &vf, NULL, 0, callback); - int rate = vf.vi->rate; - ov_clear(&vf); - return rate; -} - extern char* decode_koe_ogg(AvgKoeInfo info, int* dest_len) { if (info.stream == 0) return 0; // Voice ファイルを直接指定すると全ストリームを再生してしまうので