示例#1
0
static void check_renderbutton_framerate(RenderData *rd, ReportList *reports) 
{
	// to keep float framerates consistent between the codec dialog and frs/sec button.
	OSErr	err;	

	err = SCGetInfo(qtdata->theComponent, scTemporalSettingsType,	&qtdata->gTemporalSettings);
	CheckError(err, "SCGetInfo fr error", reports);

	if( (rd->frs_sec == 24 || rd->frs_sec == 30 || rd->frs_sec == 60) &&
	    (qtdata->gTemporalSettings.frameRate == 1571553 ||
	     qtdata->gTemporalSettings.frameRate == 1964113 ||
	     qtdata->gTemporalSettings.frameRate == 3928227))
	{
		/* do nothing */
	}
	else {
		if (rd->frs_sec_base > 0)
			qtdata->gTemporalSettings.frameRate = 
			((float)(rd->frs_sec << 16) / rd->frs_sec_base) ;
	}
	
	err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType,	&qtdata->gTemporalSettings);
	CheckError( err, "SCSetInfo error", reports );

	if(qtdata->gTemporalSettings.frameRate == 1571553) {			// 23.98 fps
		qtdata->kVideoTimeScale = 24000;
		qtdata->duration = 1001;
	} else if (qtdata->gTemporalSettings.frameRate == 1964113) {	// 29.97 fps
		qtdata->kVideoTimeScale = 30000;
		qtdata->duration = 1001;
	} else if (qtdata->gTemporalSettings.frameRate == 3928227) {	// 59.94 fps
		qtdata->kVideoTimeScale = 60000;
		qtdata->duration = 1001;
	} else {
		qtdata->kVideoTimeScale = (qtdata->gTemporalSettings.frameRate >> 16) * 100;
		qtdata->duration = 100;
	}
}
示例#2
0
bool CEGLWrapper::ChooseConfig(EGLDisplay display, EGLint *configAttrs, EGLConfig *config)
{
  EGLint     configCount = 0;
  EGLConfig* configList = NULL;

  // Find out how many configurations suit our needs
  EGLBoolean eglStatus = eglChooseConfig(display, configAttrs, NULL, 0, &configCount);
  CheckError();

  if (!eglStatus || !configCount)
  {
    CLog::Log(LOGERROR, "EGL failed to return any matching configurations: %i", configCount);
    return false;
  }

  // Allocate room for the list of matching configurations
  configList = (EGLConfig*)malloc(configCount * sizeof(EGLConfig));
  if (!configList)
  {
    CLog::Log(LOGERROR, "EGL failure obtaining configuration list");
    return false;
  }

  // Obtain the configuration list from EGL
  eglStatus = eglChooseConfig(display, configAttrs, configList, configCount, &configCount);
  CheckError();
  if (!eglStatus || !configCount)
  {
    CLog::Log(LOGERROR, "EGL failed to populate configuration list: %d", eglStatus);
    return false;
  }

  // Select an EGL configuration that matches the native window
  *config = configList[0];

  free(configList);
  return m_result == EGL_SUCCESS;
}
示例#3
0
int OWStatement::GetInteger( OCINumber* ppoData )
{
    sb4 nRetVal;

    CheckError( OCINumberToInt(
        hError,
        ppoData,
        (uword) sizeof(sb4),
        OCI_NUMBER_SIGNED,
        (dvoid *) &nRetVal ),
        hError );

    return nRetVal;
}
示例#4
0
/*
===================================
STEAM_BlockForResources

  Instruct the STEAM resource preload system to get
  the indicated resources and block until all are
  obtained.

  ***NOTE*** THIS BLOCKS (DUH) SO DON'T USE WANTONLY
===================================
*/
int STEAM_BlockForResources( const char *hintlist )
{
	int val = TRUE;

#if STEAM_SYNCHRONIZED_PRELOADING
	{
//		val = SteamHintResourceNeed(hintlist, TRUE, &steamError); // Temporary implementation.
		val = SteamWaitForResources(hintlist, &steamError);
		CheckError(NULL, &steamError);
	}
#endif

	return val;
}
示例#5
0
文件: EGLWrapper.cpp 项目: ugers/xbmc
bool CEGLWrapper::CreateSurface(EGLDisplay display, EGLConfig config, EGLSurface *surface)
{
    if (!surface || !m_nativeTypes)
        return false;

    EGLNativeWindowType *nativeWindow=NULL;
    if (!m_nativeTypes->GetNativeWindow((XBNativeWindowType**)&nativeWindow))
        return false;

    *surface = eglCreateWindowSurface(display, config, *nativeWindow, NULL);
    CheckError();

    return *surface != EGL_NO_SURFACE;
}
示例#6
0
/*
===================================
STEAM_ResumeResourcePreloading

  Resume STEAM resource preloading
===================================
*/
int STEAM_ResumeResourcePreloading(void)
{
	int val = TRUE;

#if STEAM_SYNCHRONIZED_PRELOADING
	{
		val = SteamResumeCachePreloading(&steamError);
		CheckError(NULL, &steamError);
	}
#endif

	return val;

}
示例#7
0
   int CONetCDF4::getGroup(const CNetCDF4Path & path)
   {
      int retvalue = this->ncidp;
      
      CNetCDF4Path::const_iterator
         it  = path.begin(), end = path.end();

      for (;it != end; it++)
      {
         const std::string & groupid = *it;
         CheckError(nc_inq_ncid(retvalue, const_cast<char*>(groupid.c_str()), &retvalue));
      }
      return (retvalue);
   }
