mirror of
https://github.com/dgis/emu48android
synced 2024-12-26 09:58:49 +01:00
Fix a timer issue.
This commit is contained in:
parent
72ccc7a98b
commit
3427c62a89
3 changed files with 22 additions and 9 deletions
|
@ -71,6 +71,7 @@ Version 2.0 (2020-11-XX)
|
||||||
- Fix transparency issue (RGB -> BGR).
|
- Fix transparency issue (RGB -> BGR).
|
||||||
- Fix a printer issue from Christoph Gießelink's HP82240B Printer Simulator version 1.12.
|
- Fix a printer issue from Christoph Gießelink's HP82240B Printer Simulator version 1.12.
|
||||||
- Fix the KML button Type 3 with a Background offset which was not display at the right location (Fix #15).
|
- Fix the KML button Type 3 with a Background offset which was not display at the right location (Fix #15).
|
||||||
|
- Fix a timer issue.
|
||||||
|
|
||||||
|
|
||||||
Version 1.9 (2020-09-07)
|
Version 1.9 (2020-09-07)
|
||||||
|
|
|
@ -71,6 +71,7 @@ Version 2.0 (2020-11-XX)
|
||||||
- Fix transparency issue (RGB -> BGR).
|
- Fix transparency issue (RGB -> BGR).
|
||||||
- Fix a printer issue from Christoph Gießelink's HP82240B Printer Simulator version 1.12.
|
- Fix a printer issue from Christoph Gießelink's HP82240B Printer Simulator version 1.12.
|
||||||
- Fix the KML button Type 3 with a Background offset which was not display at the right location (Fix #15).
|
- Fix the KML button Type 3 with a Background offset which was not display at the right location (Fix #15).
|
||||||
|
- Fix a timer issue.
|
||||||
|
|
||||||
|
|
||||||
Version 1.9 (2020-09-07)
|
Version 1.9 (2020-09-07)
|
||||||
|
|
|
@ -2631,6 +2631,14 @@ static void initTimer() {
|
||||||
lastTimerId = 0;
|
lastTimerId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dumpTimers() {
|
||||||
|
TIMER_LOGD("dumpTimers()");
|
||||||
|
for (struct timerEvent * nextTimer = timersList.next; nextTimer != &timersList; nextTimer = nextTimer->next) {
|
||||||
|
TIMER_LOGD("\ttimerId: %d (%x), uDelay: %d, dwUser: %d, fuEvent: %d, triggerTime: %ld)",
|
||||||
|
nextTimer->timerId, nextTimer, nextTimer->uDelay, nextTimer->dwUser, nextTimer->fuEvent, nextTimer->triggerTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MMRESULT timeKillEvent(UINT uTimerID) {
|
MMRESULT timeKillEvent(UINT uTimerID) {
|
||||||
TIMER_LOGD("timeKillEvent(uTimerID: [%d])", uTimerID);
|
TIMER_LOGD("timeKillEvent(uTimerID: [%d])", uTimerID);
|
||||||
|
|
||||||
|
@ -2647,10 +2655,14 @@ MMRESULT timeKillEvent(UINT uTimerID) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if defined(TIMER_LOGD)
|
||||||
|
dumpTimers();
|
||||||
|
#endif
|
||||||
if(timersList.next == &timersList) {
|
if(timersList.next == &timersList) {
|
||||||
// The list is empty
|
// The list is empty
|
||||||
// Leave the thread?
|
// Leave the thread?
|
||||||
timerThreadToEnd = TRUE;
|
timerThreadToEnd = TRUE;
|
||||||
|
TIMER_LOGD("timeKillEvent(uTimerID: [%d]) timerThreadToEnd = TRUE ", uTimerID);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&timerEventsLock);
|
pthread_mutex_unlock(&timerEventsLock);
|
||||||
|
|
||||||
|
@ -2672,18 +2684,15 @@ static void insertTimer(struct timerEvent * newTimer) {
|
||||||
newTimer->prev = nextTimer->prev;
|
newTimer->prev = nextTimer->prev;
|
||||||
nextTimer->prev->next = newTimer;
|
nextTimer->prev->next = newTimer;
|
||||||
nextTimer->prev = newTimer;
|
nextTimer->prev = newTimer;
|
||||||
}
|
|
||||||
|
|
||||||
static void dumpTimers() {
|
#if defined(TIMER_LOGD)
|
||||||
TIMER_LOGD("dumpTimers()");
|
dumpTimers();
|
||||||
for (struct timerEvent * nextTimer = timersList.next; nextTimer != &timersList; nextTimer = nextTimer->next) {
|
#endif
|
||||||
TIMER_LOGD("\ttimerId: %d (%x), uDelay: %d, dwUser: %d, fuEvent: %d, triggerTime: %ld)",
|
|
||||||
nextTimer->timerId, nextTimer, nextTimer->uDelay, nextTimer->dwUser, nextTimer->fuEvent, nextTimer->triggerTime);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void timerThreadStart(LPVOID lpThreadParameter) {
|
static void timerThreadStart(LPVOID lpThreadParameter) {
|
||||||
pthread_mutex_lock(&timerEventsLock);
|
LOGD("timerThreadStart() START");
|
||||||
|
pthread_mutex_lock(&timerEventsLock);
|
||||||
while (!timerThreadToEnd) {
|
while (!timerThreadToEnd) {
|
||||||
TIMER_LOGD("timerThreadStart() %ld", GetTickCount64());
|
TIMER_LOGD("timerThreadStart() %ld", GetTickCount64());
|
||||||
|
|
||||||
|
@ -2737,12 +2746,13 @@ static void timerThreadStart(LPVOID lpThreadParameter) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pthread_mutex_unlock(&timerEventsLock);
|
pthread_mutex_unlock(&timerEventsLock);
|
||||||
Sleep(sleep_time);
|
Sleep(sleep_time > 100 ? 100 : sleep_time);
|
||||||
pthread_mutex_lock(&timerEventsLock);
|
pthread_mutex_lock(&timerEventsLock);
|
||||||
}
|
}
|
||||||
timerThreadId = 0;
|
timerThreadId = 0;
|
||||||
pthread_mutex_unlock(&timerEventsLock);
|
pthread_mutex_unlock(&timerEventsLock);
|
||||||
jniDetachCurrentThread();
|
jniDetachCurrentThread();
|
||||||
|
LOGD("timerThreadStart() END");
|
||||||
}
|
}
|
||||||
|
|
||||||
MMRESULT timeSetEvent(UINT uDelay, UINT uResolution, LPTIMECALLBACK fptc, DWORD_PTR dwUser, UINT fuEvent) {
|
MMRESULT timeSetEvent(UINT uDelay, UINT uResolution, LPTIMECALLBACK fptc, DWORD_PTR dwUser, UINT fuEvent) {
|
||||||
|
@ -2767,6 +2777,7 @@ MMRESULT timeSetEvent(UINT uDelay, UINT uResolution, LPTIMECALLBACK fptc, DWORD_
|
||||||
|
|
||||||
if(!timerThreadId) {
|
if(!timerThreadId) {
|
||||||
// If not yet created, create the thread which will handle all the timers
|
// If not yet created, create the thread which will handle all the timers
|
||||||
|
LOGD("timeSetEvent() pthread_create");
|
||||||
if (pthread_create(&timerThreadId, NULL, (void *(*)(void *)) timerThreadStart, NULL) != 0) {
|
if (pthread_create(&timerThreadId, NULL, (void *(*)(void *)) timerThreadStart, NULL) != 0) {
|
||||||
LOGD("timeSetEvent() ERROR in pthread_create, errno: %d (EAGAIN 11 / EINVAL 22 / EPERM 1)", errno);
|
LOGD("timeSetEvent() ERROR in pthread_create, errno: %d (EAGAIN 11 / EINVAL 22 / EPERM 1)", errno);
|
||||||
// EAGAIN Insufficient resources to create another thread.
|
// EAGAIN Insufficient resources to create another thread.
|
||||||
|
|
Loading…
Reference in a new issue