| 1 | /* BoCA - BonkEnc Component Architecture |
| 2 | * Copyright (C) 2007-2020 Robert Kausch <[email protected]> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License as |
| 6 | * published by the Free Software Foundation, either version 2 of |
| 7 | * the License, or (at your option) any later version. |
| 8 | * |
| 9 | * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR |
| 10 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
| 11 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ |
| 12 | |
| 13 | #include "dllinterface.h" |
| 14 | |
| 15 | CR_GETNUMCDROM ex_CR_GetNumCDROM = NIL; |
| 16 | CR_OPENCDROM ex_CR_OpenCDROM = NIL; |
| 17 | CR_CLOSECDROM ex_CR_CloseCDROM = NIL; |
| 18 | CR_READTOC ex_CR_ReadToc = NIL; |
| 19 | CR_GETNUMTOCENTRIES ex_CR_GetNumTocEntries = NIL; |
| 20 | CR_GETTOCENTRY ex_CR_GetTocEntry = NIL; |
| 21 | CR_OPENRIPPER ex_CR_OpenRipper = NIL; |
| 22 | CR_CLOSERIPPER ex_CR_CloseRipper = NIL; |
| 23 | CR_RIPCHUNK ex_CR_RipChunk = NIL; |
| 24 | CR_GETCDROMPARAMETERS ex_CR_GetCDROMParameters = NIL; |
| 25 | CR_SETCDROMPARAMETERS ex_CR_SetCDROMParameters = NIL; |
| 26 | CR_READCDTEXT ex_CR_ReadCDText = NIL; |
| 27 | CR_READANDGETISRC ex_CR_ReadAndGetISRC = NIL; |
| 28 | CR_GETNUMBEROFCACHEERRORS ex_CR_GetNumberOfCacheErrors = NIL; |
| 29 | CR_GETCDRIPVERSION ex_CR_GetCDRipVersion = NIL; |
| 30 | |
| 31 | DynamicLoader *cdripdll = NIL; |
| 32 | |
| 33 | Bool LoadCDRipDLL() |
| 34 | { |
| 35 | #ifdef __WIN32__ |
| 36 | if (!File(GUI::Application::GetApplicationDirectory().Append("CDRip.dll")).Exists()) return False; |
| 37 | #endif |
| 38 | |
| 39 | cdripdll = new DynamicLoader("CDRip"); |
| 40 | |
| 41 | ex_CR_GetNumCDROM = (CR_GETNUMCDROM) cdripdll->GetFunctionAddress("CR_GetNumCDROM"); |
| 42 | ex_CR_OpenCDROM = (CR_OPENCDROM) cdripdll->GetFunctionAddress("CR_OpenCDROM"); |
| 43 | ex_CR_CloseCDROM = (CR_CLOSECDROM) cdripdll->GetFunctionAddress("CR_CloseCDROM"); |
| 44 | ex_CR_ReadToc = (CR_READTOC) cdripdll->GetFunctionAddress("CR_ReadToc"); |
| 45 | ex_CR_GetNumTocEntries = (CR_GETNUMTOCENTRIES) cdripdll->GetFunctionAddress("CR_GetNumTocEntries"); |
| 46 | ex_CR_GetTocEntry = (CR_GETTOCENTRY) cdripdll->GetFunctionAddress("CR_GetTocEntry"); |
| 47 | ex_CR_OpenRipper = (CR_OPENRIPPER) cdripdll->GetFunctionAddress("CR_OpenRipper"); |
| 48 | ex_CR_CloseRipper = (CR_CLOSERIPPER) cdripdll->GetFunctionAddress("CR_CloseRipper"); |
| 49 | ex_CR_RipChunk = (CR_RIPCHUNK) cdripdll->GetFunctionAddress("CR_RipChunk"); |
| 50 | ex_CR_GetCDROMParameters = (CR_GETCDROMPARAMETERS) cdripdll->GetFunctionAddress("CR_GetCDROMParameters"); |
| 51 | ex_CR_SetCDROMParameters = (CR_SETCDROMPARAMETERS) cdripdll->GetFunctionAddress("CR_SetCDROMParameters"); |
| 52 | ex_CR_ReadCDText = (CR_READCDTEXT) cdripdll->GetFunctionAddress("CR_ReadCDText"); |
| 53 | ex_CR_ReadAndGetISRC = (CR_READANDGETISRC) cdripdll->GetFunctionAddress("CR_ReadAndGetISRC"); |
| 54 | ex_CR_GetNumberOfCacheErrors = (CR_GETNUMBEROFCACHEERRORS) cdripdll->GetFunctionAddress("CR_GetNumberOfCacheErrors"); |
| 55 | ex_CR_GetCDRipVersion = (CR_GETCDRIPVERSION) cdripdll->GetFunctionAddress("CR_GetCDRipVersion"); |
| 56 | |
| 57 | if (ex_CR_GetNumCDROM == NIL || |
| 58 | ex_CR_OpenCDROM == NIL || |
| 59 | ex_CR_CloseCDROM == NIL || |
| 60 | ex_CR_ReadToc == NIL || |
| 61 | ex_CR_GetNumTocEntries == NIL || |
| 62 | ex_CR_GetTocEntry == NIL || |
| 63 | ex_CR_OpenRipper == NIL || |
| 64 | ex_CR_CloseRipper == NIL || |
| 65 | ex_CR_RipChunk == NIL || |
| 66 | ex_CR_GetCDROMParameters == NIL || |
| 67 | ex_CR_SetCDROMParameters == NIL || |
| 68 | ex_CR_ReadCDText == NIL || |
| 69 | ex_CR_ReadAndGetISRC == NIL || |
| 70 | ex_CR_GetNumberOfCacheErrors == NIL || |
| 71 | ex_CR_GetCDRipVersion == NIL) { FreeCDRipDLL(); return False; } |
| 72 | |
| 73 | return True; |
| 74 | } |
| 75 | |
| 76 | Void FreeCDRipDLL() |
| 77 | { |
| 78 | Object::DeleteObject(cdripdll); |
| 79 | |
| 80 | cdripdll = NIL; |
| 81 | } |