示例#8
0
文件: getvertex.c 项目: stetre/moongl
static int ArrayGetInt_(lua_State *L, GLuint array, GLenum pname, int boolean)
#define ArrayGetInt(L, array, pname) ArrayGetInt_((L), (array), (pname), 0)
#define ArrayGetBoolean(L, array, pname) ArrayGetInt_((L), (array), (pname), 1)
    {
    GLint param;
    GLuint index = luaL_checkinteger(L, 3);
    glGetVertexArrayIndexediv(array, index, pname, &param);
    CheckError(L);
    if(boolean)
        lua_pushboolean(L, param);
    else
        lua_pushinteger(L, param);
    return 1;
    }
int InsertServerPrerequisiteForMessageType(int msgType, vector<string> * v){
	char query[200];
	char * fixedInsertStr;
	unsigned int len;
	int holder;
	char * cTemp;
	MYSQL * conn;

	if(WaitForSingleObject(mysqlMutex, INFINITE) != WAIT_OBJECT_0){
		printf("InsertServerPrerequisiteForMessageType: Couldn't acquire mutex. Returning\n");
		return GENERIC_ERROR;
	}

	conn = OpenDatabaseConnection(gffServerDBName);
	if(conn == NULL){
		printf("InsertServerPrerequisiteForMessageType: OpenDatabaseConnection(gffServerDBName) failed\n");
		v->clear();
		return ReleaseMutexAndReturnError(mysqlMutex, GENERIC_ERROR);
	}

	//For each host to measure in the vector
	for(unsigned int i=0; i < v->size(); i++){
		string temp = v->at(i);
		cTemp = (char *)temp.c_str();

		fixedInsertStr = "INSERT INTO TableVerificationPrerequisiteModules VALUES(NULL,%i,'%s')";
		len = sprintf_s(query, 200, fixedInsertStr, msgType, cTemp);

		//////////////////////////////////
		if(0 != mysql_real_query(conn, query, len)){
			holder = CheckError(conn,mysql_errno(conn));
			
			// if error code is 1062, the entry already exists, so it's ok
			if(holder != 1062){
				CloseDatabaseConnection(conn);
				v->clear();
				return ReleaseMutexAndReturnError(mysqlMutex, holder);
			}
		}

	}
	CloseDatabaseConnection(conn);
	v->clear();
	//////////////////////////////////
	if(!ReleaseMutex(mysqlMutex)){
		printf("InsertServerPrerequisiteForMessageType: Couldn't release mutex. Returning\n");
		return GENERIC_ERROR;
	}
	return GENERIC_SUCCESS;
}
示例#10
0
文件: get.c 项目: stetre/moongl
static int GetEnumOptIndex(lua_State *L, GLenum pname, uint32_t domain) /* index is optional */
    {
    GLint data;
    GLuint index;
    if(!lua_isnoneornil(L, 2))
        {
        index = luaL_checkinteger(L, 2);
        glGetIntegeri_v(pname, index, &data);
        }
    else
        glGetIntegerv(pname, &data);
    CheckError(L);
    return enums_push(L, domain, data);
    }
	void Listener::updateListener()
	{
		update();
		if(mParentNode)
		{
			mPosition = mLastParentPosition;
			mDirection = mLastParentOrientation.zAxis();
			mUp = mLastParentOrientation.yAxis();
		}
		alListener3f(AL_POSITION, mPosition.x, mPosition.y, mPosition.z);
		CheckError(alGetError(), "Failed to set Position");

		mOrientation[0]= -mDirection.x; // Forward.x
		mOrientation[1]= -mDirection.y; // Forward.y
		mOrientation[2]= -mDirection.z; // Forward.z

		mOrientation[3]= mUp.x; // Up.x
		mOrientation[4]= mUp.y; // Up.y
		mOrientation[5]= mUp.z; // Up.z

		alListenerfv(AL_ORIENTATION, mOrientation);
		CheckError(alGetError(), "Failed to set Orientation");
	}
