| 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 | return TRUE;
|
|---|
| 76 |
|
|---|
| 77 | case DLL_THREAD_ATTACH:
|
|---|
| 78 | case DLL_THREAD_DETACH:
|
|---|
| 79 | return TRUE;
|
|---|
| 80 |
|
|---|
| 81 | case DLL_PROCESS_DETACH:
|
|---|
| 82 | MULTIMEDIA_DeleteIData();
|
|---|
| 83 | auxOS2Close(); /* SvL: Close aux device if necessary */
|
|---|
| 84 | IRTMidiShutdown; /* JT: Shutdown RT Midi subsystem, if running. */
|
|---|
| 85 | ctordtorTerm();
|
|---|
| 86 | return TRUE;
|
|---|
| 87 | }
|
|---|
| 88 | return FALSE;
|
|---|
| 89 | }
|
|---|
| 90 | /****************************************************************************/
|
|---|
| 91 | /* _DLL_InitTerm is the function that gets called by the operating system */
|
|---|
| 92 | /* loader when it loads and frees this DLL for each process that accesses */
|
|---|
| 93 | /* this DLL. However, it only gets called the first time the DLL is loaded */
|
|---|
| 94 | /* and the last time it is freed for a particular process. The system */
|
|---|
| 95 | /* linkage convention MUST be used because the operating system loader is */
|
|---|
| 96 | /* calling this function. */
|
|---|
| 97 | /****************************************************************************/
|
|---|
| 98 | ULONG DLLENTRYPOINT_CCONV DLLENTRYPOINT_NAME(ULONG hModule, ULONG ulFlag)
|
|---|
| 99 | {
|
|---|
| 100 | /*-------------------------------------------------------------------------*/
|
|---|
| 101 | /* If ulFlag is zero then the DLL is being loaded so initialization should */
|
|---|
| 102 | /* be performed. If ulFlag is 1 then the DLL is being freed so */
|
|---|
| 103 | /* termination should be performed. */
|
|---|
| 104 | /*-------------------------------------------------------------------------*/
|
|---|
| 105 |
|
|---|
| 106 | switch (ulFlag)
|
|---|
| 107 | {
|
|---|
| 108 | case 0 :
|
|---|
| 109 | ctordtorInit();
|
|---|
| 110 |
|
|---|
| 111 | ParseLogStatus();
|
|---|
| 112 |
|
|---|
| 113 | CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/
|
|---|
| 114 | dllHandle = RegisterLxDll(hModule, OdinLibMain, (PVOID)&_Resource_PEResTab);
|
|---|
| 115 | if(dllHandle == 0)
|
|---|
| 116 | return 0UL;/* Error */
|
|---|
| 117 |
|
|---|
| 118 | dprintf(("winmm init %s %s (%x)", __DATE__, __TIME__, DLLENTRYPOINT_NAME));
|
|---|
| 119 | break;
|
|---|
| 120 | case 1 :
|
|---|
| 121 | auxOS2Close(); /* SvL: Close aux device if necessary */
|
|---|
| 122 | if(dllHandle) {
|
|---|
| 123 | UnregisterLxDll(dllHandle);
|
|---|
| 124 | }
|
|---|
| 125 | break;
|
|---|
| 126 | default :
|
|---|
| 127 | return 0UL;
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | /***********************************************************/
|
|---|
| 131 | /* A non-zero value must be returned to indicate success. */
|
|---|
| 132 | /***********************************************************/
|
|---|
| 133 | return 1UL;
|
|---|
| 134 | }
|
|---|
| 135 | //******************************************************************************
|
|---|
| 136 | //******************************************************************************
|
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 |
|
|---|