[vlc-devel] commit: Win32: mwait and msleep are cancellation points ( Rémi Denis-Courmont )
git version control
git at videolan.org
Wed Aug 27 22:57:28 CEST 2008
vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Wed Aug 6 23:08:11 2008 +0300| [8b74b9de6ca105c32915930228e0519633f93126] | committer: Rémi Denis-Courmont
Win32: mwait and msleep are cancellation points
Use SleepEx so APC can be executed
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8b74b9de6ca105c32915930228e0519633f93126
---
src/misc/mtime.c | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/misc/mtime.c b/src/misc/mtime.c
index 6c13eac..4ecf12a 100644
--- a/src/misc/mtime.c
+++ b/src/misc/mtime.c
@@ -340,8 +340,19 @@ void mwait( mtime_t date )
ts.tv_sec = d.quot; ts.tv_nsec = d.rem * 1000;
while( clock_nanosleep( CLOCK_REALTIME, 0, &ts, NULL ) == EINTR );
}
-#else
+#elif defined (WIN32)
+ mtime_t total;
+
+ while ((total = (date - mdate ())) > 0)
+ {
+ DWORD delay = (total > 0x7fffffff) ? 0x7fffffff : total;
+ vlc_testcancel ();
+ SleepEx (delay, TRUE);
+ }
+ vlc_testcancel ();
+
+#else
mtime_t delay = date - mdate();
if( delay > 0 )
msleep( delay );
@@ -350,9 +361,8 @@ void mwait( mtime_t date )
}
/**
- * More precise sleep()
+ * Portable usleep(). Cancellation point.
*
- * Portable usleep() function.
* \param delay the amount of time to sleep
*/
void msleep( mtime_t delay )
@@ -373,9 +383,7 @@ void msleep( mtime_t delay )
snooze( delay );
#elif defined( WIN32 ) || defined( UNDER_CE )
- for (delay /= 1000; delay > 0x7fffffff; delay -= 0x7fffffff)
- Sleep (0x7fffffff);
- Sleep (delay);
+ mwait (mdate () + delay);
#elif defined( HAVE_NANOSLEEP )
struct timespec ts_delay;
More information about the vlc-devel
mailing list