[vlc-commits] Android: remove polling timer in mwait() and msleep()
Rémi Denis-Courmont
git at videolan.org
Tue Oct 16 21:46:05 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Oct 15 21:21:32 2012 +0300| [dfccdf84e19f85a084157fbf77f82b3e8508ae4e] | committer: Rémi Denis-Courmont
Android: remove polling timer in mwait() and msleep()
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dfccdf84e19f85a084157fbf77f82b3e8508ae4e
---
src/android/thread.c | 37 ++++++++++++++-----------------------
1 file changed, 14 insertions(+), 23 deletions(-)
diff --git a/src/android/thread.c b/src/android/thread.c
index 10380cb..2715388 100644
--- a/src/android/thread.c
+++ b/src/android/thread.c
@@ -494,34 +494,25 @@ mtime_t mdate (void)
#undef mwait
void mwait (mtime_t deadline)
{
- deadline -= mdate ();
- if (deadline > 0)
- msleep (deadline);
+ vlc_mutex_t lock;
+ vlc_cond_t wait;
+
+ vlc_mutex_init (&lock);
+ vlc_cond_init (&wait);
+
+ vlc_mutex_lock (&lock);
+ mutex_cleanup_push (&lock);
+ while (!vlc_cond_timedwait (&wait, &lock, deadline));
+ vlc_cleanup_run ();
+
+ vlc_cond_destroy (&wait);
+ vlc_mutex_destroy (&lock);
}
#undef msleep
void msleep (mtime_t delay)
{
- struct timespec ts = mtime_to_ts (delay);
-
- vlc_testcancel();
- for (;;) {
- /* FIXME: drift */
- struct timespec t = { 0, 10 * 1000 * 1000 };
- if (ts.tv_sec <= 0 && t.tv_nsec > ts.tv_nsec)
- t.tv_nsec = ts.tv_nsec;
- while (nanosleep (&t, &t) == -1) {
- vlc_testcancel();
- vlc_assert (errno == EINTR);
- }
-
- ts.tv_nsec -= 10 * 1000 * 1000;
- if (ts.tv_nsec < 0) {
- if (--ts.tv_sec < 0)
- return;
- ts.tv_nsec += 1000 * 1000 * 1000;
- }
- }
+ mwait (mdate () + delay);
}
/* cpu */
More information about the vlc-commits
mailing list