Skip to content

Commit

Permalink
Merge pull request #1166 from tmm1/omega-widevine-arm64
Browse files Browse the repository at this point in the history
[widevine] add support for linux arm64
  • Loading branch information
glennguy authored Feb 25, 2023
2 parents 26ee37a + 620e8ee commit c1494bd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,19 @@ void CSession::SetSupportedDecrypterURN(std::string& key_system)
m_dllHelper = std::make_unique<kodi::tools::CDllHelper>();
if (m_dllHelper->LoadDll(item.Path()))
{
#if defined(__linux__) && defined(__aarch64__) && !defined(ANDROID)
// On linux arm64, libwidevinecdm.so depends on two dynamic symbols:
// __aarch64_ldadd4_acq_rel
// __aarch64_swp4_acq_rel
// These are defined in libssd_wv.so, but to make them available in the main binary's PLT,
// we need RTLD_GLOBAL. LoadDll() above uses RTLD_LOCAL, so we use RTLD_NOLOAD here to
// switch the flags from LOCAL to GLOBAL.
void *hdl = dlopen(item.Path().c_str(), RTLD_NOLOAD | RTLD_GLOBAL | RTLD_LAZY);
if (!hdl)
{
LOG::Log(LOGERROR, "Failed to reload dll in global mode: %s", dlerror());
}
#endif
CreateDecryptorInstanceFunc startup;
if (m_dllHelper->RegisterSymbol(startup, "CreateDecryptorInstance"))
{
Expand Down
16 changes: 16 additions & 0 deletions wvdecrypter/wvdecrypter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,22 @@ class WVDecrypter : public SSD_DECRYPTER

extern "C" {

// Linux arm64 version of libwidevinecdm.so depends on two
// dynamic symbols. See https://github.com/xbmc/inputstream.adaptive/issues/1128
#if defined(__linux__) && defined(__aarch64__) && !defined(ANDROID)
__attribute__((target("no-outline-atomics")))
int32_t __aarch64_ldadd4_acq_rel(int32_t value, int32_t *ptr)
{
return __atomic_fetch_add(ptr, value, __ATOMIC_ACQ_REL);
}

__attribute__((target("no-outline-atomics")))
int32_t __aarch64_swp4_acq_rel(int32_t value, int32_t *ptr)
{
return __atomic_exchange_n(ptr, value, __ATOMIC_ACQ_REL);
}
#endif

#ifdef _WIN32
#define MODULE_API __declspec(dllexport)
#else
Expand Down

0 comments on commit c1494bd

Please sign in to comment.