Exemplo n.º 1
0
MMRESULT _StartTimer(DWORD dwTime) {
    TIMECAPS caps;
    MMRESULT timerid;

    timeGetDevCaps(&caps, sizeof (caps));
    timeBeginPeriod(caps.wPeriodMin);
    timerid = timeSetEvent(dwTime, 0, _TimerFunc, 0, (UINT) TIME_PERIODIC);

    return timerid;
}
Exemplo n.º 2
0
void   STDCALL OSInit()
{
    timeBeginPeriod(1);

    TIMECAPS chi;
    timeGetDevCaps(&chi, sizeof(chi));

    GetSystemInfo(&si);

    osVersionInfo.dwOSVersionInfoSize = sizeof(osVersionInfo);
    GetVersionEx(&osVersionInfo);

    if (OSGetVersion() == 8)
        bWindows8 = TRUE;

    QueryPerformanceFrequency(&clockFreq);
    QueryPerformanceCounter(&startTime);
    startTick = GetTickCount();
    prevElapsedTime = 0;

    PSYSTEM_LOGICAL_PROCESSOR_INFORMATION pInfo = NULL, pTemp = NULL;
    DWORD dwLen = 0;
    if(!GetLogicalProcessorInformation(pInfo, &dwLen))
    {
        if(GetLastError() == ERROR_INSUFFICIENT_BUFFER)
        {
            pInfo = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION)malloc(dwLen);

            if(GetLogicalProcessorInformation(pInfo, &dwLen))
            {
                pTemp = pInfo;
                DWORD dwNum = dwLen/sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION);

                coreCount = 0;
                logicalCores = 0;

                for(UINT i=0; i<dwNum; i++)
                {
                    if(pTemp->Relationship == RelationProcessorCore)
                    {
                        coreCount++;
                        logicalCores += CountSetBits(pTemp->ProcessorMask);
                    }

                    pTemp++;
                }
            }

            free(pInfo);
        }
    }

    hProfilerMutex = OSCreateMutex();
}
Exemplo n.º 3
0
	CDuiTimerBase::CDuiTimerBase( HWND hWnd,LPARAM lParam,WPARAM wParam,int iInterval,int iTotalTimer /*= NULL*/,bool bAutoRun /*= true*/,bool bLoop /*= false*/,bool bRevers /*= false*/ )
	{
		SetTimerParam(hWnd,lParam,wParam,iInterval,iTotalTimer,bAutoRun,bLoop,bRevers);

		TIMECAPS tc;
		if(timeGetDevCaps(&tc,sizeof(TIMECAPS))==TIMERR_NOERROR)
		{
			m_uTimerAccuracy=min(max(tc.wPeriodMin,1),tc.wPeriodMax);
			timeBeginPeriod(m_uTimerAccuracy);
		}
	}
