Skip to content

Commit 2947760

Browse files
author
tnarine-amd
committed
Git subtree pull latest AMF shared code in preparation for 1.4.9 release.
Merge commit 'e74b6c9156dae944f7326c66246b2669ed0de83b'
2 parents 2d3061a + e74b6c9 commit 2947760

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2546
-199
lines changed

amf/public/common/AMFFactory.cpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//
1010
// MIT license
1111
//
12-
// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
12+
// Copyright (c) 2018 Advanced Micro Devices, Inc. All rights reserved.
1313
//
1414
// Permission is hereby granted, free of charge, to any person obtaining a copy
1515
// of this software and associated documentation files (the "Software"), to deal
@@ -66,13 +66,13 @@ AMF_RESULT AMFFactoryHelper::Init()
6666
amf_atomic_inc(&m_iRefCount);
6767
return AMF_OK;
6868
}
69-
m_hDLLHandle = LoadLibraryW(AMF_DLL_NAME);
69+
m_hDLLHandle = amf_load_library(AMF_DLL_NAME);
7070
if(m_hDLLHandle == NULL)
7171
{
7272
return AMF_FAIL;
7373
}
7474

75-
AMFInit_Fn initFun = (AMFInit_Fn)::GetProcAddress(m_hDLLHandle, AMF_INIT_FUNCTION_NAME);
75+
AMFInit_Fn initFun = (AMFInit_Fn)::amf_get_proc_address(m_hDLLHandle, AMF_INIT_FUNCTION_NAME);
7676
if(initFun == NULL)
7777
{
7878
return AMF_FAIL;
@@ -82,7 +82,7 @@ AMF_RESULT AMFFactoryHelper::Init()
8282
{
8383
return res;
8484
}
85-
AMFQueryVersion_Fn versionFun = (AMFQueryVersion_Fn)::GetProcAddress(m_hDLLHandle, AMF_QUERY_VERSION_FUNCTION_NAME);
85+
AMFQueryVersion_Fn versionFun = (AMFQueryVersion_Fn)::amf_get_proc_address(m_hDLLHandle, AMF_QUERY_VERSION_FUNCTION_NAME);
8686
if(versionFun == NULL)
8787
{
8888
return AMF_FAIL;
@@ -114,7 +114,7 @@ AMF_RESULT AMFFactoryHelper::Terminate()
114114
amf_atomic_dec(&m_iRefCount);
115115
if(m_iRefCount == 0)
116116
{
117-
FreeLibrary(m_hDLLHandle);
117+
amf_free_library(m_hDLLHandle);
118118
m_hDLLHandle = NULL;
119119
m_pFactory= NULL;
120120
m_pDebug = NULL;
@@ -155,10 +155,14 @@ AMF_RESULT AMFFactoryHelper::LoadExternalComponent(amf::AMFContext* pContext, c
155155
}
156156

157157
// check if DLL has already been loaded
158-
HMODULE hDll = NULL;
158+
amf_handle hDll = NULL;
159159
for (std::vector<ComponentHolder>::iterator it = m_extComponents.begin(); it != m_extComponents.end(); ++it)
160160
{
161-
if (wcsicmp(it->m_DLL.c_str(), dll) == 0)
161+
#if defined(_WIN32)
162+
if (wcsicmp(it->m_DLL.c_str(), dll) == 0) // ignore case on Windows
163+
#elif defined(__linux) // Linux
164+
if (wcscmp(it->m_DLL.c_str(), dll) == 0) // case sensitive on Linux
165+
#endif
162166
{
163167
if (it->m_hDLLHandle != NULL)
164168
{
@@ -179,7 +183,7 @@ AMF_RESULT AMFFactoryHelper::LoadExternalComponent(amf::AMFContext* pContext, c
179183
component.m_hDLLHandle = NULL;
180184
component.m_DLL = dll;
181185

182-
hDll = LoadLibraryW(dll);
186+
hDll = amf_load_library(dll);
183187
if (hDll == NULL)
184188
return AMF_FAIL;
185189

@@ -194,7 +198,7 @@ AMF_RESULT AMFFactoryHelper::LoadExternalComponent(amf::AMFContext* pContext, c
194198

195199
// look for function we want in the dll we just loaded
196200
typedef AMF_RESULT(AMF_CDECL_CALL *AMFCreateComponentFunc)(amf::AMFContext*, void* reserved, amf::AMFComponent**);
197-
AMFCreateComponentFunc initFn = (AMFCreateComponentFunc)::GetProcAddress(hDll, function);
201+
AMFCreateComponentFunc initFn = (AMFCreateComponentFunc)::amf_get_proc_address(hDll, function);
198202
if (initFn == NULL)
199203
return AMF_FAIL;
200204

@@ -209,7 +213,11 @@ AMF_RESULT AMFFactoryHelper::UnLoadExternalComponent(const wchar_t* dll)
209213
}
210214
for (std::vector<ComponentHolder>::iterator it = m_extComponents.begin(); it != m_extComponents.end(); ++it)
211215
{
212-
if (wcsicmp(it->m_DLL.c_str(), dll) == 0)
216+
#if defined(_WIN32)
217+
if (wcsicmp(it->m_DLL.c_str(), dll) == 0) // ignore case on Windows
218+
#elif defined(__linux) // Linux
219+
if (wcscmp(it->m_DLL.c_str(), dll) == 0) // case sensitive on Linux
220+
#endif
213221
{
214222
if (it->m_hDLLHandle == NULL)
215223
{
@@ -218,7 +226,7 @@ AMF_RESULT AMFFactoryHelper::UnLoadExternalComponent(const wchar_t* dll)
218226
amf_atomic_dec(&it->m_iRefCount);
219227
if (it->m_iRefCount == 0)
220228
{
221-
FreeLibrary(it->m_hDLLHandle);
229+
amf_free_library(it->m_hDLLHandle);
222230
m_extComponents.erase(it);
223231
}
224232
break;

amf/public/common/AMFFactory.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//
1010
// MIT license
1111
//
12-
// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
12+
// Copyright (c) 2018 Advanced Micro Devices, Inc. All rights reserved.
1313
//
1414
// Permission is hereby granted, free of charge, to any person obtaining a copy
1515
// of this software and associated documentation files (the "Software"), to deal
@@ -59,7 +59,7 @@ class AMFFactoryHelper
5959
protected:
6060
struct ComponentHolder
6161
{
62-
HMODULE m_hDLLHandle;
62+
amf_handle m_hDLLHandle;
6363
amf_long m_iRefCount;
6464
std::wstring m_DLL;
6565

@@ -70,7 +70,7 @@ class AMFFactoryHelper
7070
}
7171
};
7272

73-
HMODULE m_hDLLHandle;
73+
amf_handle m_hDLLHandle;
7474
amf::AMFFactory* m_pFactory;
7575
amf::AMFDebug* m_pDebug;
7676
amf::AMFTrace* m_pTrace;

0 commit comments

Comments
 (0)