Also do not needlessly lock after unregistering the callbacks. We have
to assume that when var_DelCallback returns, any pending callback
invocation has be completed. Otherwise, we would any crash when Close()
releases the mutex, destroys it, and the callback then tries to acquire
the mutex.
int i_songs; /**< number of songs */
vlc_mutex_t lock; /**< p_sys mutex */
int i_songs; /**< number of songs */
vlc_mutex_t lock; /**< p_sys mutex */
+ vlc_cond_t wait; /**< song to submit event */
/* data about audioscrobbler session */
mtime_t next_exchange; /**< when can we send data */
/* data about audioscrobbler session */
mtime_t next_exchange; /**< when can we send data */
p_intf->p_sys = p_sys;
vlc_mutex_init( &p_sys->lock );
p_intf->p_sys = p_sys;
vlc_mutex_init( &p_sys->lock );
+ vlc_cond_init( p_intf, &p_sys->wait );
p_playlist = pl_Yield( p_intf );
PL_LOCK;
p_playlist = pl_Yield( p_intf );
PL_LOCK;
- /* we lock the mutex in case p_sys is being accessed from a callback */
- vlc_mutex_lock ( &p_sys->lock );
int i;
for( i = 0; i < p_sys->i_songs; i++ )
DeleteSong( &p_sys->p_queue[i] );
int i;
for( i = 0; i < p_sys->i_songs; i++ )
DeleteSong( &p_sys->p_queue[i] );
free( p_sys->psz_nowp_host );
free( p_sys->psz_nowp_file );
#endif
free( p_sys->psz_nowp_host );
free( p_sys->psz_nowp_file );
#endif
- vlc_mutex_unlock ( &p_sys->lock );
+ vlc_cond_destroy( &p_sys->wait );
vlc_mutex_destroy( &p_sys->lock );
free( p_sys );
}
vlc_mutex_destroy( &p_sys->lock );
free( p_sys );
}
bool b_wait = false;
vlc_restorecancel( canc );
bool b_wait = false;
vlc_restorecancel( canc );
- vlc_object_lock( p_intf );
- vlc_cleanup_push( __vlc_object_unlock, p_intf );
+ vlc_mutex_lock( &p_sys->lock );
+ mutex_cleanup_push( &p_sys->lock );
if( mdate() < p_sys->next_exchange )
/* wait until we can resubmit, i.e. */
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;
+ b_wait = vlc_cond_timedwait( &p_sys->wait, &p_sys->lock,
+ p_sys->next_exchange ) == 0;
else
/* wait for data to submit */
/* we are signaled each time there is a song to submit */
else
/* wait for data to submit */
/* we are signaled each time there is a song to submit */
- vlc_object_wait( p_intf );
+ vlc_cond_wait( &p_sys->wait, &p_sys->lock );
vlc_cleanup_run();
canc = vlc_savecancel();
vlc_cleanup_run();
canc = vlc_savecancel();
p_sys->i_songs++;
/* signal the main loop we have something to submit */
p_sys->i_songs++;
/* signal the main loop we have something to submit */
- vlc_object_signal( VLC_OBJECT( p_this ) );
+ vlc_cond_signal( &p_sys->wait );
end:
DeleteSong( &p_sys->p_current_song );
end:
DeleteSong( &p_sys->p_current_song );