コード例 #1
0
ファイル: time.c プロジェクト: jiangxilong/yari
/**
 *
 * Create a native timer to expire in wakeupInSeconds or less seconds.
 * If a later timer exists, cancel it and create a new timer
 *
 * @param wakeupInMilliSecondsFromNow time to wakeup in milli-seconds
 *                              relative to current time
 *                              if -1, then ignore the call
 * @param cyclic <tt>1</tt> indicates that the timer should be repeated cuclically,
 *               <tt>0</tt> indicates that this is a one-shot timer that should call the callback function once
 * @param func callback function should be called in platform's context once the timer
 *			   expires
 * @param handle A pointer to the returned handle that will be associated with this timer
 *               On success.
 *
 * @return on success returns <tt>JAVACALL_OK</tt>,
 *         or <tt>JAVACALL_FAIL</tt> or negative value on failure
 */
javacall_result javacall_time_initialize_timer(
                    int                      wakeupInMilliSecondsFromNow,
                    javacall_bool            cyclic,
                    javacall_callback_func   func,
                    /*OUT*/ javacall_handle	*handle){

    MMRESULT hTimer;

    if (!handle || !func) {
        return JAVACALL_INVALID_ARGUMENT;
    }

    hTimer = timeSetEvent(wakeupInMilliSecondsFromNow,
            10, /* 10ms: tuned resolution from CLDC_HI porting experiences */
            win32_timer_callback,
            (DWORD)func,
            (JAVACALL_TRUE == cyclic ? TIME_PERIODIC : TIME_ONESHOT));

    if (0 == hTimer) {
        *handle = NULL;
        return JAVACALL_FAIL;
    } else {
        *handle = (javacall_handle)hTimer;
        return JAVACALL_OK;
    }
}
コード例 #2
0
unsigned HostTimerDispatcher::setTimeout(unsigned delay, IDispatch* pDisp)
{
	if (!pDisp) return 0;
	unsigned timerID = timeSetEvent(delay, m_accuracy, g_timer_proc, reinterpret_cast<DWORD_PTR>(m_hWnd), TIME_ONESHOT);
	addTimerMap(timerID, pDisp);
	return timerID;
}
コード例 #3
0
ファイル: Win-DirectSound.c プロジェクト: mctully/tntbasic
Boolean DirectSoundInit( MADDriverRec* WinMADDriver)
{
	OnOff					= false;
	
	WIN95BUFFERSIZE = WinMADDriver->BufSize;
	WIN95BUFFERSIZE *= 2L;								// double buffer system
	
	currentBuf 		= calloc( WIN95BUFFERSIZE, 1);
	
	hwnd = GetForegroundWindow();	//GetForegroundWindow();
	if( !hwnd) return false;
	
	if(DS_OK == DirectSoundCreate(NULL, &WinMADDriver->lpDirectSound, NULL))
	{
		if( !AppCreateWritePrimaryBuffer( WinMADDriver->lpDirectSound, &WinMADDriver->lpDirectSoundBuffer, hwnd, WinMADDriver))
		{
			WinMADDriver->lpDirectSound = 0L;
			return false;
		}
		if( !WinMADDriver->lpDirectSoundBuffer) return false;
		
		// Creation succeeded.
		WinMADDriver->lpDirectSound->lpVtbl->SetCooperativeLevel(WinMADDriver->lpDirectSound, hwnd, DSSCL_NORMAL);
		
		WinMADDriver->lpSwSamp = 0L;
		if( !LoadSamp(WinMADDriver->lpDirectSound, &WinMADDriver->lpSwSamp, 0L, WIN95BUFFERSIZE, DSBCAPS_LOCSOFTWARE, WinMADDriver))
		{
			//DEBUG debugger( "Error 2\n");		//DSBCAPS_LOCSOFTWARE
			WinMADDriver->lpDirectSound = 0L;
			return false;
		}
		
		if( !WinMADDriver->lpSwSamp) return false;
		
		WinMADDriver->lpSwSamp->lpVtbl->Play(WinMADDriver->lpSwSamp, 0, 0, DSBPLAY_LOOPING);
		
		///////////
		
		timeBeginPeriod(20);      /* set the minimum resolution */
		
		/*  Set up the callback event.  The callback function
		 *  MUST be in a FIXED CODE DLL!!! -> not in Win95
		 */
		 
		// debugger( "timeSetEvent\n");
		 
		gwID = timeSetEvent(	  40,   												/* how often                 */
													  40,   							/* timer resolution          */
													  TimeProc,  						/* callback function         */
													  (unsigned long) WinMADDriver,		/* info to pass to callback  */
													  TIME_PERIODIC); 					/* oneshot or periodic?      */
		
		if( gwID == 0) return false;
		else return true;
	}
	
	WinMADDriver->lpDirectSound = 0L;
	
	return false;
}
コード例 #4
0
ファイル: qemu-timer.c プロジェクト: converse2006/M2M
static void win32_rearm_timer(struct qemu_alarm_timer *t)
{
    struct qemu_alarm_win32 *data = t->priv;

    assert(alarm_has_dynticks(t));
    if (!active_timers[QEMU_CLOCK_REALTIME] &&
        !active_timers[QEMU_CLOCK_VIRTUAL] &&
        !active_timers[QEMU_CLOCK_HOST])
        return;

    timeKillEvent(data->timerId);

    data->timerId = timeSetEvent(1,
                        data->period,
                        host_alarm_handler,
                        (DWORD)t,
                        TIME_ONESHOT | TIME_CALLBACK_FUNCTION);

    if (!data->timerId) {
        fprintf(stderr, "Failed to re-arm win32 alarm timer %ld\n",
                GetLastError());

        timeEndPeriod(data->period);
        exit(1);
    }
}
コード例 #5
0
ファイル: pa_dsound.c プロジェクト: mentat/tehDJ
PaError PaHost_StartEngine( internalPortAudioStream *past )
{
    PaHostSoundControl *pahsc;
    PaError          result = paNoError;
    pahsc = (PaHostSoundControl *) past->past_DeviceData;
    past->past_StopNow = 0;
    past->past_StopSoon = 0;
    past->past_IsActive = 1;
    /* Create timer that will wake us up so we can fill the DSound buffer. */
    {
        int msecPerBuffer;
        int resolution;
        int bufsPerInterrupt = past->past_NumUserBuffers/4;
        if( bufsPerInterrupt < 1 ) bufsPerInterrupt = 1;
        msecPerBuffer = 1000 * (bufsPerInterrupt * past->past_FramesPerUserBuffer) / (int) past->past_SampleRate;
        if( msecPerBuffer < 10 ) msecPerBuffer = 10;
        else if( msecPerBuffer > 100 ) msecPerBuffer = 100;
        resolution = msecPerBuffer/4;
        pahsc->pahsc_TimerID = timeSetEvent( msecPerBuffer, resolution, (LPTIMECALLBACK) Pa_TimerCallback,
                                             (DWORD) past, TIME_PERIODIC );
    }
    if( pahsc->pahsc_TimerID == 0 )
    {
        past->past_IsActive = 0;
        result = paHostError;
        sPaHostError = 0;
        goto error;
    }
error:
    return result;
}
コード例 #6
0
ファイル: qemu-timer.c プロジェクト: converse2006/M2M
static int win32_start_timer(struct qemu_alarm_timer *t)
{
    TIMECAPS tc;
    struct qemu_alarm_win32 *data = t->priv;
    UINT flags;

    memset(&tc, 0, sizeof(tc));
    timeGetDevCaps(&tc, sizeof(tc));

    data->period = tc.wPeriodMin;
    timeBeginPeriod(data->period);

    flags = TIME_CALLBACK_FUNCTION;
    if (alarm_has_dynticks(t))
        flags |= TIME_ONESHOT;
    else
        flags |= TIME_PERIODIC;

    data->timerId = timeSetEvent(1,         // interval (ms)
                        data->period,       // resolution
                        host_alarm_handler, // function
                        (DWORD)t,           // parameter
                        flags);

    if (!data->timerId) {
        fprintf(stderr, "Failed to initialize win32 alarm timer: %ld\n",
                GetLastError());
        timeEndPeriod(data->period);
        return -1;
    }

    return 0;
}
コード例 #7
0
ファイル: arch_c.c プロジェクト: AriZuu/picoos
static void a_initTimer(void)
{
#ifdef HAVEMMLIB
  TIMECAPS timecaps;
  BOOL tok;

  timerEvent_g = CreateSemaphore(NULL, 0, 2*HZ, NULL);
  tok = (timerEvent_g != NULL);

  if (tok)
    tok = timeGetDevCaps(&timecaps, sizeof(timecaps)) == TIMERR_NOERROR;

  if (tok)
    tok = timeBeginPeriod(timecaps.wPeriodMin) == TIMERR_NOERROR;

  if (tok)
  {

    if (timeSetEvent(1000 / HZ, 1000 / HZ,
                     (LPTIMECALLBACK) a_timerCallback,
                     0, TIME_PERIODIC) == 0)
    {
      timeEndPeriod(timecaps.wPeriodMin);
      tok = FALSE;
    }
  }

  if (!tok && (timerEvent_g != NULL))
  {
    CloseHandle(timerEvent_g);
    timerEvent_g = NULL;
  }
#endif
}
コード例 #8
0
ファイル: systimer.c プロジェクト: xsmart/sdk
static int systimer_create(systimer_t* id, unsigned int period, int oneshot, systimer_proc callback, void* cbparam)
{
	UINT fuEvent;
	timer_context_t* ctx;

	if(oneshot && g_ctx.tc.wPeriodMin > period && period > g_ctx.tc.wPeriodMax)
		return -EINVAL;

	ctx = (timer_context_t*)malloc(sizeof(timer_context_t));
	if(!ctx)
		return -ENOMEM;

	memset(ctx, 0, sizeof(timer_context_t));
	ctx->callback = callback;
	ctx->cbparam = cbparam;
	ctx->period = period;
	ctx->count = 0;

	// check period value
	period = (period > g_ctx.tc.wPeriodMax) ?  TIMER_PERIOD : period;
	fuEvent = (oneshot?TIME_ONESHOT:TIME_PERIODIC)|TIME_CALLBACK_FUNCTION;
	ctx->timerId = timeSetEvent(period, 10, timer_schd_worker, (DWORD_PTR)ctx, fuEvent);
	if(0 == ctx->timerId)
	{
		free(ctx);
		return -EINVAL;
	}

	*id = (systimer_t)ctx;
	return 0;
}
コード例 #9
0
void W95_PlayStart(MADDriverRec *WinMADDriver)
{
	waveOutSetVolume(0,0xffffffff);
	
	WinMADDriver->WaveOutHdr.lpData= (char*) WinMADDriver->mydata;
	WinMADDriver->WaveOutHdr.dwBufferLength = WinMADDriver->WIN95BUFFERSIZE;
	WinMADDriver->WaveOutHdr.dwFlags = WHDR_BEGINLOOP | WHDR_ENDLOOP;
	WinMADDriver->WaveOutHdr.dwLoops = 0xffffffff;
	WinMADDriver->WaveOutHdr.dwUser = 0;
	waveOutPrepareHeader(WinMADDriver->hWaveOut, &WinMADDriver->WaveOutHdr, sizeof(WAVEHDR));
	waveOutWrite(WinMADDriver->hWaveOut, &WinMADDriver->WaveOutHdr, sizeof(WAVEHDR));
	WinMADDriver->mydma = (char*) WinMADDriver->mydata;
	
	WinMADDriver->MICROBUFState = 0;
	
	timeBeginPeriod(20);	/* set the minimum resolution */
	
	WinMADDriver->gwID = timeSetEvent(40,								/* how often                 */
									  40,								/* timer resolution          */
									  TimeProc,							/* callback function         */
									  (unsigned long)  WinMADDriver,	/* info to pass to callback  */
									  TIME_PERIODIC);					/* oneshot or periodic?      */
							  
							  
	//////
}
コード例 #10
0
ファイル: cpu.c プロジェクト: jiankangshiye/DJYOS
//----初始化tick---------------------------------------------------------------
//功能: 初始化定时器,并连接tick中断函数,启动定时器.
//参数: 无
//返回: 无
//备注: 本函数是移植敏感函数.
//-----------------------------------------------------------------------------
void __DjyInitTick(void)
{
    Int_IsrConnect(cn_int_line_timer_event,__DjyIsrTick);
    Int_SettoAsynSignal(cn_int_line_timer_event); //tick中断被设为异步信号
    Int_RestoreAsynLine(cn_int_line_timer_event);
    timeSetEvent(CN_CFG_TICK_US/mS,CN_CFG_TICK_US/mS,&TimerCallBack,0,TIME_PERIODIC);
}
コード例 #11
0
static void mm_rearm_timer(struct qemu_alarm_timer *t, int64_t delta)
{
    int64_t nearest_delta_ms = delta / 1000000;
    if (nearest_delta_ms < 1) {
        nearest_delta_ms = 1;
    }
    /* UINT_MAX can be 32 bit */
    if (nearest_delta_ms > UINT_MAX) {
        nearest_delta_ms = UINT_MAX;
    }

    timeKillEvent(mm_timer);
    mm_timer = timeSetEvent((unsigned int) nearest_delta_ms,
                            mm_period,
                            mm_alarm_handler,
                            (DWORD_PTR)t,
                            TIME_ONESHOT | TIME_CALLBACK_FUNCTION);

    if (!mm_timer) {
        fprintf(stderr, "Failed to re-arm win32 alarm timer %ld\n",
                GetLastError());

        timeEndPeriod(mm_period);
        exit(1);
    }
}
コード例 #12
0
HOOKFUNC MMRESULT WINAPI MytimeSetEvent(UINT uDelay, UINT uResolution, LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT fuEvent)
{
	if(tasflags.timersMode == 0)
	{
		debuglog(LCF_TIMERS, __FUNCTION__ " called (and suppressed).\n");
		return 11 * ++timerUID;
	}
	debuglog(LCF_TIMERS, __FUNCTION__ "(%d, %d, 0x%X, 0x%X, 0x%X) called.\n", uDelay, uResolution, (DWORD)lpTimeProc, (DWORD)dwUser, fuEvent);
	if(tasflags.timersMode == 2)
		return timeSetEvent(uDelay, uResolution, lpTimeProc, dwUser, fuEvent);
	TimerThreadInfo* threadInfo = new TimerThreadInfo(uDelay, uResolution, fuEvent, lpTimeProc, dwUser, 11 * ++timerUID);
	threadInfo->prevTime = detTimer.GetTicks();
	threadInfo->prev = ttiTail;
	ttiTail->next = threadInfo;
	ttiTail = threadInfo;
	timerListSize++;
	//threadInfo->handle = MyCreateThread(NULL, 0, MyTimerThread, threadInfo, 0, NULL);
	//SetThreadPriority(threadInfo->handle, THREAD_PRIORITY_BELOW_NORMAL);
	//if(!threadInfo->handle)
	//{
	//	threadInfo->prev->next = NULL;
	//	delete threadInfo;
	//	return NULL;
	//}
	debuglog(LCF_TIMERS, __FUNCTION__ " created TimerThreadInfo with uid 0x%X.\n", threadInfo->uid);
	return threadInfo->uid;
}
コード例 #13
0
ファイル: eLTE_Timer.cpp プロジェクト: eSDK/esdk_elte
ELTE_VOID CTimer::SetTimer(ELTE_UINT32 tick)
{
	LOG_TRACE();
	if(m_uTimerID)
	{
		timeKillEvent(m_uTimerID);
		m_uTimerID = 0;
	}

	if(0 == tick)
	{
		//默认200ms发送数据
		tick = 200;
	}

	TIMECAPS   timecaps; 
	ELTE_UINT32 TimerAccuracy = Accuracy; 

	//从系统获得关于定时器服务能力的信息, 
	//分辨率不能超出系统许可值(1到16毫秒) 
	if   (timeGetDevCaps(&timecaps,sizeof(TIMECAPS))==TIMERR_NOERROR) 
		TimerAccuracy = min(max(timecaps.wPeriodMin,Accuracy),timecaps.wPeriodMax); 

	timeBeginPeriod(TimerAccuracy); 
	m_uDelayTime = tick;

	m_uTimerID = timeSetEvent(m_uDelayTime, TimerAccuracy, TimeProc, (DWORD_PTR)this, TIME_PERIODIC);
	LOG_RUN_DEBUG("TimerId is %d.", m_uTimerID);
	timeEndPeriod(TimerAccuracy); 
}
コード例 #14
0
ファイル: multiplex.c プロジェクト: multics69/danbi
static int
mpx_startup_itimer( void )
{
	int retval = PAPI_OK;

	TIMECAPS tc;
	UINT wTimerRes;

	/* get the timer resolution capability on this system */
	if ( timeGetDevCaps( &tc, sizeof ( TIMECAPS ) ) != TIMERR_NOERROR )
		return ( PAPI_ESYS );

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

	/* initialize a periodic timer
	   triggering every (milliseconds) 
	   and calling (mpx_timer_callback())
	   with no data */
	mpxTimerID = timeSetEvent( mpx_time, wTimerRes,
							   mpx_timer_callback, ( DWORD ) NULL,
							   TIME_PERIODIC );
	if ( !mpxTimerID )
		return PAPI_ESYS;

	return ( retval );
}
コード例 #15
0
ファイル: timing.cpp プロジェクト: LordNoteworthy/al-khaser
VOID timing_timeSetEvent(UINT delayInSeconds)
{

	// Some vars
	UINT uResolution;
	TIMECAPS tc;
	MMRESULT idEvent;

	// We can obtain this minimum value by calling
	timeGetDevCaps(&tc, sizeof(TIMECAPS));
	uResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);

	// Create the timer
	idEvent = timeSetEvent(
		delayInSeconds,
		uResolution,
		TimerFunction,
		0,
		TIME_ONESHOT);

	while (!bProcessed){
		// wait until uor function finish
	}

	// destroy the timer
	timeKillEvent(idEvent);

	// reset the timer
	timeEndPeriod(uResolution);
}
コード例 #16
0
static int mm_start_timer(struct qemu_alarm_timer *t)
{
    TIMECAPS tc;
    UINT flags;

    memset(&tc, 0, sizeof(tc));
    timeGetDevCaps(&tc, sizeof(tc));

    mm_period = tc.wPeriodMin;
    timeBeginPeriod(mm_period);

    flags = TIME_CALLBACK_FUNCTION;
    if (alarm_has_dynticks(t)) {
        flags |= TIME_ONESHOT;
    } else {
        flags |= TIME_PERIODIC;
    }

    mm_timer = timeSetEvent(1,                  /* interval (ms) */
                            mm_period,          /* resolution */
                            mm_alarm_handler,   /* function */
                            (DWORD_PTR)t,       /* parameter */
                        flags);

    if (!mm_timer) {
        fprintf(stderr, "Failed to initialize win32 alarm timer: %ld\n",
                GetLastError());
        timeEndPeriod(mm_period);
        return -1;
    }

    return 0;
}
コード例 #17
0
static void mm_rearm_timer(struct qemu_alarm_timer *t)
{
    int nearest_delta_ms;

    assert(alarm_has_dynticks(t));
    if (!qemu_clock_has_timers(QEMU_CLOCK_REALTIME) &&
        !qemu_clock_has_timers(QEMU_CLOCK_VIRTUAL) &&
        !qemu_clock_has_timers(QEMU_CLOCK_HOST)) {
        return;
    }

    timeKillEvent(mm_timer);

    nearest_delta_ms = (qemu_next_alarm_deadline() + 999999) / 1000000;
    if (nearest_delta_ms < 1) {
        nearest_delta_ms = 1;
    }
    mm_timer = timeSetEvent(nearest_delta_ms,
                            mm_period,
                            mm_alarm_handler,
                            (DWORD_PTR)t,
                            TIME_ONESHOT | TIME_CALLBACK_FUNCTION);

    if (!mm_timer) {
        fprintf(stderr, "Failed to re-arm win32 alarm timer %ld\n",
                GetLastError());

        timeEndPeriod(mm_period);
        exit(1);
    }
}
コード例 #18
0
void CMackieControlMaster::SetKeyRepeatCallbackTimer(float fAlpha, UINT uMax, UINT uMin)
{
	float fMax = (float)uMax;
	float fMin = (float)uMin;

	m_fKeyRepeatTimeout = ((1.0f - fAlpha) * m_fKeyRepeatTimeout) + (fAlpha);

	UINT uElapse = (UINT)(fMax - m_fKeyRepeatTimeout * (fMax - fMin));

//	TRACE("CMackieControlMaster::SetKeyRepeatCallbackTimer(): %d\n", uElapse);

	// Just in case
	KillKeyRepeatCallbackTimer();

	// Setup the timer
	timeBeginPeriod(m_wKeyRepeatTimerPeriod);

	m_uiKeyRepeatTimerID = timeSetEvent(uElapse,
										m_wKeyRepeatTimerPeriod,
										(LPTIMECALLBACK)_KeyRepeatTimerCallback,
										(DWORD)this,
										TIME_ONESHOT | TIME_CALLBACK_FUNCTION);

	if (!m_uiKeyRepeatTimerID)
		TRACE("KeyRepeat timeSetEvent failed!\n");

	m_bKeyRepeatTimerActive = true;
}
コード例 #19
0
ファイル: timer_system_time.c プロジェクト: LMiceOrg/LMiced
int create_time_thread(lm_res_param_t *pm)
{

    TIMECAPS tc;

    pm->tm_param.count = 0;

    if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
    {
        DWORD err = GetLastError();
        lmice_critical_print("Create time thread failed[%u]\n", err);
        return 1;
    }

    pm->tm_param.wTimerRes = min(max(tc.wPeriodMin, MMTIME_RESOLUTION), tc.wPeriodMax);
    pm->tm_param.wTimerDelay = pm->tm_param.wTimerRes;

    timeBeginPeriod(pm->tm_param.wTimerRes);

    pm->tm_param.wTimerID = timeSetEvent(
                pm->tm_param.wTimerDelay,                // delay
                pm->tm_param.wTimerRes,                  // resolution (global variable)
                time_thread_proc,               // callback function
                (DWORD_PTR)pm,                  // user data
                TIME_PERIODIC );                // single timer event
    if(! pm->tm_param.wTimerID)
        return 1;
    else
        return 0;
}
コード例 #20
0
ファイル: mpf_scheduler.c プロジェクト: Jared-Prime/UniMRCP
/** Start scheduler */
MPF_DECLARE(apt_bool_t) mpf_scheduler_start(mpf_scheduler_t *scheduler)
{
	mpf_scheduler_resolution_set(scheduler);
	scheduler->timer_id = timeSetEvent(
					scheduler->resolution, 0, mm_timer_proc, (DWORD_PTR) scheduler, 
					TIME_PERIODIC | TIME_CALLBACK_FUNCTION | TIME_KILL_SYNCHRONOUS);
	return scheduler->timer_id ? TRUE : FALSE;
}
コード例 #21
0
ファイル: SimpleServer.cpp プロジェクト: Lukepahill/Lab-Code
// higer res sleep than standard.
int HiResSleep(int msecs)
{
	HANDLE hTempEvent = CreateEvent( 0, true, FALSE, _T("TEMP_EVENT") );
	timeSetEvent( msecs, 1, (LPTIMECALLBACK)hTempEvent, 0, TIME_ONESHOT | TIME_CALLBACK_EVENT_SET );
	WaitForSingleObject( hTempEvent, msecs );
	CloseHandle( hTempEvent );
	return 1;
}
コード例 #22
0
/*===================================================================*/
static BOOL InfoNES_StartTimer()
{
#ifdef WIN32
	TIMECAPS caps;

	timeGetDevCaps( &caps, sizeof(caps) );
	timeBeginPeriod( caps.wPeriodMin );

	uTimerID =
		timeSetEvent( caps.wPeriodMin * TIMER_PER_LINE, caps.wPeriodMin, TimerFunc, 0, (UINT)TIME_PERIODIC );

	// Calculate proper timing
	wLinePerTimer = LINE_PER_TIMER * caps.wPeriodMin;



#else

	struct sigevent sev;
	struct itimerspec its;
	long long freq_nanosecs = TIMER_PER_LINE*1000000;

	/* Create the timer */
	LOGV("InfoNES_StartTimer");
	if( 0 == uTimerID )
	{
		sev.sigev_notify = SIGEV_THREAD;
		sev.sigev_value.sival_ptr = &uTimerID;
		sev.sigev_notify_function = TimerFunc;
		sev.sigev_notify_attributes = NULL;
		if (timer_create(CLOCK_REALTIME, &sev, &uTimerID) == -1)
		{
			return 0;
		}
		/* Start the timer */
		its.it_value.tv_sec = freq_nanosecs / 1000000000;
		its.it_value.tv_nsec = freq_nanosecs % 1000000000;
		its.it_interval.tv_sec = its.it_value.tv_sec;
		its.it_interval.tv_nsec = its.it_value.tv_nsec;
		if (timer_settime(uTimerID, 0, &its, NULL) == -1)
		{
			return 0;
		}
	}
	LOGV("InfoNES_StartTimer finished: uTimerID=%d", uTimerID);

	// Calculate proper timing
	wLinePerTimer = LINE_PER_TIMER;
#endif
	// Initialize timer variables
	wLines = 0;
	bWaitFlag = TRUE;

	bPauseFlag = FALSE;
	// Initialize Critical Section Object

	return 1;
}
コード例 #23
0
ファイル: OSDepWin.cpp プロジェクト: bsdf/trx
    uintptr_t OSDep::startIntWriteTimer(uint32_t millis, volatile int *addr)
    {
        return (uintptr_t) timeSetEvent(millis, millis, (LPTIMECALLBACK)intWriteTimerProc, (DWORD_PTR)addr,
            TIME_PERIODIC | TIME_CALLBACK_FUNCTION
#ifndef UNDER_CE
            | kTimeKillSynchronous
#endif
            );
    }
