Skip to content

Commit

Permalink
Fixed library handle in hcaenc
Browse files Browse the repository at this point in the history
  • Loading branch information
hozuki committed Apr 25, 2020
1 parent 0961776 commit ac6c9a6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/apps/hcaenc/hcaenc.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <cstdio>
#include <Windows.h>

#include "../../lib/cgss_api.h"

#define VGAUDIO_APP_LINK "https://github.com/hozuki/vgaudio-cpp"
Expand Down Expand Up @@ -29,7 +31,7 @@ static void PrintAppTitle(FILE *out);
static void PrintHelp();

int main(int argc, const char *argv[]) {
HMODULE hHcaEncDll = nullptr;
cgss::Utilities::HLIB hHcaEncDll = nullptr;
LPCSTR inputFile = nullptr;
LPCSTR outputFile = nullptr;
// These are (nearly) the same settings as High audio profile of CGSS.
Expand Down
6 changes: 3 additions & 3 deletions src/lib/takamori/Utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@

CGSS_NS_BEGIN

void *Utilities::LoadDynamicLibrary(const char *lpstrModuleName) {
cgss::Utilities::HLIB Utilities::LoadDynamicLibrary(const char *lpstrModuleName) {
#if defined(__CGSS_OS_WINDOWS__)
return LoadLibrary(lpstrModuleName);
#elif defined(__CGSS_OS_UNIX__)
return dlopen(lpstrModuleName, RTLD_LAZY);
#endif
}

void *Utilities::GetFunctionAddress(const void *hModule, const char *lpstrFuncName) {
void *Utilities::GetFunctionAddress(cgss::Utilities::CHLIB hModule, const char *lpstrFuncName) {
#if defined(__CGSS_OS_WINDOWS__)
return (void *)GetProcAddress((HMODULE)hModule, lpstrFuncName);
#elif defined(__CGSS_OS_UNIX__)
return dlsym(hModule, lpstrFuncName);
#endif
}

bool_t Utilities::FreeDynamicLibrary(void *hModule) {
bool_t Utilities::FreeDynamicLibrary(cgss::Utilities::HLIB hModule) {
#if defined(__CGSS_OS_WINDOWS__)
return static_cast<bool_t>(FreeLibrary((HMODULE)hModule));
#elif defined(__CGSS_OS_UNIX__)
Expand Down
9 changes: 6 additions & 3 deletions src/lib/takamori/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ CGSS_NS_BEGIN

public:

static void *LoadDynamicLibrary(const char *lpstrModuleName);
typedef void *HLIB;
typedef const void *CHLIB;

static void *GetFunctionAddress(const void *hModule, const char *lpstrFuncName);
static HLIB LoadDynamicLibrary(const char *lpstrModuleName);

static bool_t FreeDynamicLibrary(void *hModule);
static void *GetFunctionAddress(CHLIB hModule, const char *lpstrFuncName);

static bool_t FreeDynamicLibrary(HLIB hModule);

PURE_STATIC(Utilities);

Expand Down

0 comments on commit ac6c9a6

Please sign in to comment.