예제 #1
0
int eMPEGStreamInformation::load(const char *filename)
{
	//eDebug("[eMPEGStreamInformation] {%d} load(%s)", gettid(), filename);
	close();
	std::string s_filename(filename);
	m_structure_read_fd = ::open((s_filename + ".sc").c_str(), O_RDONLY | O_CLOEXEC);
	m_access_points.clear();
	m_pts_to_offset.clear();
	m_timestamp_deltas.clear();
	CFile f((s_filename + ".ap").c_str(), "rb");
	if (!f)
		return -1;
	while (1)
	{
		unsigned long long d[2];
		if (fread(d, sizeof(d), 1, f) < 1)
			break;
		d[0] = be64toh(d[0]);
		d[1] = be64toh(d[1]);
		m_access_points[d[0]] = d[1];
		m_pts_to_offset.insert(std::pair<pts_t,off_t>(d[1], d[0]));
	}
	/* assume the accesspoints are in streamtime, if they start with a 0 timestamp */
	m_streamtime_accesspoints = (!m_access_points.empty() && m_access_points.begin()->second == 0);
	fixupDiscontinuties();
	return 0;
}
예제 #2
0
파일: pvrparse.cpp 프로젝트: ambrosa/test
int eMPEGStreamInformation::load(const char *filename)
{
	std::string s_filename(filename);
	if (m_structure_read)
		fclose(m_structure_read);
	m_structure_read = fopen((s_filename + ".sc").c_str(), "rb");
	FILE *f = fopen((s_filename + ".ap").c_str(), "rb");
	if (!f)
		return -1;
	m_access_points.clear();
	m_pts_to_offset.clear();
	while (1)
	{
		unsigned long long d[2];
		if (fread(d, sizeof(d), 1, f) < 1)
			break;
		
#if BYTE_ORDER == LITTLE_ENDIAN
		d[0] = bswap_64(d[0]);
		d[1] = bswap_64(d[1]);
#endif
		m_access_points[d[0]] = d[1];
		m_pts_to_offset.insert(std::pair<pts_t,off_t>(d[1], d[0]));
	}
	fclose(f);
	fixupDiscontinuties();
	return 0;
}
예제 #3
0
Dialogs::ConvertMemoryCardDialog::ConvertMemoryCardDialog( wxWindow* parent, const wxDirName& mcdPath, const AppConfig::McdOptions& mcdSourceConfig )
	: wxDialogWithHelpers( parent, _( "Convert a memory card to a different format" ) )
	, m_mcdPath( mcdPath )
	, m_mcdSourceFilename( mcdSourceConfig.Filename.GetFullName() )
{
	SetMinWidth( 472 * MSW_GetDPIScale());

	CreateControls( mcdSourceConfig.Type );

	if ( m_radio_CardType ) m_radio_CardType->Realize();

	wxBoxSizer& s_buttons( *new wxBoxSizer( wxHORIZONTAL ) );
	s_buttons += new wxButton( this, wxID_OK, _( "Convert" ) ) | pxProportion( 2 );
	s_buttons += pxStretchSpacer( 3 );
	s_buttons += new wxButton( this, wxID_CANCEL ) | pxProportion( 2 );

	wxBoxSizer& s_padding( *new wxBoxSizer( wxVERTICAL ) );

	s_padding += Heading( wxString( _( "Convert: " ) ) + ( mcdPath + m_mcdSourceFilename ).GetFullPath() ).Unwrapped() | pxSizerFlags::StdExpand();

	wxBoxSizer& s_filename( *new wxBoxSizer( wxHORIZONTAL ) );
	s_filename += Heading( _( "To: " ) ).Unwrapped().Align(wxALIGN_RIGHT) | pxProportion(1);
	m_text_filenameInput->SetValue( wxFileName( m_mcdSourceFilename ).GetName() + L"_converted" );
	s_filename += m_text_filenameInput | pxProportion(2);
	s_filename += Heading( L".ps2" ).Align(wxALIGN_LEFT) | pxProportion(1);

	s_padding += s_filename | pxSizerFlags::StdExpand();

	s_padding += m_radio_CardType | pxSizerFlags::StdExpand();

	if ( mcdSourceConfig.Type != MemoryCardType::MemoryCard_File ) {
		s_padding += Heading( pxE( L"Please note that the resulting file may not actually contain all saves, depending on how many are in the source memory card." ) );
	}
	s_padding += Heading( pxE( L"WARNING: Converting a memory card may take a while! Please do not close the emulator during the conversion process, even if the emulator is no longer responding to input." ) );

	s_padding += 12;
	s_padding += s_buttons | pxSizerFlags::StdCenter();

	*this += s_padding | pxSizerFlags::StdExpand();

	Connect( wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ConvertMemoryCardDialog::OnOk_Click ) );
	Connect( m_text_filenameInput->GetId(), wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( ConvertMemoryCardDialog::OnOk_Click ) );

	SetSizerAndFit(GetSizer());

	m_text_filenameInput->SetFocus();
	m_text_filenameInput->SelectAll();
}
예제 #4
0
LIBHANDLE
flx_load_library(const std::string& filename)
{
  LIBHANDLE library;
  FLX_SET_NOLIBRARY(library);
  if (std::getenv("FLX_SHELL_ECHO")!=(char*)0)
    fprintf(stderr,"[load_library] %s\n", filename.c_str());
//#if FLX_WIN32 || FLX_CYGWIN
#if FLX_WIN32
  // stop windows showing err dialogues, ignoring error code.
  (void)SetErrorMode(SEM_NOOPENFILEERRORBOX);
  library = LoadLibrary(filename.c_str());
  if(FLX_CHECK_NOLIBRARY(library))
    throw flx_link_failure_t(filename,"LoadLibrary","Cannot find dll");
#else
  #if FLX_MACOSX_NODLCOMPAT
    NSObjectFileImage            bndl_img;
    NSObjectFileImageReturnCode  res;

    string s_filename(filename);
    struct stat st;

    if (stat(s_filename.c_str(), &st) != 0) {
      // we can't find the file, so search DYLD_LIBRARY_PATH
      string paths = getenv("DYLD_LIBRARY_PATH");

      size_t i = 0;
      bool found = false;

      while ((i = paths.find_first_of(':')) != paths.npos) {
        string s = paths.substr(0, i) + '/' + filename;
        paths = paths.substr(i + 1);

        if (stat(s.c_str(), &st) == 0) {
          s_filename = s;
          found = true;
          break;
        }
      }

      if (!found) {
              throw flx_link_failure_t(filename, "stat",
                string("cannot find file: ") + filename);
      }
    }

    res = NSCreateObjectFileImageFromFile(s_filename.c_str(), &bndl_img);

    if(NSObjectFileImageSuccess != res)
      throw flx_link_failure_t(filename, "NSCreateObjectFileImageFromFile",
              "failure to open library");

    // don't merge globals with loader's, load programmatically
    // return on error allows us to continue without being terminated

    unsigned long link_flags;
    link_flags = NSLINKMODULE_OPTION_PRIVATE | NSLINKMODULE_OPTION_RETURN_ON_ERROR;
    library = NSLinkModule(bndl_img, filename.c_str(), link_flags);

    // even if link failed, we do this
    NSDestroyObjectFileImage(bndl_img);

    // more info can be gleaned about link errors from NSLinkEditError
    if(FLX_CHECK_NOLIBRARY(library))
      throw flx_link_failure_t(filename, "NSLinkModule", "failed to link");

  #else
    library = dlopen(filename.c_str(),RTLD_NOW);
    if(FLX_CHECK_NOLIBRARY(library))
      throw flx_link_failure_t(filename,"dlopen",dlerror());
  #endif
#endif
  return library;
}