source: trunk/src/winmm/initwinmm.cpp@ 6823

Last change on this file since 6823 was 6640, checked in by bird, 24 years ago

Added Missing $Id:$ keyword.

File size: 4.9 KB
Line 
1/* $Id: initwinmm.cpp,v 1.3 2001-09-05 10:30:21 bird Exp $
2 *
3 * WINMM DLL entry point
4 *
5 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
6 * Copyright 1998 Peter Fitzsimmons
7 * Copyright 2000 Chris Wohlgemuth
8 *
9 *
10 * Project Odin Software License can be found in LICENSE.TXT
11 *
12 */
13
14/*-------------------------------------------------------------*/
15/* INITERM.C -- Source for a custom dynamic link library */
16/* initialization and termination (_DLL_InitTerm) */
17/* function. */
18/* */
19/* When called to perform initialization, this sample function */
20/* gets storage for an array of integers, and initializes its */
21/* elements with random integers. At termination time, it */
22/* frees the array. Substitute your own special processing. */
23/*-------------------------------------------------------------*/
24
25
26/* Include files */
27#define INCL_DOSMODULEMGR
28#define INCL_DOSPROCESS
29#define INCL_DOSSEMAPHORES
30#include <os2wrap.h> //Odin32 OS/2 api wrappers
31#include <stdlib.h>
32#include <stdio.h>
33#include <string.h>
34#include <builtin.h>
35#include <misc.h> /*PLF Wed 98-03-18 23:19:26*/
36#include <odin.h>
37#include <win32type.h>
38#include <winconst.h>
39#include <odinlx.h>
40#include <initdll.h>
41#include "auxiliary.h"
42#include "winmmtype.h"
43#include "waveoutbase.h"
44#include <win\options.h>
45
46#define DBG_LOCALLOG DBG_initterm
47#include "dbglocal.h"
48
49BOOL MULTIMEDIA_MciInit(void);
50BOOL MULTIMEDIA_CreateIData(HINSTANCE hinstDLL);
51void MULTIMEDIA_DeleteIData(void);
52
53extern "C" {
54void IRTMidiShutdown(); // IRTMidi shutdown routine
55
56 //Win32 resource table (produced by wrc)
57 extern DWORD winmm_PEResTab;
58}
59static HMODULE dllHandle = 0;
60
61//******************************************************************************
62//******************************************************************************
63BOOL WINAPI LibMainWinmm(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
64{
65 static BOOL bInitDone = FALSE;
66
67 switch (fdwReason)
68 {
69 case DLL_PROCESS_ATTACH:
70 {
71 if (!MULTIMEDIA_CreateIData(hinstDLL))
72 return FALSE;
73
74 if (!bInitDone) { /* to be done only once */
75 if (!MULTIMEDIA_MciInit() /*|| !MMDRV_Init() */ ) {
76 MULTIMEDIA_DeleteIData();
77 return FALSE;
78 }
79 bInitDone = TRUE;
80 }
81 DWORD dwVolume;
82
83 dwVolume = PROFILE_GetOdinIniInt(WINMM_SECTION, DEFVOL_KEY, 100);
84 dwVolume = (dwVolume*0xFFFF)/100;
85 dwVolume = (dwVolume << 16) | dwVolume;
86 WaveOut::setDefaultVolume(dwVolume);
87 return TRUE;
88 }
89
90 case DLL_THREAD_ATTACH:
91 case DLL_THREAD_DETACH:
92 return TRUE;
93
94 case DLL_PROCESS_DETACH:
95 MULTIMEDIA_DeleteIData();
96 auxOS2Close(); /* SvL: Close aux device if necessary */
97 IRTMidiShutdown; /* JT: Shutdown RT Midi subsystem, if running. */
98 return TRUE;
99 }
100 return FALSE;
101}
102/****************************************************************************/
103/* _DLL_InitTerm is the function that gets called by the operating system */
104/* loader when it loads and frees this DLL for each process that accesses */
105/* this DLL. However, it only gets called the first time the DLL is loaded */
106/* and the last time it is freed for a particular process. The system */
107/* linkage convention MUST be used because the operating system loader is */
108/* calling this function. */
109/****************************************************************************/
110ULONG APIENTRY inittermWinmm(ULONG hModule, ULONG ulFlag)
111{
112 /*-------------------------------------------------------------------------*/
113 /* If ulFlag is zero then the DLL is being loaded so initialization should */
114 /* be performed. If ulFlag is 1 then the DLL is being freed so */
115 /* termination should be performed. */
116 /*-------------------------------------------------------------------------*/
117
118 switch (ulFlag)
119 {
120 case 0 :
121 ParseLogStatusWINMM();
122
123 dllHandle = RegisterLxDll(hModule, LibMainWinmm, (PVOID)&winmm_PEResTab);
124 if(dllHandle == 0)
125 return 0UL;/* Error */
126
127 dprintf(("winmm init %s %s (%x)", __DATE__, __TIME__, inittermWinmm));
128 break;
129 case 1 :
130 auxOS2Close(); /* SvL: Close aux device if necessary */
131 if(dllHandle) {
132 UnregisterLxDll(dllHandle);
133 }
134 break;
135 default :
136 return 0UL;
137 }
138
139 /***********************************************************/
140 /* A non-zero value must be returned to indicate success. */
141 /***********************************************************/
142 return 1UL;
143}
144//******************************************************************************
145//******************************************************************************
146
147
148
Note: See TracBrowser for help on using the repository browser.