Exemplo n.º 4
0
//=============================================================================
void _StopTimer(MMRESULT timerid)
{
 TIMECAPS caps;

	if (timerid != 0) {
		timeKillEvent(timerid);
		timerid = 0;
		timeGetDevCaps(&caps, sizeof(caps));
		timeEndPeriod(caps.wPeriodMin);
	}
}
Exemplo n.º 5
0
/*
=============================================================================
This routine intializes the system timer used for throttling the emulation
speed.
=============================================================================
*/
int init_throttle_timer(void)
{
#ifdef WIN32
	TIMECAPS		tc;

	/* Get the system's multimedia timer capabilties */
	timeGetDevCaps(&tc, sizeof(tc)); 

	/* On older systems, the minimum may be 55ms.  In this case, we just use 55ms as the tick */
	if (tc.wPeriodMin > 50)
	{
		gThrottlePeriod = tc.wPeriodMin;
		gThrottleTerminalCount = 1000 / gThrottlePeriod;
	}
	else if (tc.wPeriodMin <= 10)
	{
		/* We don't need 10ms of resolution.  Let's use 20ms instead */
		gThrottlePeriod = 50;

		/* Set TC for 50 counts = 1sec */
		gThrottleTerminalCount = 20;
	}

	/* Setup the throttle event for signalling */
	gThrottleEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
	InitializeCriticalSection(&gThrottleCritSect);

	/* Calculate the period, Throttle Delta time and setup the timer */
	gThrottleDelta = gTargetFrequency * gThrottlePeriod / 1000;
	if (timeBeginPeriod(gThrottlePeriod) == TIMERR_NOCANDO)
		return FALSE;
	gThrottleId = timeSetEvent(gThrottlePeriod, tc.wPeriodMin, ThrottleProc, 
		0, TIME_PERIODIC ); 
#else

    /* We don't need 10ms of resolution.  Let's use 20ms instead */
    gThrottlePeriod = 40;

    /* Set TC for 50 counts = 1sec */
    gThrottleTerminalCount = 25;
    gThrottlePeriodCount = 0;
	gThrottleDelta = gTargetFrequency * gThrottlePeriod / 1000;
	gThrottleCycles = cycles + (gThrottleDelta << 1);

    // Initialize thread processing
    pthread_mutex_init(&gThrottleLock, NULL);
    pthread_create(&gThrottleThread, NULL, ThrottlePeriodProc, NULL);
    sem_init(&gThrottleEvent, 0, 0);

#endif

	return 1;
}
Exemplo n.º 6
0
/*
  By default in 2000/XP, the timeGetTime call is set to some resolution
  between 10-15 ms query for the range of value periods and then set timer
  to the lowest possible.  Note: MUST make call to corresponding
  CleanupMillisTimer
*/
void SetupMillisTimer(void) {

  TIMECAPS timeCaps;
  timeGetDevCaps(&timeCaps, sizeof(TIMECAPS)); 

  if (timeBeginPeriod(timeCaps.wPeriodMin) == TIMERR_NOCANDO) {
    fprintf(stderr,"WARNING: Cannot set timer precision.  Not sure what precision we're getting!\n");
  }else {
    timerRes = timeCaps.wPeriodMin;
    fprintf(stderr,"(* Set timer resolution to %d ms. *)\n",timeCaps.wPeriodMin);
  }
}
Exemplo n.º 7
0
int main(int argc,char**argv){

    ARParam cparam;
    ARParam wparam;
    int xsize,ysize;
    glutInit(&argc,argv);

    if(arVideoOpen(vconf_name)<0){
	puts("ビデオデバイスエラー");
	return -1;
    }

    if(arVideoInqSize(&xsize,&ysize) < 0)return -1;

    if(arParamLoad(cparam_name,1,&wparam)< 0){
	puts("パラメータ読み込み失敗");
	return -1;
    }

    arParamChangeSize(&wparam,xsize,ysize,&cparam);
    arInitCparam(&cparam);
    nyobj = nyar_NyARTransMat_O2_create(&cparam);

    if( (patt_id=arLoadPatt(pattern_name)) < 0){
	puts("パターン読み込みエラー");
	return -1;
    }

    argInit(&cparam, 1.0, 0, 0, 0, 0); 
    mqoInit();

    if(Data_Load()==-1)
	return -1;

    arVideoCapStart();
    InitGame();

    arUtilTimerReset();
#ifdef _WIN32
    TIMECAPS Caps;
    timeGetDevCaps(&Caps, sizeof(TIMECAPS)); // 性能取得
    timeBeginPeriod(Caps.wPeriodMin);
#endif
    argMainLoop(MouseEvent,KeyEvent,MainLoop);
#ifdef _WIN32
    timeEndPeriod(Caps.wPeriodMin);
#endif
    nyar_NyARTransMat_O2_free(nyobj);
    return 0;


}
static UINT mwGetMinTimerResolution(void)
{
    TIMECAPS tc;

    if (timeGetDevCaps(&tc, sizeof(tc)) != TIMERR_NOERROR)
    {
        mw_printf("Failed to get timer resolution\n");
        return 0;
    }

    /* target 1-millisecond target resolution */
    return MIN(MAX(tc.wPeriodMin, 1), tc.wPeriodMax);
}
Exemplo n.º 9
0
void baseTimer::timerThread()
{
   GJV_thread::setThreadName( "hires timer" );

   currTick = 0;

   basetick = GetTickCount();


   TIMECAPS tc;

   if ( timeGetDevCaps( &tc, sizeof( TIMECAPS ) ) != TIMERR_NOERROR )
   {
      // Error; application can't continue.
      MessageBox( 0, "Timer", "GetDevCaps", MB_ICONERROR | MB_OK );
   }

   UINT wTimerRes = std::min( std::max( tc.wPeriodMin, TARGET_RESOLUTION ), tc.wPeriodMax );
   timeBeginPeriod( wTimerRes );
   MMRESULT timeEventId = timeSetEvent( TIMER_INTERVAL, 0, intrTick, 0, TIME_PERIODIC );

   hTimerThreadCloseEvent = CreateEvent(
                               NULL,     // no security attributes
                               TRUE,     // manual reset event
                               FALSE,      // not-signalled
                               NULL );  // no name

   while ( 1 )
   {
      // Wait for request to close or for a read thread to terminate.
      DWORD dwWait = WaitForSingleObject( hTimerThreadCloseEvent, 1000 );

      if ( dwWait == WAIT_TIMEOUT )
         continue;

      CloseHandle( hTimerThreadCloseEvent );
      if ( timeEventId )
      {
         timeKillEvent( timeEventId );
         timeEventId = 0;
      }

      if ( wTimerRes )
      {
         timeEndPeriod( wTimerRes );
         wTimerRes = 0;
      }
      return ;
   }

}
Exemplo n.º 10
0
//  By default in 2000/XP, the timeGetTime call is set to some resolution
// between 10-15 ms query for the range of value periods and then set timer
// to the lowest possible.  Note: MUST make call to corresponding
// CleanupMillisTimer
void SetupMillisTimer(void) {

  TIMECAPS timeCaps;
  timeGetDevCaps(&timeCaps, sizeof(TIMECAPS)); 

  if (timeBeginPeriod(timeCaps.wPeriodMin) == TIMERR_NOCANDO) {
    std::cerr << "WARNING: Cannot set timer precision.  Not sure what precision we're getting!\n";
  }
  else {
    timerRes = timeCaps.wPeriodMin;
    std::cout << "(* Set timer resolution to " << timeCaps.wPeriodMin << " ms. *)\n";
  }

}
Exemplo n.º 11
0
BOOL
StartIOManager(void)
{
    HANDLE hExit;
    WorkQueue* wq;
    UINT sleepResolution;
    TIMECAPS timecaps;
    MMRESULT mmresult;

    mmresult = timeGetDevCaps(&timecaps, sizeof(timecaps));
    if (mmresult != MMSYSERR_NOERROR) {
        return false;
    }
    sleepResolution = timecaps.wPeriodMin;
    mmresult = timeBeginPeriod(sleepResolution);
    if (mmresult != MMSYSERR_NOERROR) {
        return false;
    }

    wq = NewWorkQueue();
    if ( !wq ) return false;

    ioMan = (IOManagerState*)malloc(sizeof(IOManagerState));

    if (!ioMan) {
        FreeWorkQueue(wq);
        return false;
    }

    /* A manual-reset event */
    hExit = CreateEvent ( NULL, true, false, NULL );
    if ( !hExit ) {
        FreeWorkQueue(wq);
        free(ioMan);
        return false;
    }

    ioMan->hExitEvent = hExit;
    InitializeCriticalSection(&ioMan->manLock);
    ioMan->workQueue   = wq;
    ioMan->numWorkers  = 0;
    ioMan->workersIdle = 0;
    ioMan->queueSize   = 0;
    ioMan->requestID   = 1;
    InitializeCriticalSection(&ioMan->active_work_lock);
    ioMan->active_work_items = NULL;
    ioMan->sleepResolution = sleepResolution;

    return true;
}
Exemplo n.º 12
0
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, LPSTR lpCmdLine,int nCmdShow )
{
    MSG				msg;

	if( !initApplication(hInstance) ) return FALSE;

	HANDLE hMutex = CreateMutex(NULL,NULL,className);
	if(ERROR_ALREADY_EXISTS == GetLastError())return FALSE;

	HANDLE	hAccel = LoadAccelerators( hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR) );

	CoInitialize(NULL);
	readProfile();
	if( !OpenPackFile() ) return FALSE;
	if( !InitInstance(hInstance,nCmdShow) ) return FALSE;
	SystemInit();
	WINNLSEnableIME(sysInf.hWnd,FALSE);
	TIMECAPS tc;
	timeGetDevCaps(&tc,sizeof(tc));
	timeBeginPeriod(tc.wPeriodMin);

	while(FALSE==sysInf.bGameEnd){
		BOOL bGotMsg;

		if(sysInf.bIsActive || lpMovie || lpStaffRoll){
			bGotMsg = PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE);
		}else{
            bGotMsg = GetMessage( &msg, NULL, 0U, 0U );
		}
		if(bGotMsg){
			if(TranslateAccelerator( sysInf.hWnd, (HACCEL)hAccel, &msg ))continue;
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		if(sysInf.bIsActive || sysInf.execMode==movie_mode || lpStaffRoll){
			mainLoop();
		}
	}
	WINNLSEnableIME(sysInf.hWnd,TRUE);
	timeEndPeriod(tc.wPeriodMin);
	writeProfile();

	cleanup();
	CoUninitialize();
	CloseHandle(hMutex);
	if(CheckWinExec()){
		WinExec2( str_winpath, str_winexec );
	}
	return msg.wParam;
} // WinMain
Exemplo n.º 13
0
void
ioInitTime()
{
# if !defined(_WIN32_WCE)
	TIMECAPS tCaps;

	dwTimerPeriod = 0;
	if(timeGetDevCaps(&tCaps,sizeof(tCaps)) != 0)
		return;
	dwTimerPeriod = tCaps.wPeriodMin;
	if (timeBeginPeriod(dwTimerPeriod) != 0)
		return;
# endif
}
Exemplo n.º 14
0
//==============================================================================================
// ゲームメイン処理
//==============================================================================================
void GameMain(void) {

	TIMECAPS Caps;

	timeGetDevCaps(&Caps, sizeof(TIMECAPS)); // 性能取得
	timeBeginPeriod(Caps.wPeriodMin); // 設定
	HDC hDC_Back = CreateEmptyBMP(hDC_Wnd, pWid, pHei);
	HDC hDC_Wheel = LoadBMPfromFile(hDC_Wnd, TEXT("wheel.bmp"));
	HDC hDC_Block = LoadBMPfromResourceSTR(hDC_Wnd, hInst, TEXT("IDB_BLOCKIDB_BLOCK"));
	HDC hDC_org = LoadBMPfromResourceSTR(hDC_Wnd, hInst, TEXT("IDB_ORG"));
	HDC hDC_Mask = CreateMask(hDC_org, RGB(0, 0, 0));
	HANDLE hfile;
	DWORD file_size, read_byte;
	mciSendString(_T("close BGM"), NULL, 0, NULL); // (前回ちゃんと閉じられなかったかも…)
	mciSendString(_T("open SHOOT!.mid type sequencer alias BGM"), NULL, 0, NULL); // 開く

	TCHAR BGMStatus[256] = { 0 };
	mciSendString(_T("status BGM mode"), BGMStatus, 256, NULL); // 状態の取得
	if (lstrcmp(BGMStatus, TEXT("stopped")) == 0) {
		mciSendString(TEXT("play BGM from 0"), NULL, 0, NULL); // 停止中なら演奏
	}


	Sleep(15000);
	LPCTSTR Sound = LoadSound(_T("notify.wav"));
	PlaySound(Sound, NULL, SND_ASYNC | SND_MEMORY);
	
	//メインループ
	while (!EndFlag) {
		const DWORD StartTime = timeGetTime();
		//~ ゲーム処理いろいろ ~
		//PatBlt(hDC_Back, 0, 0, pWid, pHei, WHITENESS);
		BitBlt(hDC_Back, 0, 0, 32, 32, hDC_Wheel, 0, 0, SRCCOPY);
		BitBlt(hDC_Back, 64, 0, 32, 32, hDC_Block, 0, 0, SRCCOPY);
		//SpriteBlt(hDC_Back, 32, 0, 32, 32, hDC_org, 0, 0, hDC_Mask);
		BitBlt(hDC_Wnd, 0, 0, pWid, pHei, hDC_Back, 0, 0, SRCCOPY);
		const DWORD PassTime = timeGetTime() - StartTime; // 経過時間の計算
		(1000 / FPS > PassTime) ? Wait(1000 / FPS - PassTime) : Wait(0); // 待つ。
		mciSendString(TEXT("status BGM mode"), BGMStatus, 256, NULL); // 状態の取得
		if (lstrcmp(BGMStatus, TEXT("stopped")) == 0) {
			mciSendString(TEXT("play BGM from 0"), NULL, 0, NULL); // 停止中なら演奏
		}

		FPSCount(&fps); // FPS の計測
	}
	timeEndPeriod(Caps.wPeriodMin); // 後処理
	HeapFree(GetProcessHeap(), 0, (LPVOID)Sound); // 解放
	DeleteDC(hDC_Wheel);
	DeleteDC(hDC_Block);
}
Exemplo n.º 15
0
void newfunc_newhandler08_init(void)
{
 TIMECAPS tc;

 timeGetDevCaps(&tc,sizeof(tc));
 if(tc.wPeriodMin<1)
  tc.wPeriodMin=1;

 int08_timer_period=(long)(1000.0/(float)INT08_CYCLES_NEW);
 if(int08_timer_period<=tc.wPeriodMin)
  int08_timer_period=tc.wPeriodMin;

 timeBeginPeriod(int08_timer_period);

#ifndef MPXPLAY_USE_SMP
 {
  HANDLE curr_process=GetCurrentProcess();
  if(curr_process)
   SetProcessAffinityMask(curr_process,MPXPLAY_THREAD_AFFINITY_MASK);
 }
#endif

 if(!int08_timer_thread_handle){
  int08_timer_thread_handle=(HANDLE)_beginthreadex(NULL,0,(void *)newhandler_08_timer_thread,NULL,CREATE_SUSPENDED,NULL);
  if(int08_timer_thread_handle){
   SetThreadPriority(int08_timer_thread_handle,THREAD_PRIORITY_HIGHEST);
   SetSecurityInfo(int08_timer_thread_handle,SE_KERNEL_OBJECT,MPXPLAY_INT08THREAD_RIGHTS,NULL,NULL,NULL,NULL);
#ifndef MPXPLAY_USE_SMP
   SetThreadAffinityMask(int08_timer_thread_handle,MPXPLAY_THREAD_AFFINITY_MASK);
#endif
   ResumeThread(int08_timer_thread_handle);
  }else{

  }
 }

 if(!int08_thread_handle){
  int08_thread_handle=(HANDLE)_beginthreadex(NULL,0,(void *)newhandler_08_thread,NULL,CREATE_SUSPENDED,NULL);
  if(int08_thread_handle){
   SetThreadPriority(int08_thread_handle,THREAD_PRIORITY_HIGHEST);
   SetSecurityInfo(int08_thread_handle,SE_KERNEL_OBJECT,MPXPLAY_INT08THREAD_RIGHTS,NULL,NULL,NULL,NULL);
#ifndef MPXPLAY_USE_SMP
   SetThreadAffinityMask(int08_thread_handle,MPXPLAY_THREAD_AFFINITY_MASK);
#endif
   ResumeThread(int08_thread_handle);
  }else{

  }
 }
}
Exemplo n.º 16
0
	double getTimeSeconds(void)
	{
		static char init = 0;
		static TIMECAPS timerInfo;
		
		if(!init)
		{
			timeGetDevCaps(&timerInfo, sizeof(TIMECAPS));
			timeBeginPeriod(timerInfo.wPeriodMin);
			init = 1;
		}	
		
		return (double) (timeGetTime() / 1000.0);
	}
