1 | /*
|
---|
2 | * WINMM DLL entry point
|
---|
3 | *
|
---|
4 | * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
5 | * Copyright 1998 Peter Fitzsimmons
|
---|
6 | * Copyright 2000 Chris Wohlgemuth
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
10 | *
|
---|
11 | */
|
---|
12 |
|
---|
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 | #define INCL_DOSMODULEMGR
|
---|
27 | #define INCL_DOSPROCESS
|
---|
28 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
---|
29 | #include <stdlib.h>
|
---|
30 | #include <stdio.h>
|
---|
31 | #include <string.h>
|
---|
32 | #include <builtin.h>
|
---|
33 | #include <misc.h> /*PLF Wed 98-03-18 23:19:26*/
|
---|
34 | #include <odin.h>
|
---|
35 | #include <win32type.h>
|
---|
36 | #include <winconst.h>
|
---|
37 | #include <odinlx.h>
|
---|
38 | #include <initdll.h>
|
---|
39 | #include "auxiliary.h"
|
---|
40 |
|
---|
41 | #define DBG_LOCALLOG DBG_initterm
|
---|
42 | #include "dbglocal.h"
|
---|
43 |
|
---|
44 | BOOL MULTIMEDIA_MciInit(void);
|
---|
45 | BOOL MULTIMEDIA_CreateIData(HINSTANCE hinstDLL);
|
---|
46 | void MULTIMEDIA_DeleteIData(void);
|
---|
47 |
|
---|
48 | extern "C" {
|
---|
49 | void IRTMidiShutdown(); // IRTMidi shutdown routine
|
---|
50 |
|
---|
51 | //Win32 resource table (produced by wrc)
|
---|
52 | extern DWORD _Resource_PEResTab;
|
---|
53 | }
|
---|
54 | static HMODULE dllHandle = 0;
|
---|
55 |
|
---|
56 | //******************************************************************************
|
---|
57 | //******************************************************************************
|
---|
58 | BOOL WINAPI OdinLibMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
|
---|
59 | {
|
---|
60 | static BOOL bInitDone = FALSE;
|
---|
61 |
|
---|
62 | switch (fdwReason)
|
---|
63 | {
|
---|
64 | case DLL_PROCESS_ATTACH:
|
---|
65 | if (!MULTIMEDIA_CreateIData(hinstDLL))
|
---|
66 | return FALSE;
|
---|
67 |
|
---|
68 | if (!bInitDone) { /* to be done only once */
|
---|
69 | if (!MULTIMEDIA_MciInit() /*|| !MMDRV_Init() */ ) {
|
---|
70 | MULTIMEDIA_DeleteIData();
|
---|
71 | return FALSE;
|
---|
72 | }
|
---|
73 | bInitDone = TRUE;
|
---|
74 | }
|
---|
75 |
|
---|
76 | return TRUE;
|
---|
77 |
|
---|
78 | case DLL_THREAD_ATTACH:
|
---|
79 | case DLL_THREAD_DETACH:
|
---|
80 | return TRUE;
|
---|
81 |
|
---|
82 | case DLL_PROCESS_DETACH:
|
---|
83 | MULTIMEDIA_DeleteIData();
|
---|
84 | auxOS2Close(); /* SvL: Close aux device if necessary */
|
---|
85 | IRTMidiShutdown; /* JT: Shutdown RT Midi subsystem, if running. */
|
---|
86 | ctordtorTerm();
|
---|
87 | return TRUE;
|
---|
88 | }
|
---|
89 | return FALSE;
|
---|
90 | }
|
---|
91 | /****************************************************************************/
|
---|
92 | /* _DLL_InitTerm is the function that gets called by the operating system */
|
---|
93 | /* loader when it loads and frees this DLL for each process that accesses */
|
---|
94 | /* this DLL. However, it only gets called the first time the DLL is loaded */
|
---|
95 | /* and the last time it is freed for a particular process. The system */
|
---|
96 | /* linkage convention MUST be used because the operating system loader is */
|
---|
97 | /* calling this function. */
|
---|
98 | /****************************************************************************/
|
---|
99 | ULONG DLLENTRYPOINT_CCONV DLLENTRYPOINT_NAME(ULONG hModule, ULONG ulFlag)
|
---|
100 | {
|
---|
101 | size_t i;
|
---|
102 | APIRET rc;
|
---|
103 |
|
---|
104 | /*-------------------------------------------------------------------------*/
|
---|
105 | /* If ulFlag is zero then the DLL is being loaded so initialization should */
|
---|
106 | /* be performed. If ulFlag is 1 then the DLL is being freed so */
|
---|
107 | /* termination should be performed. */
|
---|
108 | /*-------------------------------------------------------------------------*/
|
---|
109 |
|
---|
110 | switch (ulFlag) {
|
---|
111 | case 0 :
|
---|
112 | ctordtorInit();
|
---|
113 |
|
---|
114 | ParseLogStatus();
|
---|
115 |
|
---|
116 | CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
|
---|
117 |
|
---|
118 | dllHandle = RegisterLxDll(hModule, OdinLibMain, (PVOID)&_Resource_PEResTab);
|
---|
119 | if(dllHandle == 0)
|
---|
120 | return 0UL;/* Error */
|
---|
121 |
|
---|
122 | dprintf(("winmm init %s %s (%x)", __DATE__, __TIME__, DLLENTRYPOINT_NAME));
|
---|
123 |
|
---|
124 | break;
|
---|
125 | case 1 :
|
---|
126 | auxOS2Close(); /* SvL: Close aux device if necessary */
|
---|
127 | if(dllHandle) {
|
---|
128 | UnregisterLxDll(dllHandle);
|
---|
129 | }
|
---|
130 | break;
|
---|
131 | default :
|
---|
132 | return 0UL;
|
---|
133 | }
|
---|
134 |
|
---|
135 | /***********************************************************/
|
---|
136 | /* A non-zero value must be returned to indicate success. */
|
---|
137 | /***********************************************************/
|
---|
138 | return 1UL;
|
---|
139 | }
|
---|
140 | //******************************************************************************
|
---|
141 | //******************************************************************************
|
---|
142 |
|
---|
143 |
|
---|
144 |
|
---|