コード例 #24
0
void SysTimer::trigger(unsigned long msec)
{
	EnterCriticalSection(&Win32::win32Section);
	data->lastDelay = msec;
	if (data->timerId != NULL)
		timeKillEvent(data->timerId);
	data->timerId = timeSetEvent(msec, 5, timerProc, (DWORD_PTR)data, TIME_ONESHOT | TIME_CALLBACK_FUNCTION | TIME_KILL_SYNCHRONOUS);
	LeaveCriticalSection(&Win32::win32Section);
}
コード例 #25
0
ファイル: comm.cpp プロジェクト: locke2002/ShruggingMan
void set_alarm( long seconds )
{
#if defined(WIN32)
   kill_timer(  );   /* kill old timer */
   timer_code = timeSetEvent( seconds * 1000L, 1000, alarm_handler, 0, TIME_PERIODIC );
#else
   alarm( seconds );
#endif
}
コード例 #26
0
	uintptr OSDep::startIntWriteTimer(uint32 millis, int *addr)
	{
		return (uintptr) timeSetEvent(millis, millis, (LPTIMECALLBACK)intWriteTimerProc, (DWORD_PTR)addr, 
			TIME_PERIODIC | TIME_CALLBACK_FUNCTION
#ifndef UNDER_CE
			| TIME_KILL_SYNCHRONOUS
#endif
			);
	}
