Changeset 21878 for branches/gcc-kmk/src/dsound/initterm.cpp
- Timestamp:
- Dec 13, 2011, 11:17:52 AM (14 years ago)
- File:
-
- 1 moved
-
branches/gcc-kmk/src/dsound/initterm.cpp (moved) (moved from branches/gcc-kmk/src/dsound/initdsound.cpp ) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/gcc-kmk/src/dsound/initterm.cpp
r21842 r21878 1 /* $Id: init dsound.cpp,v 1.12002-09-14 08:31:25 sandervl Exp $1 /* $Id: initterm.cpp,v 1.18 2002-09-14 08:31:25 sandervl Exp $ 2 2 * 3 * D LL entry point3 * DSOUND DLL entry point 4 4 * 5 5 * Copyright 1998 Sander van Leeuwen 6 6 * Copyright 1998 Peter Fitzsimmons 7 7 * 8 *9 8 * Project Odin Software License can be found in LICENSE.TXT 10 *11 9 */ 12 10 13 /*-------------------------------------------------------------*/14 /* INITERM.C -- Source for a custom dynamic link library */15 /* initialization and termination (_DLL_InitTerm) */16 /* function. */17 /* */18 /* When called to perform initialization, this sample function */19 /* gets storage for an array of integers, and initializes its */20 /* elements with random integers. At termination time, it */21 /* frees the array. Substitute your own special processing. */22 /*-------------------------------------------------------------*/23 24 25 /* Include files */26 11 #define INCL_DOSMODULEMGR 27 12 #define INCL_DOSPROCESS … … 43 28 #include "initdsound.h" 44 29 45 extern "C" { 46 //Win32 resource table (produced by wrc) 47 extern DWORD _Resource_PEResTab; 48 } 30 // Win32 resource table (produced by wrc) 31 extern DWORD dsound_PEResTab; 49 32 50 33 static HMODULE dllHandle = 0; 51 34 static HMODULE MMPMLibraryHandle = 0; 35 36 char dsoundPath[CCHMAXPATH] = ""; 52 37 53 38 BOOL fdsMMPMAvailable = TRUE; … … 62 47 WORD wLength) = NULL; 63 48 64 65 //******************************************************************************66 //******************************************************************************67 49 BOOL WINAPI LibMainDSound(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) 68 50 { 69 char szError[CCHMAXPATH];70 HKEY hKey;51 char szError[CCHMAXPATH]; 52 HKEY hKey; 71 53 72 switch (fdwReason)73 {74 case DLL_PROCESS_ATTACH:54 switch (fdwReason) 55 { 56 case DLL_PROCESS_ATTACH: 75 57 76 if(fdsMMPMAvailable == TRUE) 77 {//if audio access wasn't disabled already, check if mmpm2 is installed 58 if(fdsMMPMAvailable == TRUE) 59 { 60 // if audio access wasn't disabled already, check if mmpm2 is installed 78 61 // try to load the MDM library, not MMPM directly!!! 79 62 if (DosLoadModule(szError, sizeof(szError), … … 82 65 // this system has no MMPM :-( 83 66 fdsMMPMAvailable = FALSE; 84 } 67 } 85 68 else 86 69 { … … 89 72 1, /* ORD_MCISENDCOMMAND */ 90 73 NULL, 91 (PFN*)&pfnDSmciSendCommand) != NO_ERROR)74 (PFN*)&pfnDSmciSendCommand) != NO_ERROR) 92 75 { 93 76 fdsMMPMAvailable = FALSE; 94 } 77 } 95 78 else 96 79 { … … 113 96 } 114 97 115 if(fdsMMPMAvailable && RegOpenKeyA(HKEY_LOCAL_MACHINE, CUSTOM_BUILD_OPTIONS_KEY, &hKey) == 0) 98 if(fdsMMPMAvailable && RegOpenKeyA(HKEY_LOCAL_MACHINE, CUSTOM_BUILD_OPTIONS_KEY, &hKey) == 0) 116 99 { 117 100 DWORD dwSize, dwType; … … 135 118 return TRUE; 136 119 137 case DLL_THREAD_ATTACH:138 case DLL_THREAD_DETACH:120 case DLL_THREAD_ATTACH: 121 case DLL_THREAD_DETACH: 139 122 return TRUE; 140 123 141 case DLL_PROCESS_DETACH:124 case DLL_PROCESS_DETACH: 142 125 if(MMPMLibraryHandle) DosFreeModule(MMPMLibraryHandle); 143 126 return TRUE; 144 }145 return FALSE;127 } 128 return FALSE; 146 129 } 147 /****************************************************************************/148 /* _DLL_InitTerm is the function that gets called by the operating system */149 /* loader when it loads and frees this DLL for each process that accesses */150 /* this DLL. However, it only gets called the first time the DLL is loaded */151 /* and the last time it is freed for a particular process. The system */152 /* linkage convention MUST be used because the operating system loader is */153 /* calling this function. */154 /****************************************************************************/155 ULONG APIENTRY inittermDSound(ULONG hModule, ULONG ulFlag)156 {157 158 /*-------------------------------------------------------------------------*/159 /* If ulFlag is zero then the DLL is being loaded so initialization should */160 /* be performed. If ulFlag is 1 then the DLL is being freed so */161 /* termination should be performed. */162 /*-------------------------------------------------------------------------*/163 164 switch (ulFlag) {165 case 0 :166 {167 dllHandle = RegisterLxDll(hModule, LibMainDSound, (PVOID)&_Resource_PEResTab);168 if(dllHandle == 0)169 return 0UL;170 171 dprintf(("dsound init %s %s (%x)", __DATE__, __TIME__, inittermDSound));172 break;173 }174 175 case 1 :176 if(dllHandle) {177 UnregisterLxDll(dllHandle);178 }179 break;180 default :181 return 0UL;182 }183 184 /***********************************************************/185 /* A non-zero value must be returned to indicate success. */186 /***********************************************************/187 return 1UL;188 }189 //******************************************************************************190 //******************************************************************************191 130 192 131 DWORD APIENTRY dsmciSendCommand(WORD wDeviceID, … … 205 144 return ret; 206 145 } 207 //****************************************************************************** 208 //****************************************************************************** 146 209 147 DWORD APIENTRY dsmciGetErrorString(DWORD dwError, 210 148 LPSTR lpstrBuffer, … … 220 158 return ret; 221 159 } 222 //****************************************************************************** 223 //****************************************************************************** 160 161 ULONG SYSTEM DLL_InitDSound(ULONG hModule) 162 { 163 DosQueryModuleName(hModule, CCHMAXPATH, dsoundPath); 164 char *endofpath = strrchr(dsoundPath, '\\'); 165 if (endofpath) 166 *(endofpath+1) = 0; 167 168 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/ 169 170 dllHandle = RegisterLxDll(hModule, LibMainDSound, (PVOID)&dsound_PEResTab); 171 if(dllHandle == 0) 172 return -1; 173 174 dprintf(("dsound init %s %s (%x)", __DATE__, __TIME__, DLL_InitDSound)); 175 176 return 0; 177 } 178 179 void SYSTEM DLL_TermDSound(ULONG hModule) 180 { 181 if (dllHandle) 182 UnregisterLxDll(dllHandle); 183 } 184 185 ULONG SYSTEM DLL_Init(ULONG hModule) 186 { 187 if (DLL_InitDefault(hModule) == -1) 188 return -1; 189 return DLL_InitDSound(hModule); 190 } 191 192 void SYSTEM DLL_Term(ULONG hModule) 193 { 194 DLL_TermDSound(hModule); 195 DLL_TermDefault(hModule); 196 }
Note:
See TracChangeset
for help on using the changeset viewer.
