[vlc-devel] commit: vlc_object_timedwait: same change as vlc_object_wait ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat May 31 17:59:28 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sat May 31 18:55:03 2008 +0300| [425d6074da0f80e93ba092507c487068ada8e054]

vlc_object_timedwait: same change as vlc_object_wait

Also fix a minor timing problem in the screensaver plugin.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=425d6074da0f80e93ba092507c487068ada8e054
---

 modules/misc/audioscrobbler.c |   26 +++++++++++---------------
 modules/misc/screensaver.c    |    9 ++++++---
 src/misc/objects.c            |   12 +++---------
 3 files changed, 20 insertions(+), 27 deletions(-)

diff --git a/modules/misc/audioscrobbler.c b/modules/misc/audioscrobbler.c
index b6ee773..5230f20 100644
--- a/modules/misc/audioscrobbler.c
+++ b/modules/misc/audioscrobbler.c
@@ -274,25 +274,21 @@ static void Run( intf_thread_t *p_intf )
         bool b_die = false, b_wait = false;
 
         vlc_object_lock( p_intf );
-        if( vlc_object_alive( p_intf ) )
-        {
-           if( mdate() < p_sys->next_exchange )
-                /* wait until we can resubmit, i.e.  */
-                b_wait = !vlc_object_timedwait( p_intf,
-                                                p_sys->next_exchange );
-            else
-                /* wait for data to submit */
-                /* we are signaled each time there is a song to submit */
-               vlc_object_wait( p_intf );
-        }
-        b_die = !vlc_object_alive( p_intf );
-        vlc_object_unlock( p_intf );
-
-        if( b_die )
+        if( !vlc_object_alive( p_intf ) )
         {
+            vlc_object_unlock( p_intf );
             msg_Dbg( p_intf, "audioscrobbler is dying");
             return;
         }
+        if( mdate() < p_sys->next_exchange )
+            /* wait until we can resubmit, i.e.  */
+            b_wait = vlc_object_timedwait( p_intf, p_sys->next_exchange ) == 0;
+        else
+            /* wait for data to submit */
+            /* we are signaled each time there is a song to submit */
+            vlc_object_wait( p_intf );
+        vlc_object_unlock( p_intf );
+
         if( b_wait )
             continue; /* holding on until next_exchange */
 
diff --git a/modules/misc/screensaver.c b/modules/misc/screensaver.c
index 7340893..2b8c18e 100644
--- a/modules/misc/screensaver.c
+++ b/modules/misc/screensaver.c
@@ -176,8 +176,9 @@ static void Execute( intf_thread_t *p_this, const char *const *ppsz_args )
  *****************************************************************************/
 static void Run( intf_thread_t *p_intf )
 {
-    vlc_object_lock( p_intf );
+    mtime_t deadline = mdate();
 
+    vlc_object_lock( p_intf );
 #ifdef HAVE_DBUS
     p_intf->p_sys->p_connection = dbus_init( p_intf );
 #endif
@@ -186,8 +187,7 @@ static void Run( intf_thread_t *p_intf )
     {
         vlc_object_t *p_vout;
 
-        /* Check screensaver every 30 seconds */
-        if( vlc_object_timedwait( p_intf, mdate() + 30000000 ) < 0 )
+        if( vlc_object_timedwait( p_intf, deadline ) == 0 )
             continue;
 
         p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
@@ -222,6 +222,9 @@ static void Run( intf_thread_t *p_intf )
                 vlc_object_release( p_input );
             }
         }
+
+        /* Check screensaver every 30 seconds */
+        refresh = mdate() + 30000000;
     }
     vlc_object_unlock( p_intf );
 }
diff --git a/src/misc/objects.c b/src/misc/objects.c
index a108f3d..4830eda 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -545,19 +545,13 @@ void __vlc_object_wait( vlc_object_t *obj )
  * Waits for the object to be signaled (using vlc_object_signal()), or for
  * a timer to expire. It is asserted that the caller holds the object lock.
  *
- * @return negative if the object is dying and should terminate,
- * positive if the the object has been signaled but is not dying,
- * 0 if timeout has been reached.
+ * @return 0 if the object was signaled before the timer expiration, or
+ * ETIMEDOUT if the timer expired without any signal.
  */
 int __vlc_object_timedwait( vlc_object_t *obj, mtime_t deadline )
 {
-    int v;
-
     vlc_assert_locked( &obj->object_lock );
-    v = vlc_cond_timedwait( &obj->object_wait, &obj->object_lock, deadline );
-    if( v == 0 ) /* signaled */
-        return obj->b_die ? -1 : 1;
-    return 0;
+    return vlc_cond_timedwait( &obj->object_wait, &obj->object_lock, deadline );
 }
 
 




More information about the vlc-devel mailing list