コード例 #27
0
ファイル: posixtimer.c プロジェクト: github188/SimpleCode
void win_timer_init(void)
{
        timerId = timeSetEvent(TIME_INTERVAL,10,timerCb,0,TIME_PERIODIC | TIME_CALLBACK_FUNCTION);
        TimeEvent = CreateEvent(NULL,FALSE,FALSE,NULL);

        late_ticks = 0;

        offset_time = GetTickCount();
        posix_timer_time=0;
}
コード例 #28
0
ファイル: timer.cpp プロジェクト: Eih3/v0.83
int timer::start()
{
    stop();
    control.stop = timeSetEvent(control.msecs,
						  (control.msecs > 10) ? 5 : 1,
						  (LPTIMECALLBACK) timer_fnc,
						  (DWORD) &control,
						  TIME_ONESHOT | TIME_CALLBACK_FUNCTION);
    return 0;
};
コード例 #29
0
ファイル: alarma.c プロジェクト: sebasalazar/C
void alarmar(int timeout) {
#ifdef __WIN32__
    int thid = GetCurrentThreadId();
    wintimer = timeSetEvent((timeout * 1000), 10, alarma, thid, TIME_ONESHOT);
#else
    alarm(0);
    signal(SIGALRM, alarma);
    alarm(timeout);
#endif
}
コード例 #30
0
ファイル: Wmain.cpp プロジェクト: JoshShangTsung/HB-Shadow
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;
}