Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  OmxCoreLibLinker.cpp

  Sprache: C
 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#include "OmxCoreLibLinker.h"

#include "MainThreadUtils.h"
#include "PlatformDecoderModule.h"
#include "mozilla/Preferences.h"
#include "prlink.h"

#ifdef LOG
#  undef LOG
#endif

#define LOG(arg, ...)                                                          \
  MOZ_LOG_FMT(sPDMLog, mozilla::LogLevel::Debug, "OmxCoreLibLinker::{}: " arg, \
              __func__, ##__VA_ARGS__)

namespace mozilla {

OmxCoreLibLinker::LinkStatus OmxCoreLibLinker::sLinkStatus = LinkStatus_INIT;

const char* OmxCoreLibLinker::sLibNames[] = {
    "libopenmaxil.so",         // Raspberry Pi
    "libomxr_core.so",         // Renesas R-Car, RZ/G
    "libomxil-bellagio.so.0",  // Bellagio: An OSS implementation of OpenMAX IL
};

PRLibrary* OmxCoreLibLinker::sLinkedLib = nullptr;
const char* OmxCoreLibLinker::sLibName = nullptr;

#define OMX_FUNC(func) void (*func)();
#include "OmxFunctionList.inc"
#undef OMX_FUNC

bool OmxCoreLibLinker::TryLinkingLibrary(const char* libName) {
  PRLibSpec lspec;
  lspec.type = PR_LibSpec_Pathname;
  lspec.value.pathname = libName;
  sLinkedLib = PR_LoadLibraryWithFlags(lspec, PR_LD_NOW | PR_LD_LOCAL);
  if (sLinkedLib) {
    if (Bind(libName)) {
      sLibName = libName;
      LOG("Succeeded to load {}", libName);
      return true;
    } else {
      LOG("Failed to link {}", libName);
    }
    Unlink();
  }
  return false;
}

/* static */
bool OmxCoreLibLinker::Link() {
  LOG("");

  if (sLinkStatus) {
    return sLinkStatus == LinkStatus_SUCCEEDED;
  }

  MOZ_ASSERT(NS_IsMainThread());

  nsAutoCString libPath;
  nsresult rv = Preferences::GetCString("media.omx.core-lib-path", libPath);
  if (NS_SUCCEEDED(rv) && !libPath.IsEmpty()) {
    if (TryLinkingLibrary(libPath.Data())) {
      sLinkStatus = LinkStatus_SUCCEEDED;
      return true;
    }
  }

  // try known paths
  for (size_t i = 0; i < std::size(sLibNames); i++) {
    if (TryLinkingLibrary(sLibNames[i])) {
      sLinkStatus = LinkStatus_SUCCEEDED;
      return true;
    }
  }
  sLinkStatus = LinkStatus_FAILED;
  return false;
}

/* static */
bool OmxCoreLibLinker::Bind(const char* aLibName) {
#define OMX_FUNC(func)                                              \
  {                                                                 \
    if (!(func = (typeof(func))PR_FindSymbol(sLinkedLib, #func))) { \
      LOG("Couldn't load function " #func " from {}.", aLibName);   \
      return false;                                                 \
    }                                                               \
  }
#include "OmxFunctionList.inc"
#undef OMX_FUNC
  return true;
}

/* static */
void OmxCoreLibLinker::Unlink() {
  LOG("");

  if (sLinkedLib) {
    PR_UnloadLibrary(sLinkedLib);
    sLinkedLib = nullptr;
    sLibName = nullptr;
    sLinkStatus = LinkStatus_INIT;
  }
}

}  // namespace mozilla

Messung V0.5 in Prozent
C=88 H=93 G=90

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet am  2026-08-26) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002