Commit 425d6074 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

vlc_object_timedwait: same change as vlc_object_wait

Also fix a minor timing problem in the screensaver plugin.
parent cb56da1c
......@@ -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 */
......
......@@ -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 );
}
......
......@@ -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 );
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment