1 /* 2 TiMidity++ -- MIDI to WAVE converter and player 3 Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp> infinite_recursenull4 Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi> 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 */ 20 21 /*************************************************************** 22 name: vorbis_dll dll: vorbis.dll 23 ***************************************************************/ 24 25 #ifdef HAVE_CONFIG_H 26 #include "config.h" 27 #endif /* HAVE_CONFIG_H */ 28 #include "interface.h" 29 30 #ifdef AU_VORBIS_DLL 31 32 #include <windows.h> 33 #include <vorbis/codec.h> 34 35 extern int load_vorbis_dll(void); 36 extern void free_vorbis_dll(void); 37 38 typedef void (*type_vorbis_info_init)(vorbis_info *vi); 39 typedef void (*type_vorbis_info_clear)(vorbis_info *vi); 40 typedef void (*type_vorbis_comment_init)(vorbis_comment *vc); 41 typedef void (*type_vorbis_comment_add)(vorbis_comment *vc, char *comment); 42 typedef void (*type_vorbis_comment_add_tag)(vorbis_comment *vc, char *tag, char *contents); 43 typedef char *(*type_vorbis_comment_query)(vorbis_comment *vc, char *tag, int count); 44 typedef int (*type_vorbis_comment_query_count)(vorbis_comment *vc, char *tag); 45 typedef void (*type_vorbis_comment_clear)(vorbis_comment *vc); 46 typedef int (*type_vorbis_block_init)(vorbis_dsp_state *v, vorbis_block *vb); 47 typedef int (*type_vorbis_block_clear)(vorbis_block *vb); 48 typedef void (*type_vorbis_dsp_clear)(vorbis_dsp_state *v); 49 typedef int (*type_vorbis_analysis_init)(vorbis_dsp_state *v,vorbis_info *vi); 50 ////typedef int (*type_vorbis_commentheader_out)(vorbis_comment *vc, ogg_packet *op); 51 typedef int (*type_vorbis_analysis_headerout)(vorbis_dsp_state *v,vorbis_comment *vc,ogg_packet *op,ogg_packet *op_comm,ogg_packet *op_code); 52 typedef float **(*type_vorbis_analysis_buffer)(vorbis_dsp_state *v,int vals); 53 typedef int (*type_vorbis_analysis_wrote)(vorbis_dsp_state *v,int vals); 54 typedef int (*type_vorbis_analysis_blockout)(vorbis_dsp_state *v,vorbis_block *vb); 55 typedef int (*type_vorbis_analysis)(vorbis_block *vb,ogg_packet *op); 56 typedef int (*type_vorbis_bitrate_addblock)(vorbis_block *vb); 57 typedef int (*type_vorbis_bitrate_flushpacket)(vorbis_dsp_state *vd, ogg_packet *op); 58 typedef int (*type_vorbis_synthesis_headerin)(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op); 59 typedef int (*type_vorbis_synthesis_init)(vorbis_dsp_state *v,vorbis_info *vi); 60 typedef int (*type_vorbis_synthesis)(vorbis_block *vb,ogg_packet *op); 61 typedef int (*type_vorbis_synthesis_blockin)(vorbis_dsp_state *v,vorbis_block *vb); 62 typedef int (*type_vorbis_synthesis_pcmout)(vorbis_dsp_state *v,float ***pcm); 63 typedef int (*type_vorbis_synthesis_read)(vorbis_dsp_state *v,int samples); 64 65 static struct vorbis_dll_ { 66 type_vorbis_info_init vorbis_info_init; 67 type_vorbis_info_clear vorbis_info_clear; 68 type_vorbis_comment_init vorbis_comment_init; 69 type_vorbis_comment_add vorbis_comment_add; 70 type_vorbis_comment_add_tag vorbis_comment_add_tag; 71 // type_vorbis_comment_query vorbis_comment_query; 72 // type_vorbis_comment_query_count vorbis_comment_query_count; 73 type_vorbis_comment_clear vorbis_comment_clear; 74 type_vorbis_block_init vorbis_block_init; 75 type_vorbis_block_clear vorbis_block_clear; 76 type_vorbis_dsp_clear vorbis_dsp_clear; 77 type_vorbis_analysis_init vorbis_analysis_init; 78 //// type_vorbis_commentheader_out vorbis_commentheader_out; 79 type_vorbis_analysis_headerout vorbis_analysis_headerout; 80 type_vorbis_analysis_buffer vorbis_analysis_buffer; 81 type_vorbis_analysis_wrote vorbis_analysis_wrote; 82 type_vorbis_analysis_blockout vorbis_analysis_blockout; 83 type_vorbis_analysis vorbis_analysis; 84 type_vorbis_bitrate_addblock vorbis_bitrate_addblock; 85 type_vorbis_bitrate_flushpacket vorbis_bitrate_flushpacket; 86 // type_vorbis_synthesis_headerin vorbis_synthesis_headerin; 87 // type_vorbis_synthesis_init vorbis_synthesis_init; 88 // type_vorbis_synthesis vorbis_synthesis; 89 // type_vorbis_synthesis_blockin vorbis_synthesis_blockin; 90 // type_vorbis_synthesis_pcmout vorbis_synthesis_pcmout; 91 // type_vorbis_synthesis_read vorbis_synthesis_read; 92 } vorbis_dll; 93 94 static volatile HANDLE h_vorbis_dll = NULL; 95 96 void free_vorbis_dll(void) 97 { 98 if(h_vorbis_dll){ 99 FreeLibrary(h_vorbis_dll); 100 h_vorbis_dll = NULL; 101 } 102 } 103 104 int load_vorbis_dll(void) 105 { 106 if(!h_vorbis_dll){ 107 h_vorbis_dll = LoadLibrary("vorbis.dll"); 108 if(!h_vorbis_dll) return -1; 109 } 110 vorbis_dll.vorbis_info_init = (type_vorbis_info_init)GetProcAddress(h_vorbis_dll,"vorbis_info_init"); 111 if(!vorbis_dll.vorbis_info_init){ free_vorbis_dll(); return -1; } 112 vorbis_dll.vorbis_info_clear = (type_vorbis_info_clear)GetProcAddress(h_vorbis_dll,"vorbis_info_clear"); 113 if(!vorbis_dll.vorbis_info_clear){ free_vorbis_dll(); return -1; } 114 vorbis_dll.vorbis_comment_init = (type_vorbis_comment_init)GetProcAddress(h_vorbis_dll,"vorbis_comment_init"); 115 if(!vorbis_dll.vorbis_comment_init){ free_vorbis_dll(); return -1; } 116 vorbis_dll.vorbis_comment_add = (type_vorbis_comment_add)GetProcAddress(h_vorbis_dll,"vorbis_comment_add"); 117 if(!vorbis_dll.vorbis_comment_add){ free_vorbis_dll(); return -1; } 118 vorbis_dll.vorbis_comment_add_tag = (type_vorbis_comment_add_tag)GetProcAddress(h_vorbis_dll,"vorbis_comment_add_tag"); 119 if(!vorbis_dll.vorbis_comment_add_tag){ free_vorbis_dll(); return -1; } 120 // vorbis_dll.vorbis_comment_query = (type_vorbis_comment_query)GetProcAddress(h_vorbis_dll,"vorbis_comment_query"); 121 // if(!vorbis_dll.vorbis_comment_query){ free_vorbis_dll(); return -1; } 122 // vorbis_dll.vorbis_comment_query_count = (type_vorbis_comment_query_count)GetProcAddress(h_vorbis_dll,"vorbis_comment_query_count"); 123 // if(!vorbis_dll.vorbis_comment_query_count){ free_vorbis_dll(); return -1; } 124 vorbis_dll.vorbis_comment_clear = (type_vorbis_comment_clear)GetProcAddress(h_vorbis_dll,"vorbis_comment_clear"); 125 if(!vorbis_dll.vorbis_comment_clear){ free_vorbis_dll(); return -1; } 126 vorbis_dll.vorbis_block_init = (type_vorbis_block_init)GetProcAddress(h_vorbis_dll,"vorbis_block_init"); 127 if(!vorbis_dll.vorbis_block_init){ free_vorbis_dll(); return -1; } 128 vorbis_dll.vorbis_block_clear = (type_vorbis_block_clear)GetProcAddress(h_vorbis_dll,"vorbis_block_clear"); 129 if(!vorbis_dll.vorbis_block_clear){ free_vorbis_dll(); return -1; } 130 vorbis_dll.vorbis_dsp_clear = (type_vorbis_dsp_clear)GetProcAddress(h_vorbis_dll,"vorbis_dsp_clear"); 131 if(!vorbis_dll.vorbis_dsp_clear){ free_vorbis_dll(); return -1; } 132 vorbis_dll.vorbis_analysis_init = (type_vorbis_analysis_init)GetProcAddress(h_vorbis_dll,"vorbis_analysis_init"); 133 if(!vorbis_dll.vorbis_analysis_init){ free_vorbis_dll(); return -1; } 134 //// vorbis_dll.vorbis_commentheader_out = (type_vorbis_commentheader_out)GetProcAddress(h_vorbis_dll,"vorbis_commentheader_out"); 135 //// if(!vorbis_dll.vorbis_commentheader_out){ free_vorbis_dll(); return -1; } 136 vorbis_dll.vorbis_analysis_headerout = (type_vorbis_analysis_headerout)GetProcAddress(h_vorbis_dll,"vorbis_analysis_headerout"); 137 if(!vorbis_dll.vorbis_analysis_headerout){ free_vorbis_dll(); return -1; } 138 vorbis_dll.vorbis_analysis_buffer = (type_vorbis_analysis_buffer)GetProcAddress(h_vorbis_dll,"vorbis_analysis_buffer"); 139 if(!vorbis_dll.vorbis_analysis_buffer){ free_vorbis_dll(); return -1; } 140 vorbis_dll.vorbis_analysis_wrote = (type_vorbis_analysis_wrote)GetProcAddress(h_vorbis_dll,"vorbis_analysis_wrote"); 141 if(!vorbis_dll.vorbis_analysis_wrote){ free_vorbis_dll(); return -1; } 142 vorbis_dll.vorbis_analysis_blockout = (type_vorbis_analysis_blockout)GetProcAddress(h_vorbis_dll,"vorbis_analysis_blockout"); 143 if(!vorbis_dll.vorbis_analysis_blockout){ free_vorbis_dll(); return -1; } 144 vorbis_dll.vorbis_analysis = (type_vorbis_analysis)GetProcAddress(h_vorbis_dll,"vorbis_analysis"); 145 if(!vorbis_dll.vorbis_analysis){ free_vorbis_dll(); return -1; } 146 vorbis_dll.vorbis_bitrate_addblock = (type_vorbis_bitrate_addblock)GetProcAddress(h_vorbis_dll,"vorbis_bitrate_addblock"); 147 if(!vorbis_dll.vorbis_bitrate_addblock){ free_vorbis_dll(); return -1; } 148 vorbis_dll.vorbis_bitrate_flushpacket = (type_vorbis_bitrate_flushpacket)GetProcAddress(h_vorbis_dll,"vorbis_bitrate_flushpacket"); 149 if(!vorbis_dll.vorbis_bitrate_flushpacket){ free_vorbis_dll(); return -1; } 150 // vorbis_dll.vorbis_synthesis_headerin = (type_vorbis_synthesis_headerin)GetProcAddress(h_vorbis_dll,"vorbis_synthesis_headerin"); 151 // if(!vorbis_dll.vorbis_synthesis_headerin){ free_vorbis_dll(); return -1; } 152 // vorbis_dll.vorbis_synthesis_init = (type_vorbis_synthesis_init)GetProcAddress(h_vorbis_dll,"vorbis_synthesis_init"); 153 // if(!vorbis_dll.vorbis_synthesis_init){ free_vorbis_dll(); return -1; } 154 // vorbis_dll.vorbis_synthesis = (type_vorbis_synthesis)GetProcAddress(h_vorbis_dll,"vorbis_synthesis"); 155 // if(!vorbis_dll.vorbis_synthesis){ free_vorbis_dll(); return -1; } 156 // vorbis_dll.vorbis_synthesis_blockin = (type_vorbis_synthesis_blockin)GetProcAddress(h_vorbis_dll,"vorbis_synthesis_blockin"); 157 // if(!vorbis_dll.vorbis_synthesis_blockin){ free_vorbis_dll(); return -1; } 158 // vorbis_dll.vorbis_synthesis_pcmout = (type_vorbis_synthesis_pcmout)GetProcAddress(h_vorbis_dll,"vorbis_synthesis_pcmout"); 159 // if(!vorbis_dll.vorbis_synthesis_pcmout){ free_vorbis_dll(); return -1; } 160 // vorbis_dll.vorbis_synthesis_read = (type_vorbis_synthesis_read)GetProcAddress(h_vorbis_dll,"vorbis_synthesis_read"); 161 // if(!vorbis_dll.vorbis_synthesis_read){ free_vorbis_dll(); return -1; } 162 return 0; 163 } 164 165 void vorbis_info_init(vorbis_info *vi) 166 { 167 if(h_vorbis_dll){ 168 vorbis_dll.vorbis_info_init(vi); 169 } 170 } 171 172 void vorbis_info_clear(vorbis_info *vi) 173 { 174 if(h_vorbis_dll){ 175 vorbis_dll.vorbis_info_clear(vi); 176 } 177 } 178 179 void vorbis_comment_init(vorbis_comment *vc) 180 { 181 if(h_vorbis_dll){ 182 vorbis_dll.vorbis_comment_init(vc); 183 } 184 } 185 186 void vorbis_comment_add(vorbis_comment *vc, char *comment) 187 { 188 if(h_vorbis_dll){ 189 vorbis_dll.vorbis_comment_add(vc,comment); 190 } 191 } 192 193 void vorbis_comment_add_tag(vorbis_comment *vc, char *tag, char *contents) 194 { 195 if(h_vorbis_dll){ 196 vorbis_dll.vorbis_comment_add_tag(vc,tag,contents); 197 } 198 } 199 200 #if 0 201 char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count) 202 { 203 if(h_vorbis_dll){ 204 return vorbis_dll.vorbis_comment_query(vc,tag,count); 205 } 206 return (char *)0; 207 } 208 209 int vorbis_comment_query_count(vorbis_comment *vc, char *tag) 210 { 211 if(h_vorbis_dll){ 212 return vorbis_dll.vorbis_comment_query_count(vc,tag); 213 } 214 return (int )0; 215 } 216 #endif 217 218 void vorbis_comment_clear(vorbis_comment *vc) 219 { 220 if(h_vorbis_dll){ 221 vorbis_dll.vorbis_comment_clear(vc); 222 } 223 } 224 225 int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb) 226 { 227 if(h_vorbis_dll){ 228 return vorbis_dll.vorbis_block_init(v,vb); 229 } 230 return (int )0; 231 } 232 233 int vorbis_block_clear(vorbis_block *vb) 234 { 235 if(h_vorbis_dll){ 236 return vorbis_dll.vorbis_block_clear(vb); 237 } 238 return (int )0; 239 } 240 241 void vorbis_dsp_clear(vorbis_dsp_state *v) 242 { 243 if(h_vorbis_dll){ 244 vorbis_dll.vorbis_dsp_clear(v); 245 } 246 } 247 248 int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi) 249 { 250 if(h_vorbis_dll){ 251 return vorbis_dll.vorbis_analysis_init(v,vi); 252 } 253 return (int )0; 254 } 255 256 //int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op) 257 //{ 258 // if(h_vorbis_dll){ 259 // return vorbis_dll.vorbis_commentheader_out(vc,op); 260 // } 261 // return (int )0; 262 //} 263 264 int vorbis_analysis_headerout(vorbis_dsp_state *v,vorbis_comment *vc,ogg_packet *op,ogg_packet *op_comm,ogg_packet *op_code) 265 { 266 if(h_vorbis_dll){ 267 return vorbis_dll.vorbis_analysis_headerout(v,vc,op,op_comm,op_code); 268 } 269 return (int )0; 270 } 271 272 float **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals) 273 { 274 if(h_vorbis_dll){ 275 return vorbis_dll.vorbis_analysis_buffer(v,vals); 276 } 277 return (float **)0; 278 } 279 280 int vorbis_analysis_wrote(vorbis_dsp_state *v,int vals) 281 { 282 if(h_vorbis_dll){ 283 return vorbis_dll.vorbis_analysis_wrote(v,vals); 284 } 285 return (int )0; 286 } 287 288 int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb) 289 { 290 if(h_vorbis_dll){ 291 return vorbis_dll.vorbis_analysis_blockout(v,vb); 292 } 293 return (int )0; 294 } 295 296 int vorbis_analysis(vorbis_block *vb,ogg_packet *op) 297 { 298 if(h_vorbis_dll){ 299 return vorbis_dll.vorbis_analysis(vb,op); 300 } 301 return (int )0; 302 } 303 304 int vorbis_bitrate_addblock(vorbis_block *vb) 305 { 306 if(h_vorbis_dll){ 307 return vorbis_dll.vorbis_bitrate_addblock(vb); 308 } 309 return (int )0; 310 } 311 312 int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd, ogg_packet *op) 313 { 314 if(h_vorbis_dll){ 315 return vorbis_dll.vorbis_bitrate_flushpacket(vd,op); 316 } 317 return (int )0; 318 } 319 320 #if 0 321 int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op) 322 { 323 if(h_vorbis_dll){ 324 return vorbis_dll.vorbis_synthesis_headerin(vi,vc,op); 325 } 326 return (int )0; 327 } 328 329 int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi) 330 { 331 if(h_vorbis_dll){ 332 return vorbis_dll.vorbis_synthesis_init(v,vi); 333 } 334 return (int )0; 335 } 336 337 int vorbis_synthesis(vorbis_block *vb,ogg_packet *op) 338 { 339 if(h_vorbis_dll){ 340 return vorbis_dll.vorbis_synthesis(vb,op); 341 } 342 return (int )0; 343 } 344 345 int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb) 346 { 347 if(h_vorbis_dll){ 348 return vorbis_dll.vorbis_synthesis_blockin(v,vb); 349 } 350 return (int )0; 351 } 352 353 int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm) 354 { 355 if(h_vorbis_dll){ 356 return vorbis_dll.vorbis_synthesis_pcmout(v,pcm); 357 } 358 return (int )0; 359 } 360 361 int vorbis_synthesis_read(vorbis_dsp_state *v,int samples) 362 { 363 if(h_vorbis_dll){ 364 return vorbis_dll.vorbis_synthesis_read(v,samples); 365 } 366 return (int )0; 367 } 368 #endif 369 370 /***************************************************************/ 371 #endif /* AU_VORBIS_DLL */ 372