comparison music2/koedec.cc @ 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 01aa5ddf7dc8
children 35ce1a30f3f9
comparison
equal deleted inserted replaced
44:a85cdca1980a 45:53a311ea8289
84 static AvgKoeCache koe_cache; 84 static AvgKoeCache koe_cache;
85 85
86 AvgKoeInfo FindKoe(int file_number, int index) { 86 AvgKoeInfo FindKoe(int file_number, int index) {
87 return koe_cache.Find(file_number, index); 87 return koe_cache.Find(file_number, index);
88 }; 88 };
89 #if HAVE_LIBVORBISFILE || HAVE_LIBVORBISIDEC 89
90 extern int ogg_get_rate(FILE*);
91 #endif
92 AvgKoeInfo AvgKoeCache::Find(int file_number, int index) { 90 AvgKoeInfo AvgKoeCache::Find(int file_number, int index) {
93 AvgKoeInfo info; 91 AvgKoeInfo info;
94 info.stream = 0; info.length = 0; info.offset = 0; 92 info.stream = 0; info.length = 0; info.offset = 0;
95 93
96 list<AvgKoeHead>::iterator it; 94 list<AvgKoeHead>::iterator it;
111 sprintf(fname, "z%04d.ovk", file_number); 109 sprintf(fname, "z%04d.ovk", file_number);
112 arcinfo = file_searcher.Find(FILESEARCH::KOE,fname,".ovk"); 110 arcinfo = file_searcher.Find(FILESEARCH::KOE,fname,".ovk");
113 } 111 }
114 #if HAVE_LIBVORBISFILE || HAVE_LIBVORBISIDEC 112 #if HAVE_LIBVORBISFILE || HAVE_LIBVORBISIDEC
115 if (arcinfo == 0) { 113 if (arcinfo == 0) {
114 //FIXME: OMG that's ugly, improve it as soon as you can!
116 DIRFILE* koedir = (DIRFILE*) file_searcher.MakeARCFILE((FILESEARCH::ARCTYPE)0, "koe"); 115 DIRFILE* koedir = (DIRFILE*) file_searcher.MakeARCFILE((FILESEARCH::ARCTYPE)0, "koe");
117 sprintf(fname, "%04d", file_number); 116 sprintf(fname, "%04d", file_number);
118 koedir = new DIRFILE(koedir->SearchFile(fname)); 117 koedir = new DIRFILE(koedir->SearchFile(fname));
119 sprintf(fname, "z%04d%05d.ogg", file_number, index); 118 sprintf(fname, "z%04d%05d.ogg", file_number, index);
120 arcinfo = koedir->Find(fname, ".ogg"); 119 arcinfo = koedir->Find(fname, ".ogg");
121 delete koedir; 120 delete koedir;
122 121
123 if (arcinfo == 0) return info; 122 if (arcinfo == 0) return info;
124 FILE* stream = arcinfo->OpenFile(); 123 FILE* stream = arcinfo->OpenFile(&info.length);
125 info.rate = ogg_get_rate(stream);
126 fseek(stream, 0L, SEEK_END);
127 info.length = ftell(stream);
128 fseek(stream, 0L, SEEK_CUR);
129 info.type = koe_ogg; 124 info.type = koe_ogg;
130 info.stream = stream; 125 info.stream = stream;
131 return info; 126 return info;
132 } 127 }
133 #endif 128 #endif