| 1 | /* BoCA - BonkEnc Component Architecture |
| 2 | * Copyright (C) 2007-2017 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 <boca.h> |
| 14 | #include "dllinterface.h" |
| 15 | |
| 16 | using namespace BoCA; |
| 17 | |
| 18 | HIP_DECODE_INIT ex_hip_decode_init = NIL; |
| 19 | HIP_DECODE_EXIT ex_hip_decode_exit = NIL; |
| 20 | HIP_DECODE ex_hip_decode = NIL; |
| 21 | HIP_DECODE_HEADERS ex_hip_decode_headers = NIL; |
| 22 | GET_LAME_SHORT_VERSION ex_get_lame_short_version = NIL; |
| 23 | |
| 24 | DynamicLoader *lamedll = NIL; |
| 25 | |
| 26 | Bool LoadLAMEDLL() |
| 27 | { |
| 28 | #ifdef __WIN32__ |
| 29 | lamedll = BoCA::Utilities::LoadCodecDLL("LAME"); |
| 30 | #else |
| 31 | lamedll = BoCA::Utilities::LoadCodecDLL("mp3lame"); |
| 32 | #endif |
| 33 | |
| 34 | if (lamedll == NIL) return False; |
| 35 | |
| 36 | ex_hip_decode_init = (HIP_DECODE_INIT) lamedll->GetFunctionAddress("hip_decode_init"); |
| 37 | ex_hip_decode_exit = (HIP_DECODE_EXIT) lamedll->GetFunctionAddress("hip_decode_exit"); |
| 38 | ex_hip_decode = (HIP_DECODE) lamedll->GetFunctionAddress("hip_decode"); |
| 39 | ex_hip_decode_headers = (HIP_DECODE_HEADERS) lamedll->GetFunctionAddress("hip_decode_headers"); |
| 40 | ex_get_lame_short_version = (GET_LAME_SHORT_VERSION) lamedll->GetFunctionAddress("get_lame_short_version"); |
| 41 | |
| 42 | if (ex_hip_decode_init == NIL || |
| 43 | ex_hip_decode_exit == NIL || |
| 44 | ex_hip_decode == NIL || |
| 45 | ex_hip_decode_headers == NIL || |
| 46 | ex_get_lame_short_version == NIL) { FreeLAMEDLL(); return False; } |
| 47 | |
| 48 | return True; |
| 49 | } |
| 50 | |
| 51 | Void FreeLAMEDLL() |
| 52 | { |
| 53 | BoCA::Utilities::FreeCodecDLL(lamedll); |
| 54 | |
| 55 | lamedll = NIL; |
| 56 | } |