PHPAPI int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue) { int timeout = value->it_value.tv_sec * 1000 + value->it_value.tv_usec; int repeat = TIME_ONESHOT; /*make sure the message queue is initialized */ PeekMessage(phpmsg, NULL, WM_USER, WM_USER, PM_NOREMOVE); if (timeout > 0) { struct timer_msg *msg = malloc(sizeof(struct timer_msg)); msg->threadid = GetCurrentThreadId(); if (!ovalue) { repeat = TIME_PERIODIC; } switch (which) { case ITIMER_REAL: msg->signal = SIGALRM; realtimer = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat); break; case ITIMER_VIRT: msg->signal = SIGVTALRM; virttimer = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat); break; case ITIMER_PROF: msg->signal = SIGPROF; proftimer = timeSetEvent(timeout, 100, (LPTIMECALLBACK) setitimer_timeout, (UINT) msg, repeat); break; default: errno = EINVAL; return -1; break; } } else { switch (which) { case ITIMER_REAL: timeKillEvent(realtimer); break; case ITIMER_VIRT: timeKillEvent(virttimer); break; case ITIMER_PROF: timeKillEvent(proftimer); break; default: errno = EINVAL; return -1; break; } } return 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); } }
kgmDSound::~kgmDSound() { m_proceed = false; if(m_timer) timeKillEvent(m_timer); Sleep(100); m_thread.join(); kgmThread::mxfree(m_mutex); if(m_pSbuf) { if(FAILED(m_pSbuf->Release())) { #ifdef DEBUG kgm_log() << "Error: can't release direct sound buffer.\n"; #endif } } if(m_pSnd) { if(FAILED(m_pSnd->Release())) { #ifdef DEBUG kgm_log() << "Error: can't release direct sound.\n"; #endif } } }
/** * Timer callback used to check about end of media (except JTS type) */ static void CALLBACK audio_timer_callback(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2) { audio_handle* pHandle = (audio_handle*)dwUser; if (pHandle->hWnd) { if (-1 == pHandle->duration) { pHandle->duration = MCIWndGetLength(pHandle->hWnd); JAVA_DEBUG_PRINT1("[jc_media] audio_timer_callback %d\n", pHandle->duration); } pHandle->offset = MCIWndGetPosition(pHandle->hWnd); pHandle->curTime = pHandle->offset; /* Is end of media reached? */ if (pHandle->offset >= pHandle->duration) { /* Post EOM event to Java and kill player timer */ pHandle->timerId = 0; pHandle->offset = 0; timeKillEvent(uID); JAVA_DEBUG_PRINT1("[jc_media] javanotify_on_media_notification %d\n", pHandle->playerId); javanotify_on_media_notification(JAVACALL_EVENT_MEDIA_END_OF_MEDIA, pHandle->playerId, (void*)pHandle->duration); } } }
static void mpx_shutdown_itimer( void ) { if ( timeKillEvent( mpxTimerID ) != TIMERR_NOERROR ) { MPXDBG( "setitimer(MPX_ITIMER) in mpx_shutdown_itimer" ); } }
int destroy_timer_event ( int timer_id ) { int count, found; found = FALSE; for ( count = 0; ( ( count < number_of_timers ) && ( !found ) ); count++ ) { if ( ( timer_list[count].used ) && ( timer_list[count].id ) ) { found = TRUE; } } if ( found ) { #ifdef _WIN32 timeKillEvent ( timer_list[count].id ); #endif timer_list[count].used = FALSE; return ( TRUE ); } else { return ( FALSE ); } }
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); }
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); }
void COptionsAbout::OnDestroy() { CDialog::OnDestroy(); timeKillEvent( mmTimer ); //KillTimer( TIMER_ABOUT ); }
void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) { DirectSoundDevice * device = (DirectSoundDevice*)dwUser; DWORD start_time = GetTickCount(); DWORD end_time; TRACE("(%d,%d,0x%lx,0x%lx,0x%lx)\n",timerID,msg,dwUser,dw1,dw2); TRACE("entering at %d\n", start_time); if (DSOUND_renderer[device->drvdesc.dnDevNode] != device) { ERR("dsound died without killing us?\n"); timeKillEvent(timerID); timeEndPeriod(DS_TIME_RES); return; } RtlAcquireResourceShared(&(device->buffer_list_lock), TRUE); if (device->ref) DSOUND_PerformMix(device); RtlReleaseResource(&(device->buffer_list_lock)); end_time = GetTickCount(); TRACE("completed processing at %d, duration = %d\n", end_time, end_time - start_time); }
static ULONG DirectSoundCaptureDevice_Release( DirectSoundCaptureDevice * device) { ULONG ref = InterlockedDecrement(&(device->ref)); TRACE("(%p) ref was %d\n", device, ref + 1); if (!ref) { TRACE("deleting object\n"); timeKillEvent(device->timerID); timeEndPeriod(DS_TIME_RES); EnterCriticalSection(&DSOUND_capturers_lock); list_remove(&device->entry); LeaveCriticalSection(&DSOUND_capturers_lock); if (device->capture_buffer) IDirectSoundCaptureBufferImpl_Release(&device->capture_buffer->IDirectSoundCaptureBuffer8_iface); if(device->mmdevice) IMMDevice_Release(device->mmdevice); HeapFree(GetProcessHeap(), 0, device->pwfx); device->lock.DebugInfo->Spare[0] = 0; DeleteCriticalSection( &(device->lock) ); HeapFree(GetProcessHeap(), 0, device); TRACE("(%p) released\n", device); } return ref; }
HRESULT CLHTMLActiveDocument::StopPlay() { #if 0 if (m_dsBuffer8) { m_dsBuffer8->Stop(); //m_dsBuffer8.Release(); } if (m_hEvent) { CloseHandle(m_hEvent); m_hEvent = NULL; } #endif if (m_nTimerID) { timeKillEvent(m_nTimerID); m_nTimerID = 0; } if (m_hThread) { ::PostThreadMessage(m_threadID, WM_QUIT, 0, 0); ::WaitForSingleObject(m_hThread, INFINITE); m_hThread = NULL; m_threadID = 0; } return S_OK; }
/* ------------------------------------------------------------------------------------ */ int StreamingAudio::Delete() { if(ogg) { if(Ogg == NULL) return RGF_FAILURE; Ogg->Stop(); delete Ogg; Ogg = NULL; return RGF_SUCCESS; } timeKillEvent(m_nTimerID); // Kill timer if(mp3) { if(Mpeg3 == NULL) return RGF_FAILURE; Mpeg3->StopMp3(); delete Mpeg3; Mpeg3 = NULL; return RGF_SUCCESS; } // Check for stream availability if(m_pStream == NULL) return RGF_FAILURE; // No stream Stop(); // Stop playback return RGF_SUCCESS; }
int timer::stop() { if (control.stop) timeKillEvent(control.stop); control.stop = 0; return 0; };
void tranquilizar() { #ifdef __WIN32__ timeKillEvent(wintimer); #else alarm(0); #endif }
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); } }
void PASCAL TimeProc(UINT wTimerID, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2) { sprintf(str, "%s", "res//"); if (c > 5472) { timeKillEvent(wTimerID); } if (c / 10 == 0) sprintf(buff, "B000%d.BMP", c); else if (c / 100 == 0) sprintf(buff, "B00%d.BMP", c); else if (c / 1000 == 0) sprintf(buff, "B0%d.BMP", c); else { sprintf(buff, "B%d.BMP", c); } str1 = str; str1 += buff; temp = c%25; if (temp == 0) count++; if (count == 10)count = 0; DrawImg(str1,count); c++; }
// Destructor void Timer::destructor(void) { if (m_nIDTimer) { timeKillEvent (m_nIDTimer); m_nIDTimer = NULL; } }
static void win32_stop_timer(struct qemu_alarm_timer *t) { struct qemu_alarm_win32 *data = t->priv; timeKillEvent(data->timerId); timeEndPeriod(data->period); }
bool CDirectSoundPlayer::Stop() { HRESULT hr; if(m_InitOK && m_AudioEnabled) { if(m_TimerID!=NULL) timeKillEvent(m_TimerID); hr=m_BufferSecondary->Stop(); if(hr!=DS_OK) { CString message ("CDirectSoundPlayer::Stop - Error: \n"); message += DXAppErrorToString (hr); gError->Warning(message); } hr=m_BufferSecondary->SetCurrentPosition(0); if(hr!=DS_OK) { CString message ("CDirectSoundPlayer::Stop - Error: \n"); message += DXAppErrorToString (hr); gError->Warning(message); } // dbg.Close(); } m_AudioEnabled=FALSE; return m_AudioEnabled; }
void SDL_SYS_TimerQuit(void) { if ( timerID ) { timeKillEvent(timerID); } timeEndPeriod(TIMER_RESOLUTION); }
static void mm_rearm_timer(struct qemu_alarm_timer *t) { int nearest_delta_ms; assert(alarm_has_dynticks(t)); if (!active_timers[QEMU_CLOCK_REALTIME] && !active_timers[QEMU_CLOCK_VIRTUAL] && !active_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); } }
void Timer::Stop() { if (mTimerID) { timeKillEvent(mTimerID); mTimerID = 0; } }
void SysTimer::cancel() { EnterCriticalSection(&Win32::win32Section); if (data->timerId != NULL) timeKillEvent(data->timerId); data->timerId = NULL; LeaveCriticalSection(&Win32::win32Section); }
void CDuiTimerBase::InnerKillTimer() { timeKillEvent(m_uTimerID); timeEndPeriod(m_uTimerAccuracy); m_uTimerID = NULL; m_uTimerAccuracy = NULL; m_iCurTimer = m_iInterval; }
void KillMMTimer(UINT nID) { if(nID!=0) { timeKillEvent(nID); timeEndPeriod(g_iAccuracy); } g_iMMTimerID=0; }
DttSP_EXP void StopKeyer () { EnterCriticalSection(update_ok); if (timerid) timeKillEvent ((UINT) timerid); LeaveCriticalSection(update_ok); timerid = 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); }
void VirtualOHT::DestoryTimer(void) { if (m_nTimerID > 0) { timeKillEvent(m_nTimerID); timeEndPeriod(1); m_nTimerID = 0; } }
void _StopTimer(MMRESULT timerid) {TIMECAPS caps; if (timerid != 0) { timeKillEvent(timerid); timerid = 0; timeGetDevCaps(&caps, sizeof(caps)); timeEndPeriod(caps.wPeriodMin); } }