Mercurial > otakunoraifu
comparison music2/koedec_ogg.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 | a85cdca1980a |
children | 15a18fbe6f21 |
comparison
equal
deleted
inserted
replaced
44:a85cdca1980a | 45:53a311ea8289 |
---|---|
102 static int fseek_wrap(FILE *f,ogg_int64_t off,int whence){ | 102 static int fseek_wrap(FILE *f,ogg_int64_t off,int whence){ |
103 if(f==NULL)return(-1); | 103 if(f==NULL)return(-1); |
104 return fseek(f,off,whence); | 104 return fseek(f,off,whence); |
105 } | 105 } |
106 | 106 |
107 | |
108 int ogg_get_rate(FILE *stream) | |
109 { | |
110 OggVorbis_File vf; | |
111 ov_callbacks callback; | |
112 callback.read_func = (size_t (*)(void*, size_t, size_t, void*))fread; | |
113 callback.seek_func = (int (*)(void*, ogg_int64_t, int))fseek_wrap; | |
114 callback.tell_func = (long int (*)(void*))ftell; | |
115 callback.close_func = NULL; | |
116 ov_test_callbacks(stream, &vf, NULL, 0, callback); | |
117 int rate = vf.vi->rate; | |
118 ov_clear(&vf); | |
119 return rate; | |
120 } | |
121 | |
122 extern char* decode_koe_ogg(AvgKoeInfo info, int* dest_len) { | 107 extern char* decode_koe_ogg(AvgKoeInfo info, int* dest_len) { |
123 if (info.stream == 0) return 0; | 108 if (info.stream == 0) return 0; |
124 // Voice ファイルを直接指定すると全ストリームを再生してしまうので | 109 // Voice ファイルを直接指定すると全ストリームを再生してしまうので |
125 // 必要な部分だけ切り出して callback 経由で帰す | 110 // 必要な部分だけ切り出して callback 経由で帰す |
126 fseek(info.stream, info.offset, 0); | 111 fseek(info.stream, info.offset, 0); |