Exemplo n.º 17
0
void vlc_timer_schedule (vlc_timer_t timer, bool absolute,
                         mtime_t value, mtime_t interval)
{
#ifndef UNDER_CE
    if (timer->handle != INVALID_HANDLE_VALUE)
    {
        DeleteTimerQueueTimer (NULL, timer->handle, NULL);
        timer->handle = INVALID_HANDLE_VALUE;
    }
#else
    if (timer->id)
    {
        timeKillEvent (timer->id);
        timer->id = 0;
        timer->interval = 0;
    }
#endif
    if (value == 0)
        return; /* Disarm */

    if (absolute)
        value -= mdate ();
    value = (value + 999) / 1000;
    interval = (interval + 999) / 1000;

#ifndef UNDER_CE
    if (!CreateTimerQueueTimer (&timer->handle, NULL, vlc_timer_do, timer,
                                value, interval, WT_EXECUTEDEFAULT))
#else
    TIMECAPS caps;
    timeGetDevCaps (&caps, sizeof(caps));

    unsigned delay = value;
    delay = __MAX(delay, caps.wPeriodMin);
    delay = __MIN(delay, caps.wPeriodMax);

    unsigned event = TIME_ONESHOT;

    if (interval == delay)
        event = TIME_PERIODIC;
    else if (interval)
        timer->interval = interval;

    timer->id = timeSetEvent (delay, delay / 20, vlc_timer_do, (DWORD) timer,
                              event);
    if (!timer->id)
#endif
        abort ();
}
Exemplo n.º 18
0
// A derived class may supply a hThreadEvent if it has its own thread that will take care
// of calling the schedulers Advise method.  (Refere to CBaseReferenceClock::AdviseThread()
// to see what such a thread has to do.)
CBaseReferenceClock::CBaseReferenceClock( TCHAR *pName, LPUNKNOWN pUnk, HRESULT *phr, CAMSchedule * pShed )
: CUnknown( pName, pUnk )
, m_rtLastGotTime(0)
, m_TimerResolution(0)
, m_bAbort( FALSE )
, m_pSchedule( pShed ? pShed : new CAMSchedule(CreateEvent(NULL, FALSE, FALSE, NULL)) )
, m_hThread(0) {


    ASSERT(m_pSchedule);
    if(!m_pSchedule) {
        *phr = E_OUTOFMEMORY;
    }
    else {
        // Set up the highest resolution timer we can manage
        TIMECAPS tc;
        m_TimerResolution = (TIMERR_NOERROR == timeGetDevCaps(&tc, sizeof(tc)))
        ? tc.wPeriodMin : 1;

        timeBeginPeriod(m_TimerResolution);

        /* Initialise our system times - the derived clock should set the right values */
        m_dwPrevSystemTime = timeGetTime();
        m_rtPrivateTime = (UNITS / MILLISECONDS) * m_dwPrevSystemTime;

#ifdef PERF
        m_idGetSystemTime = MSR_REGISTER(TEXT("CBaseReferenceClock::GetTime"));
#endif

        if(!pShed) {
            DWORD ThreadID;
            m_hThread = ::CreateThread(NULL,                  // Security attributes
                (DWORD) 0,             // Initial stack size
                AdviseThreadFunction,  // Thread start address
                (LPVOID) this,         // Thread parameter
                (DWORD) 0,             // Creation flags
                &ThreadID);            // Thread identifier

            if(m_hThread) {
                SetThreadPriority(m_hThread, THREAD_PRIORITY_TIME_CRITICAL);
            }
            else {
                *phr = E_FAIL;
                EXECUTE_ASSERT(CloseHandle(m_pSchedule->GetEvent()));
                delete m_pSchedule;
            }
        }
    }
}
Exemplo n.º 19
0
TimeSource * TimeSource::get()
{
    if (!m_pTimeSource) {
#ifdef _WIN32
        TIMECAPS tc;
        UINT wTimerRes;
        MMRESULT err = timeGetDevCaps(&tc, sizeof(TIMECAPS));
        AVG_ASSERT(err == TIMERR_NOERROR);
        wTimerRes = max(tc.wPeriodMin, 1);
        timeBeginPeriod(wTimerRes);
#endif
        m_pTimeSource = new TimeSource;
    }
    return m_pTimeSource;
}
Exemplo n.º 20
0
	NativeTimer(){
		MMRESULT result = timeGetDevCaps(&timeCaps_,sizeof(TIMECAPS));
		if( result != TIMERR_NOERROR ){
			timeCaps_.wPeriodMin = 1;
			isUseTimeGetTime_ = false;
			return;
		}
		if( timeCaps_.wPeriodMin >= 10 ){
			timeCaps_.wPeriodMin = 1;
			isUseTimeGetTime_ = false;
		}else{
			::timeBeginPeriod( timeCaps_.wPeriodMin );
			isUseTimeGetTime_ = true;
		}
	}
