From: RĂ©mi Denis-Courmont Date: Wed, 23 Jan 2008 17:19:15 +0000 (+0000) Subject: Cleanup condition handling, should fix #1448 X-Git-Tag: 0.9.0-test0~3261 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=c6245fff79fd70ed626303155b9a761ce6ef7294;p=vlc Cleanup condition handling, should fix #1448 --- diff --git a/modules/misc/audioscrobbler.c b/modules/misc/audioscrobbler.c index 3f6ae3f119..47fa296713 100644 --- a/modules/misc/audioscrobbler.c +++ b/modules/misc/audioscrobbler.c @@ -263,28 +263,32 @@ static void Run( intf_thread_t *p_intf ) intf_sys_t *p_sys = p_intf->p_sys; /* main loop */ - while( !intf_ShouldDie( p_intf ) ) + for( ;; ) { - vlc_bool_t b_die; + vlc_bool_t b_die = VLC_FALSE, b_wait = VLC_FALSE; - /* waiting for data to submit, if waiting interval is elapsed */ - if( mdate() < p_sys->next_exchange ) + vlc_object_lock( p_intf ); + if( vlc_object_alive( p_intf ) ) { - vlc_object_lock( p_intf ); - b_die = ( vlc_object_timedwait( p_intf, p_sys->next_exchange ) < 0 ); - vlc_object_unlock( 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 ); } - else - b_die = vlc_object_lock_and_wait( p_intf ); + b_die = !vlc_object_alive( p_intf ); + vlc_object_unlock( p_intf ); if( b_die ) { msg_Dbg( p_intf, "audioscrobbler is dying"); return; } - /* we are signaled each time there is a song to submit */ - else if( mdate() < p_sys->next_exchange ) - continue; + if( b_wait ) + continue; /* holding on until next_exchange */ /* handshake if needed */ if( p_sys->b_handshaked == VLC_FALSE )