1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
|
/*
TiMidity++ -- MIDI to WAVE converter and player
Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>
Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
w32_gogo.c
Functions to use gogo.dll for mp3 gogo (Windows 95/98/NT).
Orignal source : stub.c by odmlb and ւ.
Modified by Daisuke Aoki <dai@y7.net>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#ifdef __POCC__
#include <sys/types.h>
#endif //for off_t
#include "interface.h"
#ifdef AU_GOGO_DLL
#include <stdio.h>
#ifdef __W32__
#include <stdlib.h>
#include <io.h>
#include <windows.h>
#include <process.h>
#include <windowsx.h>
#include <winuser.h>
#include <stdio.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#ifndef NO_STRING_H
#include <string.h>
#else
#include <strings.h>
#endif
#include <fcntl.h>
/* #include <musenc.h> /* for gogo */
#include <gogo/gogo.h> /* for gogo */
#include "w32_gogo.h"
#include "gogo_a.h"
#include "timidity.h"
#include "common.h"
#include "output.h"
#include "controls.h"
#include "instrum.h"
#include "playmidi.h"
#include "readmidi.h"
static HINSTANCE hModule = NULL;
typedef MERET (*me_init)(void);
typedef MERET (*me_setconf)(UPARAM mode, UPARAM dwPara1, UPARAM dwPara2 );
typedef MERET (*me_getconf)(UPARAM mode, void *para1 );
typedef MERET (*me_detect)();
typedef MERET (*me_procframe)();
typedef MERET (*me_close)();
typedef MERET (*me_end)();
typedef MERET (*me_getver)( unsigned long *vercode, char *verstring );
typedef MERET (*me_haveunit)( unsigned long *unit );
static me_init mpge_init = NULL;
static me_setconf mpge_setconf = NULL;
static me_getconf mpge_getconf = NULL;
static me_detect mpge_detector = NULL;
static me_procframe mpge_processframe = NULL;
static me_close mpge_close = NULL;
static me_end mpge_end = NULL;
static me_getver mpge_getver = NULL;
static me_haveunit mpge_haveunit = NULL;
int MPGE_available = 0;
// DLL̓ǂݍ(ŏ1ڂ̂)ƃ[NGȀs܂B
MERET MPGE_initializeWork(void)
{
if( hModule == NULL ){
// (DLLǂݍ܂ĂȂꍇ)
// JgfBNgAysystemfBNgGOGO.DLL̓ǂݍ
hModule = LoadLibrary("gogo.dll");
if( hModule == NULL ){ // DLLȂꍇ
#define Key HKEY_CURRENT_USER
#define SubKey "Software\\MarineCat\\GOGO_DLL"
HKEY hKey;
DWORD dwType, dwKeySize;
LONG lResult;
static char *szName = "INSTPATH";
char szPathName[ _MAX_PATH + 8];
dwKeySize = sizeof( szPathName );
// WXgڂ HEY_CURENT_USER\Software\MarineCat\GOGO_DLLL[ȉ
// INSTPATH (REG_SZ)擾܂B
if( RegOpenKeyEx(
Key,
SubKey,
0,
KEY_ALL_ACCESS,
&hKey ) == ERROR_SUCCESS
){
lResult = RegQueryValueEx(
hKey,
szName,
0,
&dwType,
(BYTE *)szPathName,
&dwKeySize);
RegCloseKey(hKey);
if( lResult == ERROR_SUCCESS && REG_SZ == dwType ){
// WXg擾pXōēxDLL̓ǂݍ݂݂
hModule = LoadLibrary( szPathName );
}
}
#undef Key
#undef SubKey
}
// DLLȂ
if( hModule == NULL ){
ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "can not find gogo.dll.");
return ME_INTERNALERROR;
// MessageBox( "DLL̓ǂݍ݂s܂B\nDLLEXEt@CƓfBNg֕ʂĂ\n");
// fprintf( stderr,"DLL̓ǂݍ݂s܂B\nDLLEXEt@CƓfBNg֕ʂĂ\n");
// exit( -1 );
}
// GNX|[g̎擾
mpge_init = (me_init )GetProcAddress( hModule, "MPGE_initializeWork" );
mpge_setconf = (me_setconf )GetProcAddress( hModule, "MPGE_setConfigure" );
mpge_getconf = (me_getconf )GetProcAddress( hModule, "MPGE_getConfigure" );
mpge_detector = (me_detect )GetProcAddress( hModule, "MPGE_detectConfigure" );
mpge_processframe = (me_procframe )GetProcAddress( hModule, "MPGE_processFrame" );
mpge_close = (me_close )GetProcAddress( hModule, "MPGE_closeCoder" );
mpge_end = (me_end )GetProcAddress( hModule, "MPGE_endCoder" );
mpge_getver = (me_getver )GetProcAddress( hModule, "MPGE_getVersion" );
mpge_haveunit= (me_haveunit )GetProcAddress( hModule, "MPGE_getUnitStates" );
}
// ׂĂ̊킩mF
if( mpge_init && mpge_setconf && mpge_getconf &&
mpge_detector && mpge_processframe && mpge_end && mpge_getver && mpge_haveunit ){
MPGE_available = 1;
return (mpge_init)();
}
// G[
//fprintf( stderr, "DLL̓e𐳂ʂ邱Ƃo܂ł\n");
FreeLibrary( hModule );
hModule = NULL;
MPGE_available = 0;
//exit( -1 );
return ME_NOERR;
}
MERET MPGE_terminateWork(void) // I
{
mpge_init = NULL;
mpge_setconf = NULL;
mpge_getconf = NULL;
mpge_detector = NULL;
mpge_processframe = NULL;
mpge_close = NULL;
mpge_end = NULL;
mpge_getver = NULL;
mpge_haveunit= NULL;
if(hModule)
FreeLibrary( hModule );
hModule = NULL;
MPGE_available = 0;
return ME_NOERR;
}
MERET MPGE_setConfigure(UPARAM mode, UPARAM dwPara1, UPARAM dwPara2 )
{
if(!mpge_setconf)
return ME_INTERNALERROR;
return (mpge_setconf)( mode, dwPara1, dwPara2 );
}
MERET MPGE_getConfigure(UPARAM mode, void *para1 )
{
if(!mpge_getconf)
return ME_INTERNALERROR;
return (mpge_getconf)( mode, para1 );
}
MERET MPGE_detectConfigure(void)
{
if(!mpge_detector)
return ME_INTERNALERROR;
return (mpge_detector)();
}
MERET MPGE_processFrame(void)
{
if(!mpge_processframe)
return ME_INTERNALERROR;
return (mpge_processframe)();
}
MERET MPGE_closeCoder(void)
{
if(!mpge_close)
return ME_INTERNALERROR;
return (mpge_close)();
}
MERET MPGE_endCoder(void)
{
MERET val;
if(!mpge_end)
return ME_INTERNALERROR;
val = (mpge_end)();
if( val == ME_NOERR ){
mpge_setconf = NULL;
mpge_getconf = NULL;
mpge_detector = NULL;
mpge_processframe = NULL;
mpge_close = NULL;
mpge_end = NULL;
mpge_getver = NULL;
mpge_haveunit= NULL;
FreeLibrary( hModule ); // DLLJ
hModule = NULL;
MPGE_available = 0;
}
return val;
}
MERET MPGE_getVersion( unsigned long *vercode, char *verstring )
{
if(!mpge_getver)
return ME_INTERNALERROR;
return (mpge_getver)( vercode, verstring );
}
MERET MPGE_getUnitStates( unsigned long *unit)
{
if(!mpge_haveunit)
return ME_INTERNALERROR;
return (mpge_haveunit)( unit );
}
int gogo_dll_check(void)
{
HANDLE hDLL = NULL;
if(hModule)
return 1;
hDLL = LoadLibrary("gogo.dll");
if(hDLL){
FreeLibrary(hDLL);
return 1;
} else {
#define Key HKEY_CURRENT_USER
#define SubKey "Software\\MarineCat\\GOGO_DLL"
HKEY hKey;
DWORD dwType, dwKeySize;
LONG lResult;
static char *szName = "INSTPATH";
char szPathName[ _MAX_PATH + 8];
dwKeySize = sizeof( szPathName );
if( RegOpenKeyEx(Key,SubKey,0,KEY_ALL_ACCESS,&hKey ) == ERROR_SUCCESS ){
lResult = RegQueryValueEx(hKey,szName,0,&dwType,(BYTE *)szPathName,&dwKeySize);
RegCloseKey(hKey);
if( lResult == ERROR_SUCCESS && REG_SZ == dwType ){
hDLL = LoadLibrary( szPathName );
}
}
#undef Key
#undef SubKey
}
if(hDLL){
FreeLibrary(hDLL);
return 1;
}
return 0;
}
#endif /* AU_GOGO_DLL */
|