Exemplo n.º 21
0
static void get_min_period(void)
{
  TIMECAPS tc;
  MMRESULT result = timeGetDevCaps(&tc, sizeof(TIMECAPS));
  switch(result) {
  case TIMERR_NOERROR:
    DIAGNOSTIC(4,"time caps: %d min, %d max",tc.wPeriodMin,tc.wPeriodMax);
    break;
  case TIMERR_STRUCT:
    error("timeGetDevCaps() failed");
  default:
    error ("timeGetDevCaps() returned %d",result);
  }
  time_resolution = tc.wPeriodMin;
}
Exemplo n.º 22
0
Arquivo: port.c Projeto: HclX/freertos
static BOOL WINAPI prvEndProcess( DWORD dwCtrlType )
{
TIMECAPS xTimeCaps;

	( void ) dwCtrlType;

	if( timeGetDevCaps( &xTimeCaps, sizeof( xTimeCaps ) ) == MMSYSERR_NOERROR )
	{
		/* Match the call to timeBeginPeriod( xTimeCaps.wPeriodMin ) made when
		the process started with a timeEndPeriod() as the process exits. */
		timeEndPeriod( xTimeCaps.wPeriodMin );
	}

	return pdPASS;
}
Exemplo n.º 23
0
void sleepImpl(Time time)
{
    // Get the supported timer resolutions on this system
    TIMECAPS tc;
    timeGetDevCaps(&tc, sizeof(TIMECAPS));

    // Set the timer resolution to the minimum for the Sleep call
    timeBeginPeriod(tc.wPeriodMin);

    // Wait...
    ::Sleep(time.asMilliseconds());

    // Reset the timer resolution back to the system default
    timeEndPeriod(tc.wPeriodMin);
}
Exemplo n.º 24
0
uint32_t gvl_get_ticks()
{
	static int setup = 0;
	if(!setup)
	{
		TIMECAPS caps;
		setup = 1;
		
		if(timeGetDevCaps(&caps, sizeof(caps)) == TIMERR_NOERROR)
		{
			timeBeginPeriod(min(max(caps.wPeriodMin, 1), caps.wPeriodMax)); 
		}
	}
	
	return (uint32_t)(timeGetTime());
}
Exemplo n.º 25
0
void NativeSoundMix::NativeConstruct()
{
    hWaveOut = 0;
	isOpen	 = false;
	memset( &waveHDR, 0, sizeof( WAVEHDR ) * MAX_SOUND_BUFFERS );

	InitializeCriticalSection(&playLock);
	playThread = 0;
	playEvent = CreateEvent(0, false, false, 0);

	// Set the timer interval
	TIMECAPS tc;
	timeGetDevCaps(&tc, sizeof(tc));
	period = max(1, (int)tc.wPeriodMin);	// get the best possible resolution...
	timeBeginPeriod(period);
}
Exemplo n.º 26
0
SERVER_EXPORT void InitTime()
{
	QueryPerformanceFrequency(&_jack_freq);
    TIMECAPS caps;
    if (timeGetDevCaps(&caps, sizeof(TIMECAPS)) != TIMERR_NOERROR) {
        jack_error("InitTime : could not get timer device");
    } else {
        gPeriod = caps.wPeriodMin;
        if (timeBeginPeriod(gPeriod) != TIMERR_NOERROR) {
            jack_error("InitTime : could not set minimum timer");
            gPeriod = 0;
        } else {
            jack_info("InitTime : multimedia timer resolution set to %d milliseconds", gPeriod);
       }
    }
}
Exemplo n.º 27
0
StopWatch::StopWatch()
{    
    QueryPerformanceFrequency( &frequency ) ;

    #define TARGET_RESOLUTION 1         // 1-millisecond target resolution
    TIMECAPS tc;
    

    if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) 
    {
        // Error; application can't continue.
    }

    wTimerRes = min(max(tc.wPeriodMin, TARGET_RESOLUTION), tc.wPeriodMax);
    timeBeginPeriod(wTimerRes); 
}
CMackieControlMaster::CMackieControlMaster()
{
//	TRACE("CMackieControlMaster::CMackieControlMaster()\n");

	m_bExpectedDeviceType = 0x14;

	m_bWasInEQFreqGainMode = false;

	m_eCurrentTransportDir = DIR_FORWARD;
	m_fTransportTimeout = 0;

	m_bKeyRepeatKey = 0;
	m_fKeyRepeatTimeout = 0;
	
	int n = 0;

	// Wire everything up together
	for (n = 0; n < NUM_VSELECT_DISPLAY_CELLS; n++)
		m_cVSelectDisplay[n].Setup(this, 0x0A + NUM_VSELECT_DISPLAY_CELLS - n - 1);

	for (n = 0; n < NUM_TIME_CODE_DISPLAY_CELLS; n++)
		m_cTimeCodeDisplay[n].Setup(this, NUM_TIME_CODE_DISPLAY_CELLS - n - 1);

	m_HwMasterFader.Setup(this, 8);

	CCriticalSectionAuto csa(m_cState.GetCS());

	// Default user key and foot bindings
	m_cState.SetUserFunctionKey(0, CMD_VIEW_NEW_EXPLORER);
	m_cState.SetUserFunctionKey(1, CMD_VIEW_NEW_LOOP_CONSTR);
	m_cState.SetUserFunctionKey(2, CMD_VIEW_CONSOLE);
	m_cState.SetUserFunctionKey(3, CMD_VIEW_NEW_EVENT_LIST);
	m_cState.SetUserFunctionKey(4, CMD_VIEW_NEW_PIANO_ROLL);
	m_cState.SetUserFunctionKey(5, CMD_VIEW_VIDEO);
	m_cState.SetUserFunctionKey(6, CMD_VIEW_NEW_STAFF);
	m_cState.SetUserFunctionKey(7, CMD_VIEW_NEW_LYRICS);
	m_cState.SetUserFootSwitch(0, CMD_REALTIME_PLAY);
	m_cState.SetUserFootSwitch(1, CMD_REALTIME_RECORD);

	TIMECAPS timeDevCaps;
	timeGetDevCaps(&timeDevCaps, sizeof(timeDevCaps));
	TRACE("timeDevCaps.wPeriodMin = %d\n", timeDevCaps.wPeriodMin);
	m_wTransportTimerPeriod = max(timeDevCaps.wPeriodMin, 10);
	m_wKeyRepeatTimerPeriod = max(timeDevCaps.wPeriodMin, 10);
	m_bTransportTimerActive = false;
	m_bKeyRepeatTimerActive = false;
}
Exemplo n.º 29
0
CSpeedLimiter::CSpeedLimiter()
{
    m_Frames = 0;
    m_LastTime = 0;
    m_Speed = 60;
    m_BaseSpeed = 60;
    m_Ratio = 1000.0F / (float)m_Speed;

#ifdef _WIN32
    TIMECAPS Caps;
    timeGetDevCaps(&Caps, sizeof(Caps));
    if (timeBeginPeriod(Caps.wPeriodMin) == TIMERR_NOCANDO)
    {
        g_Notify->DisplayError("Error during timer begin");
    }
#endif
}
Exemplo n.º 30
0
ArtWindow::ArtWindow()
{
	TIMECAPS tc;
	UINT wTimerRes;

	if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) 
	{
		console::error("Smooth Album Art: Timer error");
		// TODO: handle error
	}

	wTimerRes = min(max(tc.wPeriodMin, 1), tc.wPeriodMax);
	timeBeginPeriod(wTimerRes); 

	TimerQueue = NULL;
	RepaintTimer = NULL;
}