[vlc-commits] commit: Timer: remove the static lock ( Rémi Denis-Courmont )
git at videolan.org
git at videolan.org
Wed Oct 13 18:23:38 CEST 2010
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Oct 13 19:14:01 2010 +0300| [d25fd8d74a7be4bd367410bfeda08ab63f247ee7] | committer: Rémi Denis-Courmont
Timer: remove the static lock
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d25fd8d74a7be4bd367410bfeda08ab63f247ee7
---
src/misc/pthread.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/src/misc/pthread.c b/src/misc/pthread.c
index 12be0a8..fcbf3e7 100644
--- a/src/misc/pthread.c
+++ b/src/misc/pthread.c
@@ -939,17 +939,17 @@ void vlc_timer_destroy (vlc_timer_t timer)
void vlc_timer_schedule (vlc_timer_t timer, bool absolute,
mtime_t value, mtime_t interval)
{
- static vlc_mutex_t lock = VLC_STATIC_MUTEX;
-
- vlc_mutex_lock (&lock);
vlc_mutex_lock (&timer->lock);
- if (timer->value)
+ while (timer->value)
{
+ vlc_thread_t thread = timer->thread;
+
+ timer->value = 0;
vlc_mutex_unlock (&timer->lock);
- vlc_cancel (timer->thread);
- vlc_join (timer->thread, NULL);
+ vlc_cancel (thread);
+ /* cannot keep the lock during vlc_join X( */
+ vlc_join (thread, NULL);
vlc_mutex_lock (&timer->lock);
- timer->value = 0;
}
if ((value != 0)
&& (vlc_clone (&timer->thread, vlc_timer_thread, timer,
@@ -959,7 +959,6 @@ void vlc_timer_schedule (vlc_timer_t timer, bool absolute,
timer->interval = interval;
}
vlc_mutex_unlock (&timer->lock);
- vlc_mutex_unlock (&lock);
}
/**
More information about the vlc-commits
mailing list