Ignore:
Timestamp:
Dec 1, 2011, 10:19:11 PM (14 years ago)
Author:
dmik
Message:

Port WINMM, MCICDA and MCIWAVE DLLs to GCC/kBuild.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • branches/gcc-kmk/src/winmm/initterm.cpp

    r21796 r21841  
    1 /* $Id: initwinmm.cpp,v 1.15 2004-04-13 12:49:03 sandervl Exp $
     1/* $Id: initterm.cpp,v 1.20 2001-09-05 10:30:39 bird Exp $
    22 *
    33 * WINMM DLL entry point
     
    77 * Copyright 2000 Chris Wohlgemuth
    88 *
    9  *
    109 * Project Odin Software License can be found in LICENSE.TXT
    11  *
    1210 */
    1311
    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 */
    2712#define  INCL_DOSMODULEMGR
    2813#define  INCL_DOSPROCESS
     
    3520#include <stdio.h>
    3621#include <string.h>
     22#ifndef __GNUC__
    3723#include <builtin.h>
     24#endif
    3825#include <misc.h>       /*PLF Wed  98-03-18 23:19:26*/
    3926#include <odin.h>
     
    4734#include "waveoutbase.h"
    4835#include <win/options.h>
    49 #include "initwinmm.h"
     36#include "initterm.h"
    5037#include <custombuild.h>
    5138#include "mixer.h"
     
    5845void MULTIMEDIA_DeleteIData(void);
    5946
    60 extern "C" {
    61 void IRTMidiShutdown();  // IRTMidi shutdown routine
    62 
    63  //Win32 resource table (produced by wrc)
    64  extern DWORD winmm_PEResTab;
    65 }
     47extern "C" void IRTMidiShutdown(); // IRTMidi shutdown routine
     48
     49// Win32 resource table (produced by wrc)
     50extern DWORD winmm_PEResTab;
     51
    6652static HMODULE dllHandle = 0;
    6753static HMODULE MMPMLibraryHandle = 0;
    6854
    69 static char *szBuggyAudio[] = {
    70 "CWAUD",
    71 "BSAUD",
    72 "CRYSTAL"
     55static const char *szBuggyAudio[] =
     56{
     57    "CWAUD",
     58    "BSAUD",
     59    "CRYSTAL"
    7360};
    7461
     
    7663
    7764DWORD (APIENTRY *pfnmciSendCommand)(WORD   wDeviceID,
    78                                    WORD   wMessage,
    79                                    DWORD  dwParam1,
    80                                    PVOID  dwParam2,
    81                                    WORD   wUserParm) = NULL;
     65                                    WORD   wMessage,
     66                                    DWORD  dwParam1,
     67                                    PVOID  dwParam2,
     68                                    WORD   wUserParm) = NULL;
    8269DWORD (APIENTRY *pfnmciGetErrorString)(DWORD   dwError,
    83                                       LPSTR   lpstrBuffer,
    84                                       WORD    wLength) = NULL;
    85 
    86 //******************************************************************************
    87 //******************************************************************************
     70                                       LPSTR   lpstrBuffer,
     71                                       WORD    wLength) = NULL;
     72
    8873void WIN32API DisableWaveAudio()
    8974{
     
    9277    pfnmciSendCommand    = NULL;
    9378}
    94 //******************************************************************************
    95 //******************************************************************************
     79
    9680BOOL WINAPI LibMainWinmm(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
    9781{
     
    216200   return FALSE;
    217201}
    218 /****************************************************************************/
    219 /* _DLL_InitTerm is the function that gets called by the operating system   */
    220 /* loader when it loads and frees this DLL for each process that accesses   */
    221 /* this DLL.  However, it only gets called the first time the DLL is loaded */
    222 /* and the last time it is freed for a particular process.  The system      */
    223 /* linkage convention MUST be used because the operating system loader is   */
    224 /* calling this function.                                                   */
    225 /****************************************************************************/
    226 ULONG APIENTRY inittermWinmm(ULONG hModule, ULONG ulFlag)
    227 {
    228     /*-------------------------------------------------------------------------*/
    229     /* If ulFlag is zero then the DLL is being loaded so initialization should */
    230     /* be performed.  If ulFlag is 1 then the DLL is being freed so            */
    231     /* termination should be performed.                                        */
    232     /*-------------------------------------------------------------------------*/
    233 
    234     switch (ulFlag)
    235     {
    236     case 0 :
    237         ParseLogStatusWINMM();
    238 
    239         dllHandle = RegisterLxDll(hModule, LibMainWinmm, (PVOID)&winmm_PEResTab);
    240         if(dllHandle == 0)
    241             return 0UL;/* Error */
    242 
    243         dprintf(("winmm init %s %s (%x)", __DATE__, __TIME__, inittermWinmm));
    244         break;
    245     case 1 :
    246         auxOS2Close(); /* SvL: Close aux device if necessary */
    247         if(dllHandle) {
    248             UnregisterLxDll(dllHandle);
    249         }
    250         break;
    251     default  :
    252         return 0UL;
    253     }
    254 
    255     /***********************************************************/
    256     /* A non-zero value must be returned to indicate success.  */
    257     /***********************************************************/
    258     return 1UL;
    259 }
    260 //******************************************************************************
    261 //******************************************************************************
     202
    262203DWORD APIENTRY mymciSendCommand(WORD   wDeviceID,
    263204                                WORD   wMessage,
     
    275216    return ret;
    276217}
    277 //******************************************************************************
    278 //******************************************************************************
     218
    279219DWORD APIENTRY mymciGetErrorString(DWORD   dwError,
    280220                                   LPSTR   lpstrBuffer,
     
    290230    return ret;
    291231}
    292 //******************************************************************************
    293 //******************************************************************************
     232
     233ULONG SYSTEM DLL_InitWinMM32(ULONG hModule)
     234{
     235    CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
     236
     237    ParseLogStatusWINMM();
     238
     239    dllHandle = RegisterLxDll(hModule, LibMainWinmm, (PVOID)&winmm_PEResTab);
     240    if (dllHandle == 0)
     241        return -1;
     242
     243    dprintf(("winmm init %s %s (%x)", __DATE__, __TIME__, DLL_InitWinMM32));
     244
     245    return 0;
     246}
     247
     248void SYSTEM DLL_TermWinMM32(ULONG hModule)
     249{
     250    auxOS2Close(); /* SvL: Close aux device if necessary */
     251
     252    if(dllHandle)
     253        UnregisterLxDll(dllHandle);
     254}
     255
     256ULONG SYSTEM DLL_Init(ULONG hModule)
     257{
     258    if (DLL_InitDefault(hModule) == -1)
     259        return -1;
     260    return DLL_InitWinMM32(hModule);
     261}
     262
     263void SYSTEM DLL_Term(ULONG hModule)
     264{
     265    DLL_TermWinMM32(hModule);
     266    DLL_TermDefault(hModule);
     267}
Note: See TracChangeset for help on using the changeset viewer.