From: RĂ©mi Denis-Courmont Date: Sat, 31 May 2008 15:55:03 +0000 (+0300) Subject: vlc_object_timedwait: same change as vlc_object_wait X-Git-Tag: 0.9.0-test0~508 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=425d6074da0f80e93ba092507c487068ada8e054;p=vlc vlc_object_timedwait: same change as vlc_object_wait Also fix a minor timing problem in the screensaver plugin. --- diff --git a/modules/misc/audioscrobbler.c b/modules/misc/audioscrobbler.c index b6ee7739f3..5230f20804 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 7340893862..2b8c18e802 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 a108f3d42c..4830eda23a 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 ); }