/* static */ bool
FFVPXRuntimeLinker::Init()
{
  if (sLinkStatus) {
    return sLinkStatus == LinkStatus_SUCCEEDED;
  }

  MOZ_ASSERT(NS_IsMainThread());
  sLinkStatus = LinkStatus_FAILED;

  // We retrieve the path of the lgpllibs library as this is where mozavcodec
  // and mozavutil libs are located.
  PathString lgpllibsname = GetLibraryName(nullptr, "lgpllibs");
  if (lgpllibsname.IsEmpty()) {
    return false;
  }
  PathString path =
    GetLibraryFilePathname(lgpllibsname.get(),
                           (PRFuncPtr)&soundtouch::SoundTouch::getVersionId);
  if (path.IsEmpty()) {
    return false;
  }
  RefPtr<nsLocalFile> xulFile = new nsLocalFile(path);
  if (xulFile->NativePath().IsEmpty()) {
    return false;
  }

  nsCOMPtr<nsIFile> rootDir;
  if (NS_FAILED(xulFile->GetParent(getter_AddRefs(rootDir))) || !rootDir) {
    return false;
  }
  PathString rootPath = rootDir->NativePath();

  /* Get the platform-dependent library name of the module */
  PathString libname = GetLibraryName(rootPath.get(), "mozavutil");
  if (libname.IsEmpty()) {
    return false;
  }
  RefPtr<nsLocalFile> libFile = new nsLocalFile(libname);
  if (libFile->NativePath().IsEmpty()) {
    return false;
  }
  sFFVPXLib.mAVUtilLib = MozAVLink(libFile);
  libname = GetLibraryName(rootPath.get(), "mozavcodec");
  if (!libname.IsEmpty()) {
    libFile = new nsLocalFile(libname);
    if (!libFile->NativePath().IsEmpty()) {
      sFFVPXLib.mAVCodecLib = MozAVLink(libFile);
    }
  }
  if (sFFVPXLib.Link() == FFmpegLibWrapper::LinkResult::Success) {
    sLinkStatus = LinkStatus_SUCCEEDED;
    return true;
  }
  return false;
}
void DelayLoadLibrary::Ensure(DWORD dwFlags)
{
    if (!m_isInit)
    {
        m_hModule = LoadLibraryEx(GetLibraryName(), nullptr, dwFlags);
        m_isInit = true;
    }
}
Esempio n. 3
0
void InstructionTrace(INS ins, void* v)
{
	// check if we just received a snapshot request
	bool snapshotStatus = CheckSnapshotEvent();
	if (snapshotStatus)
	{
		// We just detected a monitoring change! Take a memory snapshot now
		TakeSnapshot();

		// reset the event
		DisableSnapshotEvent();
	}

	// check the monitoring event if we should still be monitoring or not 
	bool monitoringStatus = CheckMonitoringEvent();
	if (!monitoringStatus)
	{
		return;
	}

	instruction_trace trace;
	trace.tid = PIN_GetTid();
	trace.address = INS_Address(ins);

	memset(trace.library_name, 0, 260);
	std::string libraryName;
	if (CHECK_LIBRARY_NAMES && GetLibraryName(trace.address, libraryName))
	{
		snprintf(trace.library_name, sizeof(trace.library_name), "%s", libraryName.c_str());
	}
	

	if (INS_IsCall(ins) == true)
	{
		trace.execution_depth = executionDepth++;
	}
	else if (INS_IsRet(ins) == true)
	{
		trace.execution_depth = executionDepth--;
	}
	else
		trace.execution_depth = executionDepth;

	trace.instruction_count = instructionCount++;
	
#ifdef TARGET_WINDOWS
	trace.execution_time = WINDOWS::GetTickCount();
#else
	timeval time;
	gettimeofday(&time, NULL);
	unsigned long millis = (time.tv_sec * 1000) + (time.tv_usec / 1000);
	trace.execution_time = millis;
#endif

	LogStruct(trace);
}
Esempio n. 4
0
bool MP3Exporter::FindLibrary(wxWindow *parent)
{
   mLibPath = gPrefs->Read("/MP3/MP3LibPath", "");

   if (mLibPath=="" || !::wxFileExists(mLibPath)) {
   
      int action = wxMessageBox(GetLibraryMessage(),
                                _("Export MP3"),
                                wxYES_NO | wxICON_EXCLAMATION,
                                parent);

      if (action == wxYES) {
         wxString question;
         question.Printf(_("Where is %s?"), (const char *)GetLibraryName());
         mLibPath = wxFileSelector(question, 
                                   GetLibraryPath(),        // Path
                                   GetLibraryName(),        // Name
                                   "",      // Extension
                                   GetLibraryTypeString(),
                                   wxOPEN, parent);
         
         if (mLibPath == "") {
            mLibPath = "";
            gPrefs->Write("/MP3/MP3LibPath", mLibPath);
         
            return false;
         }
         
         wxString path, baseName, extension;
         ::wxSplitPath(mLibPath, &path, &baseName, &extension);
         
         if (extension != "")
            baseName += "." + extension;
         
         if (baseName.CmpNoCase(GetLibraryName())) {
         
            wxString question;
            question.Printf(_("Audacity was expecting a library named \"%s\".  "
                              "Are you sure you want to attempt to export MP3 "
                              "files using \"%s\"?"),
                            (const char *)GetLibraryName(),
                            (const char *)baseName);

            int action = wxMessageBox(question,
                                      _("Export MP3"),
                                      wxYES_NO | wxICON_EXCLAMATION,
                                      parent);
            
            if (action != wxYES) {
               mLibPath = "";
               gPrefs->Write("/MP3/MP3LibPath", mLibPath);
            
               return false;
            }
         }
      }
      else {
         mLibPath = "";
         gPrefs->Write("/MP3/MP3LibPath", mLibPath);
            
         return false;
      }
      
      gPrefs->Write("/MP3/MP3LibPath", mLibPath);
   }
   
   return true;
}