diff music2/koedec.cc @ 2:422f3cb3614b

Enabled voice playing with "%04d/%04d%05d.ogg" format. Don't use a cache for this
author thib
date Fri, 01 Aug 2008 19:17:15 +0000
parents 223b71206888
children c9e218c2c3f1
line wrap: on
line diff
--- a/music2/koedec.cc
+++ b/music2/koedec.cc
@@ -33,6 +33,7 @@
 #include <algorithm>
 #include"music.h"
 #include"system/file.h"
+#include"system/file_impl.h"
 
 using namespace std;
 
@@ -85,7 +86,7 @@ static AvgKoeCache koe_cache;
 AvgKoeInfo FindKoe(int file_number, int index) {
 	return koe_cache.Find(file_number, index);
 };
-
+extern int ogg_get_rate(FILE*);
 AvgKoeInfo AvgKoeCache::Find(int file_number, int index) {
 	AvgKoeInfo info;
 	info.stream = 0; info.length = 0; info.offset = 0;
@@ -108,6 +109,24 @@ AvgKoeInfo AvgKoeCache::Find(int file_nu
 			sprintf(fname, "z%04d.ovk", file_number);
 			arcinfo = file_searcher.Find(FILESEARCH::KOE,fname,".ovk");
 		}
+		if (arcinfo == 0) {
+			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);
+			info.type = koe_ogg;
+			info.stream = stream;
+			return info;
+		}
 		if (arcinfo == 0) return info;
 		FILE* stream = arcinfo->OpenFile();
 		delete arcinfo;
@@ -141,6 +160,7 @@ AvgKoeHead::AvgKoeHead(const AvgKoeHead&
 	table = from.table;
 	type = from.type;
 }
+
 AvgKoeHead::AvgKoeHead(FILE* _s, int _file_number, KoeType _type) {
 	char head[0x20];
 	stream = _s; file_number = _file_number;