| 1 |
/*************************************************************************/ |
| 2 |
/* Cobalt Speech and Language, Inc */ |
| 3 |
/* Copyright (c) 2015 */ |
| 4 |
/* All Rights Reserved. */ |
| 5 |
/* */ |
| 6 |
/* Permission is hereby granted, free of charge, to use and distribute */ |
| 7 |
/* this software and its documentation without restriction, including */ |
| 8 |
/* without limitation the rights to use, copy, modify, merge, publish, */ |
| 9 |
/* distribute, sublicense, and/or sell copies of this work, and to */ |
| 10 |
/* permit persons to whom this work is furnished to do so, subject to */ |
| 11 |
/* the following conditions: */ |
| 12 |
/* 1. The code must retain the above copyright notice, this list of */ |
| 13 |
/* conditions and the following disclaimer. */ |
| 14 |
/* 2. Any modifications must be clearly marked as such. */ |
| 15 |
/* 3. Original authors' names are not deleted. */ |
| 16 |
/* 4. The authors' names are not used to endorse or promote products */ |
| 17 |
/* derived from this software without specific prior written */ |
| 18 |
/* permission. */ |
| 19 |
/* */ |
| 20 |
/* COBALT SPEECH AND LANGUAGE INC AND THE CONTRIBUTORS TO THIS WORK */ |
| 21 |
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ |
| 22 |
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */ |
| 23 |
/* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */ |
| 24 |
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ |
| 25 |
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ |
| 26 |
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ |
| 27 |
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ |
| 28 |
/* THIS SOFTWARE. */ |
| 29 |
/* */ |
| 30 |
/*************************************************************************/ |
| 31 |
/* Authors: Alok Parlikar ([email protected]) */ |
| 32 |
/* Date: December 2015 */ |
| 33 |
/* */ |
| 34 |
/* Thanks to VocaliD Inc. for supporting this work. */ |
| 35 |
/*************************************************************************/ |
| 36 |
// FliteCMUGenericCG.cpp : Implementation of DLL Exports. |
| 37 |
|
| 38 |
|
| 39 |
#include "stdafx.h" |
| 40 |
#include "resource.h" |
| 41 |
#include "FliteCMUGenericCG_i.h" |
| 42 |
#include "FliteCMUGenericCGObj.h" |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
using namespace ATL; |
| 47 |
|
| 48 |
CComModule _Module; |
| 49 |
|
| 50 |
BEGIN_OBJECT_MAP(ObjectMap) |
| 51 |
OBJECT_ENTRY(CLSID_FliteCMUGenericCGObj, CFliteCMUGenericCGObj) |
| 52 |
END_OBJECT_MAP() |
| 53 |
|
| 54 |
///////////////////////////////////////////////////////////////////////////// |
| 55 |
// DLL Entry Point |
| 56 |
|
| 57 |
extern "C" |
| 58 |
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) |
| 59 |
{ |
| 60 |
if (dwReason == DLL_PROCESS_ATTACH) |
| 61 |
{ |
| 62 |
_Module.Init(ObjectMap, hInstance, &LIBID_FliteCMUGenericCGLib); |
| 63 |
DisableThreadLibraryCalls(hInstance); |
| 64 |
/*AllocConsole(); |
| 65 |
CONSOLE_SCREEN_BUFFER_INFO coninfo; |
| 66 |
|
| 67 |
freopen("conin$", "r+t", stdin); |
| 68 |
freopen("conout$", "w+t", stdout); |
| 69 |
freopen("conout$", "w+t", stderr); |
| 70 |
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo); |
| 71 |
coninfo.dwSize.Y = 5000; |
| 72 |
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize); |
| 73 |
*/ |
| 74 |
flite_add_lang("eng", usenglish_init, cmulex_init); |
| 75 |
// Sai Krishna + Tim 13 March 2017 ////////// |
| 76 |
flite_add_lang("cmu_indic_lang", cmu_indic_lang_init, cmu_indic_lex_init); |
| 77 |
flite_add_lang("cmu_grapheme_lang", cmu_grapheme_lang_init, cmu_grapheme_lex_init); |
| 78 |
////////////////////////////////////// |
| 79 |
} |
| 80 |
else if (dwReason == DLL_PROCESS_DETACH) |
| 81 |
_Module.Term(); |
| 82 |
return TRUE; // ok |
| 83 |
} |
| 84 |
|
| 85 |
///////////////////////////////////////////////////////////////////////////// |
| 86 |
// Used to determine whether the DLL can be unloaded by OLE |
| 87 |
|
| 88 |
STDAPI DllCanUnloadNow(void) |
| 89 |
{ |
| 90 |
return (_Module.GetLockCount() == 0) ? S_OK : S_FALSE; |
| 91 |
} |
| 92 |
|
| 93 |
///////////////////////////////////////////////////////////////////////////// |
| 94 |
// Returns a class factory to create an object of the requested type |
| 95 |
|
| 96 |
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) |
| 97 |
{ |
| 98 |
return _Module.GetClassObject(rclsid, riid, ppv); |
| 99 |
} |
| 100 |
|
| 101 |
///////////////////////////////////////////////////////////////////////////// |
| 102 |
// DllRegisterServer - Adds entries to the system registry |
| 103 |
|
| 104 |
STDAPI DllRegisterServer(void) |
| 105 |
{ |
| 106 |
// registers object, typelib and all interfaces in typelib |
| 107 |
return _Module.RegisterServer(TRUE); |
| 108 |
} |
| 109 |
|
| 110 |
///////////////////////////////////////////////////////////////////////////// |
| 111 |
// DllUnregisterServer - Removes entries from the system registry |
| 112 |
|
| 113 |
STDAPI DllUnregisterServer(void) |
| 114 |
{ |
| 115 |
return _Module.UnregisterServer(TRUE); |
| 116 |
} |
| 117 |
|
| 118 |
// DllInstall - Adds/Removes entries to the system registry per user per machine. |
| 119 |
STDAPI DllInstall(BOOL bInstall, _In_opt_ LPCWSTR pszCmdLine) |
| 120 |
{ |
| 121 |
HRESULT hr = E_FAIL; |
| 122 |
static const wchar_t szUserSwitch[] = L"user"; |
| 123 |
|
| 124 |
if (pszCmdLine != NULL) |
| 125 |
{ |
| 126 |
if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0) |
| 127 |
{ |
| 128 |
ATL::AtlSetPerUserRegistration(true); |
| 129 |
} |
| 130 |
} |
| 131 |
|
| 132 |
if (bInstall) |
| 133 |
{ |
| 134 |
hr = DllRegisterServer(); |
| 135 |
if (FAILED(hr)) |
| 136 |
{ |
| 137 |
DllUnregisterServer(); |
| 138 |
} |
| 139 |
} |
| 140 |
else |
| 141 |
{ |
| 142 |
hr = DllUnregisterServer(); |
| 143 |
} |
| 144 |
|
| 145 |
return hr; |
| 146 |
} |
| 147 |
|
| 148 |
|