Also fix a minor timing problem in the screensaver plugin.
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 */
*****************************************************************************/
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
{
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 );
vlc_object_release( p_input );
}
}
+
+ /* Check screensaver every 30 seconds */
+ refresh = mdate() + 30000000;
}
vlc_object_unlock( p_intf );
}
* 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 );
}