| 1 | /* BoCA - BonkEnc Component Architecture |
| 2 | * Copyright (C) 2007-2015 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 | BONKDECODERCREATE ex_bonk_decoder_create = NIL; |
| 19 | BONKDECODERINIT ex_bonk_decoder_init = NIL; |
| 20 | BONKDECODERDECODEPACKET ex_bonk_decoder_decode_packet = NIL; |
| 21 | BONKDECODERFINISH ex_bonk_decoder_finish = NIL; |
| 22 | BONKDECODERCLOSE ex_bonk_decoder_close = NIL; |
| 23 | BONKDECODERGETSTREAMINFO ex_bonk_decoder_get_stream_info = NIL; |
| 24 | BONKDECODERGETID3DATA ex_bonk_decoder_get_id3_data = NIL; |
| 25 | BONKDECODERINITSEEKTABLE ex_bonk_decoder_init_seektable = NIL; |
| 26 | BONKDECODERSEEKTO ex_bonk_decoder_seek_to = NIL; |
| 27 | BONKGETVERSIONSTRING ex_bonk_get_version_string = NIL; |
| 28 | |
| 29 | DynamicLoader *bonkdll = NIL; |
| 30 | |
| 31 | Bool LoadBonkDLL() |
| 32 | { |
| 33 | bonkdll = BoCA::Utilities::LoadCodecDLL("bonk"); |
| 34 | |
| 35 | if (bonkdll == NIL) return False; |
| 36 | |
| 37 | ex_bonk_decoder_create = (BONKDECODERCREATE) bonkdll->GetFunctionAddress("bonk_decoder_create"); |
| 38 | ex_bonk_decoder_init = (BONKDECODERINIT) bonkdll->GetFunctionAddress("bonk_decoder_init"); |
| 39 | ex_bonk_decoder_decode_packet = (BONKDECODERDECODEPACKET) bonkdll->GetFunctionAddress("bonk_decoder_decode_packet"); |
| 40 | ex_bonk_decoder_finish = (BONKDECODERFINISH) bonkdll->GetFunctionAddress("bonk_decoder_finish"); |
| 41 | ex_bonk_decoder_close = (BONKDECODERCLOSE) bonkdll->GetFunctionAddress("bonk_decoder_close"); |
| 42 | ex_bonk_decoder_get_stream_info = (BONKDECODERGETSTREAMINFO) bonkdll->GetFunctionAddress("bonk_decoder_get_stream_info"); |
| 43 | ex_bonk_decoder_get_id3_data = (BONKDECODERGETID3DATA) bonkdll->GetFunctionAddress("bonk_decoder_get_id3_data"); |
| 44 | ex_bonk_decoder_init_seektable = (BONKDECODERINITSEEKTABLE) bonkdll->GetFunctionAddress("bonk_decoder_init_seektable"); |
| 45 | ex_bonk_decoder_seek_to = (BONKDECODERSEEKTO) bonkdll->GetFunctionAddress("bonk_decoder_seek_to"); |
| 46 | ex_bonk_get_version_string = (BONKGETVERSIONSTRING) bonkdll->GetFunctionAddress("bonk_get_version_string"); |
| 47 | |
| 48 | if (ex_bonk_decoder_create == NIL || |
| 49 | ex_bonk_decoder_init == NIL || |
| 50 | ex_bonk_decoder_decode_packet == NIL || |
| 51 | ex_bonk_decoder_finish == NIL || |
| 52 | ex_bonk_decoder_close == NIL || |
| 53 | ex_bonk_decoder_get_stream_info == NIL || |
| 54 | ex_bonk_decoder_get_id3_data == NIL || |
| 55 | ex_bonk_decoder_init_seektable == NIL || |
| 56 | ex_bonk_decoder_seek_to == NIL || |
| 57 | ex_bonk_get_version_string == NIL) { FreeBonkDLL(); return False; } |
| 58 | |
| 59 | return True; |
| 60 | } |
| 61 | |
| 62 | Void FreeBonkDLL() |
| 63 | { |
| 64 | BoCA::Utilities::FreeCodecDLL(bonkdll); |
| 65 | |
| 66 | bonkdll = NIL; |
| 67 | } |