- /* verify if there is data to submit
- * and if waiting interval is elapsed */
- if ( ( p_sys->p_first_queue->i_songs_nb > 0 ) &&
- ( time( NULL ) >= p_sys->time_next_exchange ) )
- {
- /* handshake if needed */
- if( p_sys->b_handshaked == VLC_FALSE )
- {
- msg_Dbg( p_this, "Handshaking with last.fm ..." );
-
- switch( Handshake( p_this ) )
- {
- case VLC_ENOMEM:
- MEM_ERROR
- break;
-
- case VLC_ENOVAR:
- /* username not set */
- vlc_mutex_unlock ( &p_sys->lock );
- intf_UserFatal( p_this, VLC_FALSE,
- _("Last.fm username not set"),
- _("Please set an username or disable "
- "audioscrobbler plugin, and then restart VLC.\n"
- "Visit https://www.last.fm/join/ to get an account")
- );
- free( psz_submit );
- free( psz_submit_song );
- free( p_buffer );
- return;
- break;
-
- case VLC_SUCCESS:
- msg_Dbg( p_this, "Handshake successfull :)" );
- vlc_mutex_lock ( &p_sys->lock );
- p_sys->b_handshaked = VLC_TRUE;
- vlc_mutex_unlock ( &p_sys->lock );
- break;
-
- case VLC_EGENERIC:
- default:
- /* protocol error : we'll try later */
- vlc_mutex_lock ( &p_sys->lock );
- time( &p_sys->time_next_exchange );
- p_sys->time_next_exchange += DEFAULT_INTERVAL;
- vlc_mutex_unlock ( &p_sys->lock );
- break;
- }
- }
+ /* waiting for data to submit, if waiting interval is elapsed */
+ vlc_object_lock( p_intf );
+ if( time( NULL ) < p_sys->next_exchange )
+ b_die = vlc_object_timedwait( p_intf, p_sys->next_exchange );
+ else
+ b_die = vlc_object_wait( p_intf );
+ vlc_object_unlock( p_intf );