vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Tue Jul 7 22:36:48 2015 +0300| [4b8e7b833b69e4ce9542c5b86ea9953943551431] | committer: Rémi Denis-Courmont
audioscrobbler: fix condition variable usage Wait for the end of the pacing interval, then wait for the next song (if it did not start in the mean time). > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4b8e7b833b69e4ce9542c5b86ea9953943551431 --- modules/misc/audioscrobbler.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/misc/audioscrobbler.c b/modules/misc/audioscrobbler.c index 4ec46d4..b463bff 100644 --- a/modules/misc/audioscrobbler.c +++ b/modules/misc/audioscrobbler.c @@ -685,7 +685,7 @@ static void *Run(void *data) bool b_handshaked = false; /* data about audioscrobbler session */ - mtime_t next_exchange = -1; /**< when can we send data */ + mtime_t next_exchange = 0; /**< when can we send data */ unsigned int i_interval = 0; /**< waiting interval (secs)*/ intf_sys_t *p_sys = p_intf->p_sys; @@ -694,14 +694,16 @@ static void *Run(void *data) for (;;) { vlc_restorecancel(canc); + mwait(next_exchange); + vlc_mutex_lock(&p_sys->lock); mutex_cleanup_push(&p_sys->lock); - do + while (p_sys->i_songs == 0) vlc_cond_wait(&p_sys->wait, &p_sys->lock); - while (mdate() < next_exchange); - vlc_cleanup_run(); + vlc_cleanup_pop(); + vlc_mutex_unlock(&p_sys->lock); canc = vlc_savecancel(); /* handshake if needed */ @@ -727,7 +729,7 @@ static void *Run(void *data) msg_Dbg(p_intf, "Handshake successful :)"); b_handshaked = true; i_interval = 0; - next_exchange = mdate(); + next_exchange = 0; break; case VLC_AUDIOSCROBBLER_EFATAL: @@ -870,7 +872,7 @@ static void *Run(void *data) DeleteSong(&p_sys->p_queue[i]); p_sys->i_songs = 0; i_interval = 0; - next_exchange = mdate(); + next_exchange = 0; msg_Dbg(p_intf, "Submission successful!"); } else _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