示例#12
0
void AudioChannel::SetVolume(float newVolume)
{
	volume = std::max(newVolume, 0.f);

	if (cur_sources.empty())
		return;

	boost::recursive_mutex::scoped_lock lck(soundMutex);

	for (std::map<CSoundSource*, bool>::iterator it = cur_sources.begin(); it != cur_sources.end(); ++it) {
		it->first->UpdateVolume();
	}
	CheckError("AudioChannel::SetVolume");
}
示例#13
0
void FOpenGLDrv::DrawArrayedPrimitive(GLenum InMode, GLint InStart, GLsizei InCount)
{
	// bind shader program
	SetupPendingShaderProgram();
	// Set Program Parameters
	SetupPendingShaderProgramParameters();
	// Bind Vertex Attributes
	SetupPendingVertexAttributeArray();
	// Setup Texture
	SetupPendingTexture();

	glDrawArrays(InMode, InStart, InCount);
	CheckError(__FILE__, __LINE__);
}
示例#14
0
GLint
LinkProgram(GLint vshader, GLint fshader)
{
    GLint program = glCreateProgram();

    glAttachShader(program, vshader);
    glAttachShader(program, fshader);
    glLinkProgram(program);

    // todo return placeholder program instead?
    cpAssertHard(CheckError(program, GL_LINK_STATUS, glGetProgramiv, glGetProgramInfoLog), "Error linking shader program");

    return program;
}
示例#15
0
bool CEGLWrapper::InitDisplay(EGLDisplay *display)
{
  if (!display || !m_nativeTypes)
    return false;

  //nativeDisplay can be (and usually is) NULL. Don't use if(nativeDisplay) as a test!
  EGLint status;
  EGLNativeDisplayType *nativeDisplay = NULL;
  if (!m_nativeTypes->GetNativeDisplay((XBNativeDisplayType**)&nativeDisplay))
    return false;

  *display = eglGetDisplay(*nativeDisplay);
  CheckError();
  if (*display == EGL_NO_DISPLAY)
  {
    CLog::Log(LOGERROR, "EGL failed to obtain display");
    return false;
  }

  status = eglInitialize(*display, 0, 0);
  CheckError();
  return status;
}
示例#16
0
bool PaPlayer::initStream()
{
    close();
    PaStreamParameters outputParameters;
    PaError err;

    outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
    if (outputParameters.device == paNoDevice) {
       m_lastError = "No default output device.";
       return false;
    }
    outputParameters.channelCount = m_wavFile->channelsCount();       /* stereo/mono output */
    outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
    outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
    outputParameters.hostApiSpecificStreamInfo = NULL;
    const double sampleRate = m_wavFile->audioSampleRate();
    const unsigned int framesPerBuffer = 64;

    err = Pa_OpenStream(
              &m_stream,
              NULL, // no input
              &outputParameters,
              sampleRate,
              framesPerBuffer,
              paClipOff,      // we won't output out of range samples so don't bother clipping them
              wavPlayCallback,
              this );
    CheckError(err);

    err = Pa_SetStreamFinishedCallback( m_stream, &StreamFinished );
    CheckError(err);

    err = Pa_StartStream( m_stream );
    CheckError(err);

    return true;
}
示例#17
0
//  Write a socket
wxInt32 BufferedSocket::SendData(wxInt32 Timeout)
{   
    CreateSocket();

    // create a transfer buffer, from memory stream to socket
    wxStopWatch sw;

    // clear it
    memset(sData, 0, sizeof(sData));
    
    // copy data
    wxInt32 actual_size = send_buf->CopyTo(sData, MAX_PAYLOAD);
    
    // set the start ping
    // (Horrible, needs to be improved)
    SendPing = sw.Time();
                
    // send the data
    if (!Socket->WaitForWrite(0,Timeout))
    {
        CheckError();
        
        SendPing = 0;
        RecvPing = 0;
        
        DestroySocket();
        
        return 0;
    }
    else
        Socket->SendTo(to_addr, sData, actual_size);
    
    CheckError();    
        
    // return the amount of bytes sent
    return Socket->LastCount();
}
HRESULT CModuleConfiguration::GetString(IAppHostElement* section, LPCWSTR propertyName, LPWSTR* value)
{
	HRESULT hr = S_OK;
    BSTR sysPropertyName = NULL;
    BSTR sysPropertyValue = NULL;
    IAppHostProperty* prop = NULL;

	CheckNull(value);
	*value = NULL;
	ErrorIf(NULL == (sysPropertyName = SysAllocString(propertyName)), ERROR_NOT_ENOUGH_MEMORY);
	CheckError(section->GetPropertyByName(sysPropertyName, &prop));
	CheckError(prop->get_StringValue(&sysPropertyValue));
	ErrorIf(NULL == (*value = new WCHAR[wcslen(sysPropertyValue) + 1]), ERROR_NOT_ENOUGH_MEMORY);
	wcscpy(*value, sysPropertyValue);

Error:

    if ( sysPropertyName )
    {
        SysFreeString(sysPropertyName);
        sysPropertyName = NULL;
    }

    if ( sysPropertyValue )
    {
        SysFreeString(sysPropertyValue);
        sysPropertyValue = NULL;
    }

    if (prop)
    {
        prop->Release();
        prop = NULL;
    }

    return hr;
}
示例#19
0
文件: oglp.cpp 项目: ekpyron/oglp
bool Init (GetProcAddressCallback callback)
{
    std::vector <std::string> needed_extensions = {
            "GL_ARB_separate_shader_objects",
            "GL_ARB_sampler_objects",
            "GL_ARB_direct_state_access"
    };
    std::stringstream version;
    int major, minor;

#ifdef _WIN32
	internal::_opengl32dllhandle = LoadLibrary ("OPENGL32.DLL");
	internal::_usergetprocaddress = callback;
	InitPrototypes (internal::_getprocaddress);
#else
    InitPrototypes (callback);
#endif
    if (!GetString || GetString == (PFNGLGETSTRINGPROC) oglp::Unsupported) {
#ifdef OGLP_THROW_EXCEPTIONS
		throw std::runtime_error ("No entry point for glGetString found.");
#else
        return false;
#endif
    }

    version << GetString (GL_VERSION);
    CheckError ();
    version >> major;
    version.ignore (1);
    version >> minor;

    if (major < 3) {
#ifdef OGLP_THROW_EXCEPTIONS
		throw std::runtime_error ("OpenGL version 3.0 or higher is required.");
#else
        return false;
#endif
    }
    for (std::string &extension : needed_extensions) {
        if (!IsExtensionSupported (extension)) {
#ifdef OGLP_THROW_EXCEPTIONS
			throw std::runtime_error (extension + " is required.");
#else
            return false;
#endif
        }
    }
    return true;
}
示例#20
0
int STEAM_fputc(int c, FILE *stream)
{
	unsigned char chr = (unsigned char)c;
	SteamHandle_t hndl = (SteamHandle_t)stream;
	int n;
	TSteamError steamError;

	n = SteamWriteFile(&chr, sizeof(chr), 1, hndl, &steamError);
	if ( n != 1 || steamError.eSteamError != eSteamErrorNone )
	{
		CheckError((FILE *)hndl, &steamError);
		return EOF;
	}
	return c;
}
示例#21
0
//-----------------------------
void GameMain()
{
  DDraw->FillSurface(DDraw->DDSBack,0) ;

  //turn
  CheckAction(mouse,EditInfo,world) ;
  mouse.button = mouse_NO ;
  //map scroll
  ThisTickCount = GetTickCount() ;
  if(ThisTickCount-MouseScrollTickCount>map_scroll_DELAY)
  {
    MouseScrollTickCount=ThisTickCount ;
    MoveMapByMouse(mouse.x,mouse.y,
                   (world->player[player_ID]).current_x_screen,(world->player[player_ID]).current_y_screen,
                   screen_HEIGHT,screen_WIDTH) ;
  } ;
  //drawind
  res=world->Draw(player_ID,screen,DDraw->DDSBack) ; // draw world
  CheckError(res,"world->Draw") ;
  if(mouse.x_frame>=0&&mouse.y_frame>=0)                                                                  //
  {                                                                                                       //  Draw
    res=(mouse.sprite)->Draw(DDraw->DDSBack,(mouse.x>>5)<<5,(mouse.y>>5)<<5,mouse.x_frame,mouse.y_frame) ;//  mouse
    CheckError(res,"mouse->Draw") ;                                                                       //
  } ;                                                                                                     //
示例#22
0
void AudioChannel::SetVolume(float newVolume)
{
	volume = std::max(newVolume, 0.0f);

	if (curSources.empty())
		return;

	std::lock_guard<spring::recursive_mutex> lck(soundMutex);

	for (auto it = curSources.begin(); it != curSources.end(); ++it) {
		(*it)->UpdateVolume();
	}

	CheckError("AudioChannel::SetVolume");
}
示例#23
0
文件: get.c 项目: stetre/moongl
static int GetBooleanOptIndex(lua_State *L, GLenum pname) /* index is optional */
    {
    GLboolean data;
    GLuint index;
    if(!lua_isnoneornil(L, 2))
        {
        index = luaL_checkinteger(L, 2);
        glGetBooleani_v(pname, index, &data);
        }
    else
        glGetBooleanv(pname, &data);
    CheckError(L);
    lua_pushboolean(L, data);
    return 1;
    }
示例#24
0
bool
qtCanvas::Impl::setupMovie()
{
	OSErr err;

	Handle dataRefH = nil;
	OSType dataRefType = 0;
	
	err = QTNewDataReferenceFromFullPathCFString(
			mPath, (UInt32)kQTNativeDefaultPathStyle, 0,
			&dataRefH, &dataRefType);
    CheckError(err, "QTNewDataReferenceFromFullPathCFString");

	CreateMovieStorage(dataRefH, dataRefType,
			'TVOD', smSystemScript,
			createMovieFileDeleteCurFile |
				createMovieFileDontCreateResFile |
				newMovieActive,
			&mDataHandler, &mMovie);
    CheckMoviesError("CreateMovieStorage");
    CheckError((OSErr)((nil != mMovie) ? noErr : -1), "CreateMovieStorage movie");
    
    return (err == noErr) && (GetMoviesError() == noErr) && (nil != mMovie);
}
示例#25
0
void
qtCanvas::Impl::setupImage()
{
    MacSetRect(&mFrame, 0, 0, mWidth, mHeight);
    
    mImageStride = mWidth * 4;
    mImageData = new unsigned char[mImageStride * mHeight];

    OSErr err;
	err = QTNewGWorldFromPtr(&mGWorld,
				k32ARGBPixelFormat, &mFrame,
				nil, nil, (GWorldFlags)0,
				mImageData, mImageStride);
    CheckError(err, "QTNewGWorldFromPtr");
}
示例#26
0
unsigned int STEAM_FileSize( FILE *file )
{
	SteamHandle_t hFile = (SteamHandle_t)file;
	TSteamError steamError;
	unsigned int result;

	if ( STEAMtrackingProgress )
	{
		DoEventTic(FALSE);
	}

	result = SteamSizeFile(hFile, &steamError);
	CheckError(file, &steamError);
	return result;
}
示例#27
0
int STEAM_findclose(long dir)
{
	SteamHandle_t hDir = (SteamHandle_t)dir;
	TSteamError steamError;
	int result;

	if ( STEAMtrackingProgress )
	{
		DoEventTic(FALSE);
	}

	result = SteamFindClose(hDir, &steamError);
	CheckError(NULL, &steamError);
	return result;
}
示例#28
0
void SimCudaHelper::Initialize(int cudaDevice)
{
    cudaDevice = Init(cudaDevice);
    cudaError res;
    // From CUDA prog guide: cudaSetDevice()and cudaGLSetGLDevice() are mutually exclusive.
    res = cudaSetDevice(cudaDevice);
    if (res != cudaSuccess)
    {
        CheckError(res, "cudaGetDeviceCount failed");
    }
    else
    {
        cout << "CUDA: Successful cudaSetDevice, using device " << cudaDevice << "\n";
    }
}
示例#29
0
// Sets the outgoing address
void BufferedSocket::SetRemoteAddress(const wxString &Address, const wxInt16 &Port)
{
    struct hostent *he;

    if((he = gethostbyname((const char *)Address.char_str())) == NULL)
    {
        CheckError();
        return;
    }

    m_RemoteAddress.sin_family = PF_INET;
    m_RemoteAddress.sin_port = htons(Port);
    m_RemoteAddress.sin_addr = *((struct in_addr *)he->h_addr);
    memset(m_RemoteAddress.sin_zero, '\0', sizeof m_RemoteAddress.sin_zero);
}
示例#30
0
int STEAM_fputs(const char *string, FILE *stream)
{
	SteamHandle_t hndl = (SteamHandle_t)stream;
	int len = strlen(string);
	int n;
	TSteamError steamError;

	n = SteamWriteFile((void*)string, sizeof(char), len, hndl, &steamError);
	if ( n != len || steamError.eSteamError != eSteamErrorNone )
	{
		CheckError((FILE *)hndl, &steamError);
		return EOF;
	}
	return 1;
}