Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 146244 Details for
Bug 213524
media-gfx/splashutils-1.5.3.4: MNG Animation stops on clockskew - Bugfix attached
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to detect clockskews
splashutils-1.5.3.4-clockskew.patch (text/plain), 8.19 KB, created by
Clemens Rabe
on 2008-03-15 18:39:01 UTC
(
hide
)
Description:
Patch to detect clockskews
Filename:
MIME Type:
Creator:
Clemens Rabe
Created:
2008-03-15 18:39:01 UTC
Size:
8.19 KB
patch
obsolete
>diff -Naur splashutils-1.5.3.4/src/daemon.c splashutils-1.5.3.4.new/src/daemon.c >--- splashutils-1.5.3.4/src/daemon.c 2008-01-27 12:46:21.000000000 +0100 >+++ splashutils-1.5.3.4.new/src/daemon.c 2008-03-15 13:46:06.000000000 +0100 >@@ -34,8 +34,9 @@ > pthread_mutex_t mtx_paint = PTHREAD_MUTEX_INITIALIZER; > pthread_mutex_t mtx_anim = PTHREAD_MUTEX_INITIALIZER; > pthread_cond_t cnd_anim = PTHREAD_COND_INITIALIZER; >+pthread_mutex_t mtx_timeSkewCheck = PTHREAD_MUTEX_INITIALIZER; > >-pthread_t th_switchmon, th_sighandler, th_anim; >+pthread_t th_switchmon, th_sighandler, th_anim, th_checkTime; > > int ctty = CTTY_VERBOSE; > >@@ -58,7 +59,68 @@ > /* A container for the original settings of the silent TTY. */ > struct termios tios; > >+/* Flag set by the checkTime thread. Locked by mtx_timeSkewCheck. */ >+bool timeSkewDetected_b = false; >+ > #if WANT_MNG >+ >+/* >+ * Check for time skews. >+ */ >+void *thf_checkTime(void *unused) >+{ >+ struct timeval tv_current; >+ const unsigned long sleepTime_ui = 100 * 1000; // 100 msecs >+ long lastMsec; >+ long currentMsec; >+ long diffMsec; >+ >+ >+ /* Try to detect system clock changed */ >+ if ( gettimeofday( &tv_current, NULL ) != 0) >+ { >+ perror( "Can't get time with gettimeofday!" ); >+ return 0; >+ } >+ >+ lastMsec = ( ( (long) tv_current.tv_sec ) * ( (long) 1000 ) ) + >+ ( ( (long) tv_current.tv_usec ) / ( (long) 1000 ) ); >+ usleep( sleepTime_ui ); >+ >+ >+ while ( 1 ) >+ { >+ gettimeofday( &tv_current, NULL ); >+ currentMsec = ( ( (long) tv_current.tv_sec ) * ( (long) 1000 ) ) + >+ ( ( (long) tv_current.tv_usec ) / ( (long) 1000 ) ); >+ >+ diffMsec = currentMsec - lastMsec; >+ >+ if ( ( diffMsec < 0 ) || ( diffMsec > 10*sleepTime_ui ) ) >+ { >+ /* Time skew detected! Signal thf_anim a reset. */ >+ pthread_mutex_lock( &mtx_timeSkewCheck ); >+ timeSkewDetected_b = true; >+ pthread_mutex_unlock( &mtx_timeSkewCheck ); >+ >+ pthread_mutex_lock(&mtx_anim); >+ pthread_cond_signal(&cnd_anim); >+ pthread_mutex_unlock(&mtx_anim); >+ >+ /* Get time again to compensate for delays caused by the mutex stuff. */ >+ gettimeofday( &tv_current, NULL ); >+ currentMsec = ( ( (long) tv_current.tv_sec ) * ( (long) 1000 ) ) + >+ ( ( (long) tv_current.tv_usec ) / ( (long) 1000 ) ); >+ } >+ >+ lastMsec = currentMsec; >+ usleep( sleepTime_ui ); >+ } >+ >+ return 0; >+} >+ >+ > /* > * Display all animations of the type 'once' or 'loop'. > */ >@@ -69,18 +131,60 @@ > item *i; > mng_anim *mng; > int delay = 10000, rdelay, oldstate; >- struct timespec ts, tsc; >+ struct timespec ts, ts_last; >+ bool resetAnims_b = false; >+ >+ /* Initialize the time value. */ >+ clock_gettime(CLOCK_REALTIME, &ts); >+ ts_last = ts; > > while(1) { >+ /* Check for a time skew */ > pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate); >- pthread_mutex_lock(&mtx_paint); >+ pthread_mutex_lock( &mtx_timeSkewCheck ); >+ resetAnims_b = timeSkewDetected_b; >+ timeSkewDetected_b = false; >+ pthread_mutex_unlock( &mtx_timeSkewCheck ); >+ pthread_setcancelstate(oldstate, NULL); >+ >+ >+ /* Reset animations if neccessary */ >+ if ( resetAnims_b ) >+ { >+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate); >+ pthread_mutex_lock(&mtx_paint); >+ >+ for (i = theme->anims.head; i != NULL; i = i->next) { >+ ca = i->p; >+ co = container_of(ca); >+ >+ if (!co->visible || >+ (ca->flags & F_ANIM_METHOD_MASK) == F_ANIM_PROPORTIONAL || >+ ca->status == F_ANIM_STATUS_DONE) >+ continue; >+ >+ mng = mng_get_userdata(ca->mng); >+ >+ if ( (!mng->displayed_first) || (mng->wait_msecs > 0) ) >+ mng_display_restart(ca->mng); >+ } >+ pthread_mutex_unlock(&mtx_paint); >+ pthread_setcancelstate(oldstate, NULL); >+ >+ /* Our times are not valid any more. */ >+ clock_gettime(CLOCK_REALTIME, &ts_last); >+ } >+ >+ > /* Find the shortest delay. */ >+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate); >+ pthread_mutex_lock(&mtx_paint); > for (i = theme->anims.head; i != NULL; i = i->next) { > ca = i->p; > co = container_of(ca); > > if (!co->visible || >- (ca->flags & F_ANIM_METHOD_MASK) == F_ANIM_PROPORTIONAL || >+ (ca->flags & F_ANIM_METHOD_MASK) == F_ANIM_PROPORTIONAL || > ca->status == F_ANIM_STATUS_DONE) > continue; > >@@ -89,24 +193,34 @@ > /* If this is a new animation (activated by a service), > * display it immediately. */ > if (!mng->displayed_first) { >+ /* Set delay to 0 and paint the complete screen later. */ >+ delay = 0; >+#if 0 > anim_render_canvas(ca); > > if (ctty == CTTY_SILENT) >- fbsplashr_render_screen(theme, true, false, FBSPL_EFF_NONE); >+ fbsplashr_render_screen(theme, true, false, FBSPL_EFF_NONE); >+#endif > } > > if (mng->wait_msecs < delay && mng->wait_msecs > 0) { >- delay = mng->wait_msecs; >+ delay = mng->wait_msecs; > } > } > pthread_mutex_unlock(&mtx_paint); > pthread_setcancelstate(oldstate, NULL); > >+ >+ /* Get the current time and calculate the delay until the next refresh. */ > pthread_mutex_lock(&mtx_anim); > clock_gettime(CLOCK_REALTIME, &ts); > >- ts.tv_sec += (int)(delay / 1000); >- ts.tv_nsec += (delay % 1000) * 1000000; >+ >+ /* Time we spent between the last update of the anim delays >+ * and now (ts - ts_last) is subtracted from the delay. >+ */ >+ ts.tv_sec += (int)(delay / 1000) - (ts.tv_sec - ts_last.tv_sec); >+ ts.tv_nsec += (delay % 1000) * 1000000 - (ts.tv_nsec - ts_last.tv_nsec); > > /* Check for overflow of the nanoseconds field */ > if (ts.tv_nsec >= 1000000000) { >@@ -114,19 +228,23 @@ > ts.tv_nsec -= 1000000000; > } > >+ /* Wait until signaled or timeout */ > pthread_cond_timedwait(&cnd_anim, &mtx_anim, &ts); > pthread_mutex_unlock(&mtx_anim); > > pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate); > pthread_mutex_lock(&mtx_paint); >+ >+ > /* Don't paint anything if we aren't in silent mode. */ > if (ctty != CTTY_SILENT) > goto next; > >+ > /* Calculate the real delay. We might have been signalled by > * the splash daemon before 'delay' msecs passed. */ >- clock_gettime(CLOCK_REALTIME, &tsc); >- rdelay = delay + (tsc.tv_sec - ts.tv_sec)*1000 + (tsc.tv_nsec - ts.tv_nsec)/1000000; >+ clock_gettime(CLOCK_REALTIME, &ts); >+ rdelay = delay + (ts.tv_sec - ts_last.tv_sec)*1000 + (ts.tv_nsec - ts_last.tv_nsec)/1000000; > > /* Update the wait time for all relevant animation objects. */ > for (i = theme->anims.head ; i != NULL; i = i->next) { >@@ -138,6 +256,13 @@ > continue; > > mng = mng_get_userdata(ca->mng); >+ >+ /* Display new anims right now. */ >+ if (!mng->displayed_first) >+ { >+ anim_render_canvas(ca); >+ } >+ > if (mng->wait_msecs > 0) { > mng->wait_msecs -= rdelay; > if (mng->wait_msecs <= 0) >@@ -146,7 +271,12 @@ > } > fbsplashr_render_screen(theme, true, false, FBSPL_EFF_NONE); > >-next: pthread_mutex_unlock(&mtx_paint); >+ >+next: >+ /* Save the time just before refreshing the wait_msecs fields. */ >+ ts_last = ts; >+ >+ pthread_mutex_unlock(&mtx_paint); > pthread_setcancelstate(oldstate, NULL); > > /* Default delay is 10s */ >@@ -560,6 +690,9 @@ > #ifdef CONFIG_MNG > /* Start the animation thread */ > pthread_create(&th_anim, NULL, &thf_anim, NULL); >+ >+ /* Start the time skew check thread */ >+ pthread_create(&th_checkTime, NULL, &thf_checkTime, NULL ); > #endif > > pthread_mutex_lock(&mtx_tty);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 213524
: 146